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

Generated by: LCOV version 1.14