30 using namespace
Input::Type;
34 return Record(
"gmsh",
"Parameters of gmsh output format.")
67 file <<
"$MeshFormat" << endl;
68 file <<
"2" <<
" 0 " <<
sizeof(double) << endl;
69 file <<
"$EndMeshFormat" << endl;
77 file <<
"$Nodes" << endl;
78 file << this->
nodes_->n_values() << endl;
79 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
80 for(
unsigned int i_node=0; i_node < id_node_vec.size(); ++i_node) {
81 file << id_node_vec[i_node] <<
" ";
82 this->
nodes_->print_ascii(file, i_node);
85 file <<
"$EndNodes" << endl;
91 const static unsigned int gmsh_simplex_types_[4] = {0, 1, 2, 4};
92 auto &id_elem_vec = *( this->
elem_ids_->get_component_data(0).get() );
93 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
94 auto &connectivity_vec = *( this->
connectivity_->get_component_data(0).get() );
95 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
96 auto ®ions_vec = *( this->
region_ids_->get_component_data(0).get() );
97 auto &partition_vec = *( this->
partitions_->get_component_data(0).get() );
99 unsigned int n_nodes, i_node=0;
102 file <<
"$Elements" << endl;
103 file << this->
offsets_->n_values() << endl;
105 for(
unsigned int i_elm=0; i_elm < id_elem_vec.size(); ++i_elm) {
106 n_nodes = (i_elm==0) ? (offsets_vec[0]) : (offsets_vec[i_elm]-offsets_vec[i_elm-1]);
108 file << id_elem_vec[i_elm]
109 <<
" " << gmsh_simplex_types_[ n_nodes-1 ]
110 <<
" 3 " << regions_vec[i_elm] <<
" " << regions_vec[i_elm] <<
" " << partition_vec[i_elm];
112 for(
unsigned int i=0; i<n_nodes; i++, i_node++) {
113 file <<
" " << id_node_vec[connectivity_vec[i_node]];
117 file <<
"$EndElements" << endl;
124 auto &id_vec = *( id_cache->get_component_data(0).get() );
127 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
128 unsigned int n_nodes, i_corner=0;
129 for(
unsigned int i=0; i < id_vec.size(); ++i) {
130 n_nodes = (i==0) ? (offsets_vec[0]) : (offsets_vec[i]-offsets_vec[i-1]);
131 file << id_vec[i] <<
" " << n_nodes <<
" ";
132 for (
unsigned int j=0; j<n_nodes; j++)
133 output_data->print_ascii(file, i_corner++);
137 for(
unsigned int i=0; i < output_data->n_values(); ++i) {
138 file << id_vec[i] <<
" ";
139 output_data->print_ascii(file, i);
150 double time_fixed = isfinite(this->
time)?this->
time:0;
153 file <<
"$NodeData" << endl;
156 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
159 file << time_fixed << endl;
163 file << output_data->n_comp() << endl;
164 file << output_data->n_values() << endl;
168 file <<
"$EndNodeData" << endl;
175 double time_fixed = isfinite(this->
time)?this->
time:0;
177 file <<
"$ElementNodeData" << endl;
180 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
183 file << time_fixed << endl;
187 file << output_data->n_comp() << endl;
188 file << this->
offsets_->n_values() << endl;
192 file <<
"$EndElementNodeData" << endl;
198 double time_fixed = isfinite(this->
time)?this->
time:0;
200 file <<
"$ElementData" << endl;
203 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
206 file << time_fixed << endl;
210 file << output_data->n_comp() << endl;
211 file << output_data->n_values() << endl;
215 file <<
"$EndElementData" << endl;
236 if (this->
rank_ != 0) {
256 for(
auto data_it = node_data_list.begin(); data_it != node_data_list.end(); ++data_it) {
260 for(
auto data_it = corner_data_list.begin(); data_it != corner_data_list.end(); ++data_it) {
264 for(
auto data_it = elem_data_list.begin(); data_it != elem_data_list.end(); ++data_it) {
287 mesh_ptr->get_master_mesh()->create_id_caches();
288 this->
node_ids_ = mesh_ptr->get_master_mesh()->node_ids_;
289 this->
elem_ids_ = mesh_ptr->get_master_mesh()->elem_ids_;
290 this->
region_ids_ = mesh_ptr->get_master_mesh()->region_ids_;
291 this->
partitions_ = mesh_ptr->get_master_mesh()->partitions_;
Classes for auxiliary output mesh.
std::vector< std::vector< OutputDataPtr > > dummy_data_list_
virtual void set_output_data_caches(std::shared_ptr< OutputMeshBase > mesh_ptr)
void write_msh_header(void)
This function write header of GMSH (.msh) file format.
static const Input::Type::Record & get_input_type()
The definition of input record for gmsh file format.
Input::Record input_record_
OutputMSH()
The constructor of this class. We open the output file in first call of write_data.
void fix_main_file_extension(std::string extension)
std::shared_ptr< ElementDataCache< unsigned int > > connectivity_
Vector maps the nodes to their coordinates in vector nodes_.
void write_msh_ascii_data(std::shared_ptr< ElementDataCache< unsigned int >> id_cache, OutputDataPtr output_data, bool discont=false)
This function writes ascii data to GMSH (.msh) output file.
std::shared_ptr< ElementDataCache< unsigned int > > offsets_
Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
static const int registrar
Registrar of class to factory.
void write_msh_geometry(void)
This function writes geometry (position of nodes) to GMSH (.msh) file format.
double convert_unit_from(std::string actual_unit) const
Convert and check user-defined unit.
void write_corner_data(OutputDataPtr output_data)
writes ElementNode data ascii GMSH (.msh) output file.
int write_tail(void)
This method should write tail of GMSH (.msh) file format.
static Input::Type::Abstract & get_input_format_type()
The specification of output file format.
std::shared_ptr< ElementDataCacheBase > OutputDataPtr
std::shared_ptr< ElementDataCache< double > > nodes_
Vector of node coordinates. [spacedim x n_nodes].
std::shared_ptr< ElementDataCache< unsigned int > > node_ids_
Vector gets ids of nodes.
#define LogOut()
Macro defining 'log' record of log.
std::shared_ptr< ElementDataCache< int > > partitions_
Vector gets partitions of elements.
void write_node_data(OutputDataPtr output_data)
This function write all data on nodes to output file. This function is used for static and dynamic da...
void open_stream(Stream &stream) const
void write_msh_topology(void)
This function writes topology (connection of nodes) to the GMSH (.msh) file format.
static const unsigned int N_DISCRETE_SPACES
void set_stream_precision(std::ofstream &stream)
string unit_string_
String representation of time unit.
~OutputMSH()
The destructor of this class.
void write_elem_data(OutputDataPtr output_data)
This function write all data on elements to output file. This function is used for static and dynamic...
void set_output_data_caches(std::shared_ptr< OutputMeshBase > mesh_ptr) override
int write_data(void)
This method writes data to GMSH (.msh) file format for current time.
Class OutputElement and its iterator OutputElementIterator on the output mesh.
OutputDataFieldVec output_data_vec_[N_DISCRETE_SPACES]
bool enable_refinement_
Auxiliary flag for refinement enabling, due to gmsh format.
std::shared_ptr< ElementDataCache< unsigned int > > elem_ids_
Vector gets ids of elements.
Class for representation SI units of Fields.
This class is used for output data to VTK file format.
int write_head(void)
This method writes head of GMSH (.msh) file format.
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
std::shared_ptr< ElementDataCache< unsigned int > > region_ids_
Vector gets ids of regions.