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),
146 bool single_precision) :
152 #ifdef LIBMESH_HAVE_EXODUS_API
158 _allow_empty_variables(false),
159 _write_complex_abs(true),
170 #ifdef LIBMESH_HAVE_EXODUS_API 195 const std::set<std::string> * system_names)
197 std::vector<std::string> solution_names;
198 std::vector<Number> v;
208 #ifdef LIBMESH_HAVE_EXODUS_API 213 const std::set<std::string> * system_names)
229 const std::set<std::string> * )
236 #ifdef LIBMESH_HAVE_EXODUS_API 246 LOG_SCOPE(
"read()",
"ExodusII_IO");
252 std::vector<unsigned int> extra_ids;
303 unsigned char weight_index = 0;
304 const bool weights_exist = !
exio_helper->w.empty();
310 const bool bex_cv_exist = !
exio_helper->bex_dense_constraint_vecs.empty();
317 const Real default_weight = 1.0;
318 weight_index = cast_int<unsigned char>
325 std::unordered_map<const Node *, Elem *> spline_nodeelem_ptrs;
338 libmesh_error_msg_if(added_node->
id() !=
static_cast<unsigned>(exodus_id-1),
339 "Error! Mesh assigned node ID " 341 <<
" which is different from the (zero-based) Exodus ID " 352 Point & p = *added_node;
366 elem->set_node(0, added_node);
368 spline_nodeelem_ptrs[added_node] = added_elem;
384 std::vector<std::map<dof_id_type, Real>> elem_ids(extra_ids.size());
387 unsigned int last_step =
exio_helper->num_time_steps;
392 int nelem_last_block = 0;
399 std::map<std::vector<std::pair<dof_id_type, Real>>,
Node *> local_nodes;
403 int max_subdomain_id = std::numeric_limits<int>::min();
417 const int subdomain_id =
exio_helper->get_block_id(i);
418 max_subdomain_id = std::max(max_subdomain_id, subdomain_id);
421 std::string subdomain_name =
exio_helper->get_block_name(i);
422 if (!subdomain_name.empty())
426 const std::string type_str (
exio_helper->get_elem_type());
427 const auto & conv =
exio_helper->get_conversion(type_str);
430 int jmax = nelem_last_block+
exio_helper->num_elem_this_blk;
431 for (
int j=nelem_last_block; j<jmax; j++)
433 auto uelem =
Elem::build(conv.libmesh_elem_type());
435 const int elem_num = j - nelem_last_block;
442 libmesh_error_msg_if(
exio_helper->num_nodes_per_elem != static_cast<int>(uelem->n_nodes()),
443 "Error: Exodus file says " 445 <<
" nodes per Elem, but Elem type " 447 <<
" has " << uelem->n_nodes() <<
" nodes.");
455 libmesh_error_msg_if(std::size_t(j) >=
exio_helper->elem_num_map.size(),
456 "Error: Trying to read Exodus file with more elements than elem_num_map entries.\n");
464 uelem->set_id(exodus_id-1);
474 libmesh_error_msg_if(elem->
id() !=
static_cast<unsigned>(exodus_id-1),
475 "Error! Mesh assigned ID " 477 <<
" which is different from the (zero-based) Exodus ID " 482 for (
auto &
id : extra_ids)
484 const Real v = elem_ids[id][elem->
id()];
495 const long long iv = std::llround(v);
500 long long max_representation = 1;
501 max_representation = (max_representation << std::min(std::numeric_limits<Real>::digits,
502 std::numeric_limits<double>::digits));
503 libmesh_error_msg_if(iv > max_representation,
504 "Error! An element integer value higher than " 505 << max_representation
506 <<
" was found! Exodus uses real numbers for storing element " 507 " integers, which can only represent integers from 0 to " 508 << max_representation
511 libmesh_error_msg_if(iv < 0,
512 "Error! An element integer value less than -1" 513 <<
" was found! Exodus uses real numbers for storing element " 514 " integers, which can only represent integers from 0 to " 515 << max_representation
529 for (
int k=0; k<
exio_helper->num_nodes_per_elem; k++)
532 int gi = (elem_num)*
exio_helper->num_nodes_per_elem + conv.get_node_map(k);
556 std::vector<std::vector<Real>>
558 for (
auto spline_node_index :
561 my_constraint_mat[spline_node_index].resize(elem->
n_nodes());
563 const auto & my_constraint_rows =
exio_helper->bex_cv_conn[elem_num];
564 const unsigned long elem_coef_vec_index =
565 my_constraint_rows[spline_node_index] - 1;
566 const auto & my_vec = bex_constraint_vec(elem_coef_vec_index, *
exio_helper);
567 for (
auto elem_node_index :
570 my_constraint_mat[spline_node_index][elem_node_index] =
571 my_vec[elem_node_index];
585 const auto & my_constraint_rows =
exio_helper->bex_cv_conn[elem_num];
587 for (
auto elem_node_index :
595 std::vector<std::pair<dof_id_type, Real>> key;
597 for (
auto spline_node_index :
601 const unsigned long elem_coef_vec_index =
602 my_constraint_rows[spline_node_index] - 1;
605 bex_constraint_vec(elem_coef_vec_index, *
exio_helper);
609 libmesh_vector_at(coef_vec, elem_node_index);
612 const int gi = (elem_num)*
exio_helper->bex_num_elem_cvs +
618 key.emplace_back(libmesh_node_id, coef);
622 if (
const auto local_node_it = local_nodes.find(key);
623 local_node_it != local_nodes.end())
624 elem->
set_node(dyna_elem_defn.
nodes[elem_node_index], local_node_it->second);
632 std::vector<std::pair<std::pair<const Elem *, unsigned int>,
Real>> constraint_row;
634 for (
auto [libmesh_spline_node_id, coef] : key)
639 const Real spline_w = weights_exist ?
641 w += coef * spline_w;
643 const Elem * nodeelem =
644 libmesh_map_find(spline_nodeelem_ptrs, &spline_node);
645 constraint_row.emplace_back(std::make_pair(nodeelem, 0), coef);
658 local_nodes[key] = n;
661 constraint_rows[n] = constraint_row;
669 nelem_last_block +=
exio_helper->num_elem_this_blk;
674 for (
auto p : spline_nodeelem_ptrs)
675 p.second->subdomain_id() = max_subdomain_id;
682 for (
unsigned char i=0; i!=4; ++i)
694 offset += (i > 0 ?
exio_helper->num_sides_per_set[i-1] : 0);
697 std::string sideset_name =
exio_helper->get_side_set_name(i);
698 if (!sideset_name.empty())
700 (cast_int<boundary_id_type>(
exio_helper->get_side_set_id(i)))
719 const auto & conv =
exio_helper->get_conversion(elem.type());
722 unsigned int raw_side_index =
exio_helper->side_list[e]-1;
723 std::size_t side_index_offset = conv.get_shellface_index_offset();
725 if (raw_side_index < side_index_offset)
728 int mapped_shellface = raw_side_index;
731 libmesh_error_msg_if(mapped_shellface < 0 || mapped_shellface >= 2,
732 "Bad 0-based shellface id: " 734 <<
" detected in Exodus file " 739 cast_int<unsigned short>(mapped_shellface),
740 cast_int<boundary_id_type>(
exio_helper->id_list[e]));
744 unsigned int side_index =
static_cast<unsigned int>(raw_side_index - side_index_offset);
745 int mapped_side = conv.get_side_map(side_index);
749 "Invalid 1-based side id: " 753 <<
" in Exodus file " 756 libmesh_error_msg_if(mapped_side < 0 ||
757 cast_int<unsigned int>(mapped_side) >= elem.n_sides(),
758 "Bad 0-based side id: " 762 <<
" in Exodus file " 767 cast_int<unsigned short>(mapped_side),
768 cast_int<boundary_id_type>(
exio_helper->id_list[e]));
783 offset += (i > 0 ?
exio_helper->num_elems_per_set[i-1] : 0);
804 std::map<Elem *, MeshBase::elemset_type> elem_to_elemsets;
823 elem_to_elemsets[elem].insert(
exio_helper->elemset_id_list[e]);
827 std::set<MeshBase::elemset_type> unique_elemsets;
828 for (
const auto & pr : elem_to_elemsets)
829 unique_elemsets.insert(pr.second);
842 for (
const auto & s : unique_elemsets)
850 <<
", but mesh should have " <<
exio_helper->num_elem_sets <<
" elemsets.");
854 unsigned int elemset_index =
859 for (
const auto & [elem, s] : elem_to_elemsets)
876 for (
int nodeset=0; nodeset<
exio_helper->num_node_sets; nodeset++)
879 cast_int<boundary_id_type>(
exio_helper->nodeset_ids[nodeset]);
881 std::string nodeset_name =
exio_helper->get_node_set_name(nodeset);
882 if (!nodeset_name.empty())
886 unsigned int offset =
exio_helper->node_sets_node_index[nodeset];
888 for (
int i=0; i<
exio_helper->num_nodes_per_set[nodeset]; ++i)
890 int exodus_id =
exio_helper->node_sets_node_list[i + offset];
896 libmesh_error_msg_if(static_cast<std::size_t>(exodus_id - 1) >=
exio_helper->node_num_map.size(),
897 "Invalid Exodus node id " << exodus_id
898 <<
" found in nodeset " << nodeset_id);
903 int libmesh_node_id =
exio_helper->node_num_map[exodus_id - 1] - 1;
912 "Cannot open dimension " 914 <<
" mesh file when configured without " 978 exio_helper->use_mesh_dimension_instead_of_spatial_dimension(val);
992 libmesh_warning(
"This method may be deprecated in the future");
1022 libmesh_error_msg_if
1024 "ERROR, ExodusII file must be opened for reading before calling ExodusII_IO::get_time_steps()!");
1035 "ERROR, ExodusII file must be opened for reading or writing before calling ExodusII_IO::get_num_time_steps()!");
1044 std::string system_var_name,
1045 std::string exodus_var_name,
1046 unsigned int timestep)
1048 LOG_SCOPE(
"copy_nodal_solution()",
"ExodusII_IO");
1058 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1059 "ERROR, ExodusII file must be opened for reading before copying a nodal solution!");
1061 exio_helper->read_nodal_var_values(exodus_var_name, timestep);
1064 auto & node_var_value_map =
exio_helper->nodal_var_values;
1071 if (!serial_on_zero)
1073 std::unordered_map<processor_id_type, std::vector<dof_id_type>> node_ids_to_request;
1076 std::vector<dof_id_type> node_ids;
1077 for (
auto & node :
mesh.local_node_ptr_range())
1078 node_ids.push_back(node->id());
1079 if (!node_ids.empty())
1080 node_ids_to_request[0] = std::move(node_ids);
1083 auto value_gather_functor =
1084 [& node_var_value_map]
1086 const std::vector<dof_id_type> & ids,
1087 std::vector<Real> & values)
1089 const std::size_t query_size = ids.size();
1090 values.resize(query_size);
1091 for (std::size_t i=0; i != query_size; ++i)
1093 if (
const auto it = node_var_value_map.find(ids[i]);
1094 it != node_var_value_map.end())
1096 values[i] = it->second;
1097 node_var_value_map.erase(it);
1100 values[i] = std::numeric_limits<Real>::quiet_NaN();
1104 auto value_action_functor =
1105 [& node_var_value_map]
1107 const std::vector<dof_id_type> & ids,
1108 const std::vector<Real> & values)
1110 const std::size_t query_size = ids.size();
1111 for (std::size_t i=0; i != query_size; ++i)
1113 node_var_value_map[ids[i]] = values[i];
1116 Real * value_ex =
nullptr;
1117 Parallel::pull_parallel_vector_data
1118 (system.
comm(), node_ids_to_request, value_gather_functor,
1119 value_action_functor, value_ex);
1137 system.
solution->set (dof_index, p.second);
1148 std::string system_var_name,
1149 std::string exodus_var_name,
1150 unsigned int timestep)
1152 LOG_SCOPE(
"copy_elemental_solution()",
"ExodusII_IO");
1161 "Error! Trying to copy elemental solution into a variable that is not of CONSTANT MONOMIAL nor CONSTANT MONOMIAL_VEC type.");
1171 std::map<dof_id_type, Real> elem_var_value_map;
1177 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1178 "ERROR, ExodusII file must be opened for reading before copying an elemental solution!");
1180 exio_helper->read_elemental_var_values(exodus_var_name, timestep, elem_var_value_map);
1188 if (!serial_on_zero)
1190 std::unordered_map<processor_id_type, std::vector<dof_id_type>> elem_ids_to_request;
1193 std::vector<dof_id_type> elem_ids;
1194 for (
auto & elem :
mesh.active_local_element_ptr_range())
1195 elem_ids.push_back(elem->id());
1197 if (!elem_ids.empty())
1198 elem_ids_to_request[0] = std::move(elem_ids);
1201 auto value_gather_functor =
1202 [& elem_var_value_map]
1204 const std::vector<dof_id_type> & ids,
1205 std::vector<Real> & values)
1207 const std::size_t query_size = ids.size();
1208 values.resize(query_size);
1209 for (std::size_t i=0; i != query_size; ++i)
1211 if (
const auto it = elem_var_value_map.find(ids[i]);
1212 it != elem_var_value_map.end())
1214 values[i] = it->second;
1215 elem_var_value_map.erase(it);
1218 values[i] = std::numeric_limits<Real>::quiet_NaN();
1222 auto value_action_functor =
1223 [& elem_var_value_map]
1225 const std::vector<dof_id_type> & ids,
1226 const std::vector<Real> & values)
1228 const std::size_t query_size = ids.size();
1229 for (std::size_t i=0; i != query_size; ++i)
1231 elem_var_value_map[ids[i]] = values[i];
1234 Real * value_ex =
nullptr;
1235 Parallel::pull_parallel_vector_data
1236 (system.
comm(), elem_ids_to_request, value_gather_functor,
1237 value_action_functor, value_ex);
1240 std::map<dof_id_type, Real>::iterator
1241 it = elem_var_value_map.begin(),
1242 end = elem_var_value_map.end();
1247 for (; it!=end; ++it)
1251 if (elem && elem->
n_comp(system.
number(), var_num) > 0)
1254 if (serial_on_zero || dof_map.
local_index(dof_index ))
1255 system.
solution->set (dof_index, it->second);
1264 std::vector<std::string> system_var_names,
1265 std::vector<std::string> exodus_var_names,
1266 unsigned int timestep)
1268 LOG_SCOPE(
"copy_scalar_solution()",
"ExodusII_IO");
1270 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
1271 "ERROR, ExodusII file must be opened for reading before copying a scalar solution!");
1273 libmesh_error_msg_if(system_var_names.size() != exodus_var_names.size(),
1274 "ERROR, the number of system_var_names must match exodus_var_names.");
1276 std::vector<Real> values_from_exodus;
1279 #ifdef LIBMESH_HAVE_MPI 1298 std::vector<dof_id_type> SCALAR_dofs;
1301 system.
solution->set (SCALAR_dofs[0], values_from_exodus[i]);
1310 unsigned int timestep,
1311 std::map<unsigned int, Real> & unique_id_to_value_map)
1313 LOG_SCOPE(
"read_elemental_variable()",
"ExodusII_IO");
1316 std::map<dof_id_type, Real> elem_var_value_map;
1318 exio_helper->read_elemental_var_values(elemental_var_name, timestep, elem_var_value_map);
1319 for (
auto & pr : elem_var_value_map)
1327 unsigned int timestep,
1328 std::vector<Real> & global_values)
1330 LOG_SCOPE(
"read_global_variable()",
"ExodusII_IO");
1332 std::size_t size = global_var_names.size();
1333 libmesh_error_msg_if(size == 0,
"ERROR, empty list of global variables to read from the Exodus file.");
1336 std::vector<Real> values_from_exodus;
1338 exio_helper->read_global_values(values_from_exodus, timestep);
1339 std::vector<std::string> global_var_names_exodus =
exio_helper->global_var_names;
1341 if (values_from_exodus.size() == 0)
1344 global_values.clear();
1345 for (std::size_t i = 0; i != size; ++i)
1349 auto it = find(global_var_names_exodus.begin(), global_var_names_exodus.end(), global_var_names[i]);
1350 if (it != global_var_names_exodus.end())
1351 global_values.push_back(values_from_exodus[it - global_var_names_exodus.begin()]);
1353 libmesh_error_msg(
"ERROR, Global variable " << global_var_names[i] << \
1354 " not found in Exodus file.");
1361 LOG_SCOPE(
"write_element_data()",
"ExodusII_IO");
1365 "ERROR, ExodusII file must be initialized before outputting element variables.");
1379 std::vector<std::string> names;
1386 std::vector<std::string> monomials;
1396 for (
const auto & var : monomials)
1398 names.push_back(var);
1403 std::vector<Number> soln;
1407 std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1420 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1422 std::vector<std::string> complex_names =
1425 std::vector<std::set<subdomain_id_type>>
1426 complex_vars_active_subdomains =
1427 exio_helper->get_complex_vars_active_subdomains(vars_active_subdomains,
1429 exio_helper->initialize_element_variables(complex_names, complex_vars_active_subdomains);
1431 const std::vector<Real> complex_soln =
1437 exio_helper->initialize_element_variables(names, vars_active_subdomains);
1447 const std::set<std::string> * system_names,
1448 const std::string & var_suffix)
1450 LOG_SCOPE(
"write_element_data_from_discontinuous_nodal_data()",
"ExodusII_IO");
1456 "ERROR, ExodusII file must be initialized before outputting element variables.");
1470 std::vector<std::string> var_names;
1486 std::vector<std::string> monomial_var_names;
1494 if (!_output_variables.empty())
1500 [
this](
const std::string &
name)
1501 {
return !std::count(_output_variables.begin(),
1502 _output_variables.end(),
1507 monomial_var_names.erase
1509 (monomial_var_names.begin(),
1510 monomial_var_names.end(),
1511 [
this](
const std::string &
name)
1512 {
return !std::count(_output_variables.begin(),
1513 _output_variables.end(),
1515 monomial_var_names.end());
1521 std::vector<Number> v;
1523 (v, system_names, &var_names,
true);
1526 std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
1532 std::map<subdomain_id_type, unsigned int> subdomain_id_to_vertices_per_elem;
1533 for (
const auto & elem :
mesh.active_element_ptr_range())
1540 auto pr2 = subdomain_id_to_vertices_per_elem.emplace
1541 (elem->subdomain_id(), elem->n_vertices());
1542 libmesh_error_msg_if(!pr2.second && pr2.first->second != elem->n_vertices(),
1543 "Elem with different number of vertices found.");
1566 std::vector<std::string> derived_var_names;
1571 std::map<std::string, std::pair<std::string, unsigned int>>
1572 derived_name_to_orig_name_and_node_id;
1574 for (
const auto & pr : subdomain_id_to_vertices_per_elem)
1577 const unsigned int vertices_per_elem =
1578 subdomain_id_to_vertices_per_elem[sbd_id];
1580 std::ostringstream oss;
1581 for (
unsigned int n=0; n<vertices_per_elem; ++n)
1582 for (
const auto & orig_var_name : var_names)
1586 oss << orig_var_name << var_suffix << n;
1587 std::string derived_name = oss.str();
1590 if (!std::count(derived_var_names.begin(), derived_var_names.end(), derived_name))
1592 derived_var_names.push_back(derived_name);
1594 derived_name_to_orig_name_and_node_id[derived_name] =
1595 std::make_pair(orig_var_name, n);
1603 std::vector<std::set<subdomain_id_type>>
1604 derived_vars_active_subdomains(derived_var_names.size());
1616 std::map<subdomain_id_type, std::vector<std::string>>
1617 subdomain_to_var_names;
1619 for (
auto derived_var_id :
index_range(derived_var_names))
1621 const auto & derived_name = derived_var_names[derived_var_id];
1622 const auto & [orig_name, node_id] =
1623 libmesh_map_find (derived_name_to_orig_name_and_node_id,
1628 for (
const auto & pr : subdomain_id_to_vertices_per_elem)
1633 unsigned int vertices_per_elem_this_sbd =
1634 subdomain_id_to_vertices_per_elem[sbd_id];
1641 auto var_loc = std::find(var_names.begin(), var_names.end(), orig_name);
1642 libmesh_error_msg_if(var_loc == var_names.end(),
1643 "Variable " << orig_name <<
" somehow not found in var_names array.");
1648 if (node_id < vertices_per_elem_this_sbd)
1654 subdomain_to_var_names[sbd_id].push_back(derived_name);
1663 bool orig_var_active =
1664 (vars_active_subdomains[var_id].empty() ||
1665 vars_active_subdomains[var_id].count(sbd_id));
1669 if (orig_var_active)
1670 derived_vars_active_subdomains[derived_var_id].insert(sbd_id);
1682 for (
auto & derived_var_name : derived_var_names)
1685 const auto & name_and_id =
1686 libmesh_map_find (derived_name_to_orig_name_and_node_id,
1690 const std::string & orig_name = name_and_id.first;
1693 if (std::count(monomial_var_names.begin(),
1694 monomial_var_names.end(),
1698 for (
auto & pr : subdomain_to_var_names)
1701 auto & name_vec = pr.second;
1704 std::find(name_vec.begin(),
1708 if (name_vec_it != name_vec.end())
1712 *name_vec_it = orig_name;
1717 derived_var_name = orig_name;
1724 std::vector<std::string> derived_var_names_edited;
1725 std::vector<std::set<subdomain_id_type>> derived_vars_active_subdomains_edited;
1726 std::vector<unsigned int> found_first(monomial_var_names.size());
1730 const auto & derived_var_name = derived_var_names[i];
1731 const auto & active_set = derived_vars_active_subdomains[i];
1737 if (derived_var_name == monomial_var_names[j])
1739 if (!found_first[j])
1749 if (active_set.empty())
1754 derived_var_names_edited.push_back(derived_var_name);
1755 derived_vars_active_subdomains_edited.push_back(active_set);
1760 derived_var_names.swap(derived_var_names_edited);
1761 derived_vars_active_subdomains.swap(derived_vars_active_subdomains_edited);
1764 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1767 auto complex_var_names =
1768 exio_helper->get_complex_names(derived_var_names,
1769 _write_complex_abs);
1770 auto complex_vars_active_subdomains =
1771 exio_helper->get_complex_vars_active_subdomains(derived_vars_active_subdomains,
1772 _write_complex_abs);
1773 auto complex_subdomain_to_var_names =
1774 exio_helper->get_complex_subdomain_to_var_names(subdomain_to_var_names,
1775 _write_complex_abs);
1781 std::vector<Real> complex_v;
1782 int nco = _write_complex_abs ? 3 : 2;
1783 complex_v.reserve(nco * v.size());
1784 for (
const auto & val : v)
1786 complex_v.push_back(val.real());
1787 complex_v.push_back(val.imag());
1788 if (_write_complex_abs)
1789 complex_v.push_back(std::abs(val));
1793 exio_helper->initialize_element_variables
1794 (complex_var_names, complex_vars_active_subdomains);
1795 exio_helper->write_element_values_element_major
1796 (
mesh, complex_v, _timestep,
1797 complex_vars_active_subdomains,
1799 complex_subdomain_to_var_names);
1804 exio_helper->initialize_element_variables(derived_var_names, derived_vars_active_subdomains);
1809 exio_helper->write_element_values_element_major
1810 (
mesh, v, _timestep,
1811 derived_vars_active_subdomains,
1813 subdomain_to_var_names);
1820 const std::vector<Number> & soln,
1821 const std::vector<std::string> & names)
1823 LOG_SCOPE(
"write_nodal_data()",
"ExodusII_IO");
1827 int num_vars = cast_int<int>(names.size());
1831 std::vector<std::string> output_names;
1836 output_names = names;
1838 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1839 std::vector<std::string> complex_names =
1855 for (
int c=0; c<num_vars; c++)
1857 std::stringstream name_to_find;
1859 std::vector<std::string>::iterator pos =
1860 std::find(output_names.begin(), output_names.end(), names[c]);
1861 if (pos == output_names.end())
1864 unsigned int variable_name_position =
1865 cast_int<unsigned int>(pos - output_names.begin());
1869 #ifdef LIBMESH_USE_REAL_NUMBERS 1870 std::vector<Number> cur_soln;
1875 cur_soln.reserve(num_nodes);
1877 std::vector<Real> real_parts;
1878 std::vector<Real> imag_parts;
1879 std::vector<Real> magnitudes;
1880 real_parts.reserve(num_nodes);
1881 imag_parts.reserve(num_nodes);
1883 magnitudes.reserve(num_nodes);
1893 for (
const auto & node :
mesh.node_ptr_range())
1898 #ifdef LIBMESH_USE_REAL_NUMBERS 1899 cur_soln.push_back(soln[
idx]);
1901 real_parts.push_back(soln[
idx].
real());
1902 imag_parts.push_back(soln[
idx].
imag());
1904 magnitudes.push_back(std::abs(soln[
idx]));
1916 std::vector<std::vector<const Elem *>>
1919 for (
const auto & elem :
mesh.active_element_ptr_range())
1920 elems_by_pid[elem->processor_id()].push_back(elem);
1925 exio_helper->added_node_offset_on(p) * num_vars + c;
1926 for (
const Elem * elem : elems_by_pid[p])
1928 for (
auto s : elem->side_index_range())
1933 const std::vector<unsigned int> side_nodes =
1934 elem->nodes_on_side(s);
1939 libmesh_assert_less(global_idx, soln.size());
1940 #ifdef LIBMESH_USE_REAL_NUMBERS 1941 cur_soln.push_back(soln[global_idx]);
1943 real_parts.push_back(soln[global_idx].
real());
1944 imag_parts.push_back(soln[global_idx].
imag());
1946 magnitudes.push_back(std::abs(soln[global_idx]));
1948 global_idx += num_vars;
1956 #ifdef LIBMESH_USE_REAL_NUMBERS 1977 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
1978 "ERROR, ExodusII file must be initialized before outputting information records.");
1986 const std::vector<std::string> & names)
1988 LOG_SCOPE(
"write_global_data()",
"ExodusII_IO");
1993 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
1994 "ERROR, ExodusII file must be initialized before outputting global variables.");
1996 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 1998 std::vector<std::string> complex_names =
2002 exio_helper->initialize_global_variables(complex_names);
2004 const std::vector<Real> complex_soln =
2021 const std::set<std::string> * system_names)
2035 const std::set<std::string> * system_names)
2043 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2044 "ERROR, ExodusII file must be opened for writing " 2045 "before calling ExodusII_IO::write_elemsets()!");
2054 const std::vector<std::string> & var_names,
2055 const std::vector<std::set<boundary_id_type>> & side_ids,
2056 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals)
2058 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2059 "ERROR, ExodusII file must be opened for writing " 2060 "before calling ExodusII_IO::write_sideset_data()!");
2063 exio_helper->write_sideset_data(
mesh, timestep, var_names, side_ids, bc_vals);
2071 std::vector<std::string> & var_names,
2072 std::vector<std::set<boundary_id_type>> & side_ids,
2073 std::vector<std::map<BoundaryInfo::BCTuple, Real>> & bc_vals)
2075 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2076 "ERROR, ExodusII file must be opened for reading " 2077 "before calling ExodusII_IO::read_sideset_data()!");
2080 exio_helper->read_sideset_data(
mesh, timestep, var_names, side_ids, bc_vals);
2090 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2091 "ERROR, ExodusII file must be opened for reading " 2092 "before calling ExodusII_IO::get_sideset_data_indices()!");
2102 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2103 "ERROR, ExodusII file must be opened for reading " 2104 "before calling ExodusII_IO::get_nodeset_data_indices()!");
2106 exio_helper->get_nodeset_data_indices(bc_array_indices);
2112 const std::vector<std::string> & var_names,
2113 const std::vector<std::set<boundary_id_type>> & node_boundary_ids,
2114 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals)
2116 libmesh_error_msg_if(!
exio_helper->opened_for_writing,
2117 "ERROR, ExodusII file must be opened for writing " 2118 "before calling ExodusII_IO::write_nodeset_data()!");
2120 exio_helper->write_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2128 std::vector<std::string> & var_names,
2129 std::vector<std::set<boundary_id_type>> & node_boundary_ids,
2130 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> & bc_vals)
2132 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2133 "ERROR, ExodusII file must be opened for reading " 2134 "before calling ExodusII_IO::read_nodeset_data()!");
2136 exio_helper->read_nodeset_data(timestep, var_names, node_boundary_ids, bc_vals);
2142 const std::vector<std::string> & var_names,
2143 const std::vector<std::set<elemset_id_type>> & elemset_ids_in,
2144 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals)
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_elemset_data()!");
2150 exio_helper->write_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2158 std::vector<std::string> & var_names,
2159 std::vector<std::set<elemset_id_type>> & elemset_ids_in,
2160 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> & elemset_vals)
2162 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2163 "ERROR, ExodusII file must be opened for reading " 2164 "before calling ExodusII_IO::read_elemset_data()!");
2166 exio_helper->read_elemset_data(timestep, var_names, elemset_ids_in, elemset_vals);
2172 libmesh_error_msg_if(!
exio_helper->opened_for_reading,
2173 "ERROR, ExodusII file must be opened for reading " 2174 "before calling ExodusII_IO::get_elemset_data_indices()!");
2176 exio_helper->get_elemset_data_indices(elemset_array_indices);
2182 LOG_SCOPE(
"write()",
"ExodusII_IO");
2190 (const_cast<MeshBase &>(
mesh),
2200 libmesh_warning(
"Warning: Appending in ExodusII_IO::write() does not make sense.\n" 2201 "Creating a new file instead!");
2212 libmesh_warning(
"Warning: Mesh contains edge boundary IDs, but these " 2213 "are not supported by the ExodusII format.");
2219 const std::vector<Number> & soln,
2220 const std::vector<std::string> & names)
2222 LOG_SCOPE(
"write_nodal_data_discontinuous()",
"ExodusII_IO");
2226 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 2228 std::vector<std::string> complex_names =
2243 int num_vars = cast_int<int>(names.size());
2244 libmesh_assert_equal_to(soln.size() % num_vars, 0);
2245 int num_nodes = soln.size() / num_vars;
2246 libmesh_assert_equal_to(
exio_helper->num_nodes, num_nodes);
2251 int num_real_nodes = 0;
2252 for (
const auto & elem :
mesh.active_element_ptr_range())
2253 num_real_nodes += elem->n_nodes();
2254 libmesh_assert_equal_to(num_real_nodes, num_nodes);
2258 for (
int c=0; c<num_vars; c++)
2260 #ifdef LIBMESH_USE_COMPLEX_NUMBERS 2261 std::vector<Real> real_parts(num_nodes);
2262 std::vector<Real> imag_parts(num_nodes);
2263 std::vector<Real> magnitudes;
2265 magnitudes.resize(num_nodes);
2271 for (
int i=0; i<num_nodes; ++i)
2273 real_parts[i] = soln[i*num_vars + c].real();
2274 imag_parts[i] = soln[i*num_vars + c].imag();
2276 magnitudes[i] = std::abs(soln[i*num_vars + c]);
2284 std::vector<Number> cur_soln(num_nodes);
2286 for (
int i=0; i<num_nodes; i++)
2287 cur_soln[i] = soln[i*num_vars + c];
2297 const std::vector<std::string> & names,
2355 libmesh_error_msg_if(fname !=
exio_helper->current_filename,
2356 "Error! This ExodusII_IO object is already associated with file: " 2358 <<
", cannot use it with requested file: " 2401 libmesh_experimental();
2431 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2438 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2445 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2452 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2459 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2466 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2473 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2480 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2487 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2495 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2502 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2511 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2521 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2527 std::vector<std::string>,
2528 std::vector<std::string>,
2531 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2538 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2546 const std::set<std::string> *,
2547 const std::string & )
2549 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2555 const std::vector<Number> &,
2556 const std::vector<std::string> &)
2558 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2565 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2571 const std::vector<std::string> &)
2573 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2582 const std::set<std::string> *)
2584 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2590 const std::set<std::string> *)
2592 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2598 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2604 const std::vector<std::string> &,
2605 const std::vector<std::set<boundary_id_type>> &,
2606 const std::vector<std::map<BoundaryInfo::BCTuple, Real>> &)
2608 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2616 std::vector<std::string> &,
2617 std::vector<std::set<boundary_id_type>> &,
2618 std::vector<std::map<BoundaryInfo::BCTuple, Real>> &)
2620 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2628 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2634 const std::vector<std::string> &,
2635 const std::vector<std::set<boundary_id_type>> &,
2636 const std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> &)
2638 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2644 std::vector<std::string> &,
2645 std::vector<std::set<boundary_id_type>> &,
2646 std::vector<std::map<BoundaryInfo::NodeBCTuple, Real>> &)
2648 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2655 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2661 const std::vector<std::string> &,
2662 const std::vector<std::set<elemset_id_type>> &,
2663 const std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> &)
2665 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2671 std::vector<std::string> &,
2672 std::vector<std::set<elemset_id_type>> &,
2673 std::vector<std::map<std::pair<dof_id_type, elemset_id_type>,
Real>> &)
2675 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2682 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2687 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2693 const std::vector<Number> &,
2694 const std::vector<std::string> &)
2696 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2702 const std::vector<std::string> &,
2705 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2711 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2716 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2721 libmesh_error_msg(
"ERROR, ExodusII API is not defined.");
2726 #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.
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
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...
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_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.
static const dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
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.
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.
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
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