31 if (not location.
empty())
52 outFile <<
"POINTS " << mesh.
nVertices() <<
" double \n\n";
60 outFile <<
"CELLS " << mesh.
edges().
size() <<
' ' << mesh.
edges().
size() * 3 <<
"\n\n";
61 for (
auto const &edge : mesh.
edges()) {
62 int internalIndices[2];
63 internalIndices[0] = edge.vertex(0).getID();
64 internalIndices[1] = edge.vertex(1).getID();
67 outFile <<
"\nCELL_TYPES " << mesh.
edges().
size() <<
"\n\n";
68 for (
size_t i = 0; i < mesh.
edges().size(); ++i) {
78 size_t sizeElements = sizeTriangles + sizeEdges + sizeTetrahedra;
80 outFile <<
"CELLS " << sizeElements <<
' '
81 << sizeTetrahedra * 5 + sizeTriangles * 4 + sizeEdges * 3 <<
"\n\n";
83 int internalIndices[4];
84 internalIndices[0] = tetra.vertex(0).getID();
85 internalIndices[1] = tetra.vertex(1).getID();
86 internalIndices[2] = tetra.vertex(2).getID();
87 internalIndices[3] = tetra.vertex(3).getID();
90 for (
auto const &triangle : mesh.
triangles()) {
91 int internalIndices[3];
92 internalIndices[0] = triangle.vertex(0).getID();
93 internalIndices[1] = triangle.vertex(1).getID();
94 internalIndices[2] = triangle.vertex(2).getID();
97 for (
auto const &edge : mesh.
edges()) {
98 int internalIndices[2];
99 internalIndices[0] = edge.vertex(0).getID();
100 internalIndices[1] = edge.vertex(1).getID();
104 outFile <<
"\nCELL_TYPES " << sizeElements <<
"\n\n";
106 for (
size_t i = 0; i < sizeTetrahedra; i++) {
109 for (
size_t i = 0; i < sizeTriangles; i++) {
112 for (
size_t i = 0; i < sizeEdges; ++i) {
124 outFile <<
"POINT_DATA " << mesh.
nVertices() <<
"\n\n";
126 outFile <<
"SCALARS Rank unsigned_int\n";
127 outFile <<
"LOOKUP_TABLE default\n";
132 Eigen::VectorXd &values = data->values();
133 if (data->getDimensions() > 1) {
134 Eigen::VectorXd viewTemp(data->getDimensions());
135 outFile <<
"VECTORS " << data->getName() <<
" double\n";
137 int offset = vertex.getID() * data->getDimensions();
138 for (
int i = 0; i < data->getDimensions(); i++) {
139 viewTemp[i] = values(offset + i);
142 for (; i < data->getDimensions(); i++) {
143 outFile << viewTemp[i] <<
' ';
151 }
else if (data->getDimensions() == 1) {
152 outFile <<
"SCALARS " << data->getName() <<
" double\n";
153 outFile <<
"LOOKUP_TABLE default\n";
155 outFile << values(vertex.getID()) <<
'\n';
166 if (data->hasGradient()) {
167 auto &gradients = data->gradients();
168 if (data->getDimensions() == 1) {
169 outFile <<
"VECTORS " << data->getName() <<
"_gradient"
171 for (
int i = 0; i < gradients.cols(); i++) {
173 for (; j < gradients.rows(); j++) {
174 outFile << gradients.coeff(j, i) <<
" ";
182 outFile <<
"VECTORS " << data->getName() <<
"_dx"
184 for (
int i = 0; i < gradients.cols(); i += spaceDim) {
186 for (; j < gradients.rows(); j++) {
187 outFile << gradients.coeff(j, i) <<
" ";
196 outFile <<
"VECTORS " << data->getName() <<
"_dy"
198 for (
int i = 1; i < gradients.cols(); i += spaceDim) {
200 for (; j < gradients.rows(); j++) {
201 outFile << gradients.coeff(j, i) <<
" ";
211 outFile <<
"VECTORS " << data->getName() <<
"_dz"
213 for (
int i = 2; i < gradients.cols(); i += spaceDim) {
215 for (; j < gradients.rows(); j++) {
216 outFile << gradients.coeff(j, i) <<
" ";
237 filestream.
setf(std::ios::showpoint);
238 filestream.
setf(std::ios::scientific);
245 outFile <<
"# vtk DataFile Version 2.0\n\n"
247 <<
"DATASET UNSTRUCTURED_GRID\n\n";
251 const Eigen::VectorXd &position,
254 if (position.size() == 2) {
255 outFile << position(0) <<
" " << position(1) <<
" " << 0.0 <<
'\n';
258 outFile << position(0) <<
" " << position(1) <<
" " << position(2) <<
'\n';
263 int vertexIndices[3],
267 for (
int i = 0; i < 3; i++) {
268 outFile << vertexIndices[i] <<
' ';
274 int vertexIndices[4],
278 for (
int i = 0; i < 4; i++) {
279 outFile << vertexIndices[i] <<
' ';
285 int vertexIndices[2],
289 for (
int i = 0; i < 2; i++) {
290 outFile << vertexIndices[i] <<
' ';
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
void exportData(std::ofstream &outFile, const mesh::Mesh &mesh)
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 exportMesh(std::ofstream &outFile, const mesh::Mesh &mesh)
virtual void doExport(const std::string &name, const std::string &location, const mesh::Mesh &mesh)
Perform writing to VTK file.
static void writeTriangle(int vertexIndices[3], std::ostream &outFile)
void exportGradient(std::ofstream &outFile, const mesh::Mesh &mesh)
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.
static bool isParallel()
True if this process is running in parallel.
T create_directories(T... args)
T generic_string(T... args)
provides Import and Export of the coupling mesh and data.
T setprecision(T... args)