LCOV - code coverage report
Current view: top level - src/userobjects - NodalDensity.C (source / functions) Hit Total Coverage
Test: idaholab/moose contact: #32971 (54bef8) with base c6cf66 Lines: 35 37 94.6 %
Date: 2026-05-29 20:36:03 Functions: 7 8 87.5 %
Legend: Lines: hit not hit

          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 "NodalDensity.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", NodalDensity);
      20             : 
      21             : InputParameters
      22          87 : NodalDensity::validParams()
      23             : {
      24          87 :   InputParameters params = SideIntegralVariableUserObject::validParams();
      25          87 :   params.set<ExecFlagEnum>("execute_on") = EXEC_LINEAR;
      26          87 :   params.addClassDescription("Compute the tributary densities for nodes on a surface");
      27          87 :   return params;
      28           0 : }
      29             : 
      30          46 : NodalDensity::NodalDensity(const InputParameters & parameters)
      31             :   : SideIntegralVariableUserObject(parameters),
      32          46 :     _phi(_variable->phiFace()),
      33          46 :     _system(_variable->sys()),
      34          46 :     _aux_solution(_system.solution()),
      35          92 :     _density(getMaterialProperty<Real>("density"))
      36             : {
      37          46 : }
      38             : 
      39          92 : NodalDensity::~NodalDensity() {}
      40             : 
      41             : void
      42         658 : NodalDensity::threadJoin(const UserObject & fred)
      43             : {
      44         658 :   const NodalDensity & na = dynamic_cast<const NodalDensity &>(fred);
      45             : 
      46             :   std::map<const Node *, Real>::const_iterator it = na._node_densities.begin();
      47             :   const std::map<const Node *, Real>::const_iterator it_end = na._node_densities.end();
      48         658 :   for (; it != it_end; ++it)
      49             :   {
      50           0 :     _node_densities[it->first] += it->second;
      51             :   }
      52         658 : }
      53             : 
      54             : void
      55        5318 : NodalDensity::initialize()
      56             : {
      57             :   _node_densities.clear();
      58        5318 : }
      59             : 
      60             : void
      61       28421 : NodalDensity::execute()
      62             : {
      63       28421 :   std::vector<Real> node_densities(_phi.size());
      64      142085 :   for (unsigned qp(0); qp < _qrule->n_points(); ++qp)
      65     1022896 :     for (unsigned j(0); j < _phi.size(); ++j)
      66      909232 :       node_densities[j] += (_phi[j][qp] * _density[qp]);
      67             : 
      68      255749 :   for (unsigned j(0); j < _phi.size(); ++j)
      69             :   {
      70      227328 :     const Real density = node_densities[j];
      71      227328 :     if (density != 0)
      72      113664 :       _node_densities[_current_elem->node_ptr(j)] = density;
      73             :   }
      74       28421 : }
      75             : 
      76             : void
      77        4660 : NodalDensity::finalize()
      78             : {
      79             : 
      80             :   const std::map<const Node *, Real>::iterator it_end = _node_densities.end();
      81       60615 :   for (std::map<const Node *, Real>::iterator it = _node_densities.begin(); it != it_end; ++it)
      82             :   {
      83       55955 :     const Node * const node = it->first;
      84       55955 :     dof_id_type dof = node->dof_number(_system.number(), _variable->number(), 0);
      85       55955 :     _aux_solution.set(dof, it->second);
      86             :   }
      87        4660 :   _aux_solution.close();
      88        4660 : }

Generated by: LCOV version 1.14