⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nonlocdamg.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
字号:
#include <string.h>#include "nonlocdamg.h"#include "global.h"#include "mechmat.h"#include "intpoints.h"#include "matrix.h"#include "vector.h"#include "vecttens.h"/**  This constructor inializes attributes to zero values.*/nonlocdamg::nonlocdamg(void){  r = 0;  af = avrgf(0);}/**  This destructor is only for the formal purposes.*/nonlocdamg::~nonlocdamg(void){  r = 0;  af = avrgf(0);}/**  This function reads material parameters from the opened text file given  by the parameter in.  @param in - pointer to the opned text file*/long nonlocdamg::read(XFILE *in){  if (xfscanf(in, "%le %d", &r, (int*)&af) == 2)    return 0;  fprintf(stderr, "\n Error reading parameters of nonlocal plasticity\n");  fprintf(stderr, " in function nonlocdamg::read, (file %s, line %d)\n", __FILE__, __LINE__);  return 1;}/**  This function allocates additional data arrays on the given integration point for the computed  averaged internal parameters.  @param ipp - integration point number*/void nonlocdamg::allocation (long ipp){  Mm->ip[ipp].nonloc = new double [Mm->ip[ipp].ncompother];  memset (Mm->ip[ipp].nonloc, 0, sizeof(*Mm->ip[ipp].nonloc)*Mm->ip[ipp].ncompother);}/**  This function averages values of the damage function parameter in the given integration point.  Which average function is used is defined by the data member af.  @param ipp - integration point number*/void nonlocdamg::average (long ipp){  double rr, alpha, sum = 0.0;  double aeps = 0.0, weight;  long i, nad, aip;  //nad .... number of adjacent points  nad=Mt->nadjip[ipp];  //loop over all adjacent points  for (i = 0; i < nad; i++)  {    //number of adj. int. point    aip=Mt->adjip[ipp][i];    //compute distance of int. points ipp<->aip    rr=Mt->dist[ipp][i];    //compute nonlocal weight    switch (af)    {      case parab :        alpha = (rr >= r) ? 0 : (1-rr*rr/(r*r));        break;      case cubic :        alpha = (rr >= r) ? 0 : (1-rr*rr/(r*r))*(1-rr*rr/(r*r));        break;      default :        fprintf(stderr, "\n Error - unknown type of the averaging function is required\n");        fprintf(stderr, " in function nonlocdamg::average, file %s, line %d\n", __FILE__, __LINE__);        break;    }    if (alpha < 1.0e-3)      continue;//    sum += alpha;    weight = alpha * Mm->ipv[aip];    sum += weight;    aeps += weight*Mm->ip[aip].other[0];  }//loop i  Mm->ip[ipp].nonloc[0] = aeps / sum;}

⌨️ 快捷键说明

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