C++ main module for stochmagnet Package  1.0
SM_XDMF.h
Go to the documentation of this file.
1 #ifndef SM_XDMF_H
2 #define SM_XDMF_H
3 
4 //base class header
5 #include "SM_VTK.h"
6 
7 //file header
8 #include "CORE_OutputFile.h"
9 
10 //vector header
11 #include <vector>
12 
20 class SM_XDMF : public SM_VTK {
21 
22  // ATTRIBUTES
23 
24 
25 private:
26 
27  // the format of the data
31 
32 
33  //output stream
35 
36 
37 protected:
38  // METHODS
39 
40  // CONSTRUCTORS
41 
44  SM_XDMF(void);
45 
46 
47 
48  // DESTRUCTORS
49 
50 
53  virtual ~SM_XDMF(void);
54 
55 
56 
57 public:
61  inline static CORE_UniquePointer<SM_XDMF> New() {
63  };
68  inline static CORE_UniquePointer<SM_XDMF> New(const tString& format) {
70  p->setFormat(format);
71  return p;
72  };
73 
74  //MEMORY
75 
89  virtual tMemSize getMemorySize() const {
90  return sizeof(*this)+getContentsMemorySize();
91  }
92 
101  virtual tMemSize getContentsMemorySize() const {
103  mem+=mFormat.size();
104  mem+=mName.size();
105  mem+=mExternalFileName.size();
106  mem+=(mFile.get()==null)?0:mFile->getContentsMemorySize();
107  return mem;
108 
109  }
110 
111  //Virtual classes for writing VTK files
112  //======================================
113 
117  virtual tBoolean open() override;
118 
119 
124  virtual tBoolean open(const tIndex& t) override {
125 
126  return true;
127  }
128 
129 
135  virtual tBoolean writeGeometryHeader(const tIndex&t,const SM_Network& network) override;
136 
142  virtual tBoolean writeGeometryData(const tIndex& t,const SM_Network& network) override;
143 
151  virtual tBoolean writeContentHeader(const tIndex& t,
152  const tFlag& support,
153  const std::vector<tString>& scalarNames,
154  const std::vector<tString>& vectorNames) override;
155 
165  virtual tBoolean writeContentData(const tIndex& t,
166  const SM_Network& network,
167  const tFlag& support,
168  const tString& name,
169  const tReal* f) override;
170 
176  virtual tBoolean writeContentFooter(const tIndex& t,const tFlag& support) override;
177 
178 
183  virtual tBoolean writeGeometryFooter(const tIndex& t)override;
184 
185 
186 
191  virtual tBoolean close(const tIndex& t) override {
192  return true;
193  }
194 
198  virtual tBoolean close() override;
199 
203  inline void setExternalFileName(const tString& f) {
205  }
206 
207 public:
211  inline void setFormat(const tString& f) {
212  mFormat=f;
213  }
214 
215 
216 
217 protected:
218 
219  //XDMF writing method
220  //===================
221 
225  inline const tString& getFormat() const {
226  return mFormat;
227  }
231  inline const tString& getExternalFileName() const {
232  return mExternalFileName;
233  }
234 
235 protected:
242  virtual tBoolean writeVertices(CORE_OutputFile& file,
243  const SM_Network& mesh,
244  const tString& tag) const;
245 
252  const SM_Network& mesh) {
253  return writeVertices(file,mesh,"");
254  }
265  const tIndex& nVertexCells,const tIndex& nEdgeCells,
266  const std::valarray<tUInt>& neighborsNumber,
267  const std::valarray<tIndex>& neighborIndices,
268  const tString& tagN) const;
269 
279  const tIndex& nVertexCells,const tIndex& nEdgeCells,
280  const std::valarray<tUInt>& neighbors,
281  const std::valarray<tIndex>& neighborIndices) const {
282  return writeConnectivity(file,nVertexCells,nEdgeCells,neighbors,neighborIndices,"");
283  }
284 
285 
286 
298  virtual tBoolean writeField(CORE_OutputFile& file,
299  const tIndex& t,
300  const tFlag& contentType,
301  const tString& name,
302  const tString& tagName,
303  const tIndex& n,
304  const tDimension& dim,
305  const tReal* f) const;
306 
307 
319  const tIndex& t,
320  const tFlag& contentType,
321  const tString& name,
322  const tIndex& n,
323  const tDimension& dim,
324  const tReal* f) const {
325  return writeField(file,t,contentType,name,"",n,dim,f);
326  }
327 
328 
329 
330 
331 
332 
333 
334 
335 
336 };
337 
338 #endif
tUCInt tDimension
Definition: CORE_StdPtrField.h:567
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:94
this class describes a writing file
Definition: CORE_OutputFile.h:16
This class is describes a a network.
Definition: SM_Network.h:18
This class is a beam output interface for VTK / Paraview software.
Definition: SM_VTK.h:22
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_VTK.h:85
This class is a beam interface output for XMF format for paraview visualization software.
Definition: SM_XDMF.h:20
SM_XDMF(void)
create
Definition: SM_XDMF.cpp:6
virtual tBoolean writeConnectivity(CORE_OutputFile &file, const tIndex &nVertexCells, const tIndex &nEdgeCells, const std::valarray< tUInt > &neighbors, const std::valarray< tIndex > &neighborIndices) const
write the connectivity between vertices
Definition: SM_XDMF.h:278
static CORE_UniquePointer< SM_XDMF > New()
create an XDMF class
Definition: SM_XDMF.h:61
virtual ~SM_XDMF(void)
destroy
Definition: SM_XDMF.cpp:20
virtual tMemSize getContentsMemorySize() const
return the memory size of the included associations
Definition: SM_XDMF.h:101
void setFormat(const tString &f)
set the format of the data
Definition: SM_XDMF.h:211
virtual tBoolean writeContentFooter(const tIndex &t, const tFlag &support) override
write a content footer
Definition: SM_XDMF.cpp:130
virtual tBoolean writeGeometryFooter(const tIndex &t) override
write the geometry footer
Definition: SM_XDMF.cpp:110
virtual tBoolean writeGeometryData(const tIndex &t, const SM_Network &network) override
write the geometry data of the network
Definition: SM_XDMF.cpp:90
const tString & getExternalFileName() const
get the external file name to find data
Definition: SM_XDMF.h:231
const tString & getFormat() const
get the format of the data
Definition: SM_XDMF.h:225
tString mExternalFileName
Definition: SM_XDMF.h:30
virtual tBoolean writeGeometryHeader(const tIndex &t, const SM_Network &network) override
write the geometry header corresponding to the network
Definition: SM_XDMF.cpp:64
virtual tMemSize getMemorySize() const
return the memory size of the class and the memory size of all its attributes/associations
Definition: SM_XDMF.h:89
static CORE_UniquePointer< SM_XDMF > New(const tString &format)
create an XDMF class
Definition: SM_XDMF.h:68
tString mName
Definition: SM_XDMF.h:29
virtual tBoolean open() override
open the vtkfile
Definition: SM_XDMF.cpp:26
virtual tBoolean writeField(CORE_OutputFile &file, const tIndex &t, const tFlag &contentType, const tString &name, const tString &tagName, const tIndex &n, const tDimension &dim, const tReal *f) const
write a field with name
Definition: SM_XDMF.cpp:305
virtual tBoolean writeVertices(CORE_OutputFile &file, const SM_Network &mesh)
write the vertices coordinates
Definition: SM_XDMF.h:251
tString mFormat
Definition: SM_XDMF.h:28
virtual tBoolean close(const tIndex &t) override
close the file for the time step t
Definition: SM_XDMF.h:191
virtual tBoolean open(const tIndex &t) override
open the vtk field for writing or appending at the time step
Definition: SM_XDMF.h:124
virtual tBoolean writeConnectivity(CORE_OutputFile &file, const tIndex &nVertexCells, const tIndex &nEdgeCells, const std::valarray< tUInt > &neighborsNumber, const std::valarray< tIndex > &neighborIndices, const tString &tagN) const
write the connectivity between vertices
Definition: SM_XDMF.cpp:223
virtual tBoolean writeContentData(const tIndex &t, const SM_Network &network, const tFlag &support, const tString &name, const tReal *f) override
write a content data
Definition: SM_XDMF.cpp:135
virtual tBoolean writeContentHeader(const tIndex &t, const tFlag &support, const std::vector< tString > &scalarNames, const std::vector< tString > &vectorNames) override
write a content header
Definition: SM_XDMF.cpp:115
void setExternalFileName(const tString &f)
set the external file to find the vector data
Definition: SM_XDMF.h:203
virtual tBoolean writeField(CORE_OutputFile &file, const tIndex &t, const tFlag &contentType, const tString &name, const tIndex &n, const tDimension &dim, const tReal *f) const
write a field with name
Definition: SM_XDMF.h:318
virtual tBoolean close() override
close the file
Definition: SM_XDMF.cpp:49
CORE_UniquePointer< CORE_OutputFile > mFile
Definition: SM_XDMF.h:34
virtual tBoolean writeVertices(CORE_OutputFile &file, const SM_Network &mesh, const tString &tag) const
write the vertices coordinates
Definition: SM_XDMF.cpp:179
typename std::unique_ptr< T, CORE_Object::Delete > CORE_UniquePointer
Definition: sp.h:8
#define tFlag
Definition: types.h:91
#define tIndex
Definition: types.h:157
#define tString
Definition: types.h:147
#define tMemSize
Definition: types.h:166
#define tBoolean
Definition: types.h:151
#define tReal
Definition: types.h:137