HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge and cell polynomials as unknowns
Loading...
Searching...
No Matches
vtu_writer.hpp
Go to the documentation of this file.
1// Creates a .vtu file of the solution, to be visualised by paraview
2//
3// Author: Jerome Droniou (jerome.droniou@monash.edu)
4//
5
6/*
7*
8* This library was developed around HHO methods, although some parts of it have a more
9* general purpose. If you use this code or part of it in a scientific publication,
10* please mention the following book as a reference for the underlying principles
11* of HHO schemes:
12*
13* The Hybrid High-Order Method for Polytopal Meshes: Design, Analysis, and Applications.
14* D. A. Di Pietro and J. Droniou. Modeling, Simulation and Applications, vol. 19.
15* Springer International Publishing, 2020, xxxi + 525p. doi: 10.1007/978-3-030-37203-3.
16* url: https://hal.archives-ouvertes.fr/hal-02151813.
17*
18*/
19
20
21
22#ifndef VTU_WRITER_HPP
23#define VTU_WRITER_HPP
24#include <mesh.hpp>
25#include <cstring>
26#include <vector>
27#include <Eigen/Dense>
28using Eigen::Vector2d;
29
35namespace HArDCore2D {
36
41class VtuWriter {
42public:
48 VtuWriter(const Mesh* mesh);
49
51 bool write_to_vtu(
52 const std::string & filename,
53 const std::vector<Eigen::VectorXd> & sol_vrtx,
54 const std::vector<std::string> & sol_names = {}
55 );
56
58 bool write_to_vtu(std::string file_name);
59
61 inline bool write_to_vtu(
62 const std::string & filename,
63 const Eigen::VectorXd & sol_vrtx,
64 const std::string & sol_name = "solution"
65 )
66 {
67 return write_to_vtu(filename, std::vector<Eigen::VectorXd> {sol_vrtx}, std::vector<std::string> {sol_name});
68 }
69
70private:
71 void write_vertices(FILE* pFile);
72 void write_vertices(FILE* pFile, const Eigen::VectorXd & data);
73 void write_header(FILE* pFile);
74 void write_cells(FILE* pFile);
82 void write_solution(FILE* pFile, const Eigen::VectorXd & sol, const std::string & name);
83 void write_footer(FILE* pFile);
84
85 const Mesh* _mesh;
86
87};
88
90} // namespace HArDCore2D
91
92#endif /* VTU_WRITER_HPP */
Definition vtu_writer.hpp:41
Definition Mesh2D.hpp:26
bool write_to_vtu(const std::string &filename, const Eigen::VectorXd &sol_vrtx, const std::string &sol_name="solution")
Overload to simplify the call when only one solution is involved.
Definition vtu_writer.hpp:61
bool write_to_vtu(const std::string &filename, const std::vector< Eigen::VectorXd > &sol_vrtx, const std::vector< std::string > &sol_names={})
Writes the vtu file
Definition vtu_writer.cpp:130
Definition ddr-klplate.hpp:27