LCOV - code coverage report
Current view: top level - src/userobjects - NodalNormalsCorner.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 38 39 97.4 %
Date: 2025-07-17 01:28:37 Functions: 5 5 100.0 %
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 "NodalNormalsCorner.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "AuxiliarySystem.h"
      14             : #include "MooseMesh.h"
      15             : #include "MooseVariableFE.h"
      16             : #include "NodalNormalsPreprocessor.h"
      17             : 
      18             : #include "libmesh/numeric_vector.h"
      19             : 
      20             : registerMooseObject("MooseApp", NodalNormalsCorner);
      21             : 
      22             : InputParameters
      23       14540 : NodalNormalsCorner::validParams()
      24             : {
      25       14540 :   InputParameters params = SideUserObject::validParams();
      26       14540 :   params.addClassDescription("Computes nodal normals at boundary corners.");
      27       14540 :   params.addRequiredParam<BoundaryName>(
      28             :       "corner_boundary", "Node set ID which contains the nodes that are in 'corners'.");
      29       14540 :   return params;
      30           0 : }
      31             : 
      32         143 : NodalNormalsCorner::NodalNormalsCorner(const InputParameters & parameters)
      33             :   : SideUserObject(parameters),
      34         286 :     _aux(_fe_problem.getAuxiliarySystem()),
      35         143 :     _corner_boundary_id(_mesh.getBoundaryID(getParam<BoundaryName>("corner_boundary")))
      36             : {
      37         143 : }
      38             : 
      39             : void
      40       18592 : NodalNormalsCorner::execute()
      41             : {
      42       18592 :   std::scoped_lock lock(NodalNormalsPreprocessor::_nodal_normals_mutex);
      43       18592 :   NumericVector<Number> & sln = _aux.solution();
      44             : 
      45             :   // Get a reference to our BoundaryInfo object
      46       18592 :   BoundaryInfo & boundary_info = _mesh.getMesh().get_boundary_info();
      47             : 
      48      104064 :   for (unsigned int nd = 0; nd < _current_side_elem->n_nodes(); nd++)
      49             :   {
      50       85472 :     const Node * node = _current_side_elem->node_ptr(nd);
      51      114784 :     if (boundary_info.has_boundary_id(node, _corner_boundary_id) &&
      52       29312 :         node->n_dofs(_aux.number(),
      53       29312 :                      _fe_problem
      54      114784 :                          .getVariable(_tid,
      55             :                                       "nodal_normal_x",
      56             :                                       Moose::VarKindType::VAR_AUXILIARY,
      57             :                                       Moose::VarFieldType::VAR_FIELD_STANDARD)
      58             :                          .number()) > 0)
      59             :     {
      60       28800 :       dof_id_type dof_x = node->dof_number(_aux.number(),
      61       28800 :                                            _fe_problem
      62       57600 :                                                .getVariable(_tid,
      63             :                                                             "nodal_normal_x",
      64             :                                                             Moose::VarKindType::VAR_AUXILIARY,
      65             :                                                             Moose::VarFieldType::VAR_FIELD_STANDARD)
      66             :                                                .number(),
      67             :                                            0);
      68       28800 :       dof_id_type dof_y = node->dof_number(_aux.number(),
      69       28800 :                                            _fe_problem
      70       57600 :                                                .getVariable(_tid,
      71             :                                                             "nodal_normal_y",
      72             :                                                             Moose::VarKindType::VAR_AUXILIARY,
      73             :                                                             Moose::VarFieldType::VAR_FIELD_STANDARD)
      74             :                                                .number(),
      75             :                                            0);
      76       28800 :       dof_id_type dof_z = node->dof_number(_aux.number(),
      77       28800 :                                            _fe_problem
      78       57600 :                                                .getVariable(_tid,
      79             :                                                             "nodal_normal_z",
      80             :                                                             Moose::VarKindType::VAR_AUXILIARY,
      81             :                                                             Moose::VarFieldType::VAR_FIELD_STANDARD)
      82             :                                                .number(),
      83             :                                            0);
      84             : 
      85             :       // substitute the normal from the face, we are going to have at least one normal every time
      86       28800 :       sln.add(dof_x, _normals[0](0));
      87       28800 :       sln.add(dof_y, _normals[0](1));
      88       28800 :       sln.add(dof_z, _normals[0](2));
      89             :     }
      90             :   }
      91       18592 : }
      92             : 
      93             : void
      94        5688 : NodalNormalsCorner::initialize()
      95             : {
      96        5688 :   _aux.solution().close();
      97        5688 : }
      98             : 
      99             : void
     100        5214 : NodalNormalsCorner::finalize()
     101             : {
     102        5214 :   _aux.solution().close();
     103        5214 : }

Generated by: LCOV version 1.14