LCOV - code coverage report
Current view: top level - src/auxkernels - Courant.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 17 19 89.5 %
Date: 2025-08-14 10:14:56 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 "Courant.h"
      11             : #include "MooseMesh.h"
      12             : 
      13             : registerMooseObject("NavierStokesApp", Courant);
      14             : 
      15             : InputParameters
      16         101 : Courant::validParams()
      17             : {
      18         101 :   InputParameters params = AuxKernel::validParams();
      19             : 
      20         101 :   params.addClassDescription("Computes |u| dt / h_min.");
      21             :   // Coupled variables
      22         202 :   params.addRequiredCoupledVar("u", "x-velocity");
      23         202 :   params.addCoupledVar("v", "y-velocity"); // only required in 2D and 3D
      24         202 :   params.addCoupledVar("w", "z-velocity"); // only required in 3D
      25             : 
      26         101 :   return params;
      27           0 : }
      28             : 
      29          55 : Courant::Courant(const InputParameters & parameters)
      30             :   : AuxKernel(parameters),
      31          55 :     _u_vel(coupledValue("u")),
      32          55 :     _v_vel(_mesh.dimension() >= 2 ? coupledValue("v") : _zero),
      33         110 :     _w_vel(_mesh.dimension() == 3 ? coupledValue("w") : _zero)
      34             : {
      35          55 :   if (isNodal())
      36           0 :     mooseError("This AuxKernel only supports Elemental fields");
      37          55 : }
      38             : 
      39             : Real
      40      104200 : Courant::computeValue()
      41             : {
      42      104200 :   const RealVectorValue U(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
      43      104200 :   Real vel_mag = U.norm();
      44             : 
      45      104200 :   return vel_mag * _dt / _current_elem->hmin();
      46             : }

Generated by: LCOV version 1.14