46 std::map<ElemType, std::string> ret;
55 ret[
TET10] =
"tetra10";
57 ret[
HEX20] =
"hexa20";
73 std::ostringstream tmp_file;
82 const std::string & vec_description,
83 const std::string & u,
84 const std::string & v)
92 vec.components.push_back(u);
93 vec.components.push_back(v);
101 const std::string & vec_name,
102 const std::string & u,
103 const std::string & v,
104 const std::string & w)
113 vec.components.push_back(u);
114 vec.components.push_back(v);
115 vec.components.push_back(w);
122 const std::string & scl_description,
123 const std::string & s)
171 std::ostringstream file;
175 << std::setprecision(0)
181 std::ofstream mesh_stream(file.str().c_str());
183 mesh_stream <<
"EnSight Gold Geometry File Format\n";
184 mesh_stream <<
"Generated by \n";
185 mesh_stream <<
"node id off\n";
186 mesh_stream <<
"element id given\n";
187 mesh_stream <<
"part\n";
188 mesh_stream << std::setw(10) << 1 <<
"\n";
189 mesh_stream <<
"uns-elements\n";
190 mesh_stream <<
"coordinates\n";
193 std::map<int, Point> mesh_nodes_map;
196 std::map<ElemType, std::vector<const Elem *>> ensight_parts_map;
203 ensight_parts_map[elem->type()].push_back(elem);
205 for (
unsigned int i = 0; i < elem->n_nodes(); i++)
206 mesh_nodes_map[elem->node_id(i)] = elem->point(i);
210 mesh_stream << std::setw(10) << mesh_nodes_map.size() <<
"\n";
214 std::map <int, int> ensight_node_index;
215 for (
unsigned direction=0; direction<3; ++direction)
218 for (
const auto & pr : mesh_nodes_map)
220 mesh_stream << std::setw(12)
221 << std::setprecision(5)
223 << pr.second(direction)
225 ensight_node_index[pr.first] = i++;
230 for (
const auto & pr : ensight_parts_map)
235 libmesh_error_msg(
"Error: Unsupported ElemType " << pr.first <<
" for EnsightIO.");
238 mesh_stream <<
"\n" << name_it->second <<
"\n";
240 const std::vector<const Elem *> & elem_ref = pr.second;
243 mesh_stream << std::setw(10) << elem_ref.size() <<
"\n";
246 for (
const auto & elem : elem_ref)
247 mesh_stream << std::setw(10) << elem->id() <<
"\n";
252 for (
const auto & node : elem_ref[i]->node_ref_range())
255 if (pr.first ==
QUAD9 && i==4)
259 if (pr.first ==
HEX27 &&
260 (i==4 || i ==10 || i == 12 ||
261 i == 13 || i ==14 || i == 16 || i == 22))
264 mesh_stream << std::setw(10) << ensight_node_index[node.id()];
277 std::ostringstream case_file;
281 std::ofstream case_stream(case_file.str().c_str());
283 case_stream <<
"FORMAT\n";
284 case_stream <<
"type: ensight gold\n\n";
285 case_stream <<
"GEOMETRY\n";
290 case_stream <<
"\n\nVARIABLE\n";
294 for (
const auto & scalar : pr.second.EnsightScalars)
295 case_stream <<
"scalar per node: 1 " 296 << scalar.description <<
" " 299 for (
const auto & vec : pr.second.EnsightVectors)
300 case_stream <<
"vector per node: 1 " 301 << vec.description <<
" " 307 case_stream <<
"\n\nTIME\n";
308 case_stream <<
"time set: 1\n";
309 case_stream <<
"number of steps: " << std::setw(10) <<
_time_steps.size() <<
"\n";
310 case_stream <<
"filename start number: " << std::setw(10) << 0 <<
"\n";
311 case_stream <<
"filename increment: " << std::setw(10) << 1 <<
"\n";
312 case_stream <<
"time values:\n";
314 case_stream << std::setw(12) << std::setprecision(5) << std::scientific << time <<
"\n";
325 for (
const auto & scalar : pr.second.EnsightScalars)
329 for (
const auto & vec : pr.second.EnsightVectors)
338 const std::string & var_name)
341 std::ostringstream scl_file;
347 << std::setprecision(0)
353 std::ofstream scl_stream(scl_file.str().c_str());
354 scl_stream <<
"Per node scalar value\n";
355 scl_stream <<
"part\n";
356 scl_stream << std::setw(10) << 1 <<
"\n";
357 scl_stream <<
"coordinates\n";
365 std::vector<dof_id_type> dof_indices_scl;
370 std::map<int, Real> local_soln;
372 std::vector<Number> elem_soln;
373 std::vector<Number> nodal_soln;
382 elem_soln.resize(dof_indices_scl.size());
389 libmesh_assert_equal_to (nodal_soln.size(), elem->n_nodes());
391 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 392 libmesh_error_msg(
"Complex-valued Ensight output not yet supported");
395 for (
unsigned int n=0; n<elem->n_nodes(); n++)
396 local_soln[elem->node_id(n)] =
libmesh_real(nodal_soln[n]);
399 for (
const auto & pr : local_soln)
400 scl_stream << std::setw(12)
401 << std::setprecision(5)
409 const std::vector<std::string> & vec,
410 const std::string & var_name)
413 std::ostringstream vec_file;
419 << std::setprecision(0)
425 std::ofstream vec_stream(vec_file.str().c_str());
426 vec_stream <<
"Per vector per value\n";
427 vec_stream <<
"part\n";
428 vec_stream << std::setw(10) << 1 <<
"\n";
429 vec_stream <<
"coordinates\n";
443 const unsigned int w_var = (dim==3) ? system.
variable_number(vec[2]) : 0;
445 std::vector<dof_id_type> dof_indices_u;
446 std::vector<dof_id_type> dof_indices_v;
447 std::vector<dof_id_type> dof_indices_w;
452 std::map<int,std::vector<Real>> local_soln;
464 std::vector<Number> elem_soln_u;
465 std::vector<Number> elem_soln_v;
466 std::vector<Number> elem_soln_w;
468 std::vector<Number> nodal_soln_u;
469 std::vector<Number> nodal_soln_v;
470 std::vector<Number> nodal_soln_w;
472 elem_soln_u.resize(dof_indices_u.size());
473 elem_soln_v.resize(dof_indices_v.size());
475 elem_soln_w.resize(dof_indices_w.size());
490 libmesh_assert_equal_to (nodal_soln_u.size(), elem->n_nodes());
491 libmesh_assert_equal_to (nodal_soln_v.size(), elem->n_nodes());
493 #ifdef LIBMESH_ENABLE_COMPLEX 494 libmesh_error_msg(
"Complex-valued Ensight output not yet supported");
497 for (
const auto & n : elem->node_index_range())
499 std::vector<Real> node_vec(3);
505 local_soln[elem->node_id(n)] = node_vec;
509 for (
unsigned dir=0; dir<3; ++dir)
511 for (
const auto & pr : local_soln)
512 vec_stream << std::setw(12)
514 << std::setprecision(5)
std::string name(const ElemQuality q)
Manages the family, order, etc. parameters for a given FE.
const MeshBase & mesh() const
void write_solution_ascii()
void write_geometry_ascii()
std::string _ensight_file_name
Manages multiples systems of equations.
EnsightIO(const std::string &filename, const EquationSystems &eq)
static std::map< ElemType, std::string > build_element_map()
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
const bool _is_parallel_format
const T_sys & get_system(const std::string &name) const
IntRange< std::size_t > index_range(const std::vector< T > &vec)
std::map< std::string, SystemVars > _system_vars_map
void write_scalar_ascii(const std::string &sys, const std::string &var)
void add_vector(const std::string &system, const std::string &vec_description, const std::string &u, const std::string &v)
Number current_solution(const dof_id_type global_dof_number) const
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
Manages the degrees of freedom (DOFs) in a simulation.
processor_id_type n_processors() const
static std::map< ElemType, std::string > _element_map
void write_vector_ascii(const std::string &sys, const std::vector< std::string > &vec, const std::string &var_name)
Manages consistently variables, degrees of freedom, and coefficient vectors.
unsigned short int variable_number(const std::string &var) const
const EquationSystems & _equation_systems
void add_scalar(const std::string &system, const std::string &scalar_description, const std::string &s)
const FEType & variable_type(const unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Temporarily serializes a DistributedMesh for output.
unsigned int mesh_dimension() const
bool has_system(const std::string &name) const
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln)
std::vector< Real > _time_steps
processor_id_type processor_id() const
const DofMap & get_dof_map() const
void write_ascii(Real time=0)