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)
A regular single 3D cuboid is the basic component of a 3D cuboid structure which defines the grid.
Vector< T, 3 > getOrigin() const
Read only access to left lower corner coordinates.
T getDeltaR() const
Read only access to the distance of cuboid nodes.
int getNz() const
Read access to cuboid depth.
int getNy() const
Read access to cuboid height.
int getNx() const
Read access to cuboid width.
A cuboid geometry represents a voxel mesh.
Cuboid3D< T > & get(int iC)
Read and write access to a single cuboid.
Cuboid3D< T > getMotherCuboid()
Returns the smallest cuboid that includes all cuboids of the structure.
Base class for all LoadBalancer.
const BlockData< D, T, U > & getBlock(int iC) const
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
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.
The description of a single 3D cuboid – header file.
The description of a vector of 3D cuboid – header file.
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.