COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
NavierStokes.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 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 "../NavierStokes.hpp"
8 
9 #include <boost/bind.hpp>
10 #include <boost/function.hpp>
11 
12 #include <boost/mpl/back_inserter.hpp>
13 #include <boost/mpl/copy.hpp>
14 
15 #include "common/Component.hpp"
16 #include "common/Builder.hpp"
17 #include "common/OptionT.hpp"
18 #include "common/OptionArray.hpp"
19 #include "common/PropertyList.hpp"
20 
21 #include "math/LSS/SolveLSS.hpp"
22 #include "math/LSS/ZeroLSS.hpp"
23 
27 #include "solver/CriterionTime.hpp"
29 #include "solver/Time.hpp"
30 #include "solver/Tags.hpp"
31 
32 #include "../NavierStokesSpecializations.hpp"
33 #include "../Tags.hpp"
34 
35 namespace cf3 {
36 namespace UFEM {
37 
38 using namespace common;
39 using namespace solver;
40 using namespace solver::actions;
41 using namespace solver::actions::Proto;
42 
43 
45 
46 NavierStokes::NavierStokes(const std::string& name) :
47  LSSActionUnsteady(name),
48  u("Velocity", "navier_stokes_solution"),
49  p("Pressure", "navier_stokes_solution"),
50  T("Temperature", "scalar_advection_solution"),
51  u_adv("AdvectionVelocity", "linearized_velocity"),
52  u1("AdvectionVelocity1", "linearized_velocity"),
53  u2("AdvectionVelocity2", "linearized_velocity"),
54  u3("AdvectionVelocity3", "linearized_velocity"),
55  nu_eff("EffectiveViscosity", "navier_stokes_viscosity"),
56  g("Force", "body_force"),
57  rho("density"),
58  nu("kinematic_viscosity"),
59  Tref("reference_temperature")
60 {
61  const std::vector<std::string> restart_field_tags = boost::assign::list_of("navier_stokes_solution")("linearized_velocity")("navier_stokes_viscosity");
62  properties().add("restart_field_tags", restart_field_tags);
63 
64  options().add("use_specializations", true)
65  .pretty_name("Use Specializations")
66  .description("Activate the use of specialized high performance code")
67  .attach_trigger(boost::bind(&NavierStokes::trigger_assembly, this));
68 
69  options().add("supg_type", compute_tau.data.op.supg_type_str)
70  .pretty_name("SUPG Type")
71  .description("Type of computation for the stabilization coefficients.")
72  .link_to(&(compute_tau.data.op.supg_type_str))
73  .attach_trigger(boost::bind(&ComputeTauImpl::trigger_supg_type, &compute_tau.data.op));
74 
75  options().add("theta", 1.)
76  .pretty_name("Theta")
77  .description("Theta coefficient for the theta-method.")
78  .attach_trigger(boost::bind(&NavierStokes::trigger_assembly, this));
79 
80  set_solution_tag("navier_stokes_solution");
81 
82  // This ensures that the linear system matrix is reset to zero each timestep
83  create_component<math::LSS::ZeroLSS>("ZeroLSS")->options().set("reset_solution", false);
84  // Extrapolate the velocity
85  add_component(create_proto_action("LinearizeU", nodes_expression(u_adv = 2.1875*u - 2.1875*u1 + 1.3125*u2 - 0.3125*u3)));
86  //add_component(create_proto_action("LinearizeU", nodes_expression(u_adv = u)));
87 
88  // Container for the assembly actions. Will be filled depending on the value of options, such as using specializations or not
89  m_assembly = create_component<solver::ActionDirector>("Assembly");
90 
91  // Boundary conditions
92  Handle<BoundaryConditions> bc = create_component<BoundaryConditions>("BoundaryConditions");
93  bc->mark_basic();
94  bc->set_solution_tag(solution_tag());
95 
96  // Solution of the LSS
97  create_component<math::LSS::SolveLSS>("SolveLSS");
98 
99  // Update of the solution
100  m_update = create_component<solver::ActionDirector>("UpdateActions");
101 
103 }
104 
106 {
107 }
108 
109 
111 {
112  m_assembly->clear();
113  m_update->clear();
114  // Add the assembly, depending on the use of specialized code or not
115  const bool use_specializations = options().value<bool>("use_specializations");
116  set_triag_assembly(use_specializations);
117  set_tetra_assembly(use_specializations);
121 
123  {
124  Handle<InitialConditions> solver_ic(m_initial_conditions->parent());
125  cf3_assert(is_not_null(solver_ic));
126  solver_ic->remove_component(*m_initial_conditions);
127  m_initial_conditions = solver_ic->create_initial_condition(solution_tag());
128  }
129 
130  m_update->add_component(create_proto_action("Update", nodes_expression(group
131  (
132  u3 = u2,
133  u2 = u1,
134  u1 = u,
135  u += solution(u),
136  p += solution(p)
137  ))));
138 
139  if(is_not_null(m_physical_model))
140  {
141  configure_option_recursively(solver::Tags::physical_model(), m_physical_model);
142  }
143 
144  // Ensure the initial condition field list gets updated
146  m_initial_conditions->options().set("field_tag", solution_tag());
147 
148  configure_option_recursively(solver::Tags::regions(), options().option(solver::Tags::regions()).value());
149 }
150 
152 {
153  // Initial condition for the viscosity, defaulting to the molecular viscosity
154  Handle<ProtoAction> visc_ic(initial_conditions.create_initial_condition("navier_stokes_viscosity", "cf3.solver.ProtoAction"));
155  visc_ic->set_expression(nodes_expression(nu_eff = nu));
156 
157  // Initial condition for the temperature field, defaulting to the reference temperature
158  Handle<ProtoAction> temp_ic(initial_conditions.create_initial_condition("scalar_advection_solution", "cf3.solver.ProtoAction"));
159  temp_ic->set_expression(nodes_expression(T = Tref));
160 
162 
163  // Use a proto action to set the linearized_velocity easily
164  Handle<ProtoAction> lin_vel_ic (initial_conditions.create_initial_condition("linearized_velocity", "cf3.solver.ProtoAction"));
165  lin_vel_ic->set_expression(nodes_expression(group(u_adv = u, u1 = u, u2 = u, u3 = u)));
166 }
167 
168 
169 } // UFEM
170 } // cf3
Handle< solver::ActionDirector > m_assembly
std::string name(ComponentWrapper &self)
PhysicsConstant Tref
const solver::actions::Proto::SolutionVector & solution
Proto placeholder for the solution vector.
Definition: LSSAction.hpp:109
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
void set_solution_tag(const std::string &tag)
Set the tag used to keep track of what field stores the solution to the LSS.
Definition: LSSAction.cpp:354
void configure_option_recursively(const std::string &optname, const boost::any &val)
Definition: Component.cpp:1157
FieldVariable< 3, VectorField > u1
Velocity at time n-1.
#define cf3_assert(a)
Definition: Assertions.hpp:93
PropertyList & add(const std::string &name, const boost::any &value)
adds a property to the list
void set_tetra_assembly(const bool use_specialization)
virtual void on_initial_conditions_set(InitialConditions &initial_conditions)
Called when the initial condition manager is changed.
FieldVariable< 4, VectorField > u2
Velocity at time n-2.
Holds the Component class, as well as the ComponentIterator class plus some functions related to comp...
std::string solution_tag()
Access to the tag this component uses for finding its solution field.
Definition: LSSAction.cpp:349
void trigger_assembly()
Create the solver structure, based on the choice of specialized code.
ComponentBuilder< NavierStokes, LSSActionUnsteady, LibUFEM > NavierStokes_builder
PropertyList & properties()
Definition: Component.cpp:842
InitialConditions for UFEM problems.
void set_triag_assembly(const bool use_specialization)
Helper functions to split the compilation over multiple units, to save memory. Each one is in a diffe...
Component & add_component(const boost::shared_ptr< Component > &subcomp)
Add the passed component as a subcomponent.
Definition: Component.cpp:289
NavierStokes(const std::string &name)
Top-level namespace for coolfluid.
Definition: Action.cpp:18
FieldVariable< 5, VectorField > u3
Velocity at time n-3.
const TYPE value(const std::string &opt_name) const
Get the value of the option with given name.
Definition: OptionList.hpp:104
solver::actions::Proto::MakeSFOp< ComputeTauImpl >::stored_type data
Definition: SUPG.hpp:246
FieldVariable< 7, ScalarField > T
Temperature field.
FieldVariable< 2, VectorField > u_adv
The linearized advection velocity.
FieldVariable< 1, ScalarField > p
The pressure solution field.
FieldVariable< 0, VectorField > u
The velocity solution field.
FieldVariable< 6, ScalarField > nu_eff
Effective viscosity field.
static boost::proto::terminal< ExpressionGroupTag >::type group
Use group(expr1, expr2, ..., exprN) to evaluate a group of expressions.
boost::shared_ptr< ProtoAction > create_proto_action(const std::string &name, const boost::shared_ptr< Expression > &expression)
Create a new ProtoAction, immediatly setting the expression.
boost::shared_ptr< NodesExpression< ExprT, boost::mpl::range_c< Uint, 1, 4 > > > nodes_expression(const ExprT &expr)
Definition: Expression.hpp:308
Handle< common::Action > m_initial_conditions
Handle< common::Action > create_initial_condition(const std::string &tag, const std::string &builder_name="cf3.UFEM.InitialConditionConstant")
OptionList & options()
Definition: Component.cpp:856
SelectOptionType< T >::type & add(const std::string &name, const T &default_value=T())
Definition: OptionList.hpp:45
Handle< solver::ActionDirector > m_update
void set(const std::string &pname, const boost::any &val)
Definition: OptionList.cpp:132
bool is_not_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:147
Send comments to:
COOLFluiD Web Admin