LCOV - code coverage report
Current view: top level - src/physics - WCNSFVCoupledAdvectionPhysicsHelper.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 9fc4b0 Lines: 34 39 87.2 %
Date: 2025-08-14 10:14:56 Functions: 4 5 80.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 "WCNSFVCoupledAdvectionPhysicsHelper.h"
      11             : #include "INSFVRhieChowInterpolator.h"
      12             : #include "RelationshipManager.h"
      13             : #include "WCNSFVFlowPhysicsBase.h"
      14             : #include "WCNSFVTurbulencePhysics.h"
      15             : 
      16             : InputParameters
      17        3606 : WCNSFVCoupledAdvectionPhysicsHelper::validParams()
      18             : {
      19        3606 :   InputParameters params = emptyInputParameters();
      20        3606 :   params.addClassDescription("Class to facilitate coupling between a Physics defining flow "
      21             :                              "equations and other objects, notably advection Physics.");
      22             : 
      23        7212 :   params.addParam<PhysicsName>("coupled_flow_physics",
      24             :                                "WCNSFVFlowPhysics generating the velocities");
      25        7212 :   params.addParam<PhysicsName>("coupled_turbulence_physics",
      26             :                                "Turbulence Physics coupled with this Physics");
      27        7212 :   params.addParamNamesToGroup("coupled_flow_physics coupled_turbulence_physics", "Coupled Physics");
      28             : 
      29        3606 :   return params;
      30           0 : }
      31             : 
      32        3606 : WCNSFVCoupledAdvectionPhysicsHelper::WCNSFVCoupledAdvectionPhysicsHelper(
      33        3606 :     const NavierStokesPhysicsBase * derived_physics)
      34        3606 :   : _advection_physics(derived_physics),
      35        3606 :     _flow_equations_physics(getCoupledFlowPhysics()),
      36        3606 :     _compressibility(_flow_equations_physics->compressibility()),
      37        3606 :     _porous_medium_treatment(_flow_equations_physics->porousMediumTreatment()),
      38        3606 :     _velocity_names(_flow_equations_physics->getVelocityNames()),
      39        3606 :     _pressure_name(_flow_equations_physics->getPressureName()),
      40        3606 :     _density_name(_flow_equations_physics->densityName()),
      41        3606 :     _dynamic_viscosity_name(_flow_equations_physics->dynamicViscosityName()),
      42        3606 :     _velocity_interpolation(_flow_equations_physics->getVelocityFaceInterpolationMethod())
      43             : {
      44        3606 : }
      45             : 
      46             : MooseFunctorName
      47           0 : WCNSFVCoupledAdvectionPhysicsHelper::getPorosityFunctorName(bool smoothed) const
      48             : {
      49           0 :   return _flow_equations_physics->getPorosityFunctorName(smoothed);
      50             : }
      51             : 
      52             : const WCNSFVFlowPhysicsBase *
      53        3606 : WCNSFVCoupledAdvectionPhysicsHelper::getCoupledFlowPhysics() const
      54             : {
      55             :   // User passed it, just use that
      56        7212 :   if (_advection_physics->isParamValid("coupled_flow_physics"))
      57         252 :     return _advection_physics->getCoupledPhysics<WCNSFVFlowPhysicsBase>(
      58             :         _advection_physics->getParam<PhysicsName>("coupled_flow_physics"));
      59             :   // Look for any physics of the right type, and check the block restriction
      60             :   else
      61             :   {
      62             :     const auto all_flow_physics =
      63        3522 :         _advection_physics->getCoupledPhysics<const WCNSFVFlowPhysicsBase>();
      64        3522 :     for (const auto physics : all_flow_physics)
      65        3522 :       if (_advection_physics->checkBlockRestrictionIdentical(
      66        3522 :               physics->name(), physics->blocks(), /*error_if_not_identical=*/false))
      67             :       {
      68             :         return physics;
      69             :       }
      70        3522 :   }
      71           0 :   mooseError("No coupled flow Physics found of type derived from 'WCNSFVFlowPhysicsBase'. Use the "
      72             :              "'coupled_flow_physics' parameter to give the name of the desired "
      73             :              "WCNSFVFlowPhysicsBase-derived Physics to couple with");
      74             : }
      75             : 
      76             : const WCNSFVTurbulencePhysics *
      77        1286 : WCNSFVCoupledAdvectionPhysicsHelper::getCoupledTurbulencePhysics() const
      78             : {
      79             :   // User passed it, just use that
      80        2572 :   if (_advection_physics->isParamValid("coupled_turbulence_physics"))
      81           0 :     return _advection_physics->getCoupledPhysics<WCNSFVTurbulencePhysics>(
      82             :         _advection_physics->getParam<PhysicsName>("coupled_turbulence_physics"));
      83             :   // Look for any physics of the right type, and check the block restriction
      84             :   else
      85             :   {
      86             :     const auto all_turbulence_physics =
      87        1286 :         _advection_physics->getCoupledPhysics<const WCNSFVTurbulencePhysics>(true);
      88        1286 :     for (const auto physics : all_turbulence_physics)
      89        1051 :       if (_advection_physics->checkBlockRestrictionIdentical(
      90             :               physics->name(), physics->blocks(), /*error_if_not_identical=*/false))
      91             :         return physics;
      92        1286 :   }
      93             :   // Did not find one
      94         235 :   return nullptr;
      95             : }

Generated by: LCOV version 1.14