Line data Source code
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 : 19 : registerMooseObject("ContactApp", NodalArea); 20 : 21 : InputParameters 22 5441 : NodalArea::validParams() 23 : { 24 5441 : InputParameters params = SideIntegralVariableUserObject::validParams(); 25 5441 : params.set<ExecFlagEnum>("execute_on") = EXEC_LINEAR; 26 5441 : params.addClassDescription("Compute the tributary area for nodes on a surface"); 27 5441 : return params; 28 0 : } 29 : 30 2927 : NodalArea::NodalArea(const InputParameters & parameters) 31 : : SideIntegralVariableUserObject(parameters), 32 2927 : _phi(_variable->phiFace()), 33 2927 : _system(_variable->sys()), 34 2927 : _aux_solution(_system.solution()) 35 : { 36 2927 : } 37 : 38 8781 : NodalArea::~NodalArea() {} 39 : 40 : void 41 4856 : NodalArea::threadJoin(const UserObject & fred) 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 18633 : for (; it != it_end; ++it) 48 : { 49 13777 : _node_areas[it->first] += it->second; 50 : } 51 4856 : } 52 : 53 : Real 54 0 : NodalArea::computeQpIntegral() 55 : { 56 0 : return 1; 57 : } 58 : 59 : void 60 25908 : NodalArea::initialize() 61 : { 62 : _node_areas.clear(); 63 25908 : } 64 : 65 : void 66 103417 : NodalArea::execute() 67 : { 68 103417 : std::vector<Real> nodeAreas(_phi.size()); 69 419485 : for (unsigned qp(0); qp < _qrule->n_points(); ++qp) 70 : { 71 2601452 : for (unsigned j(0); j < _phi.size(); ++j) 72 : { 73 2285384 : nodeAreas[j] += (_phi[j][qp] * _JxW[qp] * _coord[qp]); 74 : } 75 : } 76 767489 : for (unsigned j(0); j < _phi.size(); ++j) 77 : { 78 664072 : const Real area = nodeAreas[j]; 79 664072 : if (area != 0) 80 : { 81 334034 : _node_areas[_current_elem->node_ptr(j)] += area; 82 : } 83 : } 84 103417 : } 85 : 86 : void 87 21052 : NodalArea::finalize() 88 : { 89 : 90 : const std::map<const Node *, Real>::iterator it_end = _node_areas.end(); 91 205696 : for (std::map<const Node *, Real>::iterator it = _node_areas.begin(); it != it_end; ++it) 92 : { 93 184644 : const Node * const node = it->first; 94 184644 : dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0); 95 184644 : _aux_solution.set(dof, 0); 96 : } 97 21052 : _aux_solution.close(); 98 : 99 205696 : for (std::map<const Node *, Real>::iterator it = _node_areas.begin(); it != it_end; ++it) 100 : { 101 184644 : const Node * const node = it->first; 102 184644 : dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0); 103 184644 : _aux_solution.add(dof, it->second); 104 : } 105 21052 : _aux_solution.close(); 106 21052 : } 107 : 108 : Real 109 0 : 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 0 : if (it != _node_areas.end()) 114 : { 115 0 : retVal = it->second; 116 : } 117 0 : return retVal; 118 : }