30 using namespace
Input::Type;
34 return Record(
"gmsh",
"Parameters of gmsh output format.")
70 file <<
"$MeshFormat" << endl;
71 file <<
"2" <<
" 0 " <<
sizeof(double) << endl;
72 file <<
"$EndMeshFormat" << endl;
80 file <<
"$Nodes" << endl;
81 file << this->
nodes_->n_values() << endl;
82 auto permutation_vec =
output_mesh_->orig_mesh_->node_permutations();
83 bool is_corner_output = (this->
nodes_->n_values() != permutation_vec.size());
84 unsigned int i_gmsh_node;
85 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
86 for(
unsigned int i_node=0; i_node < id_node_vec.size(); ++i_node) {
87 if (is_corner_output) i_gmsh_node = i_node;
88 else i_gmsh_node = permutation_vec[i_node];
89 file << id_node_vec[i_gmsh_node] <<
" ";
90 this->
nodes_->print_ascii(file, i_gmsh_node);
93 file <<
"$EndNodes" << endl;
99 const static unsigned int gmsh_simplex_types_[4] = {0, 1, 2, 4};
100 auto &id_elem_vec = *( this->
elem_ids_->get_component_data(0).get() );
101 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
102 auto &connectivity_vec = *( this->
connectivity_->get_component_data(0).get() );
103 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
104 auto ®ions_vec = *( this->
region_ids_->get_component_data(0).get() );
105 auto &partition_vec = *( this->
partitions_->get_component_data(0).get() );
107 unsigned int n_nodes, i_node=0;
110 for(
unsigned int i_elm=0; i_elm < id_elem_vec.size(); ++i_elm) {
111 n_nodes = offsets_vec[i_elm+1]-offsets_vec[i_elm];
112 for(
unsigned int i=4*i_elm; i<4*i_elm+n_nodes; i++, i_node++) {
113 gmsh_connectivity[i] = connectivity_vec[i_node];
119 file <<
"$Elements" << endl;
120 file << this->
offsets_->n_values()-1 << endl;
122 bool is_corner_output = (this->
nodes_->n_values() !=
output_mesh_->orig_mesh_->node_permutations().size());
123 unsigned int gmsh_id;
124 auto permutation_vec =
output_mesh_->orig_mesh_->element_permutations();
125 for(
unsigned int i_elm=0; i_elm < id_elem_vec.size(); ++i_elm) {
126 unsigned int i_gmsh_elm = permutation_vec[i_elm];
127 n_nodes = offsets_vec[i_gmsh_elm+1]-offsets_vec[i_gmsh_elm];
129 if (is_corner_output) gmsh_id = i_elm;
130 else gmsh_id = id_elem_vec[i_gmsh_elm];
132 <<
" " << gmsh_simplex_types_[ n_nodes-1 ]
133 <<
" 3 " << regions_vec[i_gmsh_elm] <<
" " << regions_vec[i_gmsh_elm] <<
" " << partition_vec[i_gmsh_elm];
135 for(
unsigned int i=4*i_gmsh_elm; i<4*i_gmsh_elm+n_nodes; i++) {
136 file <<
" " << id_node_vec[gmsh_connectivity[i]];
140 file <<
"$EndElements" << endl;
149 auto &id_vec = *( id_cache->get_component_data(0).get() );
151 for(
unsigned int i=0; i < output_data->n_values(); ++i) {
152 i_gmsh = permutations[i];
153 file << id_vec[i_gmsh] <<
" ";
154 output_data->print_ascii(file, i_gmsh);
166 file <<
"$NodeData" << endl;
169 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
172 file << time_fixed << endl;
176 file << output_data->n_comp() << endl;
177 file << output_data->n_values() << endl;
179 auto permutation_vec =
output_mesh_->orig_mesh_->node_permutations();
190 file <<
"$EndNodeData" << endl;
199 file <<
"$ElementNodeData" << endl;
202 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
205 file << time_fixed << endl;
209 file << output_data->n_comp() << endl;
210 file << this->
offsets_->n_values()-1 << endl;
213 auto &id_vec = *( this->
elem_ids_->get_component_data(0).get() );
214 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
215 unsigned int n_nodes, i_corner;
216 auto permutation_vec =
output_mesh_->orig_mesh_->element_permutations();
217 for(
unsigned int i=0; i < id_vec.size(); ++i) {
218 unsigned int i_gmsh_elm = permutation_vec[i];
219 n_nodes = offsets_vec[i_gmsh_elm+1]-offsets_vec[i_gmsh_elm];
220 i_corner = offsets_vec[i_gmsh_elm];
221 file << id_vec[i] <<
" " << n_nodes <<
" ";
222 for (
unsigned int j=0; j<n_nodes; j++)
223 output_data->print_ascii(file, i_corner++);
227 file <<
"$EndElementNodeData" << endl;
235 file <<
"$ElementData" << endl;
238 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
241 file << time_fixed << endl;
245 file << output_data->n_comp() << endl;
246 file << output_data->n_values() << endl;
248 auto permutation_vec =
output_mesh_->orig_mesh_->element_permutations();
259 file <<
"$EndElementData" << endl;
280 if (this->
rank_ != 0) {
300 for(
auto data_it = node_data_list.begin(); data_it != node_data_list.end(); ++data_it) {
304 for(
auto data_it = corner_data_list.begin(); data_it != corner_data_list.end(); ++data_it) {
308 for(
auto data_it = elem_data_list.begin(); data_it != elem_data_list.end(); ++data_it) {
331 mesh_ptr->get_master_mesh()->create_id_caches();
332 this->
node_ids_ = mesh_ptr->get_master_mesh()->node_ids_;
333 this->
elem_ids_ = mesh_ptr->get_master_mesh()->elem_ids_;
334 this->
region_ids_ = mesh_ptr->get_master_mesh()->region_ids_;
335 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_.
std::shared_ptr< OutputMeshBase > output_mesh_
Output mesh.
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.
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.
Basic time management class.
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)
~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...
std::shared_ptr< TimeUnitConversion > time_unit_converter
Time unit conversion object from the equation time governor.
void set_output_data_caches(std::shared_ptr< OutputMeshBase > mesh_ptr) override
void write_msh_ascii_data(std::shared_ptr< ElementDataCache< unsigned int >> id_cache, OutputDataPtr output_data, const std::vector< unsigned int > &permutations)
This function writes nodes / elements ascii data to GMSH (.msh) output file.
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.
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.