12 #include "libmesh/system.h" 22 "Returns the specified variable as an auxiliary variable with a projection of the source " 23 "variable. If they are the same type, this amounts to a simple copy.");
26 params.
addParam<
bool>(
"use_block_restriction_for_source",
28 "Whether to use the auxkernel block restriction to also restrict the " 29 "locations selected for source variable values");
32 params.
set<
bool>(
"_allow_nodal_to_elemental_coupling") =
true;
35 params.
addParam<
unsigned short>(
"ghost_layers", 1,
"The number of layers of elements to ghost.");
40 rm_params.
set<
unsigned short>(
"layers") =
41 obj_params.
get<
unsigned short>(
"ghost_layers");
42 rm_params.
set<
bool>(
"use_displaced_mesh") =
43 obj_params.
get<
bool>(
"use_displaced_mesh");
50 _v(coupledValue(
"v")),
51 _source_variable(*getFieldVar(
"v", 0)),
52 _source_sys(_c_fe_problem.getSystem(coupledName(
"v"))),
53 _use_block_restriction_for_source(getParam<bool>(
"use_block_restriction_for_source"))
57 mooseInfo(
"Projection lowers order, please expect a loss of accuracy");
59 for (
const auto & sub_id :
blockIDs())
62 "ProjectionAux's block restriction must not include lower dimensional blocks");
86 "Should have found an element around node " + std::to_string(
_current_node->id()));
89 Real sum_weighted_values = 0;
91 for (
auto &
id : elem_ids->second)
94 const auto block_id = elem->subdomain_id();
100 const auto elem_volume = elem->volume();
101 sum_weighted_values +=
103 sum_volumes += elem_volume;
106 if (sum_volumes == 0)
108 return sum_weighted_values / sum_volumes;
118 const auto block_id = elem->subdomain_id();
124 mooseError(
"Source variable is not defined everywhere the target variable is");
Projects from one variable to another.
void mooseInfo(Args &&... args) const
virtual bool isNodal() const
Is this variable nodal.
registerMooseObject("MooseApp", ProjectionAux)
virtual Real computeValue() override
Compute and return the value of the aux variable.
const VariableValue & _v
The variable to project from.
bool _use_block_restriction_for_source
Whether to use the auxkernel block restriction to limit the values for the source variables...
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 ...
virtual Elem * elemPtr(const dof_id_type i)
MooseMesh & _mesh
Mesh this kernel is active on.
unsigned int number() const
Get variable number coming from libMesh.
virtual libMesh::FEContinuity getContinuity() const
Return the continuity of this variable.
const Node *const & _current_node
Current node (valid only for nodal kernels)
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
bool isLowerD(const SubdomainID subdomain_id) const
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
ProjectionAux(const InputParameters ¶meters)
const libMesh::System & _source_sys
The system owning the source variable.
const Elem * elemOnNodeVariableIsDefinedOn() const
For a node, finds an element we can use to evaluate the (continuous) source variable.
static InputParameters validParams()
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int...
registerMooseObjectRenamed("MooseApp", SelfAux, "01/30/2024 24:00", ProjectionAux)
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const MooseVariableFieldBase & _source_variable
A reference to the variable to project from We must use a field variable to support finite volume var...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
unsigned int _qp
Quadrature point index.
static InputParameters validParams()
virtual const OutputTools< Real >::VariableSecond & second()
The second derivative of the variable this object is operating on.
Base class for creating new auxiliary kernels and auxiliary boundary conditions.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
bool isNodal() const
Nodal or elemental kernel?
const std::map< dof_id_type, std::vector< dof_id_type > > & nodeToElemMap()
If not already created, creates a map from every node to all elements to which they are connected...