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

📄 outdriverm.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#include <string.h>#include <stdlib.h>#include "outdriverm.h"#include "iotools.h"#include "galias.h"#include "global.h"#include "probdesc.h"#include "mechbclc.h"#include "mechtop.h"#include "mechprint.h"#include "node.h"#include "element.h"#include "globmat.h"#include "intpoints.h"#include "vecttens.h"#include <math.h>static int prdisp = 15;static int prstra = 15;static int prstre = 15;static int proth  = 15;static int prreac = 15;/**  Constructor initializes data members to zero values.*/outdriverm::outdriverm(){  memset(outfn, 0, sizeof(*outfn)*FNAMELEN);  memset(outdiagfn, 0, sizeof(*outdiagfn)*FNAMELEN);  memset(outgrfn, 0, sizeof(*outgrfn)*FNAMELEN);  outf = outgr = NULL;  outdiagf = NULL;  textout = off;  nlcs = 0;  nclcs = NULL;  bvlcs = NULL;  gf = grfmt_no;  ncut = 0;  idn1 = 1;  ide1 = 1;  ndiag = 0;  odiag = NULL;}/**  Destructor deallocates used memory.*/outdriverm::~outdriverm(){  long i;  delete [] outdiagf;  delete [] nclcs;  for (i=0; i<nlcs; i++)    delete [] bvlcs[i];  delete [] odiag;}/**  Function reads description of required output from the opened text file in.  @param in - pointer to opened text file  @retval 0 - on success  @retval 1 - error reading output text filename  @retval 2 - error reading nodal output description  @retval 3 - error reading element output description  @retval 4 - error reading user defined point output description  @retval 5 - error reading output graphics format  @retval 6 - error reading nodal graphics output description  @retval 7 - error reading element graphics output description  @retval 8 - error reading output diagram description*/long outdriverm::read(XFILE *in){  long i;  char *str;  xfscanf(in, "%k%m", "textout", &flagsw_kwdset, &textout);  if (textout)  {    if (xfscanf(in,"%a", outfn) != 1)    {      fprintf(stderr, "\n\nError reading filename for output\n");      fprintf(stderr, " function outdriverm::read (file %s, line %d)\n", __FILE__, __LINE__);      return 1;    }    fprintf(stdout, "\n Output file name (mechanics): %s", outfn);    if (no.read(in))      return 2;    if (no.dstep.st == sel_no)      str = " not";    else      str = "";    fprintf(stdout, "\n Output of mechanical nodal values will%s be performed", str);    if (eo.read(in))      return 3;    if (eo.dstep.st == sel_no)      str = " not";    else      str = "";    fprintf(stdout, "\n Output of mechanical element values will%s be performed", str);    if (po.read(in))      return 4;    if (po.dstep.st == sel_no)      str = " not";    else      str = "";    fprintf(stdout, "\n Output of mechanical UDP values will%s be performed", str);  }  if (xfscanf(in, "%k%m", "outgr_format", &graphfmt_kwdset, (int *)&gf) != 2)  {    fprintf(stderr, "\n\nError reading type of grahics output\n");    fprintf(stderr, " function outdriverm::read (file %s, line %d)\n", __FILE__, __LINE__);    return 5;  }  if (gf == grfmt_open_dx)  {    Mp->straincomp = 1;    Mp->strainaver = 1;    Mp->stresscomp = 1;    Mp->stressaver = 1;    Mp->othercomp = 1;    Mp->otheraver = 1;    Mp->reactcomp = 1;  }  if (gf != grfmt_no)  {    if (xfscanf(in, "%a", outgrfn) != 1)    {      fprintf(stderr, "\n\nError reading filename for graphics output\n");      fprintf(stderr, " function outdriverm::read (file %s, line %d)\n", __FILE__, __LINE__);      return 5;    }  }  switch (gf)  {    case grfmt_no:      fprintf(stdout, "\n Graphic output will not be performed");      break;    case grfmt_open_dx:      fprintf(stdout, "\n Graphic output will be in OpenDX format");      fprintf(stdout, "\n Filename of graphic output : %s", outgrfn);      break;    case grfmt_femcad:      fprintf(stdout, "\n Graphic output will be in FemCAD format");      fprintf(stdout, "\n Filename of graphic output : %s", outgrfn);      break;    case grfmt_gid:      fprintf(stdout, "\n Graphic output will be in GiD format");      fprintf(stdout, "\n Filename of graphic output : %s", outgrfn);      break;    case grfmt_gid_sep:      fprintf(stdout, "\n Graphic output will be in GiD format separated to quantities");      fprintf(stdout, "\n Filename of graphic output : %s", outgrfn);      break;  }  if (gf != grfmt_no)  {    if (nog.read(in))      return 6;    if (nog.dstep.st == sel_no)      str = " not";    else      str = "";    fprintf(stdout, "\n Graphical output of mechanical nodal values will%s be performed", str);        if (eog.read(in))      return 7;    if (eog.dstep.st == sel_no)      str = " not";    else      str = "";    fprintf(stdout, "\n Graphical output of mechanical element values will%s be performed", str);  }  switch (Mp->tprob)  {    case mat_nonlinear_statics:    case forced_dynamics:    case mech_timedependent_prob:    case nonlin_floating_subdomain:    case growing_mech_structure:    case earth_pressure:      if (xfscanf(in, "%k%ld", "numdiag", &ndiag) != 2)	{	  fprintf(stderr, "\n\nError reading number of diagrams\n");	  fprintf(stderr, " function outdriverm::read (file %s, line %d)\n", __FILE__, __LINE__);	  return 8;      }      if (ndiag == 0)      {        fprintf (stdout, "\n Number of diagrams : %ld", ndiag);        return 0;      }      if (xfscanf(in, "%a", outdiagfn) != 1)      {        fprintf(stderr, "\n\nError reading filename for diagrams\n");        fprintf(stderr, " function outdriverm::read (file %s, line %d)\n", __FILE__, __LINE__);        return 8;      }      fprintf (stdout, "\n Number of diagrams : %ld", ndiag);      fprintf (stdout, "\n Diagram filename : %s",outdiagfn);      odiag = new outdiagm[ndiag];      outdiagf = new FILE* [ndiag];      memset(outdiagf, 0, sizeof(*outdiagf)*ndiag);      for (i=0; i<ndiag; i++)      {        if (odiag[i].read(in))          return 8;      }            break;    default:      break;  }   return 0;}/**  Function prints data with output description to the text file given by out.    @param out - pointer to opened text file for output    */void outdriverm::print(FILE *out){  long i;  fprintf(out, "%d\n", (int)textout);  if (textout == on)  {    fprintf(out, "\n%s\n", outfn);    no.print(out);    eo.print(out);    po.print(out);  }  fprintf(out, "%d\n", (int)gf);  if (gf != grfmt_no)  {    fprintf(out, "%s\n", outgrfn);    nog.print(out);    eog.print(out);  }  switch (Mp->tprob)    {    case mat_nonlinear_statics:    case forced_dynamics:    case mech_timedependent_prob:    case growing_mech_structure:    case nonlin_floating_subdomain:    case earth_pressure:      fprintf(out, "%ld\n", ndiag);      if (ndiag == 0)        break;      fprintf(out, "%s\n", outdiagfn);      for (i=0; i<ndiag; i++)        odiag[i].print(out);      break;    default:      break;  } }/**  Function prints header to the output text file.    @param out - pointer to the opened text output file*/void outdriverm::print_header(FILE *out){  fprintf(out, "%15s ****  *  ****  ****  *\n", " ");  fprintf(out, "%15s *     *  *     *     *\n", " ");  fprintf(out, "%15s  *    *  ***   ***   *\n", " ");  fprintf(out, "%15s   *   *  *     *     *\n", " ");  fprintf(out, "%15s****   *  *     ****  ****  MEFEL OUTPUT\n", " ");/*  long i;  for (i=0; i<72; i++)    fprintf(out, "*");  fprintf(out, "\n\n*%15s SIFEL - MEFEL OUTPUT %15s*\n\n", " ", " ");  for (i=0; i<72; i++)    fprintf(out, "*");*/  fprintf(out, "\n%s\n", Mp->name);  fprintf(out, "\n\n\n\n\n");}/**  Function prints step number to the output text file.    @param out  - pointer to the opened text output file  @param step - integer step id  @param time - time or load step*/void outdriverm::print_newstep(FILE *out, long step, double time){  long i;  if (textout)  {    for (i=0; i<53; i++)      fprintf(out, "*");    fprintf(out, "\n%10sStep number=% ld, time/load step=% g\n", " ", step, time);    for (i=0; i<53; i++)      fprintf(out, "*");    fprintf(out, "\n\n\n\n");  }}/**  Function prints required output values to the output text file.    @param out - pointer to the opened text file   @param lcid - load case id  @param istep - step id  */void outdriverm::print_out(FILE *out, long lcid, long istep, double time){  if (textout)  {    fprintf(out, "* LOAD CASE NUMBER %ld\n\n\n", lcid+1);      if (no.sellc.presence_id(lcid) && (no.dstep.presence_id(istep, time)))      no.print_out(out, lcid);    if (eo.sellc.presence_id(lcid) && (eo.dstep.presence_id(istep, time)))      eo.print_out(out, lcid);    if (po.sellc.presence_id(lcid) && (po.dstep.presence_id(istep, time)))       po.print_out(out, lcid);  }}/**  Function prints diagrams.    @param lcid - required load case id  @param lambda - actual load parameter/actual time  @param istep - actual step id  @param fi - array with values of load vector  */void outdriverm::print_diags(long lcid, double lambda, long istep, double *fi){  long i;  for(i=0; i<ndiag; i++)    odiag[i].printval(outdiagf[i], lcid, lambda, istep, fi);}/**  Function prints required value to the graphics files.    @param out - pointer to the opened text file   @param lcid - required load case id  @param lambda - actual load parameter/actual time  @param istep - actual step id  @param fi - array with values of load vector  */void outdriverm::print_graphics(FILE *out, long lcid, double lambda, long istep, double *fi){  long i;  char dlcid[50];  switch (gf)  {    case grfmt_no:      break;;    case grfmt_femcad:      break;    case grfmt_open_dx:    {      for (i=0; i<Mb->nlc; i++)      {        if (gf == grfmt_open_dx)          print_default_dx (Gtm, Mp, Mt, Mm, i, outgrfn);      }      break;    }    case grfmt_gid:    {      if (nog.sellc.presence_id(lcid) && (nog.dstep.presence_id(istep, lambda)))      {        if (Mp->tprob == linear_statics)          sprintf(dlcid, "%ld", istep);        else{	  if(Mp->tpr == seconds)	    sprintf(dlcid, "%e", lambda);	  if(Mp->tpr == minutes)	    sprintf(dlcid, "%e", lambda/60.0);	  if(Mp->tpr == hours)	    sprintf(dlcid, "%e", lambda/3600.0);	  if(Mp->tpr == days)	    sprintf(dlcid, "%e", lambda/86400.0);	}        nog.print_graphics(out, lcid, dlcid, gf);      }      if (eog.sellc.presence_id(lcid) && (eog.dstep.presence_id(istep, lambda)))      {        if (Mp->tprob == linear_statics)          sprintf(dlcid, "%ld", istep);        else{	  if(Mp->tpr == seconds)	    sprintf(dlcid, "%e", lambda);	  if(Mp->tpr == minutes)	    sprintf(dlcid, "%e", lambda/60.0);	  if(Mp->tpr == hours)	    sprintf(dlcid, "%e", lambda/3600.0);	  if(Mp->tpr == days)	    sprintf(dlcid, "%e", lambda/86400.0);	}        eog.print_graphics(out, lcid, dlcid, gf);      }      break;    }    case grfmt_gid_sep:    {            if (nog.sellc.presence_id(lcid) && (nog.dstep.presence_id(istep, lambda)))      {        if (Mp->tprob == linear_statics)          sprintf(dlcid, "%ld", istep);        else{	  if(Mp->tpr == seconds)	    sprintf(dlcid, "%e", lambda);	  if(Mp->tpr == minutes)	    sprintf(dlcid, "%e", lambda/60.0);	  if(Mp->tpr == hours)	    sprintf(dlcid, "%e", lambda/3600.0);	  if(Mp->tpr == days)	    sprintf(dlcid, "%e", lambda/86400.0);	}        nog.print_graphics(outgrfngs, "at", lcid, dlcid, gf);      }      if (eog.sellc.presence_id(lcid) && (eog.dstep.presence_id(istep, lambda)))      {        if (Mp->tprob == linear_statics)          sprintf(dlcid, "%ld", istep);        else{	  if(Mp->tpr == seconds)	    sprintf(dlcid, "%e", lambda);	  if(Mp->tpr == minutes)	    sprintf(dlcid, "%e", lambda/60.0);	  if(Mp->tpr == hours)	    sprintf(dlcid, "%e", lambda/3600.0);	  if(Mp->tpr == days)	    sprintf(dlcid, "%e", lambda/86400.0);	}        eog.print_graphics(outgrfngs, "at", lcid, dlcid, gf);      }      break;    }    default:    {      fprintf(stderr, "\nUnknown type of graphics format is required in function\n");      fprintf(stderr, "outdriverm::print_graphics (file %s, line %d)\n", __FILE__, __LINE__);    }  }}/**  Function creates output graphics files and their headers for GiD separated format (grfmt_gidsp).  For this format (grfmt_gidsp) each required quantity is printed to the sparated file named   in following way : filename.{elem|nodal}_{quanitity}{indexOfQuantity}.flavia.res  quatnitity can be : eps, sig, pesp, psig, other.  @param mode - opening mode for opened text files*/void outdriverm::create_files_gidsp(char *mode){  char dlcid[50];  if (gf != grfmt_gid_sep)  {    fprintf(stderr, "\nWrong graphics format is required in function outdriverm::create_files_gidsp\n");    fprintf(stderr, "(file %s, line %d)\n", __FILE__, __LINE__);    abort();  }  if (nog.dstep.st != sel_no)    nog.print_graphics(outgrfngs, mode, 0, dlcid, gf);  if (eog.dstep.st != sel_no)    eog.print_graphics(outgrfngs, mode, 0, dlcid, gf);}/**  Constructor initializes data to zero values*/nodeoutm::nodeoutm(){  react = 0;  seldisp = selstra = selstre = seloth = NULL;  transtra = transtre = NULL; }/**  Destructor deallocates used memory*/nodeoutm::~nodeoutm(){  delete [] seldisp;  delete [] selstra;  delete [] selstre;   delete [] seloth;  delete [] transtra;  delete [] transtre;}/**  Function reads data with description for output of nodal values from the text file.

⌨️ 快捷键说明

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