14 #include "libmesh/numeric_vector.h" 15 #include "libmesh/int_range.h" 24 "Pointwise renormalize the solution of a set of variables comprising a vector");
26 params.
addParam<
Real>(
"norm", 1.0,
"Desired norm for the coupled variable vector");
34 _mesh(_fe_problem.
mesh()),
35 _var_names(getParam<
std::vector<VariableName>>(
"v")),
36 _target_norm(getParam<
Real>(
"norm"))
47 if (first_var->
feType() != var.feType())
48 paramError(
"v",
"All supplied variables must be of the same order and family.");
50 if (!first_var->
hasBlocks(var.blockIDs()) || !var.hasBlocks(first_var->
blockIDs()))
51 paramError(
"v",
"All supplied variables must have the same block restriction.");
54 if (
_sys.
number() != var.sys().system().number())
55 paramError(
"v",
"Variables must be all in the non-linear system.");
60 for (
unsigned int p = 0; p < var.count(); ++p)
79 const auto local_dof_begin = dof_map.
first_dof();
80 const auto local_dof_end = dof_map.end_dof();
82 std::vector<std::vector<dof_id_type>> dof_indices(
_var_numbers.size());
90 dof_map.dof_indices(elem, dof_indices[i],
_var_numbers[i]);
93 mooseAssert(dof_indices[i].size() == dof_indices[0].size(),
94 "All specified variables should have the same number of DOFs");
108 if (dof_indices[0][j] > local_dof_end || dof_indices[0][j] < local_dof_begin)
122 solution.set(dof_indices[i][j], solution(dof_indices[i][j]) /
norm *
_target_norm);
libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems...
const libMesh::FEType & feType() const
Get the type of finite element object.
void execute() override
Execute method.
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 ...
static InputParameters validParams()
static InputParameters validParams()
const std::vector< VariableName > & _var_names
names of the variables to renormalize
virtual libMesh::System & system()=0
Get the reference to the libMesh 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).
This class provides an interface for common operations on field variables of both FE and FV types wit...
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.
void initialize() override
Called before execute() is ever called so that data can be cleared.
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...
unsigned int variable_number(std::string_view var) const
void update()
Update the system (doing libMesh magic)
std::unique_ptr< NumericVector< Number > > solution
std::vector< unsigned int > _var_numbers
MooseMesh & _mesh
reference to the mesh
registerMooseObject("MooseApp", PointwiseRenormalizeVector)
SystemBase & _sys
Reference to the system object for this user object.
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
Whether or not the system has the solution state (0 = current, 1 = old, 2 = older, etc).
unsigned int number() const
Gets the number of this system.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Renormalization of a vector variable (i.e.
IntRange< T > make_range(T beg, T end)
const Real _target_norm
desired norm
PointwiseRenormalizeVector(const InputParameters ¶meters)
void finalize() override
Finalize.
virtual ArrayMooseVariable & getArrayVariable(const THREAD_ID tid, const std::string &var_name) override
Returns the variable reference for requested ArrayMooseVariable which may be in any system...
dof_id_type first_dof(const processor_id_type proc) const
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
const DofMap & get_dof_map() const
auto index_range(const T &sizable)
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template pow< 2 >(tan(_arg))+1.0) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(sqrt