COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
ComputeCFL.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #include "common/Builder.hpp"
9 #include "common/OptionList.hpp"
10 
11 #include "mesh/Cells.hpp"
12 #include "mesh/Field.hpp"
13 #include "mesh/Space.hpp"
14 #include "mesh/Connectivity.hpp"
15 #include "mesh/ShapeFunction.hpp"
16 #include "mesh/Dictionary.hpp"
17 
18 #include "solver/ComputeCFL.hpp"
19 #include "solver/Term.hpp"
20 #include "solver/TermComputer.hpp"
21 #include "solver/PDE.hpp"
22 
23 using namespace cf3::common;
24 using namespace cf3::mesh;
25 using namespace cf3::solver;
26 
27 namespace cf3 {
28 namespace solver {
29 
31 
33 
35 
36 ComputeCFL::ComputeCFL ( const std::string& name ) : common::Action(name)
37 {
38  options().add("time_step", m_time_step)
39  .description("Time step")
40  .pretty_name("Time step")
41  .mark_basic()
42  .link_to(&m_time_step);
43 
44  options().add("wave_speed", m_wave_speed)
45  .description("Wave Speed divided by characteristic length")
46  .pretty_name("Wave Speed")
47  .mark_basic()
48  .link_to(&m_wave_speed);
49 
50  options().add("cfl", m_cfl)
51  .description("Courant number, local to a cell")
52  .pretty_name("CFL")
53  .mark_basic()
54  .link_to(&m_cfl);
55 
56 }
57 
59 
61 {
62  if ( is_null(m_time_step) ) SetupError(FromHere(), "time_step not configured");
63  if ( is_null(m_wave_speed) ) SetupError(FromHere(), "wave_speed not configured");
64 
65  if ( is_null(m_cfl) )
66  {
67  Handle<Component> found;
68  if ( found = find_component_ptr_with_name( m_wave_speed->dict(), "cfl" ) )
69  {
70  m_cfl = found->handle<Field>();
71  }
72  else
73  {
74  m_cfl = m_wave_speed->dict().create_field("cfl").handle<Field>();
75  }
76  }
77 
78  Field& ws = *m_wave_speed;
79  Field& dt = *m_time_step;
80  Field& cfl = *m_cfl;
81  // Calculate the CFL number = dt * wave_speed
82  for (Uint i=0; i<ws.size(); ++i)
83  {
84  cfl[i][0] = dt[i][0] * ws[i][0];
85  }
86 }
87 
89 
90 } // solver
91 } // cf3
std::string name(ComponentWrapper &self)
bool is_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:151
Safe pointer to an object. This is the supported method for referring to components.
Definition: Handle.hpp:39
Helper class to create the Builder and place it in the factory.
Definition: Builder.hpp:212
common::ComponentBuilder< ComputeCFL, common::Action, LibUFEM > ComputeCFL_Builder
Definition: ComputeCFL.cpp:51
Handle< mesh::Field > m_time_step
Definition: ComputeCFL.hpp:56
Basic Classes for Solver applications used by CF.
Definition: Action.cpp:29
Handle< mesh::Field > m_cfl
! Wave speed field
Definition: ComputeCFL.hpp:58
Uint size() const
Definition: Table.hpp:127
Basic Classes for Mesh applications used by COOLFluiD.
ComponentHandle< Component >::type find_component_ptr_with_name(Component &parent, StringConverter name)
virtual void execute()
Compute the right hand side and wave speed in configured fields.
Definition: ComputeCFL.cpp:60
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Component that executes an action. Implementation of the IAction interface as a component, exposing the execute function as a signal.
Definition: Action.hpp:21
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
Handle< Component > handle()
Get a handle to the component.
Definition: Component.hpp:179
OptionList & options()
Definition: Component.cpp:856
Handle< mesh::Field > m_wave_speed
! Time step field
Definition: ComputeCFL.hpp:57
SelectOptionType< T >::type & add(const std::string &name, const T &default_value=T())
Definition: OptionList.hpp:45
Most basic kernel library.
Definition: Action.cpp:19
#define FromHere()
Send comments to:
COOLFluiD Web Admin