IFEM 90A354
VTF.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
12//==============================================================================
13
14#ifndef _VTF_H
15#define _VTF_H
16
17#include <vector>
18#include <cstddef>
19
20class ElementBlock;
21class RealFunc;
22class Tensor;
23class Vec3;
24
25using Vec3Pair = std::pair<Vec3,Vec3>;
26using IntPair = std::pair<int,int>;
27using GridBlock = std::pair<IntPair,const ElementBlock*>;
28
29class VTFAFile;
30class VTFAStateInfoBlock;
31class VTFATransformationBlock;
32class VTFADisplacementBlock;
33class VTFAVectorBlock;
34class VTFAScalarBlock;
35class VTFAGeometryBlock;
36
37#if HAS_VTFAPI == 2
38class VTFXAFile;
39class VTFXADatabase;
40class VTFXAStateInfoBlock;
41class VTFXAResultBlock;
42class VTFXAGeometryBlock;
43#define VTFAFile VTFXAFile
44#define VTFAStateInfoBlock VTFXAStateInfoBlock
45#define VTFATransformationBlock VTFXAResultBlock
46#define VTFADisplacementBlock VTFXAResultBlock
47#define VTFAVectorBlock VTFXAResultBlock
48#define VTFAScalarBlock VTFXAResultBlock
49#define VTFAGeometryBlock VTFXAGeometryBlock
50#endif
51
52
57class VTF
58{
59public:
63 VTF(const char* filename, int type);
65 VTF(const VTF&) = delete;
67 ~VTF();
68
74 bool writeGrid(const ElementBlock* block, const char* gName,
75 int elemID, int nodeID = 0);
76
82 bool writeTransformation(const Vec3& X, const Tensor& T,
83 int idBlock = 1, int gID = 1);
89 bool writeNres(const std::vector<Real>& nodalResult,
90 int idBlock = 1, int geomID = 1);
96 bool writeEres(const std::vector<Real>& elementResult,
97 int idBlock = 1, int geomID = 1);
104 bool writeVres(const std::vector<Real>& nodeResult,
105 int idBlock = 1, int geomID = 1, size_t nvc = 0);
112 bool writeNfunc(const RealFunc& f, const Real* u = nullptr,
113 Real time = Real(0), int idBlock = 1, int gID = 1);
125 bool writeVectors(const std::vector<Vec3Pair>& pntResult, int& gID,
126 int idBlock = 1, const char* resultName = nullptr,
127 int iStep = 0, int iBlock = 1);
131 bool writePoints(const std::vector<Vec3>& points, int& gID);
132
139 bool writeSblk(int sBlockID, const char* resultName = nullptr,
140 int idBlock = 1, int iStep = 1, bool elementData = false);
147 bool writeSblk(const std::vector<int>& sBlockIDs,
148 const char* resultName = nullptr, int idBlock = 1,
149 int iStep = 1, bool elementData = false);
155 bool writeVblk(int vBlockID, const char* resultName = nullptr,
156 int idBlock = 1, int iStep = 1);
162 bool writeVblk(const std::vector<int>& vBlockIDs,
163 const char* resultName = nullptr,
164 int idBlock = 1, int iStep = 1);
170 bool writeDblk(const std::vector<int>& dBlockIDs,
171 const char* resultName = nullptr,
172 int idBlock = 1, int iStep = 1);
178 bool writeTblk(const std::vector<int>& tBlockIDs,
179 const char* resultName = nullptr,
180 int idBlock = 1, int iStep = 1);
181
187 bool writeState(int iStep, const char* fmt, Real refValue, int refType = 0);
188
190 const ElementBlock* getBlock(int geomID) const;
192 int getNodeBlock(int geomID) const;
193
195 void writeGeometryBlocks(int iStep);
197 void clearGeometryBlocks();
198
199private:
203 bool writeNodes(int iBlockID);
210 bool writeElements(const char* partName, int partID,
211 int iBlockID, int iNodeBlockID);
212
213public:
214 static Real vecOffset[3];
215
216private:
217 VTFAFile* myFile;
218#if HAS_VTFAPI == 2
219 VTFXADatabase* myDatabase;
220#endif
221 VTFAStateInfoBlock* myState;
222 VTFAGeometryBlock* myGBlock;
223 std::vector<VTFATransformationBlock*> myTBlock;
224 std::vector<VTFADisplacementBlock*> myDBlock;
225 std::vector<VTFAVectorBlock*> myVBlock;
226 std::vector<VTFAScalarBlock*> mySBlock;
227
231 std::vector<GridBlock> myBlocks;
232};
233
234#endif
#define Real
The floating point type to use.
Definition ImmersedBoundaries.h:18
std::pair< IntPair, const ElementBlock * > GridBlock
Convenience type.
Definition VTF.h:27
std::pair< int, int > IntPair
Convenience type.
Definition VTF.h:26
std::pair< Vec3, Vec3 > Vec3Pair
A pair of two point vectors.
Definition Vec3.h:316
Class for storage of a standard FE grid block.
Definition ElementBlock.h:27
Scalar-valued unary function of a spatial point.
Definition Function.h:193
Simple class for representing a non-symmetric second-order tensor.
Definition Tensor.h:28
Class for output of FE model and results to VTF file.
Definition VTF.h:58
bool writeNfunc(const RealFunc &f, const Real *u=nullptr, Real time=Real(0), int idBlock=1, int gID=1)
Writes a block of scalar nodal function values to the VTF-file.
Definition VTF.C:470
bool writeVectors(const std::vector< Vec3Pair > &pntResult, int &gID, int idBlock=1, const char *resultName=nullptr, int iStep=0, int iBlock=1)
Writes a block of point vector results to the VTF-file.
Definition VTF.C:513
const ElementBlock * getBlock(int geomID) const
Returns the pointer to a geometry block.
Definition VTF.C:257
void writeGeometryBlocks(int iStep)
Adds the current FE geometry blocks to the description block.
Definition VTF.C:225
bool writeNodes(int iBlockID)
Writes a node block to the VTF-file.
Definition VTF.C:849
bool writeDblk(const std::vector< int > &dBlockIDs, const char *resultName=nullptr, int idBlock=1, int iStep=1)
Writes a displacement block definition to the VTF-file.
Definition VTF.C:652
bool writeVblk(int vBlockID, const char *resultName=nullptr, int idBlock=1, int iStep=1)
Writes a vector block definition to the VTF-file.
Definition VTF.C:688
std::vector< GridBlock > myBlocks
The FE geometry of the whole model.
Definition VTF.h:231
bool writeVres(const std::vector< Real > &nodeResult, int idBlock=1, int geomID=1, size_t nvc=0)
Writes a block of vector nodal results to the VTF-file.
Definition VTF.C:324
~VTF()
The destructor finalizes and closes the VTF-file.
Definition VTF.C:98
int lastStep
ID of the last state written to file.
Definition VTF.h:230
bool writeGrid(const ElementBlock *block, const char *gName, int elemID, int nodeID=0)
Writes the FE geometry to the VTF-file.
Definition VTF.C:275
void clearGeometryBlocks()
Drops the current FE geometry blocks.
Definition VTF.C:247
static Real vecOffset[3]
Optional offset for vector attack points.
Definition VTF.h:34
VTF(const VTF &)=delete
No copying of this class.
VTFAGeometryBlock * myGBlock
The geometry description block for this file.
Definition VTF.h:222
bool writeState(int iStep, const char *fmt, Real refValue, int refType=0)
Writes a state info block to the VTF-file.
Definition VTF.C:824
std::vector< VTFATransformationBlock * > myTBlock
Transformation blocks.
Definition VTF.h:223
std::vector< VTFADisplacementBlock * > myDBlock
Displacement blocks.
Definition VTF.h:224
std::vector< VTFAVectorBlock * > myVBlock
Vector field blocks.
Definition VTF.h:225
int myPartID
Internal geometry block part ID.
Definition VTF.h:228
std::vector< VTFAScalarBlock * > mySBlock
Scalar field blocks.
Definition VTF.h:226
bool writePoints(const std::vector< Vec3 > &points, int &gID)
Writes a block of points (no results) to the VTF-file.
Definition VTF.C:587
VTFAStateInfoBlock * myState
The state info block for this file.
Definition VTF.h:221
bool writeTblk(const std::vector< int > &tBlockIDs, const char *resultName=nullptr, int idBlock=1, int iStep=1)
Writes a transformation block definition to the VTF-file.
Definition VTF.C:626
bool writeEres(const std::vector< Real > &elementResult, int idBlock=1, int geomID=1)
Writes a block of scalar element results to the VTF-file.
Definition VTF.C:382
bool writeSblk(int sBlockID, const char *resultName=nullptr, int idBlock=1, int iStep=1, bool elementData=false)
Writes a scalar block definition to the VTF-file.
Definition VTF.C:756
bool writeNres(const std::vector< Real > &nodalResult, int idBlock=1, int geomID=1)
Writes a block of scalar nodal results to the VTF-file.
Definition VTF.C:430
VTFAFile * myFile
Pointer to the actual VTF-file being written.
Definition VTF.h:217
int pointGeoID
ID of point vector geometry block.
Definition VTF.h:229
bool writeTransformation(const Vec3 &X, const Tensor &T, int idBlock=1, int gID=1)
Writes a transformation matrix to the VTF-file.
Definition VTF.C:293
int getNodeBlock(int geomID) const
Returns the node block ID associated with a geometry block.
Definition VTF.C:266
bool writeElements(const char *partName, int partID, int iBlockID, int iNodeBlockID)
Writes an element block to the VTF-file.
Definition VTF.C:879
Simple class for representing a point in 3D space.
Definition Vec3.h:27