31 using namespace
Input::Type;
43 this->field_input_name_ = field_name_in;
44 this->n_elem_ = n_elem_in;
51 void print_ascii(ostream &out_stream,
unsigned int idx)
override 53 for(
unsigned int i=0; i< n_elem_;i++) out_stream << 0 <<
" ";
58 for(
unsigned int i=0; i< n_elem_;i++) out_stream << 0 <<
" ";
63 ASSERT(
false).error(
"Not implemented.");
72 void read_ascii_data(Tokenizer &tok,
unsigned int n_components,
unsigned int i_row)
override 75 void read_binary_data(std::istream &data_stream,
unsigned int n_components,
unsigned int i_row)
override 86 return Record(
"gmsh",
"Parameters of gmsh output format.")
119 file <<
"$MeshFormat" << endl;
120 file <<
"2" <<
" 0 " <<
sizeof(double) << endl;
121 file <<
"$EndMeshFormat" << endl;
129 file <<
"$Nodes" << endl;
130 file << this->
nodes_->n_values() << endl;
131 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
132 unsigned int i_node=0;
133 for(
unsigned int i_node=0; i_node < id_node_vec.size(); ++i_node) {
134 file << id_node_vec[i_node] <<
" ";
135 this->
nodes_->print_ascii(file, i_node);
138 file <<
"$EndNodes" << endl;
144 const static unsigned int gmsh_simplex_types_[4] = {0, 1, 2, 4};
145 auto &id_elem_vec = *( this->
elem_ids_->get_component_data(0).get() );
146 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
147 auto &connectivity_vec = *( this->
connectivity_->get_component_data(0).get() );
148 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
149 auto ®ions_vec = *( this->
region_ids_->get_component_data(0).get() );
150 auto &partition_vec = *( this->
partitions_->get_component_data(0).get() );
152 unsigned int n_nodes, i_node=0;
155 file <<
"$Elements" << endl;
156 file << this->
offsets_->n_values() << endl;
158 for(
unsigned int i_elm=0; i_elm < id_elem_vec.size(); ++i_elm) {
159 n_nodes = (i_elm==0) ? (offsets_vec[0]) : (offsets_vec[i_elm]-offsets_vec[i_elm-1]);
161 file << id_elem_vec[i_elm]
162 <<
" " << gmsh_simplex_types_[ n_nodes-1 ]
163 <<
" 3 " << regions_vec[i_elm] <<
" " << regions_vec[i_elm] <<
" " << partition_vec[i_elm];
165 for(
unsigned int i=0; i<n_nodes; i++, i_node++) {
166 file <<
" " << id_node_vec[connectivity_vec[i_node]];
170 file <<
"$EndElements" << endl;
177 auto &id_vec = *( id_cache->get_component_data(0).get() );
180 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
181 unsigned int n_nodes, i_corner=0;
182 for(
unsigned int i=0; i < id_vec.size(); ++i) {
183 n_nodes = (i==0) ? (offsets_vec[0]) : (offsets_vec[i]-offsets_vec[i-1]);
184 file << id_vec[i] <<
" " << n_nodes <<
" ";
185 for (
unsigned int j=0; j<n_nodes; j++)
186 output_data->print_ascii(file, i_corner++);
190 for(
unsigned int i=0; i < output_data->n_values(); ++i) {
191 file << id_vec[i] <<
" ";
192 output_data->print_ascii(file, i);
203 double time_fixed = isfinite(this->
time)?this->
time:0;
206 file <<
"$NodeData" << endl;
209 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
212 file << time_fixed << endl;
216 file << output_data->n_elem() << endl;
217 file << output_data->n_values() << endl;
221 file <<
"$EndNodeData" << endl;
228 double time_fixed = isfinite(this->
time)?this->
time:0;
230 file <<
"$ElementNodeData" << endl;
233 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
236 file << time_fixed << endl;
240 file << output_data->n_elem() << endl;
241 file << this->
offsets_->n_values() << endl;
245 file <<
"$EndElementNodeData" << endl;
251 double time_fixed = isfinite(this->
time)?this->
time:0;
253 file <<
"$ElementData" << endl;
256 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
259 file << time_fixed << endl;
263 file << output_data->n_elem() << endl;
264 file << output_data->n_values() << endl;
268 file <<
"$EndElementData" << endl;
290 if(this->
rank == 0) {
306 for(
auto data_it = node_data_list.begin(); data_it != node_data_list.end(); ++data_it) {
310 for(
auto data_it = corner_data_list.begin(); data_it != corner_data_list.end(); ++data_it) {
314 for(
auto data_it = elem_data_list.begin(); data_it != elem_data_list.end(); ++data_it) {
338 for (
auto type_idx : space_types) {
343 if (dummy_data_list.size() == 0)
344 for(
auto out_ptr : data_list)
345 dummy_data_list.push_back( std::make_shared<DummyOutputData>(out_ptr->field_input_name(), out_ptr->n_elem()));
347 auto data_it = data_list.begin();
348 for(
auto dummy_it = dummy_data_list.begin(); dummy_it != dummy_data_list.end(); ++dummy_it) {
349 if ( data_it == data_list.end() ) {
350 data_list.push_back( *dummy_it );
351 }
else if ((*dummy_it)->field_input_name() == (*data_it)->field_input_name()) {
354 data_list.push_back( *dummy_it );
365 mesh_ptr->create_id_caches();
Classes for auxiliary output mesh.
void read_ascii_data(Tokenizer &tok, unsigned int n_components, unsigned int i_row) override
std::vector< std::vector< OutputDataPtr > > dummy_data_list_
virtual void set_output_data_caches(std::shared_ptr< OutputMeshBase > mesh_ptr)
void print_ascii_all(ostream &out_stream) override
void print_ascii(ostream &out_stream, unsigned int idx) override
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_
void read_binary_data(std::istream &data_stream, unsigned int n_components, unsigned int i_row) override
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].
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
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...
DummyOutputData(std::string field_name_in, ElementDataCacheBase::NumCompValueType n_elem_in)
void open_stream(Stream &stream) const
void add_dummy_fields() override
Complete information about dummy fields that are not in output_data_list_.
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
virtual ~DummyOutputData() 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.
void print_all_yaml(ostream &out_stream, unsigned int precision) override
Class for representation SI units of Fields.
void print_binary_all(ostream &out_stream, bool print_data_size=true) override
void get_min_max_range(double &min, double &max) override
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.