28 :
Export(participantName, location, mesh, kind, frequency, rank, size) {};
46 outfile = outfile / filename;
74 outFile <<
"POINTS " << mesh.
nVertices() <<
" double \n\n";
82 outFile <<
"CELLS " << mesh.
edges().
size() <<
' ' << mesh.
edges().
size() * 3 <<
"\n\n";
83 for (
auto const &edge : mesh.
edges()) {
84 int internalIndices[2];
85 internalIndices[0] = edge.vertex(0).getID();
86 internalIndices[1] = edge.vertex(1).getID();
89 outFile <<
"\nCELL_TYPES " << mesh.
edges().
size() <<
"\n\n";
90 for (
size_t i = 0; i < mesh.
edges().size(); ++i) {
100 size_t sizeElements = sizeTriangles + sizeEdges + sizeTetrahedra;
102 outFile <<
"CELLS " << sizeElements <<
' '
103 << sizeTetrahedra * 5 + sizeTriangles * 4 + sizeEdges * 3 <<
"\n\n";
105 int internalIndices[4];
106 internalIndices[0] = tetra.vertex(0).getID();
107 internalIndices[1] = tetra.vertex(1).getID();
108 internalIndices[2] = tetra.vertex(2).getID();
109 internalIndices[3] = tetra.vertex(3).getID();
112 for (
auto const &triangle : mesh.
triangles()) {
113 int internalIndices[3];
114 internalIndices[0] = triangle.vertex(0).getID();
115 internalIndices[1] = triangle.vertex(1).getID();
116 internalIndices[2] = triangle.vertex(2).getID();
119 for (
auto const &edge : mesh.
edges()) {
120 int internalIndices[2];
121 internalIndices[0] = edge.vertex(0).getID();
122 internalIndices[1] = edge.vertex(1).getID();
126 outFile <<
"\nCELL_TYPES " << sizeElements <<
"\n\n";
128 for (
size_t i = 0; i < sizeTetrahedra; i++) {
131 for (
size_t i = 0; i < sizeTriangles; i++) {
134 for (
size_t i = 0; i < sizeEdges; ++i) {
146 outFile <<
"POINT_DATA " << mesh.
nVertices() <<
"\n\n";
148 outFile <<
"SCALARS Rank unsigned_int\n";
149 outFile <<
"LOOKUP_TABLE default\n";
154 if (data->timeStepsStorage().empty()) {
157 const Eigen::VectorXd &values = data->timeStepsStorage().last().sample.values;
158 if (data->getDimensions() > 1) {
159 Eigen::VectorXd viewTemp(data->getDimensions());
160 outFile <<
"VECTORS " << data->getName() <<
" double\n";
162 int offset = vertex.getID() * data->getDimensions();
163 for (
int i = 0; i < data->getDimensions(); i++) {
164 viewTemp[i] = values(offset + i);
167 for (; i < data->getDimensions(); i++) {
168 outFile << viewTemp[i] <<
' ';
176 }
else if (data->getDimensions() == 1) {
177 outFile <<
"SCALARS " << data->getName() <<
" double\n";
178 outFile <<
"LOOKUP_TABLE default\n";
180 outFile << values(vertex.getID()) <<
'\n';
191 if (data->timeStepsStorage().empty() || !data->hasGradient()) {
194 const auto &gradients = data->timeStepsStorage().last().sample.gradients;
195 if (data->getDimensions() == 1) {
196 outFile <<
"VECTORS " << data->getName() <<
"_gradient"
198 for (
int i = 0; i < gradients.cols(); i++) {
200 for (; j < gradients.rows(); j++) {
201 outFile << gradients.coeff(j, i) <<
" ";
209 outFile <<
"VECTORS " << data->getName() <<
"_dx"
211 for (
int i = 0; i < gradients.cols(); i += spaceDim) {
213 for (; j < gradients.rows(); j++) {
214 outFile << gradients.coeff(j, i) <<
" ";
223 outFile <<
"VECTORS " << data->getName() <<
"_dy"
225 for (
int i = 1; i < gradients.cols(); i += spaceDim) {
227 for (; j < gradients.rows(); j++) {
228 outFile << gradients.coeff(j, i) <<
" ";
238 outFile <<
"VECTORS " << data->getName() <<
"_dz"
240 for (
int i = 2; i < gradients.cols(); i += spaceDim) {
242 for (; j < gradients.rows(); j++) {
243 outFile << gradients.coeff(j, i) <<
" ";
263 filestream.
setf(std::ios::showpoint);
264 filestream.
setf(std::ios::scientific);
271 outFile <<
"# vtk DataFile Version 2.0\n\n"
273 <<
"DATASET UNSTRUCTURED_GRID\n\n";
277 const Eigen::VectorXd &position,
280 if (position.size() == 2) {
281 outFile << position(0) <<
" " << position(1) <<
" " << 0.0 <<
'\n';
284 outFile << position(0) <<
" " << position(1) <<
" " << position(2) <<
'\n';
289 int vertexIndices[3],
293 for (
int i = 0; i < 3; i++) {
294 outFile << vertexIndices[i] <<
' ';
300 int vertexIndices[4],
304 for (
int i = 0; i < 4; i++) {
305 outFile << vertexIndices[i] <<
' ';
311 int vertexIndices[2],
315 for (
int i = 0; i < 2; i++) {
316 outFile << vertexIndices[i] <<
' ';
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
void exportData(std::ofstream &outFile, const mesh::Mesh &mesh)
ExportVTK(std::string_view participantName, std::string_view location, const mesh::Mesh &mesh, ExportKind kind, int frequency, int rank, int size)
static void writeVertex(const Eigen::VectorXd &position, std::ostream &outFile)
static void writeHeader(std::ostream &outFile)
static void writeLine(int vertexIndices[2], std::ostream &outFile)
static void initializeWriting(std::ofstream &filestream)
static void writeTetrahedron(int vertexIndices[4], std::ostream &outFile)
void exportSeries() const final override
void exportMesh(std::ofstream &outFile, const mesh::Mesh &mesh)
static void writeTriangle(int vertexIndices[3], std::ostream &outFile)
void doExport(int index, double time) final override
Perform writing to VTK file.
void exportGradient(std::ofstream &outFile, const mesh::Mesh &mesh)
Abstract base class of all classes exporting container data structures.
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
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.
TetraContainer & tetrahedra()
Returns modifiable container holding all tetrahedra.
const DataContainer & data() const
Allows access to all data.
TriangleContainer & triangles()
Returns modifiable container holding all triangles.
EdgeContainer & edges()
Returns modifiable container holding all edges.
T create_directories(T... args)
T generic_string(T... args)
provides Import and Export of the coupling mesh and data.
T setprecision(T... args)