www.mooseframework.org
NodalArea.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "NodalArea.h"
9 
10 // MOOSE includes
11 #include "MooseVariable.h"
12 #include "SystemBase.h"
13 
14 #include "libmesh/numeric_vector.h"
15 #include "libmesh/quadrature.h"
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<SideIntegralVariableUserObject>();
22 
23  params.set<MultiMooseEnum>("execute_on") = "linear";
24  return params;
25 }
26 
27 NodalArea::NodalArea(const InputParameters & parameters)
28  : SideIntegralVariableUserObject(parameters),
29  _phi(getCoupledVars().find("variable")->second[0]->phiFace()),
30  _system(_variable->sys()),
31  _aux_solution(_system.solution())
32 {
33 }
34 
36 
37 void
38 NodalArea::threadJoin(const UserObject & fred)
39 {
40  const NodalArea & na = dynamic_cast<const NodalArea &>(fred);
41 
42  std::map<const Node *, Real>::const_iterator it = na._node_areas.begin();
43  const std::map<const Node *, Real>::const_iterator it_end = na._node_areas.end();
44  for (; it != it_end; ++it)
45  {
46  _node_areas[it->first] += it->second;
47  }
48 }
49 
50 Real
52 {
53  return 1;
54 }
55 
56 void
58 {
59  _node_areas.clear();
60 }
61 
62 void
64 {
65  std::vector<Real> nodeAreas(_phi.size());
66  for (unsigned qp(0); qp < _qrule->n_points(); ++qp)
67  {
68  for (unsigned j(0); j < _phi.size(); ++j)
69  {
70  nodeAreas[j] += (_phi[j][qp] * _JxW[qp] * _coord[qp]);
71  }
72  }
73  for (unsigned j(0); j < _phi.size(); ++j)
74  {
75  const Real area = nodeAreas[j];
76  if (area != 0)
77  {
78  _node_areas[_current_elem->get_node(j)] += area;
79  }
80  }
81 }
82 
83 void
85 {
86 
87  const std::map<const Node *, Real>::iterator it_end = _node_areas.end();
88  for (std::map<const Node *, Real>::iterator it = _node_areas.begin(); it != it_end; ++it)
89  {
90  const Node * const node = it->first;
91  dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0);
92  _aux_solution.set(dof, 0);
93  }
94  _aux_solution.close();
95 
96  for (std::map<const Node *, Real>::iterator it = _node_areas.begin(); it != it_end; ++it)
97  {
98  const Node * const node = it->first;
99  dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0);
100  _aux_solution.add(dof, it->second);
101  }
102  _aux_solution.close();
103 }
104 
105 Real
106 NodalArea::nodalArea(const Node * node) const
107 {
108  std::map<const Node *, Real>::const_iterator it = _node_areas.find(node);
109  Real retVal(0);
110  if (it != _node_areas.end())
111  {
112  retVal = it->second;
113  }
114  return retVal;
115 }
virtual void finalize()
Definition: NodalArea.C:84
virtual void threadJoin(const UserObject &uo)
Definition: NodalArea.C:38
virtual Real computeQpIntegral()
Definition: NodalArea.C:51
NumericVector< Number > & _aux_solution
Definition: NodalArea.h:37
InputParameters validParams< NodalArea >()
Definition: NodalArea.C:19
SystemBase & _system
Definition: NodalArea.h:36
virtual void execute()
Definition: NodalArea.C:63
Real nodalArea(const Node *node) const
Definition: NodalArea.C:106
std::map< const Node *, Real > _node_areas
Definition: NodalArea.h:29
virtual ~NodalArea()
Definition: NodalArea.C:35
NodalArea(const InputParameters &parameters)
Definition: NodalArea.C:27
virtual void initialize()
Definition: NodalArea.C:57
const VariablePhiValue & _phi
Definition: NodalArea.h:34