www.mooseframework.org
LevelSetOlssonVortex.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 
8 #include "LevelSetOlssonVortex.h"
9 
10 template <>
11 InputParameters
13 {
14  MooseEnum rtype("instantaneous=0 cosine=1", "instantaneous");
15  MooseEnum comp("x=0 y=1 z=2");
16 
17  InputParameters params = validParams<Function>();
18  params.addClassDescription(
19  "A function for creating vortex velocity fields for level set equation benchmark problems.");
20  params.addParam<MooseEnum>(
21  "reverse_type", rtype, "The time of reversal to enforce (instantaneous or cosine).");
22  params.addParam<Real>("reverse_time", 2, "Total time for complete vortex reversal.");
23  params.addRequiredParam<MooseEnum>("component", comp, "The component of velocity to return.");
24 
25  return params;
26 }
27 
28 LevelSetOlssonVortex::LevelSetOlssonVortex(const InputParameters & parameters)
29  : Function(parameters),
30  _reverse_time(getParam<Real>("reverse_time")),
31  _reverse_type(getParam<MooseEnum>("reverse_type")),
32  _component(getParam<MooseEnum>("component")),
33  _pi(libMesh::pi)
34 {
35 }
36 
37 Real
38 LevelSetOlssonVortex::value(Real t, const Point & p)
39 {
40  return vectorValue(t, p)(_component);
41 }
42 
43 RealVectorValue
44 LevelSetOlssonVortex::vectorValue(Real t, const Point & p)
45 {
46  // Compute the velocity field
47  _output(0) = std::sin(_pi * p(0)) * std::sin(_pi * p(0)) * std::sin(2 * _pi * p(1));
48  _output(1) = -std::sin(_pi * p(1)) * std::sin(_pi * p(1)) * std::sin(2 * _pi * p(0));
49 
50  // Compute the coefficient used to reverse the flow
52  if (_reverse_type == 0 && t > _reverse_time / 2.)
53  _reverse_coefficient = -1.0;
54  else if (_reverse_type == 1)
55  _reverse_coefficient = std::cos(_pi * t / _reverse_time);
57 }
Real _reverse_coefficient
The time reversal coefficient.
RealVectorValue _output
The velocity field computed.
const MooseEnum & _reverse_type
Type of reverse (instantaneous or smooth)
RealVectorValue vectorValue(Real t, const Point &p) override
const MooseEnum & _component
The vector component to return.
Real value(Real t, const Point &p) override
LevelSetOlssonVortex(const InputParameters &parameters)
const Real & _reverse_time
Total time for the velocity field to complete reverse.
InputParameters validParams< LevelSetOlssonVortex >()