https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalNormalsEvaluator.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
12// MOOSE includes
13#include "AuxiliarySystem.h"
14#include "MooseVariableFE.h"
16
18
21{
24 "Helper object to compute nodal normal values via the NodalNormals input block.");
25 params.set<bool>("_dual_restrictable") = true;
26 params.set<std::vector<SubdomainName>>("block") = {"ANY_BLOCK_ID"};
27 return params;
28}
29
31 : NodalUserObject(parameters), _aux(_fe_problem.getAuxiliarySystem())
32{
33}
34
35void
37{
38
39 if (_current_node->processor_id() == processor_id())
40 {
41 if (_current_node->n_dofs(_aux.number(),
44 "nodal_normal_x",
47 .number()) > 0)
48 {
50
51 dof_id_type dof_x =
52 _current_node->dof_number(_aux.number(),
55 "nodal_normal_x",
58 .number(),
59 0);
60 dof_id_type dof_y =
61 _current_node->dof_number(_aux.number(),
64 "nodal_normal_y",
67 .number(),
68 0);
69 dof_id_type dof_z =
70 _current_node->dof_number(_aux.number(),
73 "nodal_normal_z",
76 .number(),
77 0);
78
79 NumericVector<Number> & sln = _aux.solution();
80 Real nx = sln(dof_x);
81 Real ny = sln(dof_y);
82 Real nz = sln(dof_z);
83
84 Real n = std::sqrt((nx * nx) + (ny * ny) + (nz * nz));
85 if (std::abs(n) >= 1e-13)
86 {
87 // divide by n only if it is not close to zero to avoid NaNs
88 sln.set(dof_x, nx / n);
89 sln.set(dof_y, ny / n);
90 sln.set(dof_z, nz / n);
91 }
92 }
93 }
94}
95
96void
101
102void
registerMooseObject("MooseApp", NodalNormalsEvaluator)
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...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
unsigned int number() const
Get variable number coming from libMesh.
Works on top of NodalNormalsPreprocessor.
NodalNormalsEvaluator(const InputParameters &parameters)
virtual void finalize() override
Finalize.
static InputParameters validParams()
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual void execute() override
Execute method.
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()
unsigned int number() const
Gets the number of this system.
NumericVector< Number > & solution()
Definition SystemBase.h:203
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
const THREAD_ID _tid
Thread ID of this postprocessor.
virtual void close()=0
processor_id_type processor_id() const
@ VAR_FIELD_STANDARD
Definition MooseTypes.h:777
@ VAR_AUXILIARY
Definition MooseTypes.h:771