20#include "libmesh/exodusII_io.h"
22#include "libmesh/boundary_info.h"
23#include "libmesh/cell_c0polyhedron.h"
24#include "libmesh/dof_map.h"
25#include "libmesh/dyna_io.h"
26#include "libmesh/enum_elem_type.h"
27#include "libmesh/elem.h"
28#include "libmesh/enum_to_string.h"
29#include "libmesh/equation_systems.h"
30#include "libmesh/exodusII_io_helper.h"
31#include "libmesh/face_c0polygon.h"
32#include "libmesh/fpe_disabler.h"
33#include "libmesh/int_range.h"
34#include "libmesh/libmesh_logging.h"
35#include "libmesh/mesh_base.h"
36#include "libmesh/mesh_communication.h"
37#include "libmesh/numeric_vector.h"
38#include "libmesh/parallel_mesh.h"
39#include "libmesh/parallel.h"
40#include "libmesh/system.h"
41#include "libmesh/utility.h"
54#ifdef LIBMESH_HAVE_EXODUS_API
59 const std::vector<Real> & bex_constraint_vec(std::size_t i,
62 std::size_t vec_offset = 0;
63 for (
auto block_num :
index_range(helper.bex_dense_constraint_vecs))
66 libmesh_assert_greater_equal(i, vec_offset);
67 if (i - vec_offset < vecblock.size())
68 return vecblock[i - vec_offset];
70 vec_offset += vecblock.size();
73 libmesh_error_msg(
"Requested BEX coefficient vector " << i <<
" not found");
76#ifdef LIBMESH_USE_COMPLEX_NUMBERS
77 enum class SolutionOrdering
83 std::size_t ordered_solution_index (
const std::size_t var,
84 const std::size_t geometry_index,
85 const std::size_t num_vars,
86 const std::size_t num_geometric_entries,
87 const SolutionOrdering ordering)
89 if (ordering == SolutionOrdering::variable_major)
90 return var * num_geometric_entries + geometry_index;
92 return geometry_index * num_vars + var;
96 complex_soln_components (
const std::vector<Number> & soln,
97 const std::size_t num_vars,
98 const bool write_complex_abs,
99 const SolutionOrdering source_ordering,
100 const SolutionOrdering destination_ordering)
102 const std::size_t num_values = soln.size();
103 libmesh_assert_greater(num_vars, 0);
104 libmesh_assert_equal_to(num_values % num_vars, 0);
105 const std::size_t num_geometric_entries = num_values / num_vars;
109 const std::size_t nco = write_complex_abs ? 3 : 2;
110 const std::size_t num_complex_vars = nco * num_vars;
111 std::vector<Real> complex_soln(nco * num_values);
114 for (const auto geometry_index :
make_range(num_geometric_entries))
117 soln[ordered_solution_index
118 (var, geometry_index, num_vars, num_geometric_entries, source_ordering)];
120 const std::size_t complex_var = nco * var;
121 complex_soln[ordered_solution_index
122 (complex_var, geometry_index, num_complex_vars,
123 num_geometric_entries, destination_ordering)] =
value.real();
124 complex_soln[ordered_solution_index
125 (complex_var + 1, geometry_index, num_complex_vars,
126 num_geometric_entries, destination_ordering)] =
value.imag();
128 if (write_complex_abs)
129 complex_soln[ordered_solution_index
130 (complex_var + 2, geometry_index, num_complex_vars,
131 num_geometric_entries, destination_ordering)] = std::abs(
value);
147 bool single_precision) :
153#ifdef LIBMESH_HAVE_EXODUS_API
159 _allow_empty_variables(false),
160 _write_complex_abs(true),
161 _set_unique_ids_from_maps(false),
163 _allow_hi_order_elemental(false)
172 bool single_precision) :
178#ifdef LIBMESH_HAVE_EXODUS_API
184 _allow_empty_variables(false),
185 _write_complex_abs(true),
186 _set_unique_ids_from_maps(false),
188 _allow_hi_order_elemental(false)
198#ifdef LIBMESH_HAVE_EXODUS_API
223 const std::set<std::string> * system_names)
229 std::vector<std::string> solution_names;
230 std::vector<Number> v;
240#ifdef LIBMESH_HAVE_EXODUS_API
245 const std::set<std::string> * system_names)
261 const std::set<std::string> * )
268#ifdef LIBMESH_HAVE_EXODUS_API
278 LOG_SCOPE(
"read()",
"ExodusII_IO");
284 std::vector<unsigned int> extra_ids;
335 unsigned char weight_index = 0;
336 const bool weights_exist = !
exio_helper->w.empty();
342 const bool bex_cv_exist = !
exio_helper->bex_dense_constraint_vecs.empty();
359 const Real default_weight = 1.0;
360 weight_index = cast_int<unsigned char>
367 std::unordered_map<const Node *, Elem *> spline_nodeelem_ptrs;
376 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(i+1);
383 libmesh_error_msg_if(added_node->
id() !=
static_cast<unsigned>(libmesh_node_id),
384 "Error! Mesh assigned node ID "
386 <<
" which is different from the (zero-based) Exodus ID "
401 Point & p = *added_node;
422 elem->set_node(0, added_node);
424 spline_nodeelem_ptrs[added_node] = added_elem;
440 std::vector<std::map<dof_id_type, Real>> elem_ids(extra_ids.size());
443 unsigned int last_step =
exio_helper->num_time_steps;
448 int nelem_last_block = 0;
455 std::map<std::vector<std::pair<dof_id_type, Real>>,
Node *> local_nodes;
459 subdomain_id_type max_subdomain_id = std::numeric_limits<subdomain_id_type>::min();
474 restrict_int<subdomain_id_type>(
exio_helper->get_block_id(i));
475 max_subdomain_id = std::max(max_subdomain_id, subdomain_id);
478 std::string subdomain_name =
exio_helper->get_block_name(i);
479 if (!subdomain_name.empty())
483 const std::string type_str (
exio_helper->get_elem_type());
484 const auto & conv =
exio_helper->get_conversion(type_str);
485 const bool is_c0polygon = (conv.libmesh_elem_type() ==
C0POLYGON);
486 const bool is_c0polyhedron = (conv.libmesh_elem_type() ==
C0POLYHEDRON);
487 std::size_t c0polygon_connect_offset = 0;
488 std::size_t c0polyhedron_connect_offset = 0;
491 int jmax = nelem_last_block+
exio_helper->num_elem_this_blk;
492 for (
int j=nelem_last_block; j<jmax; j++)
494 const int elem_num = j - nelem_last_block;
495 std::unique_ptr<Elem> uelem;
499 const int n_elem_nodes =
exio_helper->elem_node_counts[elem_num];
500 libmesh_error_msg_if(n_elem_nodes < 3,
501 "Error: Exodus NSIDED block element "
503 <<
" has only " << n_elem_nodes <<
" nodes.");
505 uelem = std::make_unique<C0Polygon>(cast_int<unsigned int>(n_elem_nodes));
507 else if (is_c0polyhedron)
509 const int n_faces =
exio_helper->elem_face_counts[elem_num];
510 libmesh_error_msg_if(n_faces < 4,
511 "Error: Exodus NFACED block element "
513 <<
" has only " << n_faces <<
" faces.");
515 std::vector<std::shared_ptr<Polygon>>
516 sides(cast_int<std::size_t>(n_faces));
520 libmesh_assert_less(c0polyhedron_connect_offset,
522 const int exodus_face_id =
523 exio_helper->connect[c0polyhedron_connect_offset++];
526 (exodus_face_id <= 0 ||
528 cast_int<int>(
exio_helper->c0polyhedron_face_connect.size()),
529 "Error: Exodus NFACED block element "
531 <<
" references face ID " << exodus_face_id
532 <<
", but the file contains "
536 const auto & face_nodes =
537 exio_helper->c0polyhedron_face_connect[exodus_face_id - 1];
538 auto side = std::make_shared<C0Polygon>
539 (cast_int<unsigned int>(face_nodes.size()));
543 const auto libmesh_node_id =
548 sides[s] = std::move(side);
551 std::unique_ptr<Node> mid_elem_node;
552 uelem = std::make_unique<C0Polyhedron>(sides, mid_elem_node);
567 if (!is_c0polygon && !is_c0polyhedron && !elem_num)
568 libmesh_error_msg_if(
exio_helper->num_nodes_per_elem !=
static_cast<int>(uelem->n_nodes()),
569 "Error: Exodus file says "
571 <<
" nodes per Elem, but Elem type "
573 <<
" has " << uelem->n_nodes() <<
" nodes.");
576 uelem->subdomain_id() = subdomain_id;
582 auto libmesh_elem_id =
exio_helper->get_libmesh_elem_id(j+1);
584 uelem->set_id(libmesh_elem_id);
598 libmesh_error_msg_if(elem->
id() !=
static_cast<unsigned>(libmesh_elem_id),
599 "Error! Mesh assigned ID "
601 <<
" which is different from the (zero-based) Exodus ID "
606 for (
auto &
id : extra_ids)
608 const Real v = elem_ids[id][elem->
id()];
619 const long long iv = std::llround(v);
624 long long max_representation = 1;
625 max_representation = (max_representation << std::min(std::numeric_limits<Real>::digits,
626 std::numeric_limits<double>::digits));
627 libmesh_error_msg_if(iv > max_representation,
628 "Error! An element integer value higher than "
629 << max_representation
630 <<
" was found! Exodus uses real numbers for storing element "
631 " integers, which can only represent integers from 0 to "
632 << max_representation
635 libmesh_error_msg_if(iv < 0,
636 "Error! An element integer value less than -1"
637 <<
" was found! Exodus uses real numbers for storing element "
638 " integers, which can only represent integers from 0 to "
639 << max_representation
658 const int n_nodes_this_elem =
663 for (
int k=0; k<n_nodes_this_elem; k++)
668 c0polygon_connect_offset++ :
669 elem_num *
exio_helper->num_nodes_per_elem + conv.get_node_map(k);
670 libmesh_assert_less(gi,
exio_helper->connect.size());
676 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(exodus_node_id);
691 std::vector<std::vector<Real>>
693 for (
auto spline_node_index :
696 my_constraint_mat[spline_node_index].resize(elem->
n_nodes());
698 const auto & my_constraint_rows =
exio_helper->bex_cv_conn[elem_num];
699 const unsigned long elem_coef_vec_index =
700 my_constraint_rows[spline_node_index] - 1;
701 const auto & my_vec = bex_constraint_vec(elem_coef_vec_index, *
exio_helper);
702 for (
auto elem_node_index :
705 my_constraint_mat[spline_node_index][elem_node_index] =
706 my_vec[elem_node_index];
720 const auto & my_constraint_rows =
exio_helper->bex_cv_conn[elem_num];
722 for (
auto elem_node_index :
730 std::vector<std::pair<dof_id_type, Real>> key;
732 for (
auto spline_node_index :
736 const unsigned long elem_coef_vec_index =
737 my_constraint_rows[spline_node_index] - 1;
740 bex_constraint_vec(elem_coef_vec_index, *
exio_helper);
744 libmesh_vector_at(coef_vec, elem_node_index);
747 const int gi = elem_num *
exio_helper->bex_num_elem_cvs + spline_node_index;
753 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(exodus_node_id);
756 key.emplace_back(libmesh_node_id, coef);
760 if (
const auto local_node_it = local_nodes.find(key);
761 local_node_it != local_nodes.end())
762 elem->
set_node(dyna_elem_defn.
nodes[elem_node_index], local_node_it->second);
770 std::vector<std::pair<std::pair<const Elem *, unsigned int>,
Real>> constraint_row;
772 for (
auto [libmesh_spline_node_id, coef] : key)
777 const Real spline_w = weights_exist ?
779 w += coef * spline_w;
781 const Elem * nodeelem =
782 libmesh_map_find(spline_nodeelem_ptrs, &spline_node);
783 constraint_row.emplace_back(std::make_pair(nodeelem, 0), coef);
796 local_nodes[key] = n;
799 constraint_rows[n] = constraint_row;
806 c0polygon_connect_offset ==
exio_helper->connect.size());
808 c0polyhedron_connect_offset ==
exio_helper->connect.size());
812 nelem_last_block +=
exio_helper->num_elem_this_blk;
817 for (
auto p : spline_nodeelem_ptrs)
818 p.second->subdomain_id() = max_subdomain_id;
825 for (
unsigned char i=0; i!=4; ++i)
837 offset += (i > 0 ?
exio_helper->num_sides_per_set[i-1] : 0);
840 std::string sideset_name =
exio_helper->get_side_set_name(i);
841 if (!sideset_name.empty())
843 (cast_int<boundary_id_type>(
exio_helper->get_side_set_id(i)))
860 unsigned int raw_side_index =
exio_helper->side_list[e]-1;
861 std::size_t side_index_offset = conv.get_shellface_index_offset();
863 if (raw_side_index < side_index_offset)
866 int mapped_shellface = raw_side_index;
869 libmesh_error_msg_if(mapped_shellface < 0 || mapped_shellface >= 2,
870 "Bad 0-based shellface id: "
872 <<
" detected in Exodus file "
877 cast_int<unsigned short>(mapped_shellface),
878 cast_int<boundary_id_type>(
exio_helper->id_list[e]));
882 unsigned int side_index =
static_cast<unsigned int>(raw_side_index - side_index_offset);
883 int mapped_side = conv.get_side_map(side_index);
887 "Invalid 1-based side id: "
891 <<
" in Exodus file "
894 libmesh_error_msg_if(mapped_side < 0 ||
895 cast_int<unsigned int>(mapped_side) >= elem.
n_sides(),
896 "Bad 0-based side id: "
900 <<
" in Exodus file "
905 cast_int<unsigned short>(mapped_side),
906 cast_int<boundary_id_type>(
exio_helper->id_list[e]));
921 offset += (i > 0 ?
exio_helper->num_elems_per_set[i-1] : 0);
942 std::map<Elem *, MeshBase::elemset_type> elem_to_elemsets;
957 elem_to_elemsets[elem].insert(
exio_helper->elemset_id_list[e]);
961 std::set<MeshBase::elemset_type> unique_elemsets;
962 for (
const auto & pr : elem_to_elemsets)
963 unique_elemsets.insert(pr.second);
976 for (
const auto & s : unique_elemsets)
984 <<
", but mesh should have " <<
exio_helper->num_elem_sets <<
" elemsets.");
988 unsigned int elemset_index =
993 for (
const auto & [elem, s] : elem_to_elemsets)
1010 for (
int nodeset=0; nodeset<
exio_helper->num_node_sets; nodeset++)
1013 cast_int<boundary_id_type>(
exio_helper->nodeset_ids[nodeset]);
1015 std::string nodeset_name =
exio_helper->get_node_set_name(nodeset);
1016 if (!nodeset_name.empty())
1020 unsigned int offset =
exio_helper->node_sets_node_index[nodeset];
1022 for (
int i=0; i<
exio_helper->num_nodes_per_set[nodeset]; ++i)
1024 int exodus_node_id =
exio_helper->node_sets_node_list[i + offset];
1025 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(exodus_node_id);
1033 "Cannot open dimension "
1035 <<
" mesh file when configured without "
1107 exio_helper->use_mesh_dimension_instead_of_spatial_dimension(val);
1121 libmesh_warning(
"This method may be deprecated in the future");
1151 libmesh_error_msg_if
1153 "ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!");
1164 "ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!");
1173 std::string system_var_name,
1174 std::string exodus_var_name,
1175 unsigned int timestep)
1177 LOG_SCOPE(
"copy_nodal_solution()",
"ExodusII_IO");
1184 "ERROR, nodal data cannot be loaded if the mesh may be renumbered!");
1190 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1191 "ERROR, ExodusII file must be opened for reading before copying a nodal solution!");
1193 exio_helper->read_nodal_var_values(exodus_var_name, timestep);
1196 auto & node_var_value_map =
exio_helper->nodal_var_values;
1203 if (!serial_on_zero)
1205 std::unordered_map<processor_id_type, std::vector<dof_id_type>> node_ids_to_request;
1208 std::vector<dof_id_type> node_ids;
1209 for (
auto & node :
mesh.local_node_ptr_range())
1210 node_ids.push_back(node->id());
1211 if (!node_ids.empty())
1212 node_ids_to_request[0] = std::move(node_ids);
1215 auto value_gather_functor =
1216 [& node_var_value_map]
1218 const std::vector<dof_id_type> & ids,
1219 std::vector<Real> & values)
1221 const std::size_t query_size = ids.size();
1222 values.resize(query_size);
1223 for (std::size_t i=0; i != query_size; ++i)
1225 if (
const auto it = node_var_value_map.find(ids[i]);
1226 it != node_var_value_map.end())
1228 values[i] = it->second;
1229 node_var_value_map.erase(it);
1232 values[i] = std::numeric_limits<Real>::quiet_NaN();
1236 auto value_action_functor =
1237 [& node_var_value_map]
1239 const std::vector<dof_id_type> & ids,
1240 const std::vector<Real> & values)
1242 const std::size_t query_size = ids.size();
1243 for (std::size_t i=0; i != query_size; ++i)
1245 node_var_value_map[ids[i]] = values[i];
1248 Real * value_ex =
nullptr;
1250 (system.
comm(), node_ids_to_request, value_gather_functor,
1251 value_action_functor, value_ex);
1269 system.
solution->set (dof_index, p.second);
1280 std::string system_var_name,
1281 std::string exodus_var_name,
1282 unsigned int timestep)
1284 LOG_SCOPE(
"copy_elemental_solution()",
"ExodusII_IO");
1293 "Error! Trying to copy elemental solution into a variable that is not elemental data.");
1299 "ERROR, elemental data cannot be loaded if the mesh may be renumbered!");
1306 std::map<dof_id_type, Real> elem_var_value_map;
1312 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1313 "ERROR, ExodusII file must be opened for reading before copying an elemental solution!");
1315 exio_helper->read_elemental_var_values(exodus_var_name, timestep, elem_var_value_map);
1323 if (!serial_on_zero)
1325 std::unordered_map<processor_id_type, std::vector<dof_id_type>> elem_ids_to_request;
1328 std::vector<dof_id_type> elem_ids;
1329 for (
auto & elem :
mesh.active_local_element_ptr_range())
1330 elem_ids.push_back(elem->id());
1332 if (!elem_ids.empty())
1333 elem_ids_to_request[0] = std::move(elem_ids);
1336 auto value_gather_functor =
1337 [& elem_var_value_map]
1339 const std::vector<dof_id_type> & ids,
1340 std::vector<Real> & values)
1342 const std::size_t query_size = ids.size();
1343 values.resize(query_size);
1344 for (std::size_t i=0; i != query_size; ++i)
1346 if (
const auto it = elem_var_value_map.find(ids[i]);
1347 it != elem_var_value_map.end())
1349 values[i] = it->second;
1350 elem_var_value_map.erase(it);
1353 values[i] = std::numeric_limits<Real>::quiet_NaN();
1357 auto value_action_functor =
1358 [& elem_var_value_map]
1360 const std::vector<dof_id_type> & ids,
1361 const std::vector<Real> & values)
1363 const std::size_t query_size = ids.size();
1364 for (std::size_t i=0; i != query_size; ++i)
1366 elem_var_value_map[ids[i]] = values[i];
1369 Real * value_ex =
nullptr;
1371 (system.
comm(), elem_ids_to_request, value_gather_functor,
1372 value_action_functor, value_ex);
1375 std::map<dof_id_type, Real>::iterator
1376 it = elem_var_value_map.begin(),
1377 end = elem_var_value_map.end();
1382 for (; it!=end; ++it)
1386 if (elem && elem->
n_comp(system.
number(), var_num) > 0)
1389 if (serial_on_zero || dof_map.
local_index(dof_index ))
1390 system.
solution->set (dof_index, it->second);
1399 std::vector<std::string> system_var_names,
1400 std::vector<std::string> exodus_var_names,
1401 unsigned int timestep)
1403 LOG_SCOPE(
"copy_scalar_solution()",
"ExodusII_IO");
1405 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1406 "ERROR, ExodusII file must be opened for reading before copying a scalar solution!");
1408 libmesh_error_msg_if(system_var_names.size() != exodus_var_names.size(),
1409 "ERROR, the number of system_var_names must match exodus_var_names.");
1411 std::vector<Real> values_from_exodus;
1414#ifdef LIBMESH_HAVE_MPI
1433 std::vector<dof_id_type> SCALAR_dofs;
1436 system.
solution->set (SCALAR_dofs[0], values_from_exodus[i]);
1445 unsigned int timestep,
1446 std::map<unsigned int, Real> & unique_id_to_value_map)
1448 LOG_SCOPE(
"read_elemental_variable()",
"ExodusII_IO");
1451 std::map<dof_id_type, Real> elem_var_value_map;
1453 exio_helper->read_elemental_var_values(elemental_var_name, timestep, elem_var_value_map);
1454 for (
auto & pr : elem_var_value_map)
1462 unsigned int timestep,
1463 std::vector<Real> & global_values)
1465 LOG_SCOPE(
"read_global_variable()",
"ExodusII_IO");
1467 std::size_t size = global_var_names.size();
1468 libmesh_error_msg_if(size == 0,
"ERROR, empty list of global variables to read from the Exodus file.");
1471 std::vector<Real> values_from_exodus;
1473 exio_helper->read_global_values(values_from_exodus, timestep);
1474 std::vector<std::string> global_var_names_exodus =
exio_helper->global_var_names;
1476 if (values_from_exodus.size() == 0)
1479 global_values.clear();
1480 for (std::size_t i = 0; i != size; ++i)
1484 auto it = find(global_var_names_exodus.begin(), global_var_names_exodus.end(), global_var_names[i]);
1485 if (it != global_var_names_exodus.end())
1486 global_values.push_back(values_from_exodus[it - global_var_names_exodus.begin()]);
1488 libmesh_error_msg(
"ERROR, Global variable " << global_var_names[i] << \
1489 " not found in Exodus file.");
1496 LOG_SCOPE(
"write_element_data()",
"ExodusII_IO");
1500 "ERROR, ExodusII file must be initialized before outputting element variables.");
1514 std::vector<std::string> names;
1523 std::vector<Number> soln;
1527 std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1540#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1542 std::vector<std::string> complex_names =
1545 std::vector<std::set<subdomain_id_type>>
1546 complex_vars_active_subdomains =
1547 exio_helper->get_complex_vars_active_subdomains(vars_active_subdomains,
1549 exio_helper->initialize_element_variables(complex_names, complex_vars_active_subdomains);
1551 const std::vector<Real> complex_soln =
1553 SolutionOrdering::variable_major,
1554 SolutionOrdering::variable_major);
1559 exio_helper->initialize_element_variables(names, vars_active_subdomains);
1569 const std::set<std::string> * system_names,
1570 const std::string & var_suffix)
1572 LOG_SCOPE(
"write_element_data_from_discontinuous_nodal_data()",
"ExodusII_IO");
1578 "ERROR, ExodusII file must be initialized before outputting element variables.");
1592 std::vector<std::string> var_names;
1598 std::vector<std::string> elemental_var_names;
1613 [
this](
const std::string & name)
1614 {return !std::count(_output_variables.begin(),
1615 _output_variables.end(),
1623 std::vector<Number> v;
1625 (v, system_names, &var_names,
true);
1628 std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1634 std::map<subdomain_id_type, unsigned int> subdomain_id_to_vertices_per_elem;
1635 for (
const auto & elem :
mesh.active_element_ptr_range())
1642 auto pr2 = subdomain_id_to_vertices_per_elem.emplace
1643 (elem->subdomain_id(), elem->n_vertices());
1644 libmesh_error_msg_if(!pr2.second && pr2.first->second != elem->n_vertices(),
1645 "Elem with different number of vertices found.");
1668 std::vector<std::string> derived_var_names;
1673 std::map<std::string, std::pair<std::string, unsigned int>>
1674 derived_name_to_orig_name_and_node_id;
1676 for (
const auto & pr : subdomain_id_to_vertices_per_elem)
1679 const unsigned int vertices_per_elem =
1680 subdomain_id_to_vertices_per_elem[sbd_id];
1682 std::ostringstream oss;
1683 for (
unsigned int n=0; n<vertices_per_elem; ++n)
1684 for (
const auto & orig_var_name : var_names)
1688 oss << orig_var_name << var_suffix << n;
1689 std::string derived_name = oss.str();
1692 if (!std::count(derived_var_names.begin(), derived_var_names.end(), derived_name))
1694 derived_var_names.push_back(derived_name);
1696 derived_name_to_orig_name_and_node_id[derived_name] =
1697 std::make_pair(orig_var_name, n);
1705 std::vector<std::set<subdomain_id_type>>
1706 derived_vars_active_subdomains(derived_var_names.size());
1718 std::map<subdomain_id_type, std::vector<std::string>>
1719 subdomain_to_var_names;
1721 for (
auto derived_var_id :
index_range(derived_var_names))
1723 const auto & derived_name = derived_var_names[derived_var_id];
1724 const auto & [orig_name, node_id] =
1725 libmesh_map_find (derived_name_to_orig_name_and_node_id,
1730 for (
const auto & pr : subdomain_id_to_vertices_per_elem)
1735 unsigned int vertices_per_elem_this_sbd =
1736 subdomain_id_to_vertices_per_elem[sbd_id];
1743 auto var_loc = std::find(var_names.begin(), var_names.end(), orig_name);
1744 libmesh_error_msg_if(var_loc == var_names.end(),
1745 "Variable " << orig_name <<
" somehow not found in var_names array.");
1746 auto var_id = std::distance(var_names.begin(), var_loc);
1750 if (node_id < vertices_per_elem_this_sbd)
1756 subdomain_to_var_names[sbd_id].push_back(derived_name);
1765 bool orig_var_active =
1766 (vars_active_subdomains[var_id].empty() ||
1767 vars_active_subdomains[var_id].count(sbd_id));
1771 if (orig_var_active)
1772 derived_vars_active_subdomains[derived_var_id].insert(sbd_id);
1783 for (
auto & derived_var_name : derived_var_names)
1786 const auto & name_and_id =
1787 libmesh_map_find (derived_name_to_orig_name_and_node_id,
1791 const std::string & orig_name = name_and_id.first;
1794 if (std::count(elemental_var_names.begin(),
1795 elemental_var_names.end(),
1799 for (
auto & pr : subdomain_to_var_names)
1802 auto & name_vec = pr.second;
1805 std::find(name_vec.begin(),
1809 if (name_vec_it != name_vec.end())
1813 *name_vec_it = orig_name;
1818 derived_var_name = orig_name;
1825 std::vector<std::string> derived_var_names_edited;
1826 std::vector<std::set<subdomain_id_type>> derived_vars_active_subdomains_edited;
1827 std::vector<unsigned int> found_first(elemental_var_names.size());
1831 const auto & derived_var_name = derived_var_names[i];
1832 const auto & active_set = derived_vars_active_subdomains[i];
1838 if (derived_var_name == elemental_var_names[j])
1840 if (!found_first[j])
1850 if (active_set.empty())
1855 derived_var_names_edited.push_back(derived_var_name);
1856 derived_vars_active_subdomains_edited.push_back(active_set);
1861 derived_var_names.swap(derived_var_names_edited);
1862 derived_vars_active_subdomains.swap(derived_vars_active_subdomains_edited);
1865#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1868 auto complex_var_names =
1871 auto complex_vars_active_subdomains =
1872 exio_helper->get_complex_vars_active_subdomains(derived_vars_active_subdomains,
1874 auto complex_subdomain_to_var_names =
1875 exio_helper->get_complex_subdomain_to_var_names(subdomain_to_var_names,
1882 std::vector<Real> complex_v;
1884 complex_v.reserve(nco * v.size());
1885 for (
const auto & val : v)
1887 complex_v.push_back(val.real());
1888 complex_v.push_back(val.imag());
1890 complex_v.push_back(std::abs(val));
1895 (complex_var_names, complex_vars_active_subdomains);
1898 complex_vars_active_subdomains,
1900 complex_subdomain_to_var_names);
1905 exio_helper->initialize_element_variables(derived_var_names, derived_vars_active_subdomains);
1912 derived_vars_active_subdomains,
1914 subdomain_to_var_names);
1921 const std::vector<Number> & soln,
1922 const std::vector<std::string> & names)
1924 LOG_SCOPE(
"write_nodal_data()",
"ExodusII_IO");
1928 int num_vars = cast_int<int>(names.size());
1932 std::vector<std::string> output_names;
1937 output_names = names;
1939#ifdef LIBMESH_USE_COMPLEX_NUMBERS
1940 std::vector<std::string> complex_names =
1956 for (
int c=0; c<num_vars; c++)
1958 std::stringstream name_to_find;
1960 std::vector<std::string>::iterator pos =
1961 std::find(output_names.begin(), output_names.end(), names[c]);
1962 if (pos == output_names.end())
1965 unsigned int variable_name_position =
1966 cast_int<unsigned int>(pos - output_names.begin());
1970#ifdef LIBMESH_USE_REAL_NUMBERS
1971 std::vector<Number> cur_soln;
1976 cur_soln.reserve(num_nodes);
1978 std::vector<Real> real_parts;
1979 std::vector<Real> imag_parts;
1980 std::vector<Real> magnitudes;
1981 real_parts.reserve(num_nodes);
1982 imag_parts.reserve(num_nodes);
1984 magnitudes.reserve(num_nodes);
1994 for (
const auto & node :
mesh.node_ptr_range())
1999#ifdef LIBMESH_USE_REAL_NUMBERS
2000 cur_soln.push_back(soln[idx]);
2002 real_parts.push_back(soln[idx].real());
2003 imag_parts.push_back(soln[idx].imag());
2005 magnitudes.push_back(std::abs(soln[idx]));
2017 std::vector<std::vector<const Elem *>>
2020 for (
const auto & elem :
mesh.active_element_ptr_range())
2021 elems_by_pid[elem->processor_id()].push_back(elem);
2026 exio_helper->added_node_offset_on(p) * num_vars + c;
2027 for (
const Elem * elem : elems_by_pid[p])
2029 for (
auto s : elem->side_index_range())
2034 const std::vector<unsigned int> side_nodes =
2035 elem->nodes_on_side(s);
2040 libmesh_assert_less(global_idx, soln.size());
2041#ifdef LIBMESH_USE_REAL_NUMBERS
2042 cur_soln.push_back(soln[global_idx]);
2044 real_parts.push_back(soln[global_idx].real());
2045 imag_parts.push_back(soln[global_idx].imag());
2047 magnitudes.push_back(std::abs(soln[global_idx]));
2049 global_idx += num_vars;
2057#ifdef LIBMESH_USE_REAL_NUMBERS
2078 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2079 "ERROR, ExodusII file must be initialized before outputting information records.");
2087 const std::vector<std::string> & names)
2089 LOG_SCOPE(
"write_global_data()",
"ExodusII_IO");
2094 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2095 "ERROR, ExodusII file must be initialized before outputting global variables.");
2097#ifdef LIBMESH_USE_COMPLEX_NUMBERS
2099 std::vector<std::string> complex_names =
2103 exio_helper->initialize_global_variables(complex_names);
2105 const std::vector<Real> complex_soln =
2107 SolutionOrdering::variable_major,
2108 SolutionOrdering::variable_major);
2124 const std::set<std::string> * system_names)
2138 const std::set<std::string> * system_names)
2146 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2147 "ERROR, ExodusII file must be opened for writing "
2148 "before calling ExodusII_IO::write_elemsets()!");
2157 const std::vector<std::string> & var_names,
2158 const std::vector<std::set<boundary_id_type>> & side_ids,
2159 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals)
2161 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2162 "ERROR, ExodusII file must be opened for writing "
2163 "before calling ExodusII_IO::write_sideset_data()!");
2166 exio_helper->write_sideset_data(
mesh, timestep, var_names, side_ids, bc_vals);
2174 std::vector<std::string> & var_names,
2175 std::vector<std::set<boundary_id_type>> & side_ids,
2176 std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals)
2178 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2179 "ERROR, ExodusII file must be opened for reading "
2180 "before calling ExodusII_IO::read_sideset_data()!");
2183 exio_helper->read_sideset_data(
mesh, timestep, var_names, side_ids, bc_vals);
2193 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2194 "ERROR, ExodusII file must be opened for reading "
2195 "before calling ExodusII_IO::get_sideset_data_indices()!");
2205 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2206 "ERROR, ExodusII file must be opened for reading "
2207 "before calling ExodusII_IO::get_nodeset_data_indices()!");
2209 exio_helper->get_nodeset_data_indices(bc_array_indices);
2215 const std::vector<std::string> & var_names,
2216 const std::vector<std::set<boundary_id_type>> & node_boundary_ids,
2217 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals)
2219 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2220 "ERROR, ExodusII file must be opened for writing "
2221 "before calling ExodusII_IO::write_nodeset_data()!");
2223 exio_helper->write_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2231 std::vector<std::string> & var_names,
2232 std::vector<std::set<boundary_id_type>> & node_boundary_ids,
2233 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals)
2235 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2236 "ERROR, ExodusII file must be opened for reading "
2237 "before calling ExodusII_IO::read_nodeset_data()!");
2239 exio_helper->read_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2245 const std::vector<std::string> & var_names,
2246 const std::vector<std::set<elemset_id_type>> & elemset_ids_in,
2247 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals)
2249 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2250 "ERROR, ExodusII file must be opened for writing "
2251 "before calling ExodusII_IO::write_elemset_data()!");
2253 exio_helper->write_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2261 std::vector<std::string> & var_names,
2262 std::vector<std::set<elemset_id_type>> & elemset_ids_in,
2263 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals)
2265 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2266 "ERROR, ExodusII file must be opened for reading "
2267 "before calling ExodusII_IO::read_elemset_data()!");
2269 exio_helper->read_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2275 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2276 "ERROR, ExodusII file must be opened for reading "
2277 "before calling ExodusII_IO::get_elemset_data_indices()!");
2279 exio_helper->get_elemset_data_indices(elemset_array_indices);
2285 LOG_SCOPE(
"write()",
"ExodusII_IO");
2303 libmesh_warning(
"Warning: Appending in ExodusII_IO::write() does not make sense.\n"
2304 "Creating a new file instead!");
2315 libmesh_warning(
"Warning: Mesh contains edge boundary IDs, but these "
2316 "are not supported by the ExodusII format.");
2322 const std::vector<Number> & soln,
2323 const std::vector<std::string> & names)
2325 LOG_SCOPE(
"write_nodal_data_discontinuous()",
"ExodusII_IO");
2329#ifdef LIBMESH_USE_COMPLEX_NUMBERS
2331 std::vector<std::string> complex_names =
2346 int num_vars = cast_int<int>(names.size());
2347 libmesh_assert_equal_to(soln.size() % num_vars, 0);
2348 int num_nodes = soln.size() / num_vars;
2349 libmesh_assert_equal_to(
exio_helper->num_nodes, num_nodes);
2354 int num_real_nodes = 0;
2355 for (
const auto & elem :
mesh.active_element_ptr_range())
2356 num_real_nodes += elem->n_nodes();
2357 libmesh_assert_equal_to(num_real_nodes, num_nodes);
2361 for (
int c=0; c<num_vars; c++)
2363#ifdef LIBMESH_USE_COMPLEX_NUMBERS
2364 std::vector<Real> real_parts(num_nodes);
2365 std::vector<Real> imag_parts(num_nodes);
2366 std::vector<Real> magnitudes;
2368 magnitudes.resize(num_nodes);
2374 for (
int i=0; i<num_nodes; ++i)
2376 real_parts[i] = soln[i*num_vars + c].real();
2377 imag_parts[i] = soln[i*num_vars + c].imag();
2379 magnitudes[i] = std::abs(soln[i*num_vars + c]);
2387 std::vector<Number> cur_soln(num_nodes);
2389 for (
int i=0; i<num_nodes; i++)
2390 cur_soln[i] = soln[i*num_vars + c];
2400 const std::vector<std::string> & names,
2458 libmesh_error_msg_if(fname !=
exio_helper->current_filename,
2459 "Error! This ExodusII_IO object is already associated with file: "
2461 <<
", cannot use it with requested file: "
2504 libmesh_experimental();
2546 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2553 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2560 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2567 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2574 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2581 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2588 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2595 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2602 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2610 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2617 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2626 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2636 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2642 std::vector<std::string>,
2643 std::vector<std::string>,
2646 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2653 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2661 const std::set<std::string> *,
2662 const std::string & )
2664 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2670 const std::vector<Number> &,
2671 const std::vector<std::string> &)
2673 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2680 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2686 const std::vector<std::string> &)
2688 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2697 const std::set<std::string> *)
2699 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2705 const std::set<std::string> *)
2707 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2713 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2719 const std::vector<std::string> &,
2720 const std::vector<std::set<boundary_id_type>> &,
2721 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> &)
2723 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2731 std::vector<std::string> &,
2732 std::vector<std::set<boundary_id_type>> &,
2733 std::vector<std::map<BoundaryInfo::BCTuple, Real>> &)
2735 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2743 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2749 const std::vector<std::string> &,
2750 const std::vector<std::set<boundary_id_type>> &,
2751 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> &)
2753 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2759 std::vector<std::string> &,
2760 std::vector<std::set<boundary_id_type>> &,
2761 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> &)
2763 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2770 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2776 const std::vector<std::string> &,
2777 const std::vector<std::set<elemset_id_type>> &,
2778 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> &)
2780 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2786 std::vector<std::string> &,
2787 std::vector<std::set<elemset_id_type>> &,
2788 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> &)
2790 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2797 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2802 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2808 const std::vector<Number> &,
2809 const std::vector<std::string> &)
2811 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2817 const std::vector<std::string> &,
2820 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2826 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2831 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2836 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
processor_id_type rank() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
void add_shellface(const dof_id_type elem, const unsigned short int shellface, const boundary_id_type id)
Add shell face shellface of element number elem with boundary id id to the boundary information data ...
std::string & sideset_name(boundary_id_type id)
std::size_t n_edge_conds() const
std::string & nodeset_name(boundary_id_type id)
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure.
This class handles the numbering of degrees of freedom on a mesh.
bool local_index(dof_id_type dof_index) const
void SCALAR_dof_indices(std::vector< dof_id_type > &di, const unsigned int vn, const bool old_dofs=false) const
Fills the vector di with the global degree of freedom indices corresponding to the SCALAR variable vn...
unsigned int n_comp(const unsigned int s, const unsigned int var) const
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
processor_id_type processor_id() const
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
unique_id_type unique_id() const
T get_extra_datum(const unsigned int index) const
Gets the value on this object of the extra datum associated with index, which should have been obtain...
void set_extra_datum(const unsigned int index, const T value)
Sets the value on this object of the extra datum associated with index, which should have been obtain...
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
static const ElementDefinition & find_elem_definition(dyna_int_type dyna_elem, int dim, int p)
Finds the ElementDefinition corresponding to a particular element type.
This is the base class from which all geometric element types are derived.
virtual Node *& set_node(const unsigned int i)
virtual unsigned int n_nodes() const =0
virtual Order default_order() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
virtual unsigned short dim() const =0
virtual ElemType type() const =0
virtual unsigned int n_sides() const =0
const Elem * top_parent() const
This is the EquationSystems class.
void build_elemental_data_variable_names(std::vector< std::string > &var_names, const std::set< std::string > *system_names=nullptr, bool allow_high_order_discontinuous=false) const
Filter var_names to names of variables that can be represented as elemental data.
void build_variable_names(std::vector< std::string > &var_names, const FEType *type=nullptr, const std::set< std::string > *system_names=nullptr) const
Fill the input vector var_names with the names of the variables for each system.
static bool redundant_added_side(const Elem &elem, unsigned int side)
void get_vars_active_subdomains(const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type > > &vars_active_subdomains) const
Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names.
void build_elemental_solution_vector(std::vector< Number > &soln, std::vector< std::string > &names, bool allow_high_order_discontinuous=false) const
Retrieve the solution data for elemental data variables.
static bool is_elemental_data_fe_type(const FEType &type, bool allow_high_order_discontinuous=false)
void build_discontinuous_solution_vector(std::vector< Number > &soln, const std::set< std::string > *system_names=nullptr, const std::vector< std::string > *var_names=nullptr, bool vertices_only=false, bool add_sides=false) const
Fill the input vector soln with solution values.
static const int invalid_id
An invalid_id that can be returned to signal failure in case something goes wrong.
This is the ExodusII_IO_Helper class.
std::vector< std::vector< std::vector< Real > > > bex_dense_constraint_vecs
static int get_exodus_version()
const std::vector< int > & get_node_num_map() const
Identical to the behavior of get_elem_num_map(), but for the node_num_map instead.
void set_max_name_length(unsigned int max_length)
For backwards compatibility, libMesh currently truncates names in ExodusII output to the old default ...
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
void copy_scalar_solution(System &system, std::vector< std::string > system_var_names, std::vector< std::string > exodus_var_names, unsigned int timestep=1)
Copy global variables into scalar variables of a System object.
bool _set_unique_ids_from_maps
Set Elem/Node unique_ids based on the elem_num_map and node_num_map contents during reading,...
void write_elemset_data(int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< elemset_id_type > > &elemset_ids_in, const std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real > > &elemset_vals)
The Exodus format can also store values on elemsets.
virtual bool get_add_sides() override
ExodusHeaderInfo read_header(const std::string &name)
Read only the header information, instead of the entire mesh.
void append(bool val)
If true, this flag will cause the ExodusII_IO object to attempt to open an existing file for writing,...
void read_elemset_data(int timestep, std::vector< std::string > &var_names, std::vector< std::set< elemset_id_type > > &elemset_ids_in, std::vector< std::map< std::pair< dof_id_type, elemset_id_type >, Real > > &elemset_vals)
Read all the elemset data at a particular timestep.
void write_discontinuous_elemental_data(bool allow_hi_order_elemental)
Set to true (false is the default) to allow elemental output of higher-order discontinuous (non-CONST...
void set_coordinate_offset(Point p)
Allows you to set a vector that is added to the coordinates of all of the nodes.
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
const std::vector< Real > & get_time_steps()
bool _verbose
should we be verbose?
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
const std::vector< std::string > & get_global_var_names()
Return list of the global variable names.
void get_elemset_data_indices(std::map< std::pair< dof_id_type, elemset_id_type >, unsigned int > &elemset_array_indices)
Similar to read_elemset_data(), but instead of creating one std::map per nodeset per variable,...
void verbose(bool set_verbosity)
Set the flag indicating if we should be verbose.
static int get_exodus_version()
void write_complex_magnitude(bool val)
Set the flag indicating whether the complex modulus should be written when complex numbers are enable...
void write_timestep(const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
Writes out the solution at a specific timestep.
std::vector< std::string > _extra_integer_vars
An optional list of variables in the EXODUS file that are to be used to set extra integers when loadi...
void copy_nodal_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
If we read in a nodal solution while reading in a mesh, we can attempt to copy that nodal solution in...
const std::vector< int > & get_elem_num_map() const
Returns a const reference to the elem_num_map, which is a vector that is created when a Mesh is read ...
void set_output_variables(const std::vector< std::string > &output_variables, bool allow_empty=true)
Sets the list of variable names to be included in the output.
void set_hdf5_writing(bool write_hdf5)
Set to true (the default) to write files in an HDF5-based file format (when HDF5 is available),...
std::vector< std::string > _output_variables
The names of the variables to be output.
void write_as_dimension(unsigned dim)
Directly control the num_dim which is written to the Exodus file.
void write_timestep_discontinuous(const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
Writes a discontinuous solution at a specific timestep.
void read_global_variable(std::vector< std::string > global_var_names, unsigned int timestep, std::vector< Real > &global_values)
Given a vector of global variables and a time step, returns the values of the global variable at the ...
void write_element_data_from_discontinuous_nodal_data(const EquationSystems &es, const std::set< std::string > *system_names=nullptr, const std::string &var_suffix="_elem_node_")
Similar to the function above, but instead of only handling (CONSTANT, MONOMIAL) data,...
void write_information_records(const std::vector< std::string > &)
Write out information records.
void get_nodeset_data_indices(std::map< BoundaryInfo::NodeBCTuple, unsigned int > &bc_array_indices)
Similar to read_nodeset_data(), but instead of creating one std::map per nodeset per variable,...
const std::vector< std::string > & get_elem_var_names()
Return list of the elemental variable names.
void write_discontinuous_exodusII(const std::string &name, const EquationSystems &es, const std::set< std::string > *system_names=nullptr)
Writes a exodusII file with discontinuous data.
bool _allow_hi_order_elemental
Set to true (false is the default) to allow elemental output of higher-order discontinuous variables.
void set_unique_ids_from_maps(bool val)
If true, this flag enforces the following behaviors:
ExodusII_IO_Helper & get_exio_helper()
Return a reference to the ExodusII_IO_Helper object.
bool _disc_bex
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element.
void copy_elemental_solution(System &system, std::string system_var_name, std::string exodus_var_name, unsigned int timestep=1)
If we read in a elemental solution while reading in a mesh, we can attempt to copy that elemental sol...
void use_mesh_dimension_instead_of_spatial_dimension(bool val)
In the general case, meshes containing 2D elements can be manifolds living in 3D space,...
void write_elemsets()
Write elemsets stored on the Mesh to file.
void write_nodeset_data(int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type > > &node_boundary_ids, const std::vector< std::map< BoundaryInfo::NodeBCTuple, Real > > &bc_vals)
The Exodus format can also store values on nodesets.
void write_global_data(const std::vector< Number > &, const std::vector< std::string > &)
Write out global variables.
void write_nodal_data_common(std::string fname, const std::vector< std::string > &names, bool continuous=true)
This function factors out a bunch of code which is common to the write_nodal_data() and write_nodal_d...
bool _append
Default false.
void read_sideset_data(int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type > > &side_ids, std::vector< std::map< BoundaryInfo::BCTuple, Real > > &bc_vals)
Similar to write_sideset_data(), this function is used to read the data at a particular timestep.
void read_elemental_variable(std::string elemental_var_name, unsigned int timestep, std::map< unsigned int, Real > &unique_id_to_value_map)
Given an elemental variable and a time step, returns a mapping from the elements (top parent) unique ...
void write_element_data(const EquationSystems &es)
Write out element solution.
void get_sideset_data_indices(std::map< BoundaryInfo::BCTuple, unsigned int > &bc_array_indices)
Similar to read_sideset_data(), but instead of creating one std::map per sideset per variable,...
void read_nodeset_data(int timestep, std::vector< std::string > &var_names, std::vector< std::set< boundary_id_type > > &node_boundary_ids, std::vector< std::map< BoundaryInfo::NodeBCTuple, Real > > &bc_vals)
Read all the nodeset data at a particular timestep.
const std::vector< std::string > & get_nodal_var_names()
Return list of the nodal variable names.
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
ExodusII_IO(MeshBase &mesh, bool single_precision=false)
Constructor.
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Write out a nodal solution.
bool _allow_empty_variables
Flag which controls the behavior of _output_variables: .) If true, _output_variables is allowed to re...
void write_added_sides(bool val)
By default, we only write out the elements physically stored in the mesh.
void set_extra_integer_vars(const std::vector< std::string > &extra_integer_vars)
Set the elemental variables in the Exodus file to be read into extra element integers.
void set_discontinuous_bex(bool disc_bex)
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element ...
void write_nodal_data_discontinuous(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Write out a discontinuous nodal solution.
void write_sideset_data(int timestep, const std::vector< std::string > &var_names, const std::vector< std::set< boundary_id_type > > &side_ids, const std::vector< std::map< BoundaryInfo::BCTuple, Real > > &bc_vals)
The Exodus format can also store values on sidesets.
This is the MeshBase class.
void set_subdomain_name(subdomain_id_type id, const std::string &name, bool synchronous=false)
Sets the name for the provided id.
virtual const Node & node_ref(const dof_id_type i) const
void set_default_mapping_data(const unsigned char data)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
virtual const Node * node_ptr(const dof_id_type i) const =0
unsigned int mesh_dimension() const
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use.
dof_id_type get_elemset_code(const MeshBase::elemset_type &id_set) const
virtual dof_id_type n_nodes() const =0
void set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
virtual Node * add_point(const Point &p, const dof_id_type id=DofObject::invalid_id, const processor_id_type proc_id=DofObject::invalid_processor_id)=0
Add a new Node at Point p to the end of the vertex array, with processor_id procid.
virtual const Elem * elem_ptr(const dof_id_type i) const =0
unsigned int add_elem_integer(std::string name, bool allocate_data=true, dof_id_type default_value=DofObject::invalid_id)
Register an integer datum (of type dof_id_type) to be added to each element in the mesh.
virtual Node * add_node(Node *n)=0
Add Node n to the end of the vertex array.
virtual void clear()
Deletes all the element and node data that is currently stored.
constraint_rows_type & set_constraint_rows()
void set_default_mapping_type(const ElemMappingType type)
Set the default master space to physical space mapping basis functions to be used on newly added elem...
unsigned int add_node_datum(const std::string &name, bool allocate_data=true, const T *default_value=nullptr)
Register a datum (of type T) to be added to each node in the mesh.
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(),...
void add_elemset_code(dof_id_type code, MeshBase::elemset_type id_set)
Tabulate a user-defined "code" for elements which belong to the element sets specified in id_set.
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
virtual const Elem & elem_ref(const dof_id_type i) const
void allow_node_and_elem_unique_id_overlap(bool allow)
If true is passed, then this mesh will no longer require unique_ids to be unique across the set of al...
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
virtual bool is_serial_on_zero() const
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
This class defines an abstract interface for Mesh output.
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
virtual void write_discontinuous_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with discontinuous data to a specified file where the data is t...
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
A Node is like a Point, but with more information.
An object whose state is distributed along a set of processors.
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
processor_id_type n_processors() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Manages consistently variables, degrees of freedom, and coefficient vectors.
const FEType & variable_type(const unsigned int i) const
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
virtual void update()
Update the local values to reflect the solution on neighboring processors.
unsigned int variable_number(std::string_view var) const
const DofMap & get_dof_map() const
unsigned int number() const
LIBMESH_DEVICE_INLINE void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
void pull_parallel_vector_data(const Communicator &comm, const MapToVectors &queries, GatherFunctor &gather_data, const ActionFunctor &act_on_data, const datum *example)
std::string enum_to_string(const T e)
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
void libmesh_ignore(const Args &...)
LIBMESH_DEVICE_INLINE bool libmesh_isnan(T x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Defines mapping from libMesh element types to LS-DYNA element types or vice-versa.
std::vector< unsigned int > nodes
The FPEDisabler class puts Floating-Point Exception (FPE) trapping on hold during its lifetime,...
const dof_id_type n_nodes