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;
34 MooseEnum elem_to_node_projection_weighting(
"volume identity",
"volume");
36 elem_to_node_projection_weighting,
37 "How to weight individual element contributions when projecting to a " 38 "nodal degree of freedom");
42 "GhostAllPointNeighbors",
45 { rm_params.
set<
bool>(
"use_displaced_mesh") = obj_params.
get<
bool>(
"use_displaced_mesh"); });
51 _v(coupledValue(
"v")),
52 _source_variable(*getFieldVar(
"v", 0)),
53 _source_sys(_c_fe_problem.getSystem(coupledName(
"v"))),
54 _use_block_restriction_for_source(getParam<bool>(
"use_block_restriction_for_source")),
55 _elem_to_node_projection_weighting(getParam<
MooseEnum>(
"elem_to_node_projection_weighting")
60 mooseInfo(
"Projection lowers order, please expect a loss of accuracy");
83 Real sum_weighted_values = 0;
86 for (
const auto id : elem_ids)
89 const auto block_id = elem->subdomain_id();
95 const auto elem_weight =
97 sum_weighted_values +=
99 sum_weights += elem_weight;
102 if (sum_weights == 0)
105 mooseError(
"We should not use multiple element dimensions when computing the volume weighted " 106 "projection as the units do not make sense");
107 return sum_weighted_values / sum_weights;
117 const auto block_id = elem->subdomain_id();
122 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...
virtual Elem * elemPtr(const dof_id_type i)
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
MooseMesh & _mesh
Mesh this kernel is active on.
const ElemToNodeProjectionWeighting _elem_to_node_projection_weighting
How to weight element to node projections.
ProjectionAux(const InputParameters ¶meters)
ElemToNodeProjectionWeighting
const libMesh::System & _source_sys
The system owning the source variable.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
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, hides base _var.
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.
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...
std::unordered_set< unsigned short > _elem_dims
Set for holding element dimensions when mapping from multiple element values to a node...