30 using namespace
Input::Type;
42 this->field_input_name_ = field_name_in;
43 this->n_comp_ = n_comp_in;
52 for(
unsigned int i=0; i< n_comp_;i++) out_stream << 0 <<
" ";
57 for(
unsigned int i=0; i< n_comp_;i++) out_stream << 0 <<
" ";
62 ASSERT(
false).error(
"Not implemented.");
79 return std::make_shared<DummyOutputData>(this->field_input_name_, this->n_comp_);
84 return std::make_shared<DummyOutputData>(this->field_input_name_, this->n_comp_);
89 return std::make_shared<DummyOutputData>(this->field_input_name_, this->n_comp_);
94 return std::make_shared<DummyOutputData>(this->field_input_name_, this->n_comp_);
106 return Record(
"gmsh",
"Parameters of gmsh output format.")
139 file <<
"$MeshFormat" << endl;
140 file <<
"2" <<
" 0 " <<
sizeof(double) << endl;
141 file <<
"$EndMeshFormat" << endl;
149 file <<
"$Nodes" << endl;
150 file << this->
nodes_->n_values() << endl;
151 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
152 for(
unsigned int i_node=0; i_node < id_node_vec.size(); ++i_node) {
153 file << id_node_vec[i_node] <<
" ";
154 this->
nodes_->print_ascii(file, i_node);
157 file <<
"$EndNodes" << endl;
163 const static unsigned int gmsh_simplex_types_[4] = {0, 1, 2, 4};
164 auto &id_elem_vec = *( this->
elem_ids_->get_component_data(0).get() );
165 auto &id_node_vec = *( this->
node_ids_->get_component_data(0).get() );
166 auto &connectivity_vec = *( this->
connectivity_->get_component_data(0).get() );
167 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
168 auto ®ions_vec = *( this->
region_ids_->get_component_data(0).get() );
169 auto &partition_vec = *( this->
partitions_->get_component_data(0).get() );
171 unsigned int n_nodes, i_node=0;
174 file <<
"$Elements" << endl;
175 file << this->
offsets_->n_values() << endl;
177 for(
unsigned int i_elm=0; i_elm < id_elem_vec.size(); ++i_elm) {
178 n_nodes = (i_elm==0) ? (offsets_vec[0]) : (offsets_vec[i_elm]-offsets_vec[i_elm-1]);
180 file << id_elem_vec[i_elm]
181 <<
" " << gmsh_simplex_types_[ n_nodes-1 ]
182 <<
" 3 " << regions_vec[i_elm] <<
" " << regions_vec[i_elm] <<
" " << partition_vec[i_elm];
184 for(
unsigned int i=0; i<n_nodes; i++, i_node++) {
185 file <<
" " << id_node_vec[connectivity_vec[i_node]];
189 file <<
"$EndElements" << endl;
196 auto &id_vec = *( id_cache->get_component_data(0).get() );
199 auto &offsets_vec = *( this->
offsets_->get_component_data(0).get() );
200 unsigned int n_nodes, i_corner=0;
201 for(
unsigned int i=0; i < id_vec.size(); ++i) {
202 n_nodes = (i==0) ? (offsets_vec[0]) : (offsets_vec[i]-offsets_vec[i-1]);
203 file << id_vec[i] <<
" " << n_nodes <<
" ";
204 for (
unsigned int j=0; j<n_nodes; j++)
205 output_data->print_ascii(file, i_corner++);
209 for(
unsigned int i=0; i < output_data->n_values(); ++i) {
210 file << id_vec[i] <<
" ";
211 output_data->print_ascii(file, i);
222 double time_fixed = isfinite(this->
time)?this->
time:0;
225 file <<
"$NodeData" << endl;
228 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
231 file << time_fixed << endl;
235 file << output_data->n_comp() << endl;
236 file << output_data->n_values() << endl;
240 file <<
"$EndNodeData" << endl;
247 double time_fixed = isfinite(this->
time)?this->
time:0;
249 file <<
"$ElementNodeData" << endl;
252 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
255 file << time_fixed << endl;
259 file << output_data->n_comp() << endl;
260 file << this->
offsets_->n_values() << endl;
264 file <<
"$EndElementNodeData" << endl;
270 double time_fixed = isfinite(this->
time)?this->
time:0;
272 file <<
"$ElementData" << endl;
275 file <<
"\"" << output_data->field_input_name() <<
"\"" << endl;
278 file << time_fixed << endl;
282 file << output_data->n_comp() << endl;
283 file << output_data->n_values() << endl;
287 file <<
"$EndElementData" << endl;
308 if (this->
rank_ != 0) {
328 for(
auto data_it = node_data_list.begin(); data_it != node_data_list.end(); ++data_it) {
332 for(
auto data_it = corner_data_list.begin(); data_it != corner_data_list.end(); ++data_it) {
336 for(
auto data_it = elem_data_list.begin(); data_it != elem_data_list.end(); ++data_it) {
360 for (
auto type_idx : space_types) {
365 if (dummy_data_list.size() == 0)
366 for(
auto out_ptr : data_list)
367 dummy_data_list.push_back( std::make_shared<DummyOutputData>(out_ptr->field_input_name(), out_ptr->n_comp()));
369 auto data_it = data_list.begin();
370 for(
auto dummy_it = dummy_data_list.begin(); dummy_it != dummy_data_list.end(); ++dummy_it) {
371 if ( data_it == data_list.end() ) {
372 data_list.push_back( *dummy_it );
373 }
else if ((*dummy_it)->field_input_name() == (*data_it)->field_input_name()) {
376 data_list.push_back( *dummy_it );
387 mesh_ptr->get_master_mesh()->create_id_caches();
388 this->
node_ids_ = mesh_ptr->get_master_mesh()->node_ids_;
389 this->
elem_ids_ = mesh_ptr->get_master_mesh()->elem_ids_;
390 this->
region_ids_ = mesh_ptr->get_master_mesh()->region_ids_;
391 this->
partitions_ = mesh_ptr->get_master_mesh()->partitions_;
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
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 print_ascii_all(ostream &out_stream) 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_
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)
DummyOutputData(std::string field_name_in, unsigned int n_comp_in)
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.
void read_ascii_data(Tokenizer &, unsigned int, unsigned int) override
std::shared_ptr< ElementDataCacheBase > OutputDataPtr
void read_binary_data(std::istream &, unsigned int, unsigned int) override
std::shared_ptr< ElementDataCache< double > > nodes_
Vector of node coordinates. [spacedim x n_nodes].
std::shared_ptr< ElementDataCacheBase > compute_node_data(std::vector< unsigned int > &, unsigned int) override
#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.
std::shared_ptr< ElementDataCacheBase > element_node_cache_optimize_size(std::vector< unsigned int > &) override
#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 add_dummy_fields() override
Complete information about dummy fields that are not in output_data_list_.
std::shared_ptr< ElementDataCacheBase > element_node_cache_fixed_size(std::vector< unsigned int > &) override
void write_msh_topology(void)
This function writes topology (connection of nodes) to the GMSH (.msh) file format.
void print_binary_all(ostream &, bool) override
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 print_yaml_subarray(ostream &, unsigned int, unsigned int, unsigned int) override
void set_output_data_caches(std::shared_ptr< OutputMeshBase > mesh_ptr) override
virtual ~DummyOutputData() override
void get_min_max_range(double &, double &) override
void print_ascii(ostream &out_stream, unsigned int) 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< ElementDataCacheBase > gather(Distribution *, LongIdx *) override
std::shared_ptr< ElementDataCache< unsigned int > > elem_ids_
Vector gets ids of elements.
Class for representation SI units of Fields.
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.