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");
void mooseInfo(Args &&... args)
Emit an informational message with the given stringified, concatenated args.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
registerMooseObjectRenamed("MooseApp", SelfAux, "01/30/2024 24:00", ProjectionAux)
registerMooseObject("MooseApp", ProjectionAux)
MooseMesh & _mesh
Mesh this kernel is active on.
bool isNodal() const
Nodal or elemental kernel?
const Node *const & _current_node
Current node (valid only for nodal kernels)
unsigned int _qp
Quadrature point index.
MooseVariableField< Real > & _var
This is a regular kernel so we cast to a regular MooseVariable, hides base _var.
static InputParameters validParams()
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
virtual Elem * elemPtr(const dof_id_type i)
const std::unordered_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.
virtual bool isNodal() const
Is this variable nodal.
virtual libMesh::FEContinuity getContinuity() const
Return the continuity of this variable.
libMesh::Order order() const
Get the order of this variable Note: Order enum can be implicitly converted to unsigned int.
unsigned int number() const
Get variable number coming from libMesh.
Projects from one variable to another.
const VariableValue & _v
The variable to project from.
ElemToNodeProjectionWeighting
bool _use_block_restriction_for_source
Whether to use the auxkernel block restriction to limit the values for the source variables.
static InputParameters validParams()
virtual Real computeValue() override
Compute and return the value of the aux variable.
ProjectionAux(const InputParameters ¶meters)
const MooseVariableFieldBase & _source_variable
A reference to the variable to project from We must use a field variable to support finite volume var...
std::unordered_set< unsigned short > _elem_dims
Set for holding element dimensions when mapping from multiple element values to a node.
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.
const ElemToNodeProjectionWeighting _elem_to_node_projection_weighting
How to weight element to node projections.
Number point_value(unsigned int var, const Point &p, const bool insist_on_success=true, const NumericVector< Number > *sol=nullptr) const