LCOV - code coverage report
Current view: top level - src/meshmodifiers - MoveNodesToGeometryModifierBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 32 40 80.0 %
Date: 2025-07-17 01:28:37 Functions: 4 7 57.1 %
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 "MoveNodesToGeometryModifierBase.h"
      11             : #include "MooseMesh.h"
      12             : #include "libmesh/mesh_base.h"
      13             : 
      14             : InputParameters
      15       28578 : MoveNodesToGeometryModifierBase::validParams()
      16             : {
      17       28578 :   InputParameters params = GeneralUserObject::validParams();
      18       28578 :   params.addClassDescription(
      19             :       "Snap refined nodes on a given boundary or block to a given geometry.");
      20       28578 :   params.addParam<std::vector<BoundaryName>>(
      21             :       "boundary", {}, "List of boundaries whose nodes are snapped to a given geometry");
      22       28578 :   params.addParam<std::vector<SubdomainName>>(
      23             :       "block", {}, "List of blocks whose nodes are snapped to a given geometry");
      24             : 
      25             :   // By default don't execute
      26       28578 :   params.set<ExecFlagEnum>("execute_on") = "NONE";
      27             : 
      28       28578 :   return params;
      29           0 : }
      30             : 
      31          24 : MoveNodesToGeometryModifierBase::MoveNodesToGeometryModifierBase(const InputParameters & parameters)
      32             :   : GeneralUserObject(parameters),
      33          48 :     _mesh(_subproblem.mesh()),
      34          24 :     _boundary_ids(_mesh.getBoundaryIDs(getParam<std::vector<BoundaryName>>("boundary"))),
      35          48 :     _subdomain_ids(_mesh.getSubdomainIDs(getParam<std::vector<SubdomainName>>("block")))
      36             : {
      37          24 : }
      38             : 
      39             : void
      40           0 : MoveNodesToGeometryModifierBase::initialize()
      41             : {
      42           0 : }
      43             : 
      44             : void
      45           0 : MoveNodesToGeometryModifierBase::execute()
      46             : {
      47           0 :   snapNodes();
      48           0 : }
      49             : 
      50             : void
      51           0 : MoveNodesToGeometryModifierBase::finalize()
      52             : {
      53           0 : }
      54             : 
      55             : void
      56          66 : MoveNodesToGeometryModifierBase::meshChanged()
      57             : {
      58          66 :   snapNodes();
      59          66 : }
      60             : 
      61             : void
      62          66 : MoveNodesToGeometryModifierBase::snapNodes()
      63             : {
      64          66 :   auto & mesh = _mesh.getMesh();
      65             : 
      66             :   // go over boundaries
      67         198 :   for (auto & boundary_id : _boundary_ids)
      68             :   {
      69         132 :     auto node_ids = _mesh.getNodeList(boundary_id);
      70         860 :     for (auto & node_id : node_ids)
      71             :     {
      72         728 :       auto & node = mesh.node_ref(node_id);
      73             : 
      74         728 :       snapNode(node);
      75             :     }
      76         132 :   }
      77             : 
      78             :   // go over blocks
      79          66 :   MeshBase::node_iterator node = mesh.active_nodes_begin();
      80          66 :   MeshBase::node_iterator node_end = mesh.active_nodes_end();
      81        3692 :   for (; node != node_end; ++node)
      82             :   {
      83             :     // check if node is part of any of the selected blocks
      84        1813 :     const auto & node_blocks = _mesh.getNodeBlockIds(**node);
      85        1813 :     for (const auto subdomain_id : _subdomain_ids)
      86         590 :       if (node_blocks.count(subdomain_id))
      87             :       {
      88         590 :         snapNode(**node);
      89         590 :         break;
      90             :       }
      91             :   }
      92          66 : }

Generated by: LCOV version 1.14