https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalArea.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
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
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
32 _phi(_variable->phiFace()),
33 _system(_variable->sys()),
34 _aux_solution(_system.solution())
35{
36}
37
39
40void
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
53Real
55{
56 return 1;
57}
58
59void
61{
62 _node_areas.clear();
63}
64
65void
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
86void
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
108Real
109NodalArea::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}
const ExecFlagType EXEC_LINEAR
registerMooseObject("ContactApp", NodalArea)
void addClassDescription(const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
unsigned int number() const
MooseVariableFE< Real > * _variable
const VariablePhiValue & _phi
Definition NodalArea.h:38
virtual void finalize()
Definition NodalArea.C:87
virtual ~NodalArea()
Definition NodalArea.C:38
NumericVector< Number > & _aux_solution
Definition NodalArea.h:41
virtual void execute()
Definition NodalArea.C:66
Real nodalArea(const Node *node) const
Definition NodalArea.C:109
virtual void initialize()
Definition NodalArea.C:60
SystemBase & _system
Definition NodalArea.h:40
virtual Real computeQpIntegral()
Definition NodalArea.C:54
std::map< const Node *, Real > _node_areas
Definition NodalArea.h:33
virtual void threadJoin(const UserObject &uo)
Definition NodalArea.C:41
NodalArea(const InputParameters &parameters)
Definition NodalArea.C:30
static InputParameters validParams()
Definition NodalArea.C:22
static InputParameters validParams()
const MooseArray< Real > & _coord
const QBase *const & _qrule
const MooseArray< Real > & _JxW
const Elem *const & _current_elem
unsigned int number() const
virtual void set(const numeric_index_type i, const T value)=0
virtual void close()=0
virtual void add(const numeric_index_type i, const T value)=0