20 #include "libmesh/exodusII_io.h" 22 #include "libmesh/boundary_info.h" 23 #include "libmesh/dof_map.h" 24 #include "libmesh/dyna_io.h" 25 #include "libmesh/enum_elem_type.h" 26 #include "libmesh/elem.h" 27 #include "libmesh/enum_to_string.h" 28 #include "libmesh/equation_systems.h" 29 #include "libmesh/exodusII_io_helper.h" 30 #include "libmesh/fpe_disabler.h" 31 #include "libmesh/int_range.h" 32 #include "libmesh/libmesh_logging.h" 33 #include "libmesh/mesh_base.h" 34 #include "libmesh/mesh_communication.h" 35 #include "libmesh/numeric_vector.h" 36 #include "libmesh/parallel_mesh.h" 37 #include "libmesh/parallel.h" 38 #include "libmesh/system.h" 39 #include "libmesh/utility.h" 52 #ifdef LIBMESH_HAVE_EXODUS_API 57 const std::vector<Real> & bex_constraint_vec(std::size_t i,
60 std::size_t vec_offset = 0;
64 libmesh_assert_greater_equal(i, vec_offset);
65 if (i - vec_offset < vecblock.size())
66 return vecblock[i - vec_offset];
68 vec_offset += vecblock.size();
71 libmesh_error_msg(
"Requested BEX coefficient vector " << i <<
" not found");
74 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 76 complex_soln_components (
const std::vector<Number> & soln,
77 const unsigned int num_vars,
78 const bool write_complex_abs)
80 unsigned int num_values = soln.size();
81 unsigned int num_elems = num_values / num_vars;
85 int nco = write_complex_abs ? 3 : 2;
86 std::vector<Real> complex_soln(nco * num_values);
88 for (
unsigned i=0; i<num_vars; ++i)
90 for (
unsigned int j=0; j<num_elems; ++j)
93 complex_soln[nco*i*num_elems + j] =
value.real();
95 for (
unsigned int j=0; j<num_elems; ++j)
98 complex_soln[nco*i*num_elems + num_elems + j] =
value.imag();
100 if (write_complex_abs)
102 for (
unsigned int j=0; j<num_elems; ++j)
105 complex_soln[3*i*num_elems + 2*num_elems + j] = std::abs(
value);
112 #endif // LIBMESH_USE_COMPLEX_NUMBERS 123 bool single_precision) :
129 #ifdef LIBMESH_HAVE_EXODUS_API
135 _allow_empty_variables(false),
136 _write_complex_abs(true),
137 _set_unique_ids_from_maps(false),
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),
172 #ifdef LIBMESH_HAVE_EXODUS_API 197 const std::set<std::string> * system_names)
199 std::vector<std::string> solution_names;
200 std::vector<Number> v;
210 #ifdef LIBMESH_HAVE_EXODUS_API 215 const std::set<std::string> * system_names)
231 const std::set<std::string> * )
238 #ifdef LIBMESH_HAVE_EXODUS_API 248 LOG_SCOPE(
"read()",
"ExodusII_IO");
254 std::vector<unsigned int> extra_ids;
305 unsigned char weight_index = 0;
306 const bool weights_exist = !
exio_helper->w.empty();
312 const bool bex_cv_exist = !
exio_helper->bex_dense_constraint_vecs.empty();
329 const Real default_weight = 1.0;
330 weight_index = cast_int<unsigned char>
337 std::unordered_map<const Node *, Elem *> spline_nodeelem_ptrs;
346 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(i+1);
353 libmesh_error_msg_if(added_node->
id() !=
static_cast<unsigned>(libmesh_node_id),
354 "Error! Mesh assigned node ID " 356 <<
" which is different from the (zero-based) Exodus ID " 371 Point & p = *added_node;
392 elem->set_node(0, added_node);
394 spline_nodeelem_ptrs[added_node] = added_elem;
410 std::vector<std::map<dof_id_type, Real>> elem_ids(extra_ids.size());
413 unsigned int last_step =
exio_helper->num_time_steps;
418 int nelem_last_block = 0;
425 std::map<std::vector<std::pair<dof_id_type, Real>>,
Node *> local_nodes;
429 subdomain_id_type max_subdomain_id = std::numeric_limits<subdomain_id_type>::min();
444 restrict_int<subdomain_id_type>(
exio_helper->get_block_id(i));
445 max_subdomain_id = std::max(max_subdomain_id, subdomain_id);
448 std::string subdomain_name =
exio_helper->get_block_name(i);
449 if (!subdomain_name.empty())
453 const std::string type_str (
exio_helper->get_elem_type());
454 const auto & conv =
exio_helper->get_conversion(type_str);
457 int jmax = nelem_last_block+
exio_helper->num_elem_this_blk;
458 for (
int j=nelem_last_block; j<jmax; j++)
460 auto uelem =
Elem::build(conv.libmesh_elem_type());
462 const int elem_num = j - nelem_last_block;
469 libmesh_error_msg_if(
exio_helper->num_nodes_per_elem != static_cast<int>(uelem->n_nodes()),
470 "Error: Exodus file says " 472 <<
" nodes per Elem, but Elem type " 474 <<
" has " << uelem->n_nodes() <<
" nodes.");
477 uelem->subdomain_id() = subdomain_id;
483 auto libmesh_elem_id =
exio_helper->get_libmesh_elem_id(j+1);
485 uelem->set_id(libmesh_elem_id);
499 libmesh_error_msg_if(elem->
id() !=
static_cast<unsigned>(libmesh_elem_id),
500 "Error! Mesh assigned ID " 502 <<
" which is different from the (zero-based) Exodus ID " 507 for (
auto &
id : extra_ids)
509 const Real v = elem_ids[id][elem->
id()];
520 const long long iv = std::llround(v);
525 long long max_representation = 1;
526 max_representation = (max_representation << std::min(std::numeric_limits<Real>::digits,
527 std::numeric_limits<double>::digits));
528 libmesh_error_msg_if(iv > max_representation,
529 "Error! An element integer value higher than " 530 << max_representation
531 <<
" was found! Exodus uses real numbers for storing element " 532 " integers, which can only represent integers from 0 to " 533 << max_representation
536 libmesh_error_msg_if(iv < 0,
537 "Error! An element integer value less than -1" 538 <<
" was found! Exodus uses real numbers for storing element " 539 " integers, which can only represent integers from 0 to " 540 << max_representation
554 for (
int k=0; k<
exio_helper->num_nodes_per_elem; k++)
557 int gi = elem_num *
exio_helper->num_nodes_per_elem + conv.get_node_map(k);
563 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(exodus_node_id);
578 std::vector<std::vector<Real>>
580 for (
auto spline_node_index :
583 my_constraint_mat[spline_node_index].resize(elem->
n_nodes());
585 const auto & my_constraint_rows =
exio_helper->bex_cv_conn[elem_num];
586 const unsigned long elem_coef_vec_index =
587 my_constraint_rows[spline_node_index] - 1;
588 const auto & my_vec = bex_constraint_vec(elem_coef_vec_index, *
exio_helper);
589 for (
auto elem_node_index :
592 my_constraint_mat[spline_node_index][elem_node_index] =
593 my_vec[elem_node_index];
607 const auto & my_constraint_rows =
exio_helper->bex_cv_conn[elem_num];
609 for (
auto elem_node_index :
617 std::vector<std::pair<dof_id_type, Real>> key;
619 for (
auto spline_node_index :
623 const unsigned long elem_coef_vec_index =
624 my_constraint_rows[spline_node_index] - 1;
627 bex_constraint_vec(elem_coef_vec_index, *
exio_helper);
631 libmesh_vector_at(coef_vec, elem_node_index);
634 const int gi = elem_num *
exio_helper->bex_num_elem_cvs + spline_node_index;
640 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(exodus_node_id);
643 key.emplace_back(libmesh_node_id, coef);
647 if (
const auto local_node_it = local_nodes.find(key);
648 local_node_it != local_nodes.end())
649 elem->
set_node(dyna_elem_defn.
nodes[elem_node_index], local_node_it->second);
657 std::vector<std::pair<std::pair<const Elem *, unsigned int>,
Real>> constraint_row;
659 for (
auto [libmesh_spline_node_id, coef] : key)
664 const Real spline_w = weights_exist ?
666 w += coef * spline_w;
668 const Elem * nodeelem =
669 libmesh_map_find(spline_nodeelem_ptrs, &spline_node);
670 constraint_row.emplace_back(std::make_pair(nodeelem, 0), coef);
683 local_nodes[key] = n;
686 constraint_rows[n] = constraint_row;
694 nelem_last_block +=
exio_helper->num_elem_this_blk;
699 for (
auto p : spline_nodeelem_ptrs)
700 p.second->subdomain_id() = max_subdomain_id;
707 for (
unsigned char i=0; i!=4; ++i)
719 offset += (i > 0 ?
exio_helper->num_sides_per_set[i-1] : 0);
722 std::string sideset_name =
exio_helper->get_side_set_name(i);
723 if (!sideset_name.empty())
725 (cast_int<boundary_id_type>(
exio_helper->get_side_set_id(i)))
742 unsigned int raw_side_index =
exio_helper->side_list[e]-1;
743 std::size_t side_index_offset = conv.get_shellface_index_offset();
745 if (raw_side_index < side_index_offset)
748 int mapped_shellface = raw_side_index;
751 libmesh_error_msg_if(mapped_shellface < 0 || mapped_shellface >= 2,
752 "Bad 0-based shellface id: " 754 <<
" detected in Exodus file " 759 cast_int<unsigned short>(mapped_shellface),
760 cast_int<boundary_id_type>(
exio_helper->id_list[e]));
764 unsigned int side_index =
static_cast<unsigned int>(raw_side_index - side_index_offset);
765 int mapped_side = conv.get_side_map(side_index);
769 "Invalid 1-based side id: " 773 <<
" in Exodus file " 776 libmesh_error_msg_if(mapped_side < 0 ||
777 cast_int<unsigned int>(mapped_side) >= elem.
n_sides(),
778 "Bad 0-based side id: " 782 <<
" in Exodus file " 787 cast_int<unsigned short>(mapped_side),
788 cast_int<boundary_id_type>(
exio_helper->id_list[e]));
803 offset += (i > 0 ?
exio_helper->num_elems_per_set[i-1] : 0);
824 std::map<Elem *, MeshBase::elemset_type> elem_to_elemsets;
839 elem_to_elemsets[elem].insert(
exio_helper->elemset_id_list[e]);
843 std::set<MeshBase::elemset_type> unique_elemsets;
844 for (
const auto & pr : elem_to_elemsets)
845 unique_elemsets.insert(pr.second);
858 for (
const auto & s : unique_elemsets)
866 <<
", but mesh should have " <<
exio_helper->num_elem_sets <<
" elemsets.");
870 unsigned int elemset_index =
875 for (
const auto & [elem, s] : elem_to_elemsets)
892 for (
int nodeset=0; nodeset<
exio_helper->num_node_sets; nodeset++)
895 cast_int<boundary_id_type>(
exio_helper->nodeset_ids[nodeset]);
897 std::string nodeset_name =
exio_helper->get_node_set_name(nodeset);
898 if (!nodeset_name.empty())
902 unsigned int offset =
exio_helper->node_sets_node_index[nodeset];
904 for (
int i=0; i<
exio_helper->num_nodes_per_set[nodeset]; ++i)
906 int exodus_node_id =
exio_helper->node_sets_node_list[i + offset];
907 auto libmesh_node_id =
exio_helper->get_libmesh_node_id(exodus_node_id);
915 "Cannot open dimension " 917 <<
" mesh file when configured without " 989 exio_helper->use_mesh_dimension_instead_of_spatial_dimension(val);
1003 libmesh_warning(
"This method may be deprecated in the future");
1033 libmesh_error_msg_if
1035 "ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!");
1046 "ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!");
1055 std::string system_var_name,
1056 std::string exodus_var_name,
1057 unsigned int timestep)
1059 LOG_SCOPE(
"copy_nodal_solution()",
"ExodusII_IO");
1066 "ERROR, nodal data cannot be loaded if the mesh may be renumbered!");
1072 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1073 "ERROR, ExodusII file must be opened for reading before copying a nodal solution!");
1075 exio_helper->read_nodal_var_values(exodus_var_name, timestep);
1078 auto & node_var_value_map =
exio_helper->nodal_var_values;
1085 if (!serial_on_zero)
1087 std::unordered_map<processor_id_type, std::vector<dof_id_type>> node_ids_to_request;
1090 std::vector<dof_id_type> node_ids;
1091 for (
auto & node :
mesh.local_node_ptr_range())
1092 node_ids.push_back(node->id());
1093 if (!node_ids.empty())
1094 node_ids_to_request[0] = std::move(node_ids);
1097 auto value_gather_functor =
1098 [& node_var_value_map]
1100 const std::vector<dof_id_type> & ids,
1101 std::vector<Real> & values)
1103 const std::size_t query_size = ids.size();
1104 values.resize(query_size);
1105 for (std::size_t i=0; i != query_size; ++i)
1107 if (
const auto it = node_var_value_map.find(ids[i]);
1108 it != node_var_value_map.end())
1110 values[i] = it->second;
1111 node_var_value_map.erase(it);
1114 values[i] = std::numeric_limits<Real>::quiet_NaN();
1118 auto value_action_functor =
1119 [& node_var_value_map]
1121 const std::vector<dof_id_type> & ids,
1122 const std::vector<Real> & values)
1124 const std::size_t query_size = ids.size();
1125 for (std::size_t i=0; i != query_size; ++i)
1127 node_var_value_map[ids[i]] = values[i];
1130 Real * value_ex =
nullptr;
1131 Parallel::pull_parallel_vector_data
1132 (system.
comm(), node_ids_to_request, value_gather_functor,
1133 value_action_functor, value_ex);
1151 system.
solution->set (dof_index, p.second);
1162 std::string system_var_name,
1163 std::string exodus_var_name,
1164 unsigned int timestep)
1166 LOG_SCOPE(
"copy_elemental_solution()",
"ExodusII_IO");
1175 "Error! Trying to copy elemental solution into a variable that is not of CONSTANT MONOMIAL nor CONSTANT MONOMIAL_VEC type.");
1181 "ERROR, elemental data cannot be loaded if the mesh may be renumbered!");
1188 std::map<dof_id_type, Real> elem_var_value_map;
1194 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1195 "ERROR, ExodusII file must be opened for reading before copying an elemental solution!");
1197 exio_helper->read_elemental_var_values(exodus_var_name, timestep, elem_var_value_map);
1205 if (!serial_on_zero)
1207 std::unordered_map<processor_id_type, std::vector<dof_id_type>> elem_ids_to_request;
1210 std::vector<dof_id_type> elem_ids;
1211 for (
auto & elem :
mesh.active_local_element_ptr_range())
1212 elem_ids.push_back(elem->id());
1214 if (!elem_ids.empty())
1215 elem_ids_to_request[0] = std::move(elem_ids);
1218 auto value_gather_functor =
1219 [& elem_var_value_map]
1221 const std::vector<dof_id_type> & ids,
1222 std::vector<Real> & values)
1224 const std::size_t query_size = ids.size();
1225 values.resize(query_size);
1226 for (std::size_t i=0; i != query_size; ++i)
1228 if (
const auto it = elem_var_value_map.find(ids[i]);
1229 it != elem_var_value_map.end())
1231 values[i] = it->second;
1232 elem_var_value_map.erase(it);
1235 values[i] = std::numeric_limits<Real>::quiet_NaN();
1239 auto value_action_functor =
1240 [& elem_var_value_map]
1242 const std::vector<dof_id_type> & ids,
1243 const std::vector<Real> & values)
1245 const std::size_t query_size = ids.size();
1246 for (std::size_t i=0; i != query_size; ++i)
1248 elem_var_value_map[ids[i]] = values[i];
1251 Real * value_ex =
nullptr;
1252 Parallel::pull_parallel_vector_data
1253 (system.
comm(), elem_ids_to_request, value_gather_functor,
1254 value_action_functor, value_ex);
1257 std::map<dof_id_type, Real>::iterator
1258 it = elem_var_value_map.begin(),
1259 end = elem_var_value_map.end();
1264 for (; it!=end; ++it)
1268 if (elem && elem->
n_comp(system.
number(), var_num) > 0)
1271 if (serial_on_zero || dof_map.
local_index(dof_index ))
1272 system.
solution->set (dof_index, it->second);
1281 std::vector<std::string> system_var_names,
1282 std::vector<std::string> exodus_var_names,
1283 unsigned int timestep)
1285 LOG_SCOPE(
"copy_scalar_solution()",
"ExodusII_IO");
1287 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1288 "ERROR, ExodusII file must be opened for reading before copying a scalar solution!");
1290 libmesh_error_msg_if(system_var_names.size() != exodus_var_names.size(),
1291 "ERROR, the number of system_var_names must match exodus_var_names.");
1293 std::vector<Real> values_from_exodus;
1296 #ifdef LIBMESH_HAVE_MPI 1315 std::vector<dof_id_type> SCALAR_dofs;
1318 system.
solution->set (SCALAR_dofs[0], values_from_exodus[i]);
1327 unsigned int timestep,
1328 std::map<unsigned int, Real> & unique_id_to_value_map)
1330 LOG_SCOPE(
"read_elemental_variable()",
"ExodusII_IO");
1333 std::map<dof_id_type, Real> elem_var_value_map;
1335 exio_helper->read_elemental_var_values(elemental_var_name, timestep, elem_var_value_map);
1336 for (
auto & pr : elem_var_value_map)
1344 unsigned int timestep,
1345 std::vector<Real> & global_values)
1347 LOG_SCOPE(
"read_global_variable()",
"ExodusII_IO");
1349 std::size_t size = global_var_names.size();
1350 libmesh_error_msg_if(size == 0,
"ERROR, empty list of global variables to read from the Exodus file.");
1353 std::vector<Real> values_from_exodus;
1355 exio_helper->read_global_values(values_from_exodus, timestep);
1356 std::vector<std::string> global_var_names_exodus =
exio_helper->global_var_names;
1358 if (values_from_exodus.size() == 0)
1361 global_values.clear();
1362 for (std::size_t i = 0; i != size; ++i)
1366 auto it = find(global_var_names_exodus.begin(), global_var_names_exodus.end(), global_var_names[i]);
1367 if (it != global_var_names_exodus.end())
1368 global_values.push_back(values_from_exodus[it - global_var_names_exodus.begin()]);
1370 libmesh_error_msg(
"ERROR, Global variable " << global_var_names[i] << \
1371 " not found in Exodus file.");
1378 LOG_SCOPE(
"write_element_data()",
"ExodusII_IO");
1382 "ERROR, ExodusII file must be initialized before outputting element variables.");
1396 std::vector<std::string> names;
1403 std::vector<std::string> monomials;
1413 for (
const auto & var : monomials)
1415 names.push_back(var);
1420 std::vector<Number> soln;
1424 std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1437 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1439 std::vector<std::string> complex_names =
1442 std::vector<std::set<subdomain_id_type>>
1443 complex_vars_active_subdomains =
1444 exio_helper->get_complex_vars_active_subdomains(vars_active_subdomains,
1446 exio_helper->initialize_element_variables(complex_names, complex_vars_active_subdomains);
1448 const std::vector<Real> complex_soln =
1454 exio_helper->initialize_element_variables(names, vars_active_subdomains);
1464 const std::set<std::string> * system_names,
1465 const std::string & var_suffix)
1467 LOG_SCOPE(
"write_element_data_from_discontinuous_nodal_data()",
"ExodusII_IO");
1473 "ERROR, ExodusII file must be initialized before outputting element variables.");
1487 std::vector<std::string> var_names;
1503 std::vector<std::string> monomial_var_names;
1511 if (!_output_variables.empty())
1517 [
this](
const std::string &
name)
1518 {
return !std::count(_output_variables.begin(),
1519 _output_variables.end(),
1524 monomial_var_names.erase
1526 (monomial_var_names.begin(),
1527 monomial_var_names.end(),
1528 [
this](
const std::string &
name)
1529 {
return !std::count(_output_variables.begin(),
1530 _output_variables.end(),
1532 monomial_var_names.end());
1538 std::vector<Number> v;
1540 (v, system_names, &var_names,
true);
1543 std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1549 std::map<subdomain_id_type, unsigned int> subdomain_id_to_vertices_per_elem;
1550 for (
const auto & elem :
mesh.active_element_ptr_range())
1557 auto pr2 = subdomain_id_to_vertices_per_elem.emplace
1558 (elem->subdomain_id(), elem->n_vertices());
1559 libmesh_error_msg_if(!pr2.second && pr2.first->second != elem->n_vertices(),
1560 "Elem with different number of vertices found.");
1583 std::vector<std::string> derived_var_names;
1588 std::map<std::string, std::pair<std::string, unsigned int>>
1589 derived_name_to_orig_name_and_node_id;
1591 for (
const auto & pr : subdomain_id_to_vertices_per_elem)
1594 const unsigned int vertices_per_elem =
1595 subdomain_id_to_vertices_per_elem[sbd_id];
1597 std::ostringstream oss;
1598 for (
unsigned int n=0; n<vertices_per_elem; ++n)
1599 for (
const auto & orig_var_name : var_names)
1603 oss << orig_var_name << var_suffix << n;
1604 std::string derived_name = oss.str();
1607 if (!std::count(derived_var_names.begin(), derived_var_names.end(), derived_name))
1609 derived_var_names.push_back(derived_name);
1611 derived_name_to_orig_name_and_node_id[derived_name] =
1612 std::make_pair(orig_var_name, n);
1620 std::vector<std::set<subdomain_id_type>>
1621 derived_vars_active_subdomains(derived_var_names.size());
1633 std::map<subdomain_id_type, std::vector<std::string>>
1634 subdomain_to_var_names;
1636 for (
auto derived_var_id :
index_range(derived_var_names))
1638 const auto & derived_name = derived_var_names[derived_var_id];
1639 const auto & [orig_name, node_id] =
1640 libmesh_map_find (derived_name_to_orig_name_and_node_id,
1645 for (
const auto & pr : subdomain_id_to_vertices_per_elem)
1650 unsigned int vertices_per_elem_this_sbd =
1651 subdomain_id_to_vertices_per_elem[sbd_id];
1658 auto var_loc = std::find(var_names.begin(), var_names.end(), orig_name);
1659 libmesh_error_msg_if(var_loc == var_names.end(),
1660 "Variable " << orig_name <<
" somehow not found in var_names array.");
1665 if (node_id < vertices_per_elem_this_sbd)
1671 subdomain_to_var_names[sbd_id].push_back(derived_name);
1680 bool orig_var_active =
1681 (vars_active_subdomains[var_id].empty() ||
1682 vars_active_subdomains[var_id].count(sbd_id));
1686 if (orig_var_active)
1687 derived_vars_active_subdomains[derived_var_id].insert(sbd_id);
1699 for (
auto & derived_var_name : derived_var_names)
1702 const auto & name_and_id =
1703 libmesh_map_find (derived_name_to_orig_name_and_node_id,
1707 const std::string & orig_name = name_and_id.first;
1710 if (std::count(monomial_var_names.begin(),
1711 monomial_var_names.end(),
1715 for (
auto & pr : subdomain_to_var_names)
1718 auto & name_vec = pr.second;
1721 std::find(name_vec.begin(),
1725 if (name_vec_it != name_vec.end())
1729 *name_vec_it = orig_name;
1734 derived_var_name = orig_name;
1741 std::vector<std::string> derived_var_names_edited;
1742 std::vector<std::set<subdomain_id_type>> derived_vars_active_subdomains_edited;
1743 std::vector<unsigned int> found_first(monomial_var_names.size());
1747 const auto & derived_var_name = derived_var_names[i];
1748 const auto & active_set = derived_vars_active_subdomains[i];
1754 if (derived_var_name == monomial_var_names[j])
1756 if (!found_first[j])
1766 if (active_set.empty())
1771 derived_var_names_edited.push_back(derived_var_name);
1772 derived_vars_active_subdomains_edited.push_back(active_set);
1777 derived_var_names.swap(derived_var_names_edited);
1778 derived_vars_active_subdomains.swap(derived_vars_active_subdomains_edited);
1781 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1784 auto complex_var_names =
1785 exio_helper->get_complex_names(derived_var_names,
1786 _write_complex_abs);
1787 auto complex_vars_active_subdomains =
1788 exio_helper->get_complex_vars_active_subdomains(derived_vars_active_subdomains,
1789 _write_complex_abs);
1790 auto complex_subdomain_to_var_names =
1791 exio_helper->get_complex_subdomain_to_var_names(subdomain_to_var_names,
1792 _write_complex_abs);
1798 std::vector<Real> complex_v;
1799 int nco = _write_complex_abs ? 3 : 2;
1800 complex_v.reserve(nco * v.size());
1801 for (
const auto & val : v)
1803 complex_v.push_back(val.real());
1804 complex_v.push_back(val.imag());
1805 if (_write_complex_abs)
1806 complex_v.push_back(std::abs(val));
1810 exio_helper->initialize_element_variables
1811 (complex_var_names, complex_vars_active_subdomains);
1812 exio_helper->write_element_values_element_major
1813 (
mesh, complex_v, _timestep,
1814 complex_vars_active_subdomains,
1816 complex_subdomain_to_var_names);
1821 exio_helper->initialize_element_variables(derived_var_names, derived_vars_active_subdomains);
1826 exio_helper->write_element_values_element_major
1827 (
mesh, v, _timestep,
1828 derived_vars_active_subdomains,
1830 subdomain_to_var_names);
1837 const std::vector<Number> & soln,
1838 const std::vector<std::string> & names)
1840 LOG_SCOPE(
"write_nodal_data()",
"ExodusII_IO");
1844 int num_vars = cast_int<int>(names.size());
1848 std::vector<std::string> output_names;
1853 output_names = names;
1855 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1856 std::vector<std::string> complex_names =
1872 for (
int c=0; c<num_vars; c++)
1874 std::stringstream name_to_find;
1876 std::vector<std::string>::iterator pos =
1877 std::find(output_names.begin(), output_names.end(), names[c]);
1878 if (pos == output_names.end())
1881 unsigned int variable_name_position =
1882 cast_int<unsigned int>(pos - output_names.begin());
1886 #ifdef LIBMESH_USE_REAL_NUMBERS 1887 std::vector<Number> cur_soln;
1892 cur_soln.reserve(num_nodes);
1894 std::vector<Real> real_parts;
1895 std::vector<Real> imag_parts;
1896 std::vector<Real> magnitudes;
1897 real_parts.reserve(num_nodes);
1898 imag_parts.reserve(num_nodes);
1900 magnitudes.reserve(num_nodes);
1910 for (
const auto & node :
mesh.node_ptr_range())
1915 #ifdef LIBMESH_USE_REAL_NUMBERS 1916 cur_soln.push_back(soln[
idx]);
1918 real_parts.push_back(soln[
idx].
real());
1919 imag_parts.push_back(soln[
idx].
imag());
1921 magnitudes.push_back(std::abs(soln[
idx]));
1933 std::vector<std::vector<const Elem *>>
1936 for (
const auto & elem :
mesh.active_element_ptr_range())
1937 elems_by_pid[elem->processor_id()].push_back(elem);
1942 exio_helper->added_node_offset_on(p) * num_vars + c;
1943 for (
const Elem * elem : elems_by_pid[p])
1945 for (
auto s : elem->side_index_range())
1950 const std::vector<unsigned int> side_nodes =
1951 elem->nodes_on_side(s);
1956 libmesh_assert_less(global_idx, soln.size());
1957 #ifdef LIBMESH_USE_REAL_NUMBERS 1958 cur_soln.push_back(soln[global_idx]);
1960 real_parts.push_back(soln[global_idx].
real());
1961 imag_parts.push_back(soln[global_idx].
imag());
1963 magnitudes.push_back(std::abs(soln[global_idx]));
1965 global_idx += num_vars;
1973 #ifdef LIBMESH_USE_REAL_NUMBERS 1994 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
1995 "ERROR, ExodusII file must be initialized before outputting information records.");
2003 const std::vector<std::string> & names)
2005 LOG_SCOPE(
"write_global_data()",
"ExodusII_IO");
2010 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2011 "ERROR, ExodusII file must be initialized before outputting global variables.");
2013 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 2015 std::vector<std::string> complex_names =
2019 exio_helper->initialize_global_variables(complex_names);
2021 const std::vector<Real> complex_soln =
2038 const std::set<std::string> * system_names)
2052 const std::set<std::string> * system_names)
2060 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2061 "ERROR, ExodusII file must be opened for writing " 2062 "before calling ExodusII_IO::write_elemsets()!");
2071 const std::vector<std::string> & var_names,
2072 const std::vector<std::set<boundary_id_type>> & side_ids,
2073 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals)
2075 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2076 "ERROR, ExodusII file must be opened for writing " 2077 "before calling ExodusII_IO::write_sideset_data()!");
2080 exio_helper->write_sideset_data(
mesh, timestep, var_names, side_ids, bc_vals);
2088 std::vector<std::string> & var_names,
2089 std::vector<std::set<boundary_id_type>> & side_ids,
2090 std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals)
2092 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2093 "ERROR, ExodusII file must be opened for reading " 2094 "before calling ExodusII_IO::read_sideset_data()!");
2097 exio_helper->read_sideset_data(
mesh, timestep, var_names, side_ids, bc_vals);
2107 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2108 "ERROR, ExodusII file must be opened for reading " 2109 "before calling ExodusII_IO::get_sideset_data_indices()!");
2119 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2120 "ERROR, ExodusII file must be opened for reading " 2121 "before calling ExodusII_IO::get_nodeset_data_indices()!");
2123 exio_helper->get_nodeset_data_indices(bc_array_indices);
2129 const std::vector<std::string> & var_names,
2130 const std::vector<std::set<boundary_id_type>> & node_boundary_ids,
2131 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals)
2133 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2134 "ERROR, ExodusII file must be opened for writing " 2135 "before calling ExodusII_IO::write_nodeset_data()!");
2137 exio_helper->write_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2145 std::vector<std::string> & var_names,
2146 std::vector<std::set<boundary_id_type>> & node_boundary_ids,
2147 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals)
2149 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2150 "ERROR, ExodusII file must be opened for reading " 2151 "before calling ExodusII_IO::read_nodeset_data()!");
2153 exio_helper->read_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2159 const std::vector<std::string> & var_names,
2160 const std::vector<std::set<elemset_id_type>> & elemset_ids_in,
2161 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals)
2163 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2164 "ERROR, ExodusII file must be opened for writing " 2165 "before calling ExodusII_IO::write_elemset_data()!");
2167 exio_helper->write_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2175 std::vector<std::string> & var_names,
2176 std::vector<std::set<elemset_id_type>> & elemset_ids_in,
2177 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals)
2179 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2180 "ERROR, ExodusII file must be opened for reading " 2181 "before calling ExodusII_IO::read_elemset_data()!");
2183 exio_helper->read_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2189 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2190 "ERROR, ExodusII file must be opened for reading " 2191 "before calling ExodusII_IO::get_elemset_data_indices()!");
2193 exio_helper->get_elemset_data_indices(elemset_array_indices);
2199 LOG_SCOPE(
"write()",
"ExodusII_IO");
2207 (const_cast<MeshBase &>(
mesh),
2217 libmesh_warning(
"Warning: Appending in ExodusII_IO::write() does not make sense.\n" 2218 "Creating a new file instead!");
2229 libmesh_warning(
"Warning: Mesh contains edge boundary IDs, but these " 2230 "are not supported by the ExodusII format.");
2236 const std::vector<Number> & soln,
2237 const std::vector<std::string> & names)
2239 LOG_SCOPE(
"write_nodal_data_discontinuous()",
"ExodusII_IO");
2243 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 2245 std::vector<std::string> complex_names =
2260 int num_vars = cast_int<int>(names.size());
2261 libmesh_assert_equal_to(soln.size() % num_vars, 0);
2262 int num_nodes = soln.size() / num_vars;
2263 libmesh_assert_equal_to(
exio_helper->num_nodes, num_nodes);
2268 int num_real_nodes = 0;
2269 for (
const auto & elem :
mesh.active_element_ptr_range())
2270 num_real_nodes += elem->n_nodes();
2271 libmesh_assert_equal_to(num_real_nodes, num_nodes);
2275 for (
int c=0; c<num_vars; c++)
2277 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 2278 std::vector<Real> real_parts(num_nodes);
2279 std::vector<Real> imag_parts(num_nodes);
2280 std::vector<Real> magnitudes;
2282 magnitudes.resize(num_nodes);
2288 for (
int i=0; i<num_nodes; ++i)
2290 real_parts[i] = soln[i*num_vars + c].real();
2291 imag_parts[i] = soln[i*num_vars + c].imag();
2293 magnitudes[i] = std::abs(soln[i*num_vars + c]);
2301 std::vector<Number> cur_soln(num_nodes);
2303 for (
int i=0; i<num_nodes; i++)
2304 cur_soln[i] = soln[i*num_vars + c];
2314 const std::vector<std::string> & names,
2372 libmesh_error_msg_if(fname !=
exio_helper->current_filename,
2373 "Error! This ExodusII_IO object is already associated with file: " 2375 <<
", cannot use it with requested file: " 2418 libmesh_experimental();
2454 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2461 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2468 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2475 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2482 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2489 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2496 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2503 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2510 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2518 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2525 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2534 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2544 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2550 std::vector<std::string>,
2551 std::vector<std::string>,
2554 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2561 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2569 const std::set<std::string> *,
2570 const std::string & )
2572 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2578 const std::vector<Number> &,
2579 const std::vector<std::string> &)
2581 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2588 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2594 const std::vector<std::string> &)
2596 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2605 const std::set<std::string> *)
2607 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2613 const std::set<std::string> *)
2615 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2621 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2627 const std::vector<std::string> &,
2628 const std::vector<std::set<boundary_id_type>> &,
2629 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> &)
2631 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2639 std::vector<std::string> &,
2640 std::vector<std::set<boundary_id_type>> &,
2641 std::vector<std::map<BoundaryInfo::BCTuple, Real>> &)
2643 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2651 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2657 const std::vector<std::string> &,
2658 const std::vector<std::set<boundary_id_type>> &,
2659 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> &)
2661 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2667 std::vector<std::string> &,
2668 std::vector<std::set<boundary_id_type>> &,
2669 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> &)
2671 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2678 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2684 const std::vector<std::string> &,
2685 const std::vector<std::set<elemset_id_type>> &,
2686 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> &)
2688 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2694 std::vector<std::string> &,
2695 std::vector<std::set<elemset_id_type>> &,
2696 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> &)
2698 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2705 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2710 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2716 const std::vector<Number> &,
2717 const std::vector<std::string> &)
2719 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2725 const std::vector<std::string> &,
2728 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2734 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2739 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2744 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2749 #endif // LIBMESH_HAVE_EXODUS_API std::string name(const ElemQuality q)
This function returns a string containing some name for q.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
The FPEDisabler class puts Floating-Point Exception (FPE) trapping on hold during its lifetime...
const std::vector< std::string > & get_global_var_names()
Return list of the global variable names.
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, thus by default we write all meshes with the Exodus dimension set to LIBMESH_DIM = mesh.spatial_dimension().
This is the EquationSystems class.
virtual void reserve_nodes(const dof_id_type nn)=0
Reserves space for a known number of nodes.
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
unsigned int variable_scalar_number(std::string_view var, unsigned int component) const
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.
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
virtual Node *& set_node(const unsigned int i)
A Node is like a Point, but with more information.
std::string & nodeset_name(boundary_id_type id)
boost::multiprecision::float128 real(const boost::multiprecision::float128 in)
void write_as_dimension(unsigned dim)
Directly control the num_dim which is written to the Exodus file.
unsigned int n_comp(const unsigned int s, const unsigned int var) const
ExodusII_IO_Helper & get_exio_helper()
Return a reference to the ExodusII_IO_Helper object.
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.
void allow_renumbering(bool allow)
If false is passed in then this mesh will no longer be renumbered when being prepared for use...
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 ...
std::size_t n_edge_conds() const
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...
static const int invalid_id
An invalid_id that can be returned to signal failure in case something goes wrong.
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.
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.
const Elem * top_parent() const
void set_max_name_length(unsigned int max_length)
For backwards compatibility, libMesh currently truncates names in ExodusII output to the old default ...
MessageTag get_unique_tag(int tagvalue=MessageTag::invalid_tag) const
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.
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...
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...
Defines mapping from libMesh element types to LS-DYNA element types or vice-versa.
This is the base class from which all geometric element types are derived.
processor_id_type rank() const
unique_id_type unique_id() const
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.
const Parallel::Communicator & comm() const
This class defines an abstract interface for Mesh output.
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...
The libMesh namespace provides an interface to certain functionality in the library.
dof_id_type get_elemset_code(const MeshBase::elemset_type &id_set) const
ExodusII_IO(MeshBase &mesh, bool single_precision=false)
Constructor.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
void append(bool val)
If true, this flag will cause the ExodusII_IO object to attempt to open an existing file for writing...
Real distance(const Point &p)
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.
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...
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...
uint8_t processor_id_type
This is the MeshBase class.
unsigned int variable_number(std::string_view var) const
virtual bool is_serial_on_zero() const
This class handles the numbering of degrees of freedom on a mesh.
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...
int _timestep
Stores the current value of the timestep when calling ExodusII_IO::write_timestep().
static const ElementDefinition & find_elem_definition(dyna_int_type dyna_elem, int dim, int p)
Finds the ElementDefinition corresponding to a particular element type.
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.
processor_id_type n_processors() const
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 libmesh_ignore(const Args &...)
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
const dof_id_type n_nodes
unsigned int number() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
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.
virtual bool get_add_sides() override
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...
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
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_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.
virtual unsigned int n_nodes() const =0
bool _verbose
should we be verbose?
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.
bool _append
Default false.
Manages consistently variables, degrees of freedom, and coefficient vectors.
virtual Elem * add_elem(Elem *e)=0
Add elem e to the end of the element array.
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
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...
void set_unique_ids_from_maps(bool val)
If true, this flag enforces the following behaviors:
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...
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...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const std::vector< Real > & get_time_steps()
unsigned int n_elemsets() const
Returns the number of unique elemset ids which have been added via add_elemset_code(), which is the size of the _all_elemset_ids set.
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...
std::vector< std::string > _output_variables
The names of the variables to be output.
This is the ExodusII_IO_Helper class.
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 write_information_records(const std::vector< std::string > &)
Write out information records.
std::string & subdomain_name(subdomain_id_type id)
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 set_mesh_dimension(unsigned char d)
Resets the logical dimension of the mesh.
void verbose(bool set_verbosity)
Set the flag indicating if we should be verbose.
void write_elemsets()
Write elemsets stored on the Mesh to file.
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...
An object whose state is distributed along a set of processors.
virtual void read(const std::string &name) override
This method implements reading a mesh from a specified file.
bool _disc_bex
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element...
virtual void clear()
Deletes all the element and node data that is currently stored.
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 ...
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.
std::string & sideset_name(boundary_id_type id)
void write_global_data(const std::vector< Number > &, const std::vector< std::string > &)
Write out global variables.
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 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.
std::string enum_to_string(const T e)
virtual const Elem * elem_ptr(const dof_id_type i) const =0
bool _write_complex_abs
By default, when complex numbers are enabled, for each variable we write out three values: the real p...
std::unique_ptr< ExodusII_IO_Helper > exio_helper
Only attempt to instantiate an ExodusII helper class if the Exodus API is defined.
virtual unsigned int n_sides() const =0
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 ...
virtual void update()
Update the local values to reflect the solution on neighboring processors.
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.
static int get_exodus_version()
const FEType & variable_type(const unsigned int i) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual const Elem * query_elem_ptr(const dof_id_type i) const =0
void write_complex_magnitude(bool val)
Set the flag indicating whether the complex modulus should be written when complex numbers are enable...
virtual unsigned short dim() const =0
Temporarily serialize a DistributedMesh for non-distributed-mesh capable code paths.
virtual void write(const std::string &fname) override
This method implements writing a mesh to a specified file.
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.
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
const std::vector< std::string > & get_elem_var_names()
Return list of the elemental variable names.
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...
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 ...
virtual const Elem & elem_ref(const dof_id_type i) const
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...
unsigned int mesh_dimension() const
void write_element_data(const EquationSystems &es)
Write out element solution.
ExodusHeaderInfo read_header(const std::string &name)
Read only the header information, instead of the entire mesh.
bool _allow_empty_variables
Flag which controls the behavior of _output_variables: .) If true, _output_variables is allowed to re...
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...
virtual const Node & node_ref(const dof_id_type i) const
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, writes out a general discontinuous solution field, e.g.
void set_discontinuous_bex(bool disc_bex)
Set to true (false is the default) to generate independent nodes for every Bezier Extraction element ...
boost::multiprecision::float128 imag(const boost::multiprecision::float128)
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...
virtual const Node * node_ptr(const dof_id_type i) const =0
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
Write out a nodal solution.
std::vector< unsigned int > nodes
processor_id_type processor_id() const
virtual Order default_order() const =0
void write_added_sides(bool val)
By default, we only write out the elements physically stored in the mesh.
const DofMap & get_dof_map() const
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)...
processor_id_type processor_id() const
const std::vector< std::string > & get_nodal_var_names()
Return list of the nodal variable names.
virtual ElemType type() const =0
A Point defines a location in LIBMESH_DIM dimensional Real space.
virtual void reserve_elem(const dof_id_type ne)=0
Reserves space for a known number of elements.
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 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 ErrorVector unsigned int
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 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...
virtual dof_id_type n_nodes() const =0
bool _set_unique_ids_from_maps
Set Elem/Node unique_ids based on the elem_num_map and node_num_map contents during reading...
static int get_exodus_version()
void set_coordinate_offset(Point p)
Allows you to set a vector that is added to the coordinates of all of the nodes.
void build_elemental_solution_vector(std::vector< Number > &soln, std::vector< std::string > &names) const
Retrieve the solution data for CONSTANT MONOMIALs and/or components of CONSTANT MONOMIAL_VECs.
bool local_index(dof_id_type dof_index) const
static bool redundant_added_side(const Elem &elem, unsigned int side)
std::vector< std::vector< std::vector< Real > > > bex_dense_constraint_vecs