LCOV - code coverage report
Current view: top level - src/postprocessors - LevelSetCFLCondition.C (source / functions) Hit Total Coverage
Test: idaholab/moose level_set: #32971 (54bef8) with base c6cf66 Lines: 24 25 96.0 %
Date: 2026-05-29 20:37:11 Functions: 6 6 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 "LevelSetCFLCondition.h"
      11             : 
      12             : registerMooseObject("LevelSetApp", LevelSetCFLCondition);
      13             : 
      14             : InputParameters
      15         135 : LevelSetCFLCondition::validParams()
      16             : {
      17         135 :   InputParameters params = ElementPostprocessor::validParams();
      18         135 :   params.addClassDescription("Compute the minimum timestep from the Courant-Friedrichs-Lewy (CFL) "
      19             :                              "condition for the level-set equation.");
      20         270 :   params.addRequiredCoupledVar("velocity", "Velocity vector variable.");
      21         135 :   return params;
      22           0 : }
      23             : 
      24          72 : LevelSetCFLCondition::LevelSetCFLCondition(const InputParameters & parameters)
      25             :   : ElementPostprocessor(parameters),
      26          72 :     _cfl_timestep(std::numeric_limits<Real>::max()),
      27          72 :     _velocity(adCoupledVectorValue("velocity"))
      28             : {
      29          72 : }
      30             : 
      31             : void
      32      644352 : LevelSetCFLCondition::execute()
      33             : {
      34             :   // Compute maximum velocity
      35      644352 :   _max_velocity = std::numeric_limits<Real>::min();
      36     3221760 :   for (unsigned int qp = 0; qp < _q_point.size(); ++qp)
      37             :   {
      38     2577408 :     RealVectorValue vel = MetaPhysicL::raw_value(_velocity[qp]);
      39     3897660 :     _max_velocity = std::max(_max_velocity, std::abs(vel.norm()));
      40             :   }
      41      644352 :   _cfl_timestep = std::min(_cfl_timestep, _current_elem->hmin() / _max_velocity);
      42      644352 : }
      43             : 
      44             : void
      45         116 : LevelSetCFLCondition::finalize()
      46             : {
      47         116 :   gatherMin(_cfl_timestep);
      48         116 : }
      49             : 
      50             : void
      51          16 : LevelSetCFLCondition::threadJoin(const UserObject & user_object)
      52             : {
      53             :   const auto & cfl = static_cast<const LevelSetCFLCondition &>(user_object);
      54          16 :   _cfl_timestep = std::min(_cfl_timestep, cfl._cfl_timestep);
      55          16 : }
      56             : 
      57             : PostprocessorValue
      58         116 : LevelSetCFLCondition::getValue() const
      59             : {
      60         116 :   return _cfl_timestep;
      61             : }

Generated by: LCOV version 1.14