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

📄 dbmat.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
字号:
#include "dbmat.h"#include "../../GEFEL/intools.h"#include <string.h>matr :: matr(void)/**   Constructor which initializes data members with null or zero values.   Created by Tomas Koudelka koudelka@cml.fsv.cvut.cz, 11. 2001*/{  type = mattype(-1);  nprop = 0;  prop = NULL;  propu = NULL;  ridx = NULL;  npropu = 0;}matr :: ~matr(void)/**   Destructor which deletes each string with material properties.   Created by Tomas Koudelka koudelka@cml.fsv.cvut.cz, 11. 2001*/{  long i;  for (i=0; i < nprop; i++)    delete [] prop[i];  delete [] prop;  delete [] propu;  delete [] ridx;}long matr :: read(FILE *in)/**   This method reads one type of material with different parameters from the opened text file in.   @param in - opened text file with material data.   @retval 0 - on succes   @retval 1 - error reading material type and number of different parameter sets of given material type   @retval 2 - error reading material properties string   Created by Tomas Koudelka koudelka@cml.fsv.cvut.cz, 11. 2001*/{  long i;  if (getint(in, (int &)type) || getlong(in, nprop))  // reading material type number and number of indeces  {    fprintf(stderr, "\nError reading material parameters (type, num)\n");    return(1);  }  // allocating apropriate ammount of memory  prop = new char*[nprop];  memset(prop, 0, sizeof(*prop)*nprop);  propu = new long[nprop];  memset(propu, 0, sizeof(*propu)*nprop);  ridx = new long[nprop];  memset(ridx, 0, sizeof(*ridx)*nprop);  getnextln(in);  for (i=0; i < nprop; i++)  //  Reading strings with material properties for each material index  //  each line in the input file corresponds to one string with material  //  properties of one index  {    prop[i] = new char[1025];    if (getstring2(in, prop[i], 1024))    {      fprintf(stderr, "\nError reading material parameters (properties string)\n");      return(2);    }  }  for (i = 0; i < nprop; i++)  {    if (strlen(prop[i]) == 0)      continue;    if (prop[i][strlen(prop[i])-1] == '\n')    // replace last character with 0 if equal newline      prop[i][strlen(prop[i])-1] = '\0';  }  return(0);}dbmat :: dbmat(void)/**   Constructor which initializes data members with null or zero values.   Created by Tomas Koudelka koudelka@cml.fsv.cvut.cz, 11. 2001*/{  numt = 0;  mat = NULL;}dbmat :: ~dbmat(void)/**   Destructor which deletes material database.   Created by Tomas Koudelka koudelka@cml.fsv.cvut.cz, 11. 2001*/{  delete [] mat;}long dbmat :: search_mat(mattype ce, long ci)/**   This method searches database whether contains material with    type number ce and type index number ci.   @param ce - material type number   @param ci - material type index   Returns :    @retval If the material with given parameters exists in the database function returns     index of given material in the array crs else returns -1.   Created by Tomas Koudelka koudelka@cml.fsv.cvut.cz, 11. 2001*/{  long i,ret = -1;  for (i = 0; i < numt; i++)  {    if ((mat[i].type == ce) && ((ci >= 0) && (ci < mat[i].nprop)))    {      ret = i;      break;    }  }  return(ret);}

⌨️ 快捷键说明

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