OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::SuperVTMwriter2D< T, OUT_T, W > Class Template Reference

SuperVTMwriter2D writes any SuperF2D to vtk-based output files. More...

#include <superVtmWriter2D.h>

+ Collaboration diagram for olb::SuperVTMwriter2D< T, OUT_T, W >:

Public Member Functions

 SuperVTMwriter2D (std::string name, int overlap=1, bool binary=true)
 
void write (int iT=0)
 writes functors stored in pointerVec every thread writes a vti file with data from his cuboids the vti files are linked in a pvd file
 
void write (SuperF2D< T, W > &f, int iT=0)
 writes functor instantaneously, same vti-pvd file structure as above
 
void write (std::shared_ptr< SuperF2D< T, W > > ptr_f, int iT=0)
 
void createMasterFile ()
 have to be called before calling write(int iT=0), since it creates
 
void addFunctor (SuperF2D< T, W > &f)
 put functor to _pointerVec to simplify writing process of several functors
 
void addFunctor (SuperF2D< T, W > &f, const std::string &functorName)
 put functor with specific name to _pointerVec to simplify writing process of several functors
 
void clearAddedFunctors ()
 to clear stored functors, not yet used due to lack of necessity
 
std::string getName () const
 getter for _name
 

Detailed Description

template<typename T, typename OUT_T = float, typename W = T>
class olb::SuperVTMwriter2D< T, OUT_T, W >

SuperVTMwriter2D writes any SuperF2D to vtk-based output files.

In .pvd files, there are only links/references to a VTKmultiblock file 'vtm'

.pvd file structur the time series is represented by different 'vtm' files.

.vtm file This file links cuboids ('vti') and represents the entire data of a single timestep.

Definition at line 51 of file superVtmWriter2D.h.

Constructor & Destructor Documentation

◆ SuperVTMwriter2D()

template<typename T , typename OUT_T , typename W >
olb::SuperVTMwriter2D< T, OUT_T, W >::SuperVTMwriter2D ( std::string name,
int overlap = 1,
bool binary = true )

Definition at line 49 of file superVtmWriter2D.hh.

50 : clout( std::cout,"SuperVTMwriter2D" ), _createFile(false), _name(name), _overlap(overlap), _binary(binary)
51{
52 static_assert(std::is_same_v<OUT_T, float> || std::is_same_v<OUT_T, double>,
53 "OUT_T must be either float or double");
54}

Member Function Documentation

◆ addFunctor() [1/2]

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::addFunctor ( SuperF2D< T, W > & f)

put functor to _pointerVec to simplify writing process of several functors

Definition at line 211 of file superVtmWriter2D.hh.

212{
213 _pointerVec.push_back(&f);
214}

◆ addFunctor() [2/2]

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::addFunctor ( SuperF2D< T, W > & f,
const std::string & functorName )

put functor with specific name to _pointerVec to simplify writing process of several functors

Definition at line 217 of file superVtmWriter2D.hh.

218{
219 f.getName() = functorName;
220 _pointerVec.push_back(&f);
221}
std::string & getName()
read and write access to name
Definition genericF.hh:51

References olb::GenericF< T, S >::getName().

+ Here is the call graph for this function:

◆ clearAddedFunctors()

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::clearAddedFunctors ( )

to clear stored functors, not yet used due to lack of necessity

Definition at line 224 of file superVtmWriter2D.hh.

225{
226 _pointerVec.clear();
227}

◆ createMasterFile()

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::createMasterFile ( )

have to be called before calling write(int iT=0), since it creates

Definition at line 195 of file superVtmWriter2D.hh.

196{
197 int rank = 0;
198#ifdef PARALLEL_MODE_MPI
199 rank = singleton::mpi().getRank();
200#endif
201 if ( rank == 0 ) {
202 std::string fullNamePVDmaster = singleton::directories().getVtkOutDir()
203 + createFileName( _name ) + ".pvd";
204 preamblePVD(fullNamePVDmaster);
205 closePVD(fullNamePVDmaster);
206 _createFile = true;
207 }
208}
std::string getVtkOutDir() const
Definition singleton.h:97
int getRank() const
Returns the process ID.
MpiManager & mpi()
Directories & directories()
Definition singleton.h:150
std::string createFileName(std::string name)
for .pvd masterFile
Definition fileName.hh:34

References olb::createFileName(), olb::singleton::directories(), olb::singleton::MpiManager::getRank(), olb::singleton::Directories::getVtkOutDir(), and olb::singleton::mpi().

+ Here is the call graph for this function:

◆ getName()

template<typename T , typename OUT_T , typename W >
std::string olb::SuperVTMwriter2D< T, OUT_T, W >::getName ( ) const

getter for _name

Definition at line 230 of file superVtmWriter2D.hh.

231{
232 return _name;
233}

◆ write() [1/3]

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::write ( int iT = 0)

writes functors stored in pointerVec every thread writes a vti file with data from his cuboids the vti files are linked in a pvd file

Definition at line 57 of file superVtmWriter2D.hh.

58{
59 int rank = 0;
60#ifdef PARALLEL_MODE_MPI
61 rank = singleton::mpi().getRank();
62#endif
63
64 // !!!!!!!!!!! check whether _pointerVec is empty
65 if ( _pointerVec.empty() ) {
66 clout << "Error: Did you add a Functor ?";
67 }
68 else {
69 // no gaps between vti files (cuboids)
70 for (SuperF2D<T,W>* f : _pointerVec) {
71 f->getSuperStructure().communicate();
72 }
73
74 // to get first element _pointerVec
75 // problem if functors with different SuperStructure are stored
76 // since till now, there is only one origin
77 auto it_begin = _pointerVec.cbegin();
78 if (it_begin == _pointerVec.end()) {
79 throw std::runtime_error("No functor to write");
80 }
81 CuboidGeometry2D<T> const& cGeometry = (**it_begin).getSuperStructure().getCuboidGeometry();
82 // no gaps between vti files (cuboids)
83 LoadBalancer<T>& load = (**it_begin).getSuperStructure().getLoadBalancer();
84
85 // PVD, owns all
86 if ( rank == 0 ) {
87 std::string pathPVD = singleton::directories().getVtkOutDir()
88 + createFileName( _name ) + ".pvd";
89 dataPVDmaster( iT, pathPVD, "data/" + createFileName( _name, iT ) + ".vtm" );
90
91 std::string pathVTM = singleton::directories().getVtkOutDir()
92 + "data/" + createFileName( _name, iT ) + ".vtm";
93 preambleVTM(pathVTM);
94 for (int iC = 0; iC < cGeometry.getNc(); iC++) {
95 dataVTM( iC, pathVTM, createFileName( _name, iT, iC) + ".vti" );
96 }
97 closeVTM(pathVTM);
98 }
99 // VTI, each process writes his cuboids
100 int originLatticeR[3] = {int()};
101 for (int iCloc = 0; iCloc < load.size(); iCloc++) {
102 int nx = cGeometry.get(load.glob(iCloc)).getNx();
103 int ny = cGeometry.get(load.glob(iCloc)).getNy();
104 // to be changed into the following line once local refinement has been implemented
105 // double deltaX = cGeometry.get(load.glob(iCloc)).getDeltaR();
106 T delta = cGeometry.getMotherCuboid().getDeltaR();
107
108 std::string fullNameVTI = singleton::directories().getVtkOutDir() + "data/"
109 + createFileName( _name, iT, load.glob(iCloc) ) + ".vti";
110
111 // get dimension/extent for each cuboid
112 originLatticeR[0] = load.glob(iCloc);
113 T originPhysR[2] = {T()};
114 cGeometry.getPhysR(originPhysR,originLatticeR);
115
116 preambleVTI(fullNameVTI, -_overlap,-_overlap, nx+_overlap-1, ny+_overlap-1, originPhysR[0],originPhysR[1], delta);
117 for (auto it : _pointerVec) {
118 if (_binary) {
119 dataArrayBinary(fullNameVTI, (*it), load.glob(iCloc), nx,ny);
120 }
121 else {
122 dataArray(fullNameVTI, (*it), load.glob(iCloc), nx,ny);
123 }
124 }
125 closePiece(fullNameVTI);
126 closeVTI(fullNameVTI);
127 }
128 }
129}

References olb::createFileName(), olb::singleton::directories(), olb::CuboidGeometry2D< T >::get(), olb::CuboidGeometry2D< T >::getMotherCuboid(), olb::CuboidGeometry2D< T >::getNc(), olb::CuboidGeometry2D< T >::getPhysR(), olb::singleton::MpiManager::getRank(), olb::singleton::Directories::getVtkOutDir(), olb::LoadBalancer< T >::glob(), olb::singleton::mpi(), and olb::LoadBalancer< T >::size().

+ Here is the call graph for this function:

◆ write() [2/3]

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::write ( std::shared_ptr< SuperF2D< T, W > > ptr_f,
int iT = 0 )

Definition at line 189 of file superVtmWriter2D.hh.

190{
191 write(*ptr_f, iT);
192}
void write(int iT=0)
writes functors stored in pointerVec every thread writes a vti file with data from his cuboids the vt...

◆ write() [3/3]

template<typename T , typename OUT_T , typename W >
void olb::SuperVTMwriter2D< T, OUT_T, W >::write ( SuperF2D< T, W > & f,
int iT = 0 )

writes functor instantaneously, same vti-pvd file structure as above

Definition at line 132 of file superVtmWriter2D.hh.

133{
134 CuboidGeometry2D<T> const& cGeometry = f.getSuperStructure().getCuboidGeometry();
135 LoadBalancer<T>& load = f.getSuperStructure().getLoadBalancer();
136 // no gaps between vti files (cuboids)
138 T delta = cGeometry.getMotherCuboid().getDeltaR();
139
140 int rank = 0;
141#ifdef PARALLEL_MODE_MPI
142 rank = singleton::mpi().getRank();
143#endif
144
145 // write a pvd file, which links all vti files
146 // each vti file is written by one thread, which may own severals cuboids
147 if ( rank == 0 ) {
148 // master only
149 std::string pathVTM = singleton::directories().getVtkOutDir()
150 + createFileName( f.getName(), iT ) + ".vtm";
151
152 preambleVTM(pathVTM);
153 for (int iC = 0; iC < cGeometry.getNc(); iC++) {
154 std::string nameVTI = "data/" + createFileName( f.getName(), iT, iC) + ".vti";
155 // puts name of .vti piece to a .pvd file [fullNamePVD]
156 dataVTM( iC, pathVTM, nameVTI );
157 }
158 closeVTM(pathVTM);
159 } // master only
160
161 for (int iCloc = 0; iCloc < load.size(); iCloc++) {
162 // cuboid
163 int nx = cGeometry.get(load.glob(iCloc)).getNx();
164 int ny = cGeometry.get(load.glob(iCloc)).getNy();
165 // to be changed into the following line once local refinement has been implemented
166 // double deltaX = cGeometry.get(load.glob(iCloc)).getDeltaR();
167
168 std::string fullNameVTI = singleton::directories().getVtkOutDir() + "data/"
169 + createFileName( f.getName(), iT, load.glob(iCloc) ) + ".vti";
170
171 // get dimension/extent for each cuboid
172 int const originLatticeR[3] = {load.glob(iCloc),0,0};
173 T originPhysR[2] = {T()};
174 cGeometry.getPhysR(originPhysR,originLatticeR);
175
176 preambleVTI(fullNameVTI, -_overlap,-_overlap, nx+_overlap-1, ny+_overlap-1, originPhysR[0],originPhysR[1], delta);
177 if (_binary) {
178 dataArrayBinary(fullNameVTI, f, load.glob(iCloc), nx,ny);
179 }
180 else {
181 dataArray(fullNameVTI, f, load.glob(iCloc), nx,ny);
182 }
183 closePiece(fullNameVTI);
184 closeVTI(fullNameVTI);
185 } // cuboid
186}
SuperStructure< T, 2 > & getSuperStructure()
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
virtual void communicate()
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.

References olb::SuperStructure< T, D >::communicate(), olb::createFileName(), olb::singleton::directories(), olb::CuboidGeometry2D< T >::get(), olb::SuperStructure< T, D >::getCuboidGeometry(), olb::SuperStructure< T, D >::getLoadBalancer(), olb::CuboidGeometry2D< T >::getMotherCuboid(), olb::GenericF< T, S >::getName(), olb::CuboidGeometry2D< T >::getNc(), olb::CuboidGeometry2D< T >::getPhysR(), olb::singleton::MpiManager::getRank(), olb::SuperF2D< T, W >::getSuperStructure(), olb::singleton::Directories::getVtkOutDir(), olb::LoadBalancer< T >::glob(), olb::singleton::mpi(), and olb::LoadBalancer< T >::size().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: