16#include "libmesh/id_types.h"
17#include "libmesh/string_to_enum.h"
28 "The tag of the solution vector to be transferred (default to the solution)");
31 "The tag of the solution vector to be transferred to (default to the solution)");
34 params.
addParam<std::vector<SubdomainName>>(
37 "Subdomain restriction to transfer from (defaults to all the origin app domain)");
38 params.
addParam<std::vector<SubdomainName>>(
41 "Subdomain restriction to transfer to, (defaults to all the target app domain)");
44 "Base class for copying degrees-of-freedom values (nonlinear and auxiliary) between apps "
45 "that have identical meshes.");
51 _has_block_restrictions(!getParam<
std::vector<SubdomainName>>(
"from_blocks").empty() ||
52 !getParam<
std::vector<SubdomainName>>(
"to_blocks").empty())
82 mooseError(
"The parallel types (distributed or replicated) of the meshes are not the same.");
87 const auto & from_block_names = getParam<std::vector<SubdomainName>>(
"from_blocks");
88 for (
const auto & b : from_block_names)
91 paramError(
"from_blocks",
"The block '", b,
"' was not found in the mesh");
93 if (from_block_names.size())
98 _from_blocks = std::set<SubdomainID>(block_vec.begin(), block_vec.end());
107 const auto & to_block_names = getParam<std::vector<SubdomainName>>(
"to_blocks");
108 for (
const auto & b : to_block_names)
111 paramError(
"to_blocks",
"The block '", b,
"' was not found in the mesh");
113 if (to_block_names.size())
118 _to_blocks = std::set<SubdomainID>(block_vec.begin(), block_vec.end());
135 paramError(
"from_blocks",
"Block restriction is not implemented for nodal variables");
142 paramError(
"to_blocks",
"Block restriction is not implemented for nodal variables");
150 mooseError(
"No transferred variables were specified, neither programmatically or through the "
151 "'source_variable' parameter");
153 mooseError(
"Number of variables transferred must be same in both systems.");
174 auto & from_solution =
isParamValid(
"from_solution_tag")
176 getParam<TagName>(
"from_solution_tag")))
183 "'requires that the target variable '",
185 "' and the source variable'",
187 "' must be the same type "
188 "(order and family): ",
189 libMesh::Utility::enum_to_string<FEFamily>(to_var.
feType().
family),
193 "Corresponding transfer variables must be same field type (STANDARD | VECTOR | ARRAY).");
195 mooseError(
"Corresponding transfer variables must have same number of components.");
198 mooseError(
"The meshes must be identical to utilize MultiAppDofCopyTransfer::transfer.");
201 for (
const auto & node :
as_range(to_mesh.local_nodes_begin(), to_mesh.local_nodes_end()))
203 node, from_mesh.
node_ptr(node->id()), to_var, from_var, to_solution, from_solution);
206 for (
auto & to_elem :
as_range(to_mesh.local_elements_begin(), to_mesh.local_elements_end()))
209 mooseAssert(to_elem->type() == from_elem->
type(),
"The elements must be the same type.");
223 transferDofObject(to_elem, from_elem, to_var, from_var, to_solution, from_solution);
239 for (
unsigned int vc = 0; vc < to_var.
count(); ++vc)
243 for (
unsigned int comp = 0;
250 Real from_value = from_solution(from_dof);
251 to_solution.
set(dof, from_value);
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
virtual MooseMesh & mesh() override
const std::string & name() const
Get the name of the class.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
ParallelType getParallelType() const
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
const libMesh::FEType & feType() const
Get the type of finite element object.
SystemBase & sys()
Get the system this variable is part of.
unsigned int number() const
Get variable number coming from libMesh.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
This class provides an interface for common operations on field variables of both FE and FV types wit...
virtual Moose::VarFieldType fieldType() const =0
Field type of this variable.
void transfer(FEProblemBase &to_problem, FEProblemBase &from_problem)
Performs the transfer of a variable between two problems if they have the same mesh.
const bool _has_block_restrictions
Whether block restriction is active.
static InputParameters validParams()
void transferDofObject(libMesh::DofObject *to_object, libMesh::DofObject *from_object, MooseVariableFieldBase &to_var, MooseVariableFieldBase &from_var, NumericVector< Number > &to_solution, NumericVector< Number > &from_solution)
Performs the transfer of values between a node or element.
MultiAppDofCopyTransfer(const InputParameters ¶meters)
std::set< SubdomainID > _to_blocks
Subdomain IDs of the blocks to transfer to.
std::set< SubdomainID > _from_blocks
Subdomain IDs of the blocks to transfer from.
void initialSetup() override
Method called at the beginning of the simulation for checking integrity or doing one-time setup.
Intermediary class that allows variable names as inputs.
virtual std::vector< VariableName > getFromVarNames() const =0
Virtual function defining variables to be transferred.
virtual std::vector< AuxVariableName > getToVarNames() const =0
Virtual function defining variables to transfer to.
virtual void initialSetup()
Method called at the beginning of the simulation for checking integrity or doing one-time setup.
static InputParameters validParams()
void checkVariable(const FEProblemBase &fe_problem, const VariableName &var_name, const std::string ¶m_name="") const
Helper for checking a problem for a variable.
const std::shared_ptr< MultiApp > getToMultiApp() const
Get the MultiApp to transfer data to.
const std::shared_ptr< MultiApp > getFromMultiApp() const
Get the MultiApp to transfer data from.
virtual TagID getVectorTagID(const TagName &tag_name) const
Get a TagID from a TagName.
unsigned int number() const
Gets the number of this system.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
NumericVector< Number > & solution()
void update()
Update the system (doing libMesh magic)
MooseEnum _current_direction
unsigned int n_comp(const unsigned int s, const unsigned int var) const
dof_id_type dof_number(const unsigned int s, const unsigned int var, const unsigned int comp) const
unsigned int n_dofs(const unsigned int s, const unsigned int var=libMesh::invalid_uint) const
subdomain_id_type subdomain_id() const
virtual ElemType type() const=0
virtual const Node * node_ptr(const dof_id_type i) const=0
virtual dof_id_type n_elem() const=0
virtual dof_id_type n_nodes() const=0
virtual const Elem * elem_ptr(const dof_id_type i) const=0
virtual void set(const numeric_index_type i, const T value)=0
bool hasSubdomainName(const MeshBase &input_mesh, const SubdomainName &name)
Whether a particular subdomain name exists in the mesh.
const SubdomainID INVALID_BLOCK_ID
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::string incompatVarMsg(MooseVariableFieldBase &var1, MooseVariableFieldBase &var2)
Builds and returns a string of the form: