LCOV - code coverage report
Current view: top level - src/functions - LevelSetOlssonVortex.C (source / functions) Hit Total Coverage
Test: idaholab/moose level_set: #31405 (292dce) with base fef103 Lines: 20 20 100.0 %
Date: 2025-09-04 07:53:58 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 "LevelSetOlssonVortex.h"
      11             : 
      12             : registerMooseObject("LevelSetApp", LevelSetOlssonVortex);
      13             : 
      14             : InputParameters
      15         105 : LevelSetOlssonVortex::validParams()
      16             : {
      17         210 :   MooseEnum rtype("instantaneous=0 cosine=1", "instantaneous");
      18             : 
      19         105 :   InputParameters params = Function::validParams();
      20         105 :   params.addClassDescription(
      21             :       "A function for creating vortex velocity fields for level set equation benchmark problems.");
      22         210 :   params.addParam<MooseEnum>(
      23             :       "reverse_type", rtype, "The time of reversal to enforce (instantaneous or cosine).");
      24         210 :   params.addParam<Real>("reverse_time", 2, "Total time for complete vortex reversal.");
      25         105 :   return params;
      26         105 : }
      27             : 
      28          60 : LevelSetOlssonVortex::LevelSetOlssonVortex(const InputParameters & parameters)
      29             :   : Function(parameters),
      30          60 :     _reverse_time(getParam<Real>("reverse_time")),
      31         120 :     _reverse_type(getParam<MooseEnum>("reverse_type")),
      32          60 :     _pi(libMesh::pi)
      33             : {
      34          60 : }
      35             : 
      36             : RealVectorValue
      37      245967 : LevelSetOlssonVortex::vectorValue(Real t, const Point & p) const
      38             : {
      39             :   // Compute the velocity field
      40             :   RealVectorValue output;
      41      245967 :   output(0) = std::sin(_pi * p(0)) * std::sin(_pi * p(0)) * std::sin(2 * _pi * p(1));
      42      245967 :   output(1) = -std::sin(_pi * p(1)) * std::sin(_pi * p(1)) * std::sin(2 * _pi * p(0));
      43             : 
      44             :   // Compute the coefficient used to reverse the flow
      45             :   Real reverse_coefficient = 1.0;
      46      245967 :   if (_reverse_type == 0 && t > _reverse_time / 2.)
      47             :     reverse_coefficient = -1.0;
      48      238707 :   else if (_reverse_type == 1)
      49       15246 :     reverse_coefficient = std::cos(_pi * t / _reverse_time);
      50      245967 :   return reverse_coefficient * output;
      51             : }

Generated by: LCOV version 1.14