20#ifndef LIBMESH_EQUATION_SYSTEMS_H
21#define LIBMESH_EQUATION_SYSTEMS_H
24#include "libmesh/libmesh_common.h"
25#include "libmesh/parameters.h"
26#include "libmesh/system.h"
27#include "libmesh/parallel_object.h"
31# include "libmesh/frequency_system.h"
32# include "libmesh/transient_system.h"
33# include "libmesh/newmark_system.h"
34# include "libmesh/steady_system.h"
107 virtual void clear ();
112 virtual void init ();
154 bool has_system (std::string_view name)
const;
162 template <
typename T_sys>
163 const T_sys &
get_system (std::string_view name)
const;
171 template <
typename T_sys>
180 template <
typename T_sys>
181 const T_sys &
get_system (
const unsigned int num)
const;
189 template <
typename T_sys>
217 std::string_view name);
222 template <
typename T_sys>
229 unsigned int n_vars ()
const;
235 std::size_t
n_dofs ()
const;
251 virtual void solve ();
281 const FEType * type=
nullptr,
282 const std::set<std::string> * system_names=
nullptr)
const;
299 (std::vector<std::string> & var_names,
300 const std::set<std::string> * system_names=
nullptr)
const;
311 std::string_view system_name,
312 std::string_view variable_name =
"all_vars")
const;
326 const std::set<std::string> * system_names=
nullptr,
327 bool add_sides=
false)
const;
337 std::unique_ptr<NumericVector<Number>>
339 bool add_sides=
false)
const;
346 std::vector<std::set<subdomain_id_type>> & vars_active_subdomains)
const;
357 std::vector<std::string> & names)
const;
381 std::vector<std::pair<unsigned int, unsigned int>>
383 const FEType * type=
nullptr,
384 const std::vector<FEType> * types=
nullptr)
const;
391 std::vector<std::pair<unsigned int, unsigned int>>
411 std::unique_ptr<NumericVector<Number>>
431 (std::vector<Number> & soln,
432 const std::set<std::string> * system_names =
nullptr,
433 const std::vector<std::string> * var_names =
nullptr,
434 bool vertices_only =
false,
435 bool add_sides =
false)
const;
474 template <
typename InValType = Number>
475 void read (std::string_view name,
478 bool partition_agnostic =
true);
480 template <
typename InValType = Number>
481 void read (std::string_view name,
483 bool partition_agnostic =
true);
485 template <
typename InValType = Number>
487 std::function<std::unique_ptr<Xdr>()> & local_io_functor,
489 bool partition_agnostic =
true);
515 void write (std::string_view name,
518 bool partition_agnostic =
true)
const;
520 void write (std::string_view name,
522 bool partition_agnostic =
true)
const;
526 bool partition_agnostic =
true)
const;
530 bool partition_agnostic =
true,
531 Xdr *
const local_io =
nullptr)
const;
540 const Real threshold,
541 const bool verbose)
const;
547 virtual std::string
get_info()
const;
558 friend std::ostream &
operator << (std::ostream & os,
622 std::map<std::string, std::unique_ptr<System>, std::less<>>
_systems;
640 std::vector<std::pair<unsigned int, unsigned int>>
642 (std::vector<std::string> & names,
643 const std::function<
bool(
const FEType &)> & type_filter)
const;
682 return cast_int<unsigned int>(
_systems.size());
688template <
typename T_sys>
694 const unsigned int sys_num = this->
n_systems();
697 (name, std::make_unique<T_sys>(*
this, std::string(name),
707 auto it = result.first;
708 auto & sys_ptr = it->second;
709 return cast_ref<T_sys &>(*sys_ptr);
716 return this->get_system<T_sys>(name);
733template <
typename T_sys>
737 libmesh_assert_less (num, this->
n_systems());
741 const auto & sys_ptr = pr.second;
742 if (sys_ptr->number() == num)
743 return cast_ref<const T_sys &>(*sys_ptr);
746 libmesh_error_msg(
"ERROR: no system number " << num <<
" found!");
752template <
typename T_sys>
756 libmesh_assert_less (num, this->
n_systems());
760 auto & sys_ptr = pr.second;
761 if (sys_ptr->number() == num)
762 return cast_ref<T_sys &>(*sys_ptr);
766 libmesh_error_msg(
"ERROR: no system number " << num <<
" found!");
774template <
typename T_sys>
781 libmesh_error_msg_if(pos ==
_systems.end(),
"ERROR: no system named \"" << name <<
"\" found!");
784 const auto & sys_ptr = pos->second;
785 return cast_ref<const T_sys &>(*sys_ptr);
793template <
typename T_sys>
800 libmesh_error_msg_if(pos ==
_systems.end(),
"ERROR: no system named " << name <<
" found!");
803 auto & sys_ptr = pos->second;
804 return cast_ref<T_sys &>(*sys_ptr);
816 return this->get_system<System>(name);
824 return this->get_system<System>(name);
832 return this->get_system<System>(num);
840 return this->get_system<System>(num);
void ErrorVector unsigned int
This is the base class from which all geometric element types are derived.
This is the EquationSystems class.
std::vector< std::pair< unsigned int, unsigned int > > find_elemental_data_variable_numbers(std::vector< std::string > &names) const
Finds system and variable numbers for variables that can be represented as elemental data.
virtual bool compare(const EquationSystems &other_es, const Real threshold, const bool verbose) const
virtual void reinit()
Handle any mesh changes and reinitialize all the systems on the updated mesh.
static bool is_elemental_data_fe_type(const FEType &type)
std::vector< std::pair< unsigned int, unsigned int > > find_variable_numbers_by_predicate(std::vector< std::string > &names, const std::function< bool(const FEType &)> &type_filter) const
Implementation detail for find_variable_numbers() variants.
virtual std::string get_info() const
void enable_refine_in_reinit()
Calls to reinit() will also do two-step coarsen-then-refine.
std::unique_ptr< NumericVector< Number > > build_parallel_elemental_solution_vector(std::vector< std::string > &names) const
Builds a parallel vector of elemental data solution values corresponding to the entries in the input ...
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
std::unique_ptr< NumericVector< Number > > build_parallel_solution_vector(const std::set< std::string > *system_names=nullptr, bool add_sides=false) const
A version of build_solution_vector which is appropriate for "parallel" output formats like Nemesis.
friend std::ostream & operator<<(std::ostream &os, const EquationSystems &es)
Same as above, but allows you to also use stream syntax.
virtual ~EquationSystems()
Destructor.
virtual void sensitivity_solve(const ParameterVector ¶meters)
Call sensitivity_solve on all the individual equation systems.
void _remove_default_ghosting(unsigned int sys_num)
This just calls DofMap::remove_default_ghosting() but using a shim lets us forward-declare DofMap.
std::size_t n_active_dofs() const
void update()
Updates local values for all the systems.
bool refine_in_reinit_flag()
std::vector< std::pair< unsigned int, unsigned int > > find_variable_numbers(std::vector< std::string > &names, const FEType *type=nullptr, const std::vector< FEType > *types=nullptr) const
Finds system and variable numbers for any variables of 'type' or of 'types' corresponding to the entr...
void write(std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
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.
void build_elemental_solution_vector(std::vector< Number > &soln, std::vector< std::string > &names) const
Retrieve the solution data for elemental data variables.
unsigned int n_systems() const
static bool redundant_added_side(const Elem &elem, unsigned int side)
unsigned int n_vars() const
WriteFlags
Define enumeration to set properties in EquationSystems::write()
void get_vars_active_subdomains(const std::vector< std::string > &names, std::vector< std::set< subdomain_id_type > > &vars_active_subdomains) const
Retrieve vars_active_subdomains, which indicates the active subdomains for each variable in names.
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
const MeshBase & get_mesh() const
Parameters parameters
Data structure holding arbitrary parameters.
void build_elemental_data_variable_names(std::vector< std::string > &var_names, const std::set< std::string > *system_names=nullptr) const
Filter var_names to names of variables that can be represented as elemental data.
void build_solution_vector(std::vector< Number > &soln, std::string_view system_name, std::string_view variable_name="all_vars") const
Fill the input vector soln with the solution values for the system named name.
bool has_system(std::string_view name) const
bool _refine_in_reinit
Flag for whether to call coarsen/refine in reinit().
void write(std::ostream name, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
ReadFlags
Define enumeration to set properties in EquationSystems::read()
MeshBase & _mesh
The mesh data structure.
bool reinit_solutions()
Handle any mesh changes and project any solutions onto the updated mesh.
virtual void init()
Initialize all the systems.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
virtual void reinit_mesh()
Handle the association of a completely new mesh with the EquationSystem and all the Systems assigned ...
virtual void adjoint_solve(const QoISet &qoi_indices=QoISet())
Call adjoint_solve on all the individual equation systems.
virtual void reinit_systems()
Reinitialize all systems on the current mesh.
virtual void clear()
Restores the data structure to a pristine state.
void _add_system_to_nodes_and_elems()
This function is used in the implementation of add_system, it loops over the nodes and elements of th...
const T_sys & get_system(std::string_view name) const
virtual void enable_default_ghosting(bool enable)
Enable or disable default ghosting functors on the Mesh and on all Systems.
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.
void disable_refine_in_reinit()
Calls to reinit() will not try to coarsen or refine the mesh.
std::size_t n_dofs() const
virtual void solve()
Call solve on all the individual equation systems.
bool _enable_default_ghosting
Flag for whether to enable default ghosting on newly added Systems.
std::map< std::string, std::unique_ptr< System >, std::less<> > _systems
Data structure holding the systems.
void allgather()
Serializes a distributed mesh and its associated degree of freedom numbering for all systems.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
This is the MeshBase class.
An object whose state is distributed along a set of processors.
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
This class implements reference counting.
Manages consistently variables, degrees of freedom, and coefficient vectors.
This class implements a C++ interface to the XDR (eXternal Data Representation) format.
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
XdrMODE
Defines an enum for read/write mode in Xdr format.