31 :
Export(participantName, location,
mesh, kind, frequency, rank, size) {};
71 const bool isThreeDim = (
mesh.getDimensions() == 3);
73 if (data->timeStepsStorage().empty()) {
76 int dataDimensions = data->getDimensions();
77 const bool hasGradient = data->hasGradient();
80 if (dataDimensions == 1) {
121 outfile = outfile / filename;
127 outParallelFile <<
"<?xml version=\"1.0\"?>\n";
128 outParallelFile <<
"<VTKFile type=\"P" << formatType <<
"\" version=\"0.1\" byte_order=\"";
130 outParallelFile <<
" <P" << formatType <<
" GhostLevel=\"0\">\n";
132 outParallelFile <<
" <PPoints>\n";
133 outParallelFile <<
" <PDataArray type=\"Float64\" Name=\"Position\" NumberOfComponents=\"" << 3 <<
"\"/>\n";
134 outParallelFile <<
" </PPoints>\n";
142 if (!
_mesh->isPartitionEmpty(rank)) {
148 outParallelFile <<
" </P" << formatType <<
">\n";
149 outParallelFile <<
"</VTKFile>\n";
151 outParallelFile.
close();
172 outSubFile <<
"<?xml version=\"1.0\"?>\n";
173 outSubFile <<
"<VTKFile type=\"" << formatType <<
"\" version=\"0.1\" byte_order=\"";
176 outSubFile <<
" <" << formatType <<
">\n";
187 outSubFile <<
" </Piece>\n";
188 outSubFile <<
" </" << formatType <<
"> \n";
189 outSubFile <<
"</VTKFile>\n";
196 const auto &gradients = data->timeStepsStorage().last().sample.gradients;
197 const int dataDimensions = data->getDimensions();
199 if (dataDimensions == 1) {
200 suffices = {
"_gradient"};
201 }
else if (spaceDim == 2) {
202 suffices = {
"_dx",
"_dy"};
203 }
else if (spaceDim == 3) {
204 suffices = {
"_dx",
"_dy",
"_dz"};
207 for (
const auto &suffix : suffices) {
209 outFile <<
" <DataArray type=\"Float64\" Name=\"" << dataName << suffix <<
"\" NumberOfComponents=\"" << 3;
210 outFile <<
"\" format=\"ascii\">\n";
212 for (
int i = counter; i < gradients.cols(); i += spaceDim) {
214 for (; j < gradients.rows(); j++) {
215 outFile << gradients.coeff(j, i) <<
" ";
223 <<
" </DataArray>\n";
232 outFile <<
" <PointData Scalars=\"Rank ";
234 outFile << scalarDataName <<
' ';
236 outFile <<
"\" Vectors=\"";
238 outFile << vectorDataName <<
' ';
243 outFile <<
" <DataArray type=\"UInt32\" Name=\"Rank\" NumberOfComponents=\"1\" format=\"ascii\">\n";
246 for (
size_t count = 0; count <
mesh.nVertices(); ++count) {
247 outFile << rank <<
' ';
249 outFile <<
"\n </DataArray>\n";
252 if (data->timeStepsStorage().empty()) {
255 const Eigen::VectorXd &values = data->timeStepsStorage().last().sample.values;
256 int dataDimensions = data->getDimensions();
258 int numberOfComponents = (dataDimensions == 2) ? 3 : dataDimensions;
259 const bool hasGradient = data->hasGradient();
260 outFile <<
" <DataArray type=\"Float64\" Name=\"" << dataName <<
"\" NumberOfComponents=\"" << numberOfComponents;
261 outFile <<
"\" format=\"ascii\">\n";
263 if (dataDimensions > 1) {
264 Eigen::VectorXd viewTemp(dataDimensions);
265 for (
size_t count = 0; count <
mesh.nVertices(); count++) {
266 size_t offset = count * dataDimensions;
267 for (
int i = 0; i < dataDimensions; i++) {
268 viewTemp[i] = values(offset + i);
270 for (
int i = 0; i < dataDimensions; i++) {
271 outFile << viewTemp[i] <<
' ';
273 if (dataDimensions == 2) {
274 outFile <<
"0.0" <<
' ';
278 }
else if (dataDimensions == 1) {
279 for (
size_t count = 0; count <
mesh.nVertices(); count++) {
280 outFile << values(count) <<
' ';
284 <<
" </DataArray>\n";
289 outFile <<
" </PointData> \n";
293 const Eigen::VectorXd &position,
297 for (
int i = 0; i < position.size(); i++) {
298 outFile << position(i) <<
" ";
300 if (position.size() == 2) {
301 outFile << 0.0 <<
" ";
337 outFile <<
" <Points> \n";
338 outFile <<
" <DataArray type=\"Float64\" Name=\"Position\" NumberOfComponents=\"" << 3 <<
"\" format=\"ascii\"> \n";
342 outFile <<
" </DataArray>\n";
343 outFile <<
" </Points> \n\n";
349 out <<
" <PPointData Scalars=\"Rank ";
351 out << scalarDataName <<
' ';
354 out <<
"\" Vectors=\"";
356 out << vectorDataName <<
' ';
360 out <<
" <PDataArray type=\"Int32\" Name=\"Rank\" NumberOfComponents=\"1\"/>\n";
363 out <<
" <PDataArray type=\"Float64\" Name=\"" << scalarDataName <<
"\" NumberOfComponents=\"" << 1 <<
"\"/>\n";
367 out <<
" <PDataArray type=\"Float64\" Name=\"" << vectorDataName <<
"\" NumberOfComponents=\"" << 3 <<
"\"/>\n";
369 out <<
" </PPointData>\n";
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
virtual std::string getPieceExtension() const =0
virtual std::string getPieceAttributes(const mesh::Mesh &mesh) const =0
void writeParallelData(std::ostream &out) const
std::string parallelPieceFilenameFor(int index, int rank) const
static void writeLine(const mesh::Edge &edge, std::ostream &outFile)
virtual std::string getVTKFormat() const =0
void exportData(std::ostream &outFile, const mesh::Mesh &mesh) const
virtual void exportConnectivity(std::ostream &outFile, const mesh::Mesh &mesh) const =0
void exportPoints(std::ostream &outFile, const mesh::Mesh &mesh) const
void writeParallelFile(int index, double time)
Writes the primary file (called only by the primary rank)
std::string serialPieceFilename(int index) const
void exportSeries() const final override
static void writeTriangle(const mesh::Triangle &triangle, std::ostream &outFile)
std::vector< std::string > _scalarDataNames
List of names of all scalar data on mesh.
virtual std::string getParallelExtension() const =0
static void writeTetrahedron(const mesh::Tetrahedron &tetra, std::ostream &outFile)
std::vector< std::string > _vectorDataNames
List of names of all vector data on mesh.
void exportGradient(const mesh::PtrData data, const int dataDim, std::ostream &outFile) const
void writeSubFile(int index, double time)
Writes the sub file for each rank.
void processDataNamesAndDimensions(const mesh::Mesh &mesh)
Stores scalar and vector data names in string vectors Needed for writing primary file and sub files.
static void writeVertex(const Eigen::VectorXd &position, std::ostream &outFile)
void doExport(int index, double time) final override
Export the mesh and writes files.
ExportXML(std::string_view participantName, std::string_view location, const mesh::Mesh &mesh, ExportKind kind, int frequency, int rank, int size)
virtual void writeParallelCells(std::ostream &out) const =0
Export(std::string_view participantName, std::string_view location, const mesh::Mesh &mesh, ExportKind kind, int frequency, int rank, int size)
void writeSeriesFile(std::string_view filename) const
void recordExport(std::string filename, double time)
std::string _participantName
const mesh::Mesh *const _mesh
bool keepExport(int index) const
std::string formatIndex(int index) const
Linear edge of a mesh, defined by two Vertex objects.
Vertex & vertex(int i)
Returns the edge's vertex with index 0 or 1.
Container and creator for meshes.
Tetrahedron of a mesh, defined by 4 vertices.
Vertex & vertex(int i)
Returns tetrahedron vertex with index 0, 1, 2 or 3.
Triangle of a mesh, defined by three vertices.
Vertex & vertex(int i)
Returns triangle vertex with index 0, 1 or 2.
VertexID getID() const
Returns the unique (among vertices of one mesh on one processor) ID of the vertex.
static Rank getRank()
Current rank.
static auto allRanks()
Returns an iterable range over all ranks [0, _size)
T create_directories(T... args)
T generic_string(T... args)
provides Import and Export of the coupling mesh and data.
provides Mesh, Data and primitives.
std::shared_ptr< Data > PtrData
contains the time interpolation logic.
bool isMachineBigEndian()
Returns true if machine is big-endian needed for parallel vtk output.