LCOV - code coverage report
Current view: top level - src/kernels - LevelSetOlssonReinitialization.C (source / functions) Hit Total Coverage
Test: idaholab/moose level_set: #32971 (54bef8) with base c6cf66 Lines: 21 22 95.5 %
Date: 2026-05-29 20:37:11 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             : // MOOSE includes
      11             : #include "LevelSetOlssonReinitialization.h"
      12             : 
      13             : registerMooseObject("LevelSetApp", LevelSetOlssonReinitialization);
      14             : 
      15             : InputParameters
      16          75 : LevelSetOlssonReinitialization::validParams()
      17             : {
      18          75 :   InputParameters params = ADKernelGrad::validParams();
      19          75 :   params.addClassDescription("The re-initialization equation defined by Olsson et. al. (2007).");
      20         150 :   params.addRequiredCoupledVar(
      21             :       "phi_0", "The level set variable to be reinitialized as signed distance function.");
      22         150 :   params.addParam<bool>(
      23             :       "use_modified_reinitilization_formulation",
      24         150 :       false,
      25             :       "Use the modified reinitilization formulation (Olsson et. al. (2007), section 2.2.1).");
      26         150 :   params.addRequiredParam<PostprocessorName>(
      27             :       "epsilon", "The epsilon coefficient to be used in the reinitialization calculation.");
      28          75 :   return params;
      29           0 : }
      30             : 
      31          40 : LevelSetOlssonReinitialization::LevelSetOlssonReinitialization(const InputParameters & parameters)
      32             :   : ADKernelGrad(parameters),
      33          40 :     _grad_levelset_0(adCoupledGradient("phi_0")),
      34          40 :     _epsilon(getPostprocessorValue("epsilon")),
      35          40 :     _use_modified_reinitilization_formulation(
      36         120 :         getParam<bool>("use_modified_reinitilization_formulation"))
      37             : {
      38          40 : }
      39             : 
      40             : ADRealVectorValue
      41    42729472 : LevelSetOlssonReinitialization::precomputeQpResidual()
      42             : {
      43    42729472 :   ADReal s = _grad_levelset_0[_qp].norm() + std::numeric_limits<ADReal>::epsilon();
      44    42729472 :   ADRealVectorValue n_hat = _grad_levelset_0[_qp] / s;
      45    85458944 :   ADRealVectorValue f = _u[_qp] * (1 - _u[_qp]) * n_hat;
      46    42729472 :   if (_use_modified_reinitilization_formulation)
      47    25460736 :     return (-f + _epsilon * (_grad_u[_qp] * n_hat) * n_hat);
      48             :   else
      49    68485120 :     return (-f + _epsilon * _grad_u[_qp]);
      50             : }

Generated by: LCOV version 1.14