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

📄 outdriverm.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}/**  Function reads data with description for output of element values from the text file.  @param in - pointer to the opened text file  @retval 0 - on success  @retval 1 - error reading step   @retval 2 - error reading strain selection  @retval 3 - error reading stress selection  @retval 4 - error reading other values selection */long elemoutm::read(XFILE *in){  long i;  // step and loadcases  xfscanf(in, "%k", "sel_elemstep");  dstep.read(in);  if (dstep.st == sel_no)    return 0;  xfscanf(in, "%k", "sel_elemlc");  sellc.read(in);  if (sellc.st == sel_no)    return 0;  // strains  xfscanf(in, "%k", "strain_elems");  selestra.read(in);  switch (selestra.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      xfscanf(in, "%k", "elemstrain_comp");      Mp->straincomp = 1;      transtra = new long[selestra.n];      memset(transtra, 0, sizeof(*transtra)*selestra.n);      selstra = new sel[selestra.n];      for(i=0; i<selestra.n; i++)        selstra[i].read(in);      xfscanf(in, "%k", "elemstra_transfid");      for(i=0; i<selestra.n; i++)      {        if (xfscanf(in, "%ld", transtra+i) != 1)        {          fprintf(stderr, "\n\nError reading strain selection\n");          fprintf(stderr, " in function elemoutm::read, (file %s, line %d)\n", __FILE__, __LINE__);          return 2;        }      }      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::read\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return 2;  }  // stresses  xfscanf(in, "%k", "stress_elems");  selestre.read(in);  switch (selestre.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      xfscanf(in, "%k", "elemstress_comp");      Mp->straincomp = 1;      Mp->stresscomp = 1;      transtre = new long[selestre.n];      memset(transtre, 0, sizeof(*transtre)*selestre.n);      selstre = new sel[selestre.n];      for(i=0; i<selestre.n; i++)        selstre[i].read(in);      xfscanf(in, "%k", "elemstre_transfid");      for(i=0; i<selestre.n; i++)      {        if (xfscanf(in, "%ld", transtre+i) != 1)        {          fprintf(stderr, "\n\nError reading stress selection\n");          fprintf(stderr, " in function elemoutm::read, (file %s, line %d)\n", __FILE__, __LINE__);          return 3;        }      }      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::read\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return 3;  }  // other values  xfscanf(in, "%k", "other_elems");  seleoth.read(in);  switch (seleoth.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      xfscanf(in, "%k", "elemother_comp");      Mp->othercomp = 1;      seloth = new sel[seleoth.n];       for (i=0; i<seleoth.n; i++)        seloth[i].read(in);      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::read\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return 4;  }  return 0;}/**  Function prints data with description for output of element values to the text file.  @param out - pointer to the opened text file*/void elemoutm::print(FILE *out){  long i;  // step and loadcases  dstep.print(out);  if (dstep.st == sel_no)    return;  sellc.print(out);  if (sellc.st == sel_no)    return;  // strains  selestra.print(out);  switch (selestra.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      for(i=0; i<selestra.n; i++)        selstra[i].print(out);      for(i=0; i<selestra.n; i++)        fprintf(out, "%ld ", transtra[i]);      fprintf(out, "\n");      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::print\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return;  }  // stresses  selestre.print(out);  switch (selestre.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      for(i=0; i<selestre.n; i++)        selstre[i].print(out);      for(i=0; i<selestre.n; i++)        fprintf(out, "%ld ", transtre[i]);      fprintf(out, "\n");      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::print\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return;  }  // other values  seleoth.print(out);  switch (seleoth.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      for(i=0; i<seleoth.n; i++)        seloth[i].print(out);      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::print\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return;  }}/**  Function prints required output values for selected elements and for given load case  to the output text file.    @param out  - pointer to the opened text file  @param lcid - load case id */void elemoutm::print_out(FILE *out, long lcid){  if (selestra.st != sel_no)  {    fprintf(out, "** Element strains :\n\n");    print_stra(out, lcid);  }  if (selestre.st != sel_no)  {    fprintf(out, "** Element stresses :\n\n");    print_stre(out, lcid);  }  if (seleoth.st != sel_no)  {    fprintf(out, "** Element other values :\n\n");    print_other(out);  }}/**  Function prints required strains for selected elements and for given load case  to the output text file.    @param out  - pointer to the opened text file  @param lcid - load case id */void elemoutm::print_stra(FILE *out, long lcid){  long i, j, k, ncomp, id, ipp, tnipe;  for (i=0; i<Mt->ne; i++)  {    if (selestra.presence_id(i))    {      ipp = Mt->elements[i].ipp[0][0];      tnipe = Mt->give_totnip(i);      fprintf(out, "   Element %7ld, integration points %ld - %ld\n  ", i+1, ipp+1, ipp+tnipe);      ncomp = Mm->ip[ipp].ncompstr;      id = lcid*ncomp;      for (j=0; j<tnipe; j++)      {        for (k=0; k<ncomp; k++)        {           if (selestra.presence_id(selstra, i, k))             fprintf(out, "   eps_%ld=% .*e", k+1, prstra, Mm->ip[ipp+j].strain[id+k]);        }        if (j < tnipe-1)          fprintf(out, "\n  ");        else          fprintf(out, "\n");      }    }   }  fprintf(out, "\n");}/**  Function prints required stresses for selected elements and for given load case  to the output text file.    @param out  - pointer to the opened text file  @param lcid - load case id */void elemoutm::print_stre(FILE *out, long lcid){  long i, j, k, ncomp, id, ipp, tnipe;  for (i=0; i<Mt->ne; i++)  {    if (selestre.presence_id(i))    {      ipp = Mt->elements[i].ipp[0][0];      tnipe = Mt->give_totnip(i);      fprintf(out, "   Element %7ld, integration points %ld - %ld\n  ", i+1, ipp+1, ipp+tnipe);      ncomp = Mm->ip[ipp].ncompstr;      id = lcid*ncomp;      for (j=0; j<tnipe; j++)      {        for (k=0; k<ncomp; k++)        {          if (selestre.presence_id(selstre, i, k))            fprintf(out, "   sig_%ld=% .*e", k+1, prstre, Mm->ip[ipp+j].stress[id+k]);        }        if (j < tnipe-1)          fprintf(out, "\n  ");        else          fprintf(out, "\n");      }    }   }  fprintf(out, "\n");}/**  Function prints required other values for selected elements and for given load case  to the output text file.    @param out  - pointer to the opened text file */void elemoutm::print_other(FILE *out){  long i, j, k, ncomp, ipp, tnipe;  for (i=0; i<Mt->ne; i++)  {    if (seleoth.presence_id(i))    {      ipp = Mt->elements[i].ipp[0][0];      tnipe = Mt->give_totnip(i);      fprintf(out, "   Element %7ld, integration points %ld - %ld\n  ", i+1, ipp+1, ipp+tnipe);      ncomp = Mm->ip[ipp].ncompeqother;      for (j=0; j<tnipe; j++)      {        for (k=0; k<ncomp; k++)        {          if (seleoth.presence_id(seloth, i, k))            fprintf(out, "   other_%ld=% .*e", k+1, proth, Mm->ip[ipp+j].eqother[k]);        }        if (j < tnipe-1)          fprintf(out, "\n  ");        else          fprintf(out, "\n");      }    }   }  fprintf(out, "\n");}/**  Constructor initializes data to zero values*/elemoutgm::elemoutgm(){  selstra = selstre = seloth = NULL;  transtra = transtre = NULL; }/**  Destructor deallocates used memory*/elemoutgm::~elemoutgm(){  delete [] selstra;  delete [] selstre;  delete [] seloth;  delete [] transtra;  delete [] transtre;}/**  Function reads data with description for output of element values from the text file.  @param in - pointer to the opened text file  @retval 0 - on success  @retval 1 - error reading step   @retval 2 - error reading strain selection  @retval 3 - error reading stress selection  @retval 4 - error reading other values selection */long elemoutgm::read(XFILE *in){  long i;  // step and loadcases  xfscanf(in, "%k", "sel_elemstep");  dstep.read(in);  if (dstep.st == sel_no)    return 0;  xfscanf(in, "%k", "sel_elemlc");  sellc.read(in);  if (sellc.st == sel_no)    return 0;  // strains  xfscanf(in, "%k", "strain_elems");  selestra.read(in);  switch (selestra.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      xfscanf(in, "%k", "elemstrain_comp");      Mp->straincomp = 1;      transtra = new long[selestra.n];      memset(transtra, 0, sizeof(*transtra)*selestra.n);      selstra = new sel[selestra.n];      for(i=0; i<selestra.n; i++)        selstra[i].read(in);      xfscanf(in, "%k", "elemstra_transfid");      for(i=0; i<selestra.n; i++)      {        if (xfscanf(in, "%ld", transtra+i) != 1)        {          fprintf(stderr, "\n\nError reading strain selection\n");          fprintf(stderr, " in function elemoutgm::read, (file %s, line %d)\n", __FILE__, __LINE__);          return 2;        }      }      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutgm::read\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return 2;  }  // stresses  xfscanf(in, "%k", "stress_elems");  selestre.read(in);  switch (selestre.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      xfscanf(in, "%k", "elemstress_comp");      Mp->straincomp = 1;      Mp->stresscomp = 1;      transtre = new long[selestre.n];      memset(transtre, 0, sizeof(*transtre)*selestre.n);      selstre = new sel[selestre.n];      for(i=0; i<selestre.n; i++)        selstre[i].read(in);      xfscanf(in, "%k", "elemstre_transfid");      for(i=0; i<selestre.n; i++)      {        if (xfscanf(in, "%ld", transtre+i) != 1)        {          fprintf(stderr, "\n\nError reading stress selection\n");          fprintf(stderr, " in function elemoutgm::read, (file %s, line %d)\n", __FILE__, __LINE__);          return 3;        }      }      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutgm::read\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return 3;  }  // other values  xfscanf(in, "%k", "other_elems");  seleoth.read(in);  switch (seleoth.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      xfscanf(in, "%k", "elemother_comp");      Mp->othercomp = 1;      seloth = new sel[seleoth.n];       for (i=0; i<seleoth.n; i++)        seloth[i].read(in);      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutgm::read\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return 4;  }  return 0;}/**  Function prints data with description for output of element values to the text file.  @param out - pointer to the opened text file*/void elemoutgm::print(FILE *out){  long i;  // step and loadcases  dstep.print(out);  if (dstep.st == sel_no)    return;  sellc.print(out);  if (sellc.st == sel_no)    return;  // strains  selestra.print(out);  switch (selestra.st)  {    case sel_no:      break;    case sel_all:    case sel_range:    case sel_list:      for(i=0; i<selestra.n; i++)        selstra[i].print(out);      for(i=0; i<selestra.n; i++)        fprintf(out, "%ld ", transtra[i]);      fprintf(out, "\n");      break;    default:      fprintf(stderr, "\n\nUnknown type of selection is required in function elemoutm::print\n");      fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__);      return;

⌨️ 快捷键说明

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