14#include "libmesh/numeric_vector.h"
15#include "libmesh/int_range.h"
25 "Set (all or some) values of (one or more) nonlinear variable(s) using functor evaluations");
28 "functors",
"Functors to compute the new variable values with");
31 params.
addParam<std::vector<BoundaryName>>(
32 "excluded_nodesets", {},
"Vector of nodesets to skip execution on");
35 MooseEnum techniques(
"node_arg",
"node_arg");
37 "functor_evaluation_technique", techniques,
"How to evaluate the functor");
40 params.
set<
bool>(
"unique_node_execute") =
true;
50 _mesh(_fe_problem.
mesh()),
51 _var_names(getParam<
std::vector<VariableName>>(
"variables_to_correct")),
52 _functor_names(getParam<
std::vector<MooseFunctorName>>(
"functors")),
53 _functor_evaluation_technique(getParam<
MooseEnum>(
"functor_evaluation_technique"))
59 if (
_sys.
number() != var.sys().system().number())
60 paramError(
"variables_to_correct",
"Variables must be all in the non-linear system.");
68 ") should be the same as variable list size (" +
76 const auto & excluded_nodesets = getParam<std::vector<BoundaryName>>(
"excluded_nodesets");
84 const auto local_dof_begin = dof_map.
first_dof();
85 const auto local_dof_end = dof_map.end_dof();
88 const auto & binfo =
_mesh.
getMesh().get_boundary_info();
93 std::vector<std::vector<dof_id_type>> dof_indices(
_var_numbers.size());
101 paramError(
"Only nodal evaluation of functors has been implemented at this time");
107 mooseAssert(dof_indices[i].size() <= 1,
108 "Corrector has not been implemented for this variable type");
115 for (
const auto j : index_range(dof_indices[0]))
119 if (dof_indices[0][j] > local_dof_end || dof_indices[0][j] < local_dof_begin)
125 functor_values[i] = (*
_functors[i])(node_arg, state_arg);
129 solution.
set(dof_indices[i][j], functor_values[i]);
registerMooseObject("MooseApp", FunctorNodalCorrector)
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...
Set (all or some) values of (one or more) nonlinear variable(s) using functor evaluations.
std::vector< const Moose::Functor< Real > * > _functors
Pointers to the functors.
FunctorNodalCorrector(const InputParameters ¶meters)
const MooseEnum _functor_evaluation_technique
Evaluation method (argument)
const std::vector< VariableName > & _var_names
names of the variables to set using functors
MooseMesh & _mesh
reference to the mesh
void finalize() override
Finalize.
std::vector< unsigned int > _var_numbers
internal ID numbers of the variables to smooth
const std::vector< MooseFunctorName > & _functor_names
Name of the functors.
void execute() override
Execute method.
std::vector< BoundaryID > _excluded_nodeset_ids
Vector of boundaries to not execute on.
static InputParameters validParams()
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 ...
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
A user object that runs over all the nodes and does an aggregation step to compute a single value.
const Node *const & _current_node
Reference to current node pointer.
static InputParameters validParams()
An interface for accessing Moose::Functors for systems that do not care about automatic differentiati...
static InputParameters validParams()
unsigned int number() const
Gets the number of this system.
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
Get a state of the solution (0 = current, 1 = old, 2 = older, etc).
void update()
Update the system (doing libMesh magic)
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
SystemBase & _sys
Reference to the system object for this user object.
dof_id_type first_dof(const processor_id_type proc) const
virtual void set(const numeric_index_type i, const T value)=0
std::unique_ptr< NumericVector< Number > > solution
const DofMap & get_dof_map() const
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.
static const std::set< SubdomainID > undefined_subdomain_connection
A static member that can be used when the connection of a node to subdomains is unknown.