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 
21 template <>
22 InputParameters
24 {
25  InputParameters params = validParams<SideIntegralVariableUserObject>();
26  params.set<ExecFlagEnum>("execute_on") = EXEC_LINEAR;
27  return params;
28 }
29 
30 NodalArea::NodalArea(const InputParameters & parameters)
31  : SideIntegralVariableUserObject(parameters),
32  _phi(_variable->phiFace()),
33  _system(_variable->sys()),
34  _aux_solution(_system.solution())
35 {
36 }
37 
39 
40 void
41 NodalArea::threadJoin(const UserObject & fred)
42 {
43  const NodalArea & na = dynamic_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  }
97  _aux_solution.close();
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  }
105  _aux_solution.close();
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 }
NodalArea::execute
virtual void execute()
Definition: NodalArea.C:66
NodalArea::finalize
virtual void finalize()
Definition: NodalArea.C:87
NodalArea::threadJoin
virtual void threadJoin(const UserObject &uo)
Definition: NodalArea.C:41
NodalArea::_system
SystemBase & _system
Definition: NodalArea.h:38
NodalArea::~NodalArea
virtual ~NodalArea()
Definition: NodalArea.C:38
NodalArea::NodalArea
NodalArea(const InputParameters &parameters)
Definition: NodalArea.C:30
NodalArea::initialize
virtual void initialize()
Definition: NodalArea.C:60
NodalArea::nodalArea
Real nodalArea(const Node *node) const
Definition: NodalArea.C:109
registerMooseObject
registerMooseObject("ContactApp", NodalArea)
NodalArea.h
NodalArea
Definition: NodalArea.h:14
NodalArea::computeQpIntegral
virtual Real computeQpIntegral()
Definition: NodalArea.C:54
NodalArea::_aux_solution
NumericVector< Number > & _aux_solution
Definition: NodalArea.h:39
validParams< NodalArea >
InputParameters validParams< NodalArea >()
Definition: NodalArea.C:23
NodalArea::_phi
const VariablePhiValue & _phi
Definition: NodalArea.h:36
NodalArea::_node_areas
std::map< const Node *, Real > _node_areas
Definition: NodalArea.h:31