IFEM  90A354
SIMoutput.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _SIM_OUTPUT_H
15 #define _SIM_OUTPUT_H
16 
17 #include "SIMinput.h"
18 #include "Vec3.h"
19 
20 class ElementBlock;
21 class VTF;
22 
23 
32 class SIMoutput : public SIMinput
33 {
34 protected:
36  explicit SIMoutput(IntegrandBase* itg);
37 
38 public:
40  virtual ~SIMoutput();
41 
43  virtual void clearProperties();
44 
45  using SIMinput::parse;
49  virtual bool parse(char* keyWord, std::istream& is);
50 
55  virtual bool merge(SIMbase* that, const std::map<int,int>* old2new, int poff);
56 
62  bool getElementSet(int iset, std::string& name, RealArray& elSet) const;
63 
64 protected:
66  virtual bool parseOutputTag(const tinyxml2::XMLElement* elem);
67 
69  virtual ElementBlock* tesselatePatch(size_t pidx) const;
70 
71 public:
82  virtual bool writeGlvG(int& nBlock, const char* inpFile, bool doClear = true);
83 
89  bool writeGlvG(int& nBlock, double time);
90 
92  virtual bool writeGlvA(int&, int, double, int = 1) const { return true; }
93 
97  bool writeGlvBC(int& nBlock, int iStep = 1) const;
98 
108  bool writeGlvNo(int& nBlock, int& idBlock,
109  int maxBlock = 20, int iStep = 1) const;
110 
115  bool writeGlvT(int iStep, int& geoBlk, int& nBlock) const;
116 
124  bool writeGlvV(const RealArray& vec, const char* fieldName,
125  int iStep, int& nBlock, int idBlock = 2, int ncmp = 0) const;
126 
133  bool writeGlvS(const Vector& scl, const char* fieldName,
134  int iStep, int& nBlock, int idBlock = 2) const;
135 
144  bool writeGlvS(const Vector& psol, int iStep, int& nBlock, double time = 0.0,
145  const char* pvecName = nullptr, int idBlock = 10,
146  int psolComps = 0);
147 
157  virtual int writeGlvS1(const Vector& psol, int iStep, int& nBlock,
158  double time = 0.0, const char* pvecName = nullptr,
159  int idBlock = 10, int psolComps = 0,
160  bool scalarOnly = false);
161 
169  virtual int writeGlvS2(const Vector& psol, int iStep, int& nBlock,
170  double time = 0.0, int idBlock = 20,
171  int psolComps = 0);
172 
183  bool eval2ndSolution(const Vector& psol, double time, int psolComps = 0);
184 
192  bool writeGlvP(const RealArray& ssol, int iStep, int& nBlock,
193  int idBlock = 100, const char* prefix = "Global projected",
194  std::vector<PointValues>* maxVal = nullptr);
195 
202  bool writeGlvM(const Mode& mode, bool freq, int& nBlock);
203 
212  bool writeGlvE(const Vector& field, int iStep, int& nBlock,
213  const char* name, int idBlock = 300,
214  bool internalOrder = false) const;
215 
223  bool writeGlvN(const Matrix& norms, int iStep, int& nBlock,
224  const std::vector<std::string>& prefix = {},
225  int idBlock = 200, const char* dualPrefix = nullptr);
226 
236  bool writeGlvF(const RealFunc& f, const char* fname, int iStep, int& nBlock,
237  const Vector* state = nullptr,
238  int idBlock = 50, double time = 0.0,
239  const ASMbase* patch = nullptr);
240 
245  bool writeGlvStep(int iStep, double value = 0.0, int itype = 0);
246 
248  void closeGlv();
249 
251  VTF* getVTF() const { return myVtf; }
253  void setVTF(VTF* vtf) { myVtf = vtf; }
254 
256  int getStartGeo() const { return myGeomID; }
258  void setStartGeo(int gID) { myGeomID = gID; }
259 
265  bool dumpMatlabGrid(std::ostream& os, const std::string& name = "IFEM_Mesh",
266  const std::vector<std::string>& sets = {},
267  double scale = 1.0) const;
268 
271  bool dumpGeometry(std::ostream& os) const;
272 
277  void dumpPrimSol(const Vector& psol, utl::LogStream& os,
278  bool withID = true) const;
282  bool dumpSolution(const Vector& psol, utl::LogStream& os) const;
290  bool dumpResults(const Vector& psol, double time, utl::LogStream& os,
291  bool formatted = false, std::streamsize precision = 3) const;
297  bool dumpVector(const Vector& vsol, const char* fname,
298  utl::LogStream& os, std::streamsize precision = 3) const;
300  virtual void dumpMoreResults(double, utl::LogStream&,
301  std::streamsize = 3) const {}
302 
307  bool savePoints(const Vector& psol, double time, int step) const;
308 
313  bool saveResults(const Vectors& psol, double time, int step) const;
314 
316  bool hasResultPoints() const { return !myPoints.empty(); }
318  bool hasPointResultFile() const;
322  void setPointResultFile(const std::string& filename, bool dumpCoord = false);
323 
325  virtual bool serialize(std::map<std::string,std::string>&) const;
326 
328  virtual double getReferenceNorm(const Vectors&, size_t) const = 0;
330  virtual double getEffectivityIndex(const Vectors&, size_t, size_t) const = 0;
332  virtual void printNorms(const Vectors&, size_t = 36) const = 0;
334  virtual void printIFforces(const Vector&, RealArray&) {}
336  virtual int printNRforces(const IntVec& glbNodes = {}) const;
337 
338 protected:
342  void addAddFunc(const std::string& fn, RealFunc* f) { myAddScalars[fn] = f; }
343 
350  virtual bool writeAddFuncs(int& nBlock, int& idBlock, const Vector& psol,
351  int iStep, double time);
352 
353 private:
355  bool initPatchForEvaluation(int patchNo) const;
356 
358  bool extractNodeVec(const RealArray& glbVec, Vector& locVec,
359  const ASMbase* patch, int nodalCmps,
360  bool& emptyPatches) const;
361 
363  bool writeScalarFields(const Matrix& field, int geomID, int& nBlock,
364  std::vector<IntVec>& sID, size_t* nScl = nullptr,
365  ASM::ResultClass resClass = ASM::PRIMARY);
366 
367 protected:
368  std::map<int,int> addDisBlk;
369 
371  struct ResultPoint
372  {
373  short int npar;
374  unsigned int patch;
375  double u[3];
376  Vec3 X;
377 
378  int inod;
379  int iel;
380 
382  ResultPoint(short int n = 0) : npar(n), patch(1), inod(0), iel(0)
383  { u[0] = u[1] = u[2] = 0.0; }
384  };
385 
387  using ResPointVec = std::vector<ResultPoint>;
389  using ResPtPair = std::pair<std::string,ResPointVec>;
390 
391  std::vector<ResPtPair> myPoints;
392 
394  virtual void preprocessResultPoints();
395 
396 private:
400  void preprocessResPtGroup(std::string& ptFile, ResPointVec& points);
401 
410  bool dumpResults(const Vector& psol, double time,
411  utl::LogStream& os, const ResPointVec& gPoints,
412  bool formatted, std::streamsize precision) const;
413 
424  bool evalResults(const Vectors& psol, const ResPointVec& gPoints,
425  const ASMbase* patch, IntVec& points, IntVec& elms,
426  Vec3Vec& Xp, Matrix& sol1, Matrix& sol2,
427  std::vector<std::string>* compNames = nullptr) const;
428 
429  std::map<std::string,RealFunc*> myAddScalars;
430 
431  std::set<std::string> wantComps;
432 
433  int myPrec;
434  double myPtSize;
435  int myGeomID;
436  int myGeofs1;
437  int myGeofs2;
439  bool mergeVtf;
440  bool logRpMap;
441  int idxGrid;
442 };
443 
444 #endif
std::vector< int > IntVec
General integer vector.
Definition: ASMbase.h:25
std::vector< Real > RealArray
A real-valued array without algebraic operations.
Definition: ImmersedBoundaries.h:29
std::vector< Vector > Vectors
An array of real-valued vectors with algebraic operations.
Definition: MatVec.h:37
Sub-class with functionality for model input and setup.
Representation of a point in 3D space with some basic operations.
std::vector< Vec3 > Vec3Vec
An array of point vectors.
Definition: Vec3.h:318
Base class for spline-based finite element (FE) assembly drivers.
Definition: ASMbase.h:70
Class for storage of a standard FE grid block.
Definition: ElementBlock.h:27
Base class representing a system level integrated quantity.
Definition: IntegrandBase.h:42
Scalar-valued unary function of a spatial point.
Definition: Function.h:193
std::vector< int > IntVec
Convenience alias.
Definition: SIMadmin.h:34
Base class for NURBS-based FEM simulators.
Definition: SIMbase.h:72
Sub-class with functionality for model input and setup.
Definition: SIMinput.h:37
virtual bool parse(char *keyWord, std::istream &is)
Parses a data section from an input stream.
Definition: SIMinput.C:1081
Sub-class with additional functionality for result output.
Definition: SIMoutput.h:33
void setPointResultFile(const std::string &filename, bool dumpCoord=false)
Sets the file name for result point output.
Definition: SIMoutput.C:74
std::vector< ResultPoint > ResPointVec
Result point container.
Definition: SIMoutput.h:387
virtual bool writeGlvA(int &, int, double, int=1) const
Writes additional, problem-specific, results to the VTF-file.
Definition: SIMoutput.h:92
bool hasPointResultFile() const
Checks whether point result files have been defined or not.
Definition: SIMoutput.C:64
virtual bool merge(SIMbase *that, const std::map< int, int > *old2new, int poff)
Merges the global equation system of that simulator with this.
Definition: SIMoutput.C:593
bool writeGlvV(const RealArray &vec, const char *fieldName, int iStep, int &nBlock, int idBlock=2, int ncmp=0) const
Writes a vector field for a given load/time step to the VTF-file.
Definition: SIMoutput.C:970
bool mergeVtf
If true, merge multi-patches into one on the VTF-file.
Definition: SIMoutput.h:439
std::map< int, int > addDisBlk
Additional displacement block mapping.
Definition: SIMoutput.h:368
virtual ~SIMoutput()
The destructor frees the dynamically allocated VTF object.
Definition: SIMoutput.C:45
virtual bool parse(char *keyWord, std::istream &is)
Parses a data section from an input stream.
Definition: SIMinput.C:1081
bool writeGlvT(int iStep, int &geoBlk, int &nBlock) const
Writes boundary tractions for a given time step to the VTF-file.
Definition: SIMoutput.C:957
bool writeGlvStep(int iStep, double value=0.0, int itype=0)
Writes load/time step info to the VTF-file.
Definition: SIMoutput.C:1697
std::vector< ResPtPair > myPoints
User-defined result sampling points.
Definition: SIMoutput.h:391
bool dumpResults(const Vector &psol, double time, utl::LogStream &os, bool formatted=false, std::streamsize precision=3) const
Dumps solution results at specified points in ASCII format.
Definition: SIMoutput.C:2522
void addAddFunc(const std::string &fn, RealFunc *f)
Adds a function for additional VTF-file output.
Definition: SIMoutput.h:342
virtual void printIFforces(const Vector &, RealArray &)
Prints out interface force resultants to the log stream.
Definition: SIMoutput.h:334
void closeGlv()
Closes the current VTF-file.
Definition: SIMoutput.C:1935
bool writeGlvM(const Mode &mode, bool freq, int &nBlock)
Writes a mode shape to the VTF-file.
Definition: SIMoutput.C:1713
bool logRpMap
If true, print out the result point mapping.
Definition: SIMoutput.h:440
int myGeofs1
ID offset for immersed geometry block in the VTF-file.
Definition: SIMoutput.h:436
double myPtSize
Size of result point visualization in VTF-file.
Definition: SIMoutput.h:434
virtual ElementBlock * tesselatePatch(size_t pidx) const
Tesselates the specified patch.
Definition: SIMoutput.C:617
bool getElementSet(int iset, std::string &name, RealArray &elSet) const
Retrieves the specified element set as a scalar field.
Definition: SIMoutput.C:640
std::set< std::string > wantComps
Component names for grid output.
Definition: SIMoutput.h:431
void dumpPrimSol(const Vector &psol, utl::LogStream &os, bool withID=true) const
Dumps the primary solution in ASCII format for inspection.
Definition: SIMoutput.C:2027
VTF * myVtf
VTF-file for result visualization.
Definition: SIMoutput.h:438
bool dumpSolution(const Vector &psol, utl::LogStream &os) const
Dumps the entire solution in ASCII format.
Definition: SIMoutput.C:2068
virtual double getReferenceNorm(const Vectors &, size_t) const =0
Returns the reference norm to base mesh adaptation upon.
virtual double getEffectivityIndex(const Vectors &, size_t, size_t) const =0
Returns the global effectivity index.
int myPrec
Output precision for result sampling.
Definition: SIMoutput.h:433
bool writeScalarFields(const Matrix &field, int geomID, int &nBlock, std::vector< IntVec > &sID, size_t *nScl=nullptr, ASM::ResultClass resClass=ASM::PRIMARY)
Private helper to write out scalar fields to VTF-file.
Definition: SIMoutput.C:1629
void setStartGeo(int gID)
Initializes the geometry block counter.
Definition: SIMoutput.h:258
bool writeGlvNo(int &nBlock, int &idBlock, int maxBlock=20, int iStep=1) const
Writes global node numbers as scalar fields to the VTF-file.
Definition: SIMoutput.C:908
virtual bool serialize(std::map< std::string, std::string > &) const
Serialization support.
Definition: SIMoutput.C:2703
bool extractNodeVec(const RealArray &glbVec, Vector &locVec, const ASMbase *patch, int nodalCmps, bool &emptyPatches) const
Private helper to extract patch-level solution vectors.
Definition: SIMoutput.C:2672
bool writeGlvE(const Vector &field, int iStep, int &nBlock, const char *name, int idBlock=300, bool internalOrder=false) const
Writes element field for a given load/time step to the VTF-file.
Definition: SIMoutput.C:1889
bool eval2ndSolution(const Vector &psol, double time, int psolComps=0)
Evaluates the secondary solution for a given load/time step.
Definition: SIMoutput.C:1509
virtual bool writeGlvG(int &nBlock, const char *inpFile, bool doClear=true)
Writes current model geometry to the VTF-file.
Definition: SIMoutput.C:661
bool writeGlvN(const Matrix &norms, int iStep, int &nBlock, const std::vector< std::string > &prefix={}, int idBlock=200, const char *dualPrefix=nullptr)
Writes element norms for a given load/time step to the VTF-file.
Definition: SIMoutput.C:1789
virtual int writeGlvS1(const Vector &psol, int iStep, int &nBlock, double time=0.0, const char *pvecName=nullptr, int idBlock=10, int psolComps=0, bool scalarOnly=false)
Writes primary solution for a given load/time step to the VTF-file.
Definition: SIMoutput.C:1094
int myGeomID
Geometry block ID for the first patch in the VTF-file.
Definition: SIMoutput.h:435
bool writeGlvBC(int &nBlock, int iStep=1) const
Writes boundary conditions as scalar fields to the VTF-file.
Definition: SIMoutput.C:831
bool writeGlvF(const RealFunc &f, const char *fname, int iStep, int &nBlock, const Vector *state=nullptr, int idBlock=50, double time=0.0, const ASMbase *patch=nullptr)
Writes a scalar function to the VTF-file.
Definition: SIMoutput.C:1649
virtual int printNRforces(const IntVec &glbNodes={}) const
Prints out the nodal reaction forces to the log stream.
Definition: SIMoutput.C:2641
virtual void printNorms(const Vectors &, size_t=36) const =0
Prints integrated solution norms to the log stream.
int getStartGeo() const
Returns the initial geometry block index.
Definition: SIMoutput.h:256
virtual bool parseOutputTag(const tinyxml2::XMLElement *elem)
Parses a subelement of the resultoutput XML-tag.
Definition: SIMoutput.C:105
int idxGrid
Index into myPoints for grid result output.
Definition: SIMoutput.h:441
virtual void dumpMoreResults(double, utl::LogStream &, std::streamsize=3) const
Dumps additional problem-specific results in ASCII format.
Definition: SIMoutput.h:300
void preprocessResPtGroup(std::string &ptFile, ResPointVec &points)
Preprocesses a result sampling point group.
Definition: SIMoutput.C:439
bool saveResults(const Vectors &psol, double time, int step) const
Saves result components to output files for a given time step.
Definition: SIMoutput.C:2573
bool dumpMatlabGrid(std::ostream &os, const std::string &name="IFEM_Mesh", const std::vector< std::string > &sets={}, double scale=1.0) const
Dumps the FE model to Matlab format.
Definition: SIMoutput.C:1942
bool dumpGeometry(std::ostream &os) const
Dumps the (possibly refined) spline geometry in g2-format.
Definition: SIMoutput.C:2017
bool evalResults(const Vectors &psol, const ResPointVec &gPoints, const ASMbase *patch, IntVec &points, IntVec &elms, Vec3Vec &Xp, Matrix &sol1, Matrix &sol2, std::vector< std::string > *compNames=nullptr) const
Evaluates solution results at specified points for a given patch.
Definition: SIMoutput.C:2244
int myGeofs2
ID offset for extra geometry block in the VTF-file.
Definition: SIMoutput.h:437
virtual bool writeAddFuncs(int &nBlock, int &idBlock, const Vector &psol, int iStep, double time)
Writes out the additional functions to VTF-file.
Definition: SIMoutput.C:2711
VTF * getVTF() const
Returns the current VTF-file object.
Definition: SIMoutput.h:251
bool savePoints(const Vector &psol, double time, int step) const
Saves point results to output file for a given time step.
Definition: SIMoutput.C:2546
std::map< std::string, RealFunc * > myAddScalars
Scalar functions to output.
Definition: SIMoutput.h:429
std::pair< std::string, ResPointVec > ResPtPair
File name to result point group mapping.
Definition: SIMoutput.h:389
void setVTF(VTF *vtf)
Defines the VTF-file for subsequent results output.
Definition: SIMoutput.h:253
bool writeGlvS(const Vector &scl, const char *fieldName, int iStep, int &nBlock, int idBlock=2) const
Writes a scalar field for a given load/time step to the VTF-file.
Definition: SIMoutput.C:1012
virtual int writeGlvS2(const Vector &psol, int iStep, int &nBlock, double time=0.0, int idBlock=20, int psolComps=0)
Writes secondary solution for a load/time step to the VTF-file.
Definition: SIMoutput.C:1319
SIMoutput(IntegrandBase *itg)
The constructor just forwards to the base class constructor.
Definition: SIMoutput.C:34
bool writeGlvP(const RealArray &ssol, int iStep, int &nBlock, int idBlock=100, const char *prefix="Global projected", std::vector< PointValues > *maxVal=nullptr)
Writes projected solutions for a given time step to the VTF-file.
Definition: SIMoutput.C:1545
virtual void clearProperties()
Initializes the property containers of the model.
Definition: SIMoutput.C:54
bool dumpVector(const Vector &vsol, const char *fname, utl::LogStream &os, std::streamsize precision=3) const
Dumps vector solution at specified points in ASCII format.
Definition: SIMoutput.C:2400
bool hasResultPoints() const
Checks whether result points have been defined or not.
Definition: SIMoutput.h:316
virtual void preprocessResultPoints()
Preprocesses the result sampling points.
Definition: SIMoutput.C:422
bool initPatchForEvaluation(int patchNo) const
Private helper to initialize patch for solution evaluation.
Definition: SIMoutput.C:2389
Class for output of FE model and results to VTF file.
Definition: VTF.h:58
Simple class for representing a point in 3D space.
Definition: Vec3.h:27
Logging stream class.
Definition: LogStream.h:26
A vector class with some added algebraic operations.
Definition: matrix.h:64
ResultClass
Enum for cathegorization of result quantities.
Definition: ASMenums.h:62
Struct for storage of data associated with one mode shape.
Definition: SIMbase.h:47
Struct defining a result sampling point.
Definition: SIMoutput.h:372
double u[3]
Parameters of the point (u,v,w)
Definition: SIMoutput.h:375
int iel
If non-zero, this point is the center of element iel.
Definition: SIMoutput.h:379
unsigned int patch
Patch index [1,nPatch].
Definition: SIMoutput.h:374
int inod
Local (1-based) index of the closest node.
Definition: SIMoutput.h:378
Vec3 X
Spatial coordinates of the point.
Definition: SIMoutput.h:376
short int npar
Number of parameters.
Definition: SIMoutput.h:373
ResultPoint(short int n=0)
Default constructor.
Definition: SIMoutput.h:382