LCOV - code coverage report
Current view: top level - src/postprocessors - NekPressureSurfaceForce.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 24 25 96.0 %
Date: 2025-07-15 20:50:38 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /********************************************************************/
       2             : /*                  SOFTWARE COPYRIGHT NOTIFICATION                 */
       3             : /*                             Cardinal                             */
       4             : /*                                                                  */
       5             : /*                  (c) 2021 UChicago Argonne, LLC                  */
       6             : /*                        ALL RIGHTS RESERVED                       */
       7             : /*                                                                  */
       8             : /*                 Prepared by UChicago Argonne, LLC                */
       9             : /*               Under Contract No. DE-AC02-06CH11357               */
      10             : /*                With the U. S. Department of Energy               */
      11             : /*                                                                  */
      12             : /*             Prepared by Battelle Energy Alliance, LLC            */
      13             : /*               Under Contract No. DE-AC07-05ID14517               */
      14             : /*                With the U. S. Department of Energy               */
      15             : /*                                                                  */
      16             : /*                 See LICENSE for full restrictions                */
      17             : /********************************************************************/
      18             : 
      19             : #ifdef ENABLE_NEK_COUPLING
      20             : 
      21             : #include "NekPressureSurfaceForce.h"
      22             : 
      23             : registerMooseObject("CardinalApp", NekPressureSurfaceForce);
      24             : 
      25             : InputParameters
      26          92 : NekPressureSurfaceForce::validParams()
      27             : {
      28          92 :   InputParameters params = NekSidePostprocessor::validParams();
      29         184 :   MooseEnum comp("x y z total", "total");
      30         184 :   params.addParam<MooseEnum>(
      31             :       "component",
      32             :       comp,
      33             :       "Component of pressure force to compute. 'total' takes the magnitude of the pressure force, "
      34             :       "while 'x', 'y', or 'z' return individual components.");
      35          92 :   params.addClassDescription("Pressure force that the fluid exerts on a surface");
      36          92 :   return params;
      37          92 : }
      38             : 
      39          29 : NekPressureSurfaceForce::NekPressureSurfaceForce(const InputParameters & parameters)
      40          58 :   : NekSidePostprocessor(parameters), _component(getParam<MooseEnum>("component"))
      41             : {
      42          29 :   if (_pp_mesh != nek_mesh::fluid)
      43           1 :     mooseError("The 'NekPressureSurfaceForce' postprocessor can only be applied to the fluid mesh boundaries!\n"
      44             :       "Please change 'mesh' to 'fluid'.");
      45          28 : }
      46             : 
      47             : Real
      48          28 : NekPressureSurfaceForce::getValue() const
      49             : {
      50          28 :   if (_component == "x")
      51           8 :     return nekrs::pressureSurfaceForce(_boundary, {1, 0, 0}, _pp_mesh);
      52          20 :   else if (_component == "y")
      53           8 :     return nekrs::pressureSurfaceForce(_boundary, {0, 1, 0}, _pp_mesh);
      54          12 :   else if (_component == "z")
      55           8 :     return nekrs::pressureSurfaceForce(_boundary, {0, 0, 1}, _pp_mesh);
      56           4 :   else if (_component == "total")
      57             :   {
      58           4 :     Real x = nekrs::pressureSurfaceForce(_boundary, {1, 0, 0}, _pp_mesh);
      59           4 :     Real y = nekrs::pressureSurfaceForce(_boundary, {0, 1, 0}, _pp_mesh);
      60           4 :     Real z = nekrs::pressureSurfaceForce(_boundary, {0, 0, 1}, _pp_mesh);
      61           4 :     return std::sqrt(x * x + y * y + z * z);
      62             :   }
      63             :   else
      64           0 :     mooseError("Unhandled component enum in NekPressureSurfaceForce!");
      65             : }
      66             : 
      67             : #endif

Generated by: LCOV version 1.14