LCOV - code coverage report
Current view: top level - src/markers - DiscreteNucleationMarker.C (source / functions) Hit Total Coverage
Test: idaholab/moose phase_field: #32971 (54bef8) with base c6cf66 Lines: 19 21 90.5 %
Date: 2026-05-29 20:38:39 Functions: 3 3 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 "DiscreteNucleationMarker.h"
      11             : #include "DiscreteNucleationMap.h"
      12             : 
      13             : registerMooseObject("PhaseFieldApp", DiscreteNucleationMarker);
      14             : 
      15             : InputParameters
      16          28 : DiscreteNucleationMarker::validParams()
      17             : {
      18          28 :   InputParameters params = Marker::validParams();
      19          28 :   params.addClassDescription("Mark new nucleation sites for refinement");
      20          56 :   params.addRequiredParam<UserObjectName>("map", "DiscreteNucleationMap user object");
      21          28 :   return params;
      22           0 : }
      23             : 
      24          15 : DiscreteNucleationMarker::DiscreteNucleationMarker(const InputParameters & parameters)
      25             :   : Marker(parameters),
      26          15 :     _map(getUserObject<DiscreteNucleationMap>("map")),
      27          15 :     _periodic_var(_map.getPeriodicVar()),
      28          15 :     _inserter(_map.getInserter()),
      29          15 :     _int_width(_map.getWidth()),
      30          30 :     _nucleus_list(_inserter.getNucleusList())
      31             : {
      32          15 : }
      33             : 
      34             : Marker::MarkerValue
      35        1200 : DiscreteNucleationMarker::computeElementMarker()
      36             : {
      37        1200 :   const RealVectorValue centroid = _current_elem->vertex_average();
      38        1200 :   const Real size = 0.5 * _current_elem->hmax();
      39             : 
      40             :   // check if the surface of a nucleus might touch the element
      41        2120 :   for (unsigned i = 0; i < _nucleus_list.size(); ++i)
      42             :   {
      43             :     // get the radius of the current nucleus
      44        1335 :     const Real radius = _nucleus_list[i].radius;
      45             : 
      46             :     // use a non-periodic or periodic distance
      47             :     const Real r =
      48        1335 :         _periodic_var ? _mesh.minPeriodicDistance(*_periodic_var, centroid, _nucleus_list[i].center)
      49           0 :                       : (centroid - _nucleus_list[i].center).norm();
      50        1335 :     if (r < radius + size && r > radius - size && size > _int_width)
      51             :       return REFINE;
      52             :   }
      53             : 
      54             :   // We return don't mark to allow coarsening when used in a ComboMarker
      55             :   return DONT_MARK;
      56             : }

Generated by: LCOV version 1.14