www.mooseframework.org
NodalNormalsEvaluator.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
10 #include "NodalNormalsEvaluator.h"
11 
12 // MOOSE includes
13 #include "AuxiliarySystem.h"
14 #include "MooseVariableFE.h"
16 
18 
21 {
23  params.addClassDescription(
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 
35 void
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 
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 
96 void
98 {
99  _aux.solution().close();
100 }
101 
102 void
104 {
105  _aux.solution().close();
106 }
static std::mutex _nodal_normals_mutex
NumericVector< Number > & solution()
Definition: SystemBase.h:176
unsigned int number() const
Get variable number coming from libMesh.
const Node *const & _current_node
Reference to current node pointer.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static InputParameters validParams()
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
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...
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
A user object that runs over all the nodes and does an aggregation step to compute a single value...
NodalNormalsEvaluator(const InputParameters &parameters)
virtual void finalize() override
Finalize.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
registerMooseObject("MooseApp", NodalNormalsEvaluator)
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1125
virtual void close()=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:210
Works on top of NodalNormalsPreprocessor.
const THREAD_ID _tid
Thread ID of this postprocessor.
Definition: UserObject.h:217
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...
virtual void set(const numeric_index_type i, const Number value)=0
processor_id_type processor_id() const
uint8_t dof_id_type
virtual void execute() override
Execute method.