www.mooseframework.org
NodalArea.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 "NodalArea.h"
11 
12 // MOOSE includes
13 #include "MooseVariable.h"
14 #include "SystemBase.h"
15 
16 #include "libmesh/numeric_vector.h"
17 #include "libmesh/quadrature.h"
18 
19 registerMooseObject("ContactApp", NodalArea);
20 
23 {
25  params.set<ExecFlagEnum>("execute_on") = EXEC_LINEAR;
26  params.addClassDescription("Compute the tributary area for nodes on a surface");
27  return params;
28 }
29 
31  : SideIntegralVariableUserObject(parameters),
32  _phi(_variable->phiFace()),
33  _system(_variable->sys()),
34  _aux_solution(_system.solution())
35 {
36 }
37 
39 
40 void
42 {
43  const auto & na = static_cast<const NodalArea &>(fred);
44 
45  std::map<const Node *, Real>::const_iterator it = na._node_areas.begin();
46  const std::map<const Node *, Real>::const_iterator it_end = na._node_areas.end();
47  for (; it != it_end; ++it)
48  {
49  _node_areas[it->first] += it->second;
50  }
51 }
52 
53 Real
55 {
56  return 1;
57 }
58 
59 void
61 {
62  _node_areas.clear();
63 }
64 
65 void
67 {
68  std::vector<Real> nodeAreas(_phi.size());
69  for (unsigned qp(0); qp < _qrule->n_points(); ++qp)
70  {
71  for (unsigned j(0); j < _phi.size(); ++j)
72  {
73  nodeAreas[j] += (_phi[j][qp] * _JxW[qp] * _coord[qp]);
74  }
75  }
76  for (unsigned j(0); j < _phi.size(); ++j)
77  {
78  const Real area = nodeAreas[j];
79  if (area != 0)
80  {
81  _node_areas[_current_elem->node_ptr(j)] += area;
82  }
83  }
84 }
85 
86 void
88 {
89 
90  const std::map<const Node *, Real>::iterator it_end = _node_areas.end();
91  for (std::map<const Node *, Real>::iterator it = _node_areas.begin(); it != it_end; ++it)
92  {
93  const Node * const node = it->first;
94  dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0);
95  _aux_solution.set(dof, 0);
96  }
98 
99  for (std::map<const Node *, Real>::iterator it = _node_areas.begin(); it != it_end; ++it)
100  {
101  const Node * const node = it->first;
102  dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0);
103  _aux_solution.add(dof, it->second);
104  }
106 }
107 
108 Real
109 NodalArea::nodalArea(const Node * node) const
110 {
111  std::map<const Node *, Real>::const_iterator it = _node_areas.find(node);
112  Real retVal(0);
113  if (it != _node_areas.end())
114  {
115  retVal = it->second;
116  }
117  return retVal;
118 }
virtual void finalize()
Definition: NodalArea.C:87
unsigned int number() const
virtual void threadJoin(const UserObject &uo)
Definition: NodalArea.C:41
T & set(const std::string &name, bool quiet_mode=false)
virtual Real computeQpIntegral()
Definition: NodalArea.C:54
NumericVector< Number > & _aux_solution
Definition: NodalArea.h:41
const MooseArray< Real > & _JxW
static InputParameters validParams()
SystemBase & _system
Definition: NodalArea.h:40
Real nodalArea(const Node *node) const
Definition: NodalArea.C:109
static InputParameters validParams()
Definition: NodalArea.C:22
unsigned int number() const
MooseVariableFE< Real > * _variable
const ExecFlagType EXEC_LINEAR
const MooseArray< Real > & _coord
virtual void execute()
Definition: NodalArea.C:66
virtual void close()=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
virtual void set(const numeric_index_type i, const Number value)=0
const Elem *const & _current_elem
std::map< const Node *, Real > _node_areas
Definition: NodalArea.h:33
virtual ~NodalArea()
Definition: NodalArea.C:38
virtual void add(const numeric_index_type i, const Number value)=0
NodalArea(const InputParameters &parameters)
Definition: NodalArea.C:30
virtual void initialize()
Definition: NodalArea.C:60
const VariablePhiValue & _phi
Definition: NodalArea.h:38
uint8_t dof_id_type
registerMooseObject("ContactApp", NodalArea)