www.mooseframework.org
LevelSetOlssonVortex.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
13 
14 template <>
15 InputParameters
17 {
18  MooseEnum rtype("instantaneous=0 cosine=1", "instantaneous");
19  MooseEnum comp("x=0 y=1 z=2");
20 
21  InputParameters params = validParams<Function>();
22  params.addClassDescription(
23  "A function for creating vortex velocity fields for level set equation benchmark problems.");
24  params.addParam<MooseEnum>(
25  "reverse_type", rtype, "The time of reversal to enforce (instantaneous or cosine).");
26  params.addParam<Real>("reverse_time", 2, "Total time for complete vortex reversal.");
27  params.addRequiredParam<MooseEnum>("component", comp, "The component of velocity to return.");
28 
29  return params;
30 }
31 
32 LevelSetOlssonVortex::LevelSetOlssonVortex(const InputParameters & parameters)
33  : Function(parameters),
34  _reverse_time(getParam<Real>("reverse_time")),
35  _reverse_type(getParam<MooseEnum>("reverse_type")),
36  _component(getParam<MooseEnum>("component")),
37  _pi(libMesh::pi)
38 {
39 }
40 
41 Real
42 LevelSetOlssonVortex::value(Real t, const Point & p) const
43 {
44  return vectorValue(t, p)(_component);
45 }
46 
47 RealVectorValue
48 LevelSetOlssonVortex::vectorValue(Real t, const Point & p) const
49 {
50  // Compute the velocity field
51  RealVectorValue output;
52  output(0) = std::sin(_pi * p(0)) * std::sin(_pi * p(0)) * std::sin(2 * _pi * p(1));
53  output(1) = -std::sin(_pi * p(1)) * std::sin(_pi * p(1)) * std::sin(2 * _pi * p(0));
54 
55  // Compute the coefficient used to reverse the flow
56  Real reverse_coefficient = 1.0;
57  if (_reverse_type == 0 && t > _reverse_time / 2.)
58  reverse_coefficient = -1.0;
59  else if (_reverse_type == 1)
60  reverse_coefficient = std::cos(_pi * t / _reverse_time);
61  return reverse_coefficient * output;
62 }
LevelSetOlssonVortex::_pi
const Real _pi
Definition: LevelSetOlssonVortex.h:43
registerMooseObject
registerMooseObject("LevelSetApp", LevelSetOlssonVortex)
LevelSetOlssonVortex
Defines a vortex velocity field in the x-y plane.
Definition: LevelSetOlssonVortex.h:23
LevelSetOlssonVortex::vectorValue
RealVectorValue vectorValue(Real t, const Point &p) const override
Definition: LevelSetOlssonVortex.C:48
libMesh
Definition: RANFSNormalMechanicalContact.h:24
LevelSetOlssonVortex::LevelSetOlssonVortex
LevelSetOlssonVortex(const InputParameters &parameters)
Definition: LevelSetOlssonVortex.C:32
LevelSetOlssonVortex::_component
const MooseEnum & _component
The vector component to return.
Definition: LevelSetOlssonVortex.h:40
LevelSetOlssonVortex.h
LevelSetOlssonVortex::_reverse_type
const MooseEnum & _reverse_type
Type of reverse (instantaneous or smooth)
Definition: LevelSetOlssonVortex.h:37
LevelSetOlssonVortex::_reverse_time
const Real & _reverse_time
Total time for the velocity field to complete reverse.
Definition: LevelSetOlssonVortex.h:34
LevelSetOlssonVortex::value
Real value(Real t, const Point &p) const override
Definition: LevelSetOlssonVortex.C:42
validParams< LevelSetOlssonVortex >
InputParameters validParams< LevelSetOlssonVortex >()
Definition: LevelSetOlssonVortex.C:16