30 if (not location.
empty())
46 int dataDimensions = data->getDimensions();
47 const bool hasGradient = data->hasGradient();
50 if (dataDimensions == 1) {
81 outParallelFile <<
"<?xml version=\"1.0\"?>\n";
82 outParallelFile <<
"<VTKFile type=\"P" << formatType <<
"\" version=\"0.1\" byte_order=\"";
84 outParallelFile <<
" <P" << formatType <<
" GhostLevel=\"0\">\n";
86 outParallelFile <<
" <PPoints>\n";
87 outParallelFile <<
" <PDataArray type=\"Float64\" Name=\"Position\" NumberOfComponents=\"" << 3 <<
"\"/>\n";
88 outParallelFile <<
" </PPoints>\n";
101 if (offsets[rank] - offsets[rank - 1] > 0) {
107 outParallelFile <<
" </P" << formatType <<
">\n";
108 outParallelFile <<
"</VTKFile>\n";
110 outParallelFile.
close();
116 if (!utils::IntraComm::isParallel()) {
136 outSubFile <<
"<?xml version=\"1.0\"?>\n";
137 outSubFile <<
"<VTKFile type=\"" << formatType <<
"\" version=\"0.1\" byte_order=\"";
140 outSubFile <<
" <" << formatType <<
">\n";
150 outSubFile <<
" </Piece>\n";
151 outSubFile <<
" </" << formatType <<
"> \n";
152 outSubFile <<
"</VTKFile>\n";
159 const auto & gradients = data->gradients();
160 const int dataDimensions = data->getDimensions();
162 if (dataDimensions == 1) {
163 suffices = {
"_gradient"};
164 }
else if (spaceDim == 2) {
165 suffices = {
"_dx",
"_dy"};
166 }
else if (spaceDim == 3) {
167 suffices = {
"_dx",
"_dy",
"_dz"};
170 for (
const auto &suffix : suffices) {
172 outFile <<
" <DataArray type=\"Float64\" Name=\"" << dataName << suffix <<
"\" NumberOfComponents=\"" << 3;
173 outFile <<
"\" format=\"ascii\">\n";
175 for (
int i = counter; i < gradients.cols(); i += spaceDim) {
177 for (; j < gradients.rows(); j++) {
178 outFile << gradients.coeff(j, i) <<
" ";
186 <<
" </DataArray>\n";
195 outFile <<
" <PointData Scalars=\"Rank ";
197 outFile << scalarDataName <<
' ';
199 outFile <<
"\" Vectors=\"";
201 outFile << vectorDataName <<
' ';
206 outFile <<
" <DataArray type=\"UInt32\" Name=\"Rank\" NumberOfComponents=\"1\" format=\"ascii\">\n";
209 for (
size_t count = 0; count < mesh.
nVertices(); ++count) {
210 outFile << rank <<
' ';
212 outFile <<
"\n </DataArray>\n";
215 Eigen::VectorXd &values = data->values();
216 int dataDimensions = data->getDimensions();
218 int numberOfComponents = (dataDimensions == 2) ? 3 : dataDimensions;
219 const bool hasGradient = data->hasGradient();
220 outFile <<
" <DataArray type=\"Float64\" Name=\"" << dataName <<
"\" NumberOfComponents=\"" << numberOfComponents;
221 outFile <<
"\" format=\"ascii\">\n";
223 if (dataDimensions > 1) {
224 Eigen::VectorXd viewTemp(dataDimensions);
225 for (
size_t count = 0; count < mesh.
nVertices(); count++) {
226 size_t offset = count * dataDimensions;
227 for (
int i = 0; i < dataDimensions; i++) {
228 viewTemp[i] = values(offset + i);
230 for (
int i = 0; i < dataDimensions; i++) {
231 outFile << viewTemp[i] <<
' ';
233 if (dataDimensions == 2) {
234 outFile <<
"0.0" <<
' ';
238 }
else if (dataDimensions == 1) {
239 for (
size_t count = 0; count < mesh.
nVertices(); count++) {
240 outFile << values(count) <<
' ';
244 <<
" </DataArray>\n";
249 outFile <<
" </PointData> \n";
253 const Eigen::VectorXd &position,
257 for (
int i = 0; i < position.size(); i++) {
258 outFile << position(i) <<
" ";
260 if (position.size() == 2) {
261 outFile << 0.0 <<
" ";
297 outFile <<
" <Points> \n";
298 outFile <<
" <DataArray type=\"Float64\" Name=\"Position\" NumberOfComponents=\"" << 3 <<
"\" format=\"ascii\"> \n";
302 outFile <<
" </DataArray>\n";
303 outFile <<
" </Points> \n\n";
309 out <<
" <PPointData Scalars=\"Rank ";
311 out << scalarDataName <<
' ';
314 out <<
"\" Vectors=\"";
316 out << vectorDataName <<
' ';
320 out <<
" <PDataArray type=\"Int32\" Name=\"Rank\" NumberOfComponents=\"1\"/>\n";
323 out <<
" <PDataArray type=\"Float64\" Name=\"" << scalarDataName <<
"\" NumberOfComponents=\"" << 1 <<
"\"/>\n";
327 out <<
" <PDataArray type=\"Float64\" Name=\"" << vectorDataName <<
"\" NumberOfComponents=\"" << 3 <<
"\"/>\n";
329 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
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 writeSubFile(const std::string &name, const std::string &location, const mesh::Mesh &mesh) const
Writes the sub file for each rank.
void doExport(const std::string &name, const std::string &location, const mesh::Mesh &mesh) override
Does export. Has to be implemented in subclass.
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 writeParallelFile(const std::string &name, const std::string &location, const mesh::Mesh &mesh) const
Writes the primary file (called only by the primary 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)
virtual void writeParallelCells(std::ostream &out) const =0
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.
int getDimensions() const
VertexContainer & vertices()
Returns modifieable container holding all vertices.
const std::string & getName() const
Returns the name of the mesh, as set in the config file.
std::size_t nVertices() const
Returns the number of vertices.
const VertexOffsets & getVertexOffsets() const
const DataContainer & data() const
Allows access to all data.
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 bool isPrimary()
True if this process is running the primary rank.
static auto allSecondaryRanks()
Returns an iterable range over salve ranks [1, _size)
T create_directories(T... args)
T generic_string(T... args)
provides Import and Export of the coupling mesh and data.
bool isMachineBigEndian()
Returns true if machine is big-endian needed for parallel vtk output.