50template<
typename T,
typename BaseType>
51OstreamManager VTIwriter3D<T,BaseType>::clout(
"VTIwriter3D");
53template<
typename T,
typename BaseType>
56template<
typename T,
typename BaseType>
62 std::string fullName = getFullName(fName);
63 writePreamble(fullName, cuboid);
64 writeBlockData(fullName, fieldName, blockData, cuboid);
65 writePostScript(fullName);
68template<
typename T,
typename BaseType>
74 std::string fullName = getFullName(fName);
78#ifdef PARALLEL_MODE_MPI
87#ifdef PARALLEL_MODE_MPI
92 for (
int iRank = 0; iRank < size; ++iRank) {
94 for (
int iC = 0; iC < loadBalancer.
size(); ++iC) {
96 writeBlockData(fullName, fieldName, superData.
getBlock(iC), cGeometry.
get(loadBalancer.
glob(iC)));
99#ifdef PARALLEL_MODE_MPI
107 writePostScript(fullName);
111template<
typename T,
typename BaseType>
118template<
typename T,
typename BaseType>
123 std::ofstream fout(fullName.c_str(), std::ios::app);
125 std::cout <<
"Error: could not open file " << fullName << std::endl;
132 int globX = (int) (origin[0] / (T)delta);
133 int globY = (int) (origin[1] / (T)delta);
134 int globZ = (int) (origin[2] / (T)delta);
135 fout <<
"<Piece Extent=\""
136 << globX <<
" " << cuboid.
getNx() - 1 + globX <<
" "
137 << globY <<
" " << cuboid.
getNy() - 1 + globY <<
" "
138 << globZ <<
" " << cuboid.
getNz() - 1 + globZ <<
"\">\n";
141 fout <<
"<PointData>\n";
145 fout <<
"<DataArray type=\"Float32\" Name=\"" << fieldName
146 <<
"\" NumberOfComponents=\"" << blockData.
getSize() <<
"\">\n";
149 for (
int iZ = 0; iZ < cuboid.
getNz(); ++iZ) {
150 for (
int iY = 0; iY < cuboid.
getNy(); ++iY) {
151 for (
int iX = 0; iX < cuboid.
getNx(); ++iX) {
152 for (
unsigned iSize = 0; iSize < blockData.
getSize(); ++iSize) {
153 fout << blockData.
get({iX, iY, iZ}, iSize) <<
" ";
161 fout <<
"</DataArray>\n";
162 fout <<
"</PointData>\n";
163 fout <<
"</Piece>\n";
169template<
typename T,
typename BaseType>
170void VTIwriter3D<T,BaseType>::writePreamble(std::string& fullName,
Cuboid3D<T> const& cuboid)
172 Vector<T,3> origin = cuboid.getOrigin();
173 writePreamble(fullName,
174 cuboid.getNx() - 1, cuboid.getNy() - 1, cuboid.getNz() - 1,
176 origin[0], origin[1], origin[2]);
179template<
typename T,
typename BaseType>
180void VTIwriter3D<T,BaseType>::writePreamble(std::string& fullName,
int nx,
181 int ny,
int nz, T delta, T originX, T originY, T originZ)
184 std::ofstream fout(fullName.c_str());
186 clout <<
"Error: could not open " << fullName << std::endl;
190 fout <<
"<?xml version=\"1.0\"?>\n";
191 fout <<
"<VTKFile type=\"ImageData\" version=\"0.1\" "
192 <<
"byte_order=\"LittleEndian\">\n";
193 fout <<
"<ImageData";
194 fout <<
" WholeExtent=\" 0 " << nx <<
" 0 " << ny <<
" 0 " << nz <<
" \"";
195 fout <<
" Origin=\"" << originX <<
" " << originY <<
" " << originZ <<
"\"";
196 fout <<
" Spacing=\"" << delta <<
" " << delta <<
" " << delta <<
"\">\n";
202template<
typename T,
typename BaseType>
203void VTIwriter3D<T,BaseType>::writePostScript(std::string& fullName)
205 std::ofstream fout(fullName.c_str(), std::ios::app );
207 clout <<
"Error: could not open " << fullName << std::endl;
210 fout <<
"</ImageData>\n";
211 fout <<
"</VTKFile>\n";
216template<
typename T,
typename BaseType>
217std::string VTIwriter3D<T,BaseType>::getFullName(std::string
const& fName)
U & get(std::size_t iCell, int iD=0)
const Cuboid< T, D > & get(int iC) const
Read access to a single cuboid.
const Cuboid< T, D > & getMotherCuboid() const
Returns the smallest cuboid that includes all cuboids of the structure.
Vector< T, D > getOrigin() const
Returns lower left corner coordinates.
T getDeltaR() const
Returns spacing of cuboid nodes.
Base class for all LoadBalancer.
const BlockData< D, T, U > & getBlock(int iC) const
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
CuboidDecomposition< T, D > & getCuboidDecomposition()
Read and write access to cuboid geometry.
static void writeData(std::string const &fName, std::string const &fieldName, BlockData< 3, T, BaseType > const &blockData, Cuboid3D< T > const &cuboid)
Write Single Block Data.
std::string getVtkOutDir() const
int getSize() const
Returns the number of processes.
int getRank() const
Returns the process ID.
void barrier(MPI_Comm comm=MPI_COMM_WORLD)
Synchronizes the processes.
Directories & directories()
Top level namespace for all of OpenLB.
Definition of singletons: global, publicly available information.
Dynamics for a generic 2D super data – header file.
A method to write vti data for cuboid geometries (only for uniform grids) – header file.