edgeload.cpp

来自「Finite element program for mechanical pr」· C++ 代码 · 共 95 行

CPP
95
字号
#include "edgeload.h"#include "intools.h"#include "mathem.h"#include <math.h>/**  This constructor initializes data to the zero values*/edgeload::edgeload(){  fa = NULL;  fb = NULL;  nlc  = 0;  ndir = 0;  xa = xb = ya = yb = za = zb = 0.0;}/**  This destructor deallocates used memory*/edgeload::~edgeload(){  delete [] fa;  delete [] fb;}/**  This function reads data about edge load from the text file given by the parameter in  Parameters :  @param in - pointer to the opned text file  @param lc - total number of load cases  Returns :  @retval 0 - on succes*/long edgeload::read(FILE *in, long lc){  getlong(in, nlc);  if ((nlc < 1) || (nlc > lc))    return(2);  long i;  getlong(in, ndir);  fa = new double [ndir];  fb = new double [ndir];  // first point  getdouble(in, xa);  getdouble(in, ya);  getdouble(in, za);  for (i = 0; i < ndir; i++)    getdouble(in, fa[i]);  // second point  getdouble(in, xb);  getdouble(in, yb);  getdouble(in, zb);  for (i = 0; i < ndir; i++)     getdouble(in, fb[i]);  return(0);}/**  This function approximates values on the loaded edge to the element node which  lay on it. It is used linear approximation.  Parameters :  @param tn - pointer to the node structure  @param nv - array with approximated nodal values  Returns :  @retval 0 - on succes  @retval 1 - nodal coordinates is out of edge*/long edgeload::getval(snode *tn, double *nv){  long i;  double maxx, minx, maxy, miny, maxz, minz;  (xa < xb) ? (maxx = xb, minx = xa) : (maxx = xa, minx = xb);  (ya < yb) ? (maxy = yb, miny = ya) : (maxy = ya, miny = yb);  (za < zb) ? (maxz = zb, minz = za) : (maxz = za, minz = zb);  if ((tn->x < minx) || (tn->x > maxx))    return(1);  if ((tn->y < miny) || (tn->y > maxy))    return(1);  if ((tn->z < minz) || (tn->z > maxz))    return(1);  double l, ksi;  l = sqrt(sqr(xb - xa) + sqr(yb - ya) + sqr(zb - za));  ksi = sqrt(sqr(tn->x - xa) + sqr(tn->y - ya) + sqr(tn->z - za));  for (i = 0; i < ndir; i++)    nv[i] = ksi / l * (fb[i] - fa[i]) + fa[i];  return(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?