13 #include "libmesh/dof_map.h" 14 #include "libmesh/explicit_system.h" 15 #include "libmesh/fe_compute_data.h" 16 #include "libmesh/libmesh_common.h" 17 #include "libmesh/numeric_vector.h" 23 const std::string & exodus_mesh,
24 const std::string var_name)
25 : _communicator(MPI_COMM_SELF), _mesh(_communicator), _var_name(var_name)
33 _eq = std::make_unique<EquationSystems>(
_mesh);
37 const std::vector<std::string> & all_nodal(
_exodusII_io->get_nodal_var_names());
38 const std::vector<std::string> & all_elemental(
_exodusII_io->get_elem_var_names());
40 std::string nodal_variable;
41 std::string elemental_variable;
43 if (std::find(all_nodal.begin(), all_nodal.end(),
_var_name) != all_nodal.end())
45 if (std::find(all_elemental.begin(), all_elemental.end(),
_var_name) != all_elemental.end())
51 if (!nodal_variable.empty())
53 if (!elemental_variable.empty())
58 if (nodal_variable.empty() && elemental_variable.empty())
60 std::string
out(
"\n Parameter Requested: " + var_name);
61 out +=
"\n Exodus Nodal Variables: ";
62 for (
const auto & var : all_nodal)
64 out +=
"\n Exodus Elemental Variables: ";
65 for (
const auto & var : all_elemental)
67 mooseError(
"Exodus file did not contain the parameter name being intitialized.",
out);
75 unsigned int step_to_read =
_exodusII_io->get_num_time_steps();
76 if (time_step <= step_to_read)
77 step_to_read = time_step;
78 else if (time_step != std::numeric_limits<unsigned int>::max())
79 mooseError(
"Invalid value passed as \"time_step\". Expected a valid integer " 87 const std::vector<std::string> & all_nodal(
_exodusII_io->get_nodal_var_names());
88 const std::vector<std::string> & all_elemental(
_exodusII_io->get_elem_var_names());
90 if (std::find(all_nodal.begin(), all_nodal.end(),
_var_name) != all_nodal.end())
92 else if (std::find(all_elemental.begin(), all_elemental.end(),
_var_name) != all_elemental.end())
100 std::set<dof_id_type> var_indices;
102 std::vector<dof_id_type> var_indices_vector(var_indices.begin(), var_indices.end());
104 std::vector<Real> parameter_values;
105 _sys->
solution->localize(parameter_values, var_indices_vector);
106 return parameter_values;
void local_dof_indices(const unsigned int var, std::set< dof_id_type > &var_indices) const
std::vector< Real > getParameterValues(const unsigned int timestep) const
Initializes parameter data and sets bounds in the main optmiization application getParameterValues is...
libMesh::ReplicatedMesh _mesh
void allow_renumbering(bool allow)
void mooseError(Args &&... args)
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
ReadExodusMeshVars(const libMesh::FEType ¶m_type, const std::string &exodus_mesh, const std::string var_name)
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
unsigned int variable_number(std::string_view var) const
const std::string _var_name
variable name read from Exodus mesh
std::unique_ptr< NumericVector< Number > > solution
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
std::unique_ptr< libMesh::EquationSystems > _eq
std::unique_ptr< libMesh::ExodusII_IO > _exodusII_io
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false) override