www.mooseframework.org
LevelSetCFLCondition.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 "LevelSetCFLCondition.h"
11 
13 
14 template <>
15 InputParameters
17 {
18  InputParameters params = validParams<ElementPostprocessor>();
19  params.addClassDescription("Compute the minimum timestep from the Courant-Friedrichs-Lewy (CFL) "
20  "condition for the level-set equation.");
21  params += validParams<LevelSetVelocityInterface<>>();
22  return params;
23 }
24 
25 LevelSetCFLCondition::LevelSetCFLCondition(const InputParameters & parameters)
26  : LevelSetVelocityInterface<ElementPostprocessor>(parameters),
27  _cfl_timestep(std::numeric_limits<Real>::max())
28 {
29 }
30 
31 void
33 {
34  // Compute maximum velocity
35  _max_velocity = std::numeric_limits<Real>::min();
36  for (unsigned int qp = 0; qp < _q_point.size(); ++qp)
37  {
38  RealVectorValue vel(_velocity_x[qp], _velocity_y[qp], _velocity_z[qp]);
39  _max_velocity = std::max(_max_velocity, std::abs(vel.norm()));
40  }
41  _cfl_timestep = std::min(_cfl_timestep, _current_elem->hmin() / _max_velocity);
42 }
43 
44 void
46 {
47  gatherMin(_cfl_timestep);
48 }
49 
50 void
51 LevelSetCFLCondition::threadJoin(const UserObject & user_object)
52 {
53  const LevelSetCFLCondition & cfl = static_cast<const LevelSetCFLCondition &>(user_object);
54  _cfl_timestep = std::min(_cfl_timestep, cfl._cfl_timestep);
55 }
56 
57 PostprocessorValue
59 {
60  return _cfl_timestep;
61 }
LevelSetCFLCondition::execute
void execute() override
Definition: LevelSetCFLCondition.C:32
LevelSetCFLCondition::_max_velocity
Real _max_velocity
The max velocity on an element, this is done simply to avoid creating temporary calls to execute.
Definition: LevelSetCFLCondition.h:37
LevelSetCFLCondition::getValue
virtual PostprocessorValue getValue() override
Definition: LevelSetCFLCondition.C:58
LevelSetVelocityInterface
A helper class for defining the velocity as coupled variables for the levelset equation.
Definition: LevelSetVelocityInterface.h:18
LevelSetCFLCondition::_cfl_timestep
Real _cfl_timestep
The minimum timestep computed using CFL condition.
Definition: LevelSetCFLCondition.h:40
LevelSetCFLCondition::LevelSetCFLCondition
LevelSetCFLCondition(const InputParameters &parameters)
Definition: LevelSetCFLCondition.C:25
validParams< LevelSetCFLCondition >
InputParameters validParams< LevelSetCFLCondition >()
Definition: LevelSetCFLCondition.C:16
LevelSetCFLCondition
Computes the maximum timestep based on the CFL condition.
Definition: LevelSetCFLCondition.h:25
LevelSetVelocityInterface< ElementPostprocessor >::_velocity_y
const VariableValue & _velocity_y
Definition: LevelSetVelocityInterface.h:43
LevelSetCFLCondition.h
LevelSetCFLCondition::threadJoin
void threadJoin(const UserObject &user_object) override
Definition: LevelSetCFLCondition.C:51
LevelSetVelocityInterface< ElementPostprocessor >::_velocity_x
const VariableValue & _velocity_x
Definition: LevelSetVelocityInterface.h:42
LevelSetVelocityInterface< ElementPostprocessor >::_velocity_z
const VariableValue & _velocity_z
Definition: LevelSetVelocityInterface.h:44
registerMooseObject
registerMooseObject("LevelSetApp", LevelSetCFLCondition)
LevelSetCFLCondition::finalize
void finalize() override
Definition: LevelSetCFLCondition.C:45