COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
ActionDirector.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"
8 #include "common/Foreach.hpp"
9 #include "common/URI.hpp"
10 #include "common/OptionArray.hpp"
12 #include "common/OptionList.hpp"
13 #include "common/Signal.hpp"
14 
15 #include "mesh/Mesh.hpp"
16 #include "mesh/Region.hpp"
17 
18 #include "physics/PhysModel.hpp"
19 
20 #include "solver/LibSolver.hpp"
21 #include "solver/Time.hpp"
23 #include "solver/Solver.hpp"
24 #include "solver/Tags.hpp"
25 
26 namespace cf3 {
28 namespace solver {
29 
30 
31 using namespace cf3::common;
32 using namespace cf3::mesh;
33 
35 
36 ActionDirector::ActionDirector ( const std::string& name ) :
38 {
39  mark_basic();
40 
41  // options
42 
43  options().add(Tags::solver(), m_solver)
44  .description("Link to the solver discretizing the problem")
45  .pretty_name("Solver")
46  .mark_basic()
47  .link_to(&m_solver);
48 
49  options().add("mesh", m_mesh)
50  .description("Mesh the Discretization Method will be applied to")
51  .pretty_name("Mesh")
52  .mark_basic()
53  .link_to(&m_mesh);
54 
55  options().add(Tags::physical_model(), m_physical_model)
56  .description("Physical model")
57  .pretty_name("Physical Model")
58  .mark_basic()
59  .link_to(&m_physical_model);
60 
61  std::vector< common::URI > dummy;
62  options().add(Tags::regions(), dummy)
63  .description("Regions this action is applied to")
64  .pretty_name("Regions")
65  .attach_trigger ( boost::bind ( &ActionDirector::config_regions, this ) )
66  .mark_basic();
67 }
68 
69 ActionDirector::~ActionDirector() {}
70 
71 
72 physics::PhysModel& ActionDirector::physical_model()
73 {
74  if( is_null(m_physical_model) )
76  "Physical Model not yet set for component " + uri().string() );
77  return *m_physical_model;
78 }
79 
80 
82 {
83  if( is_null(m_mesh) )
85  "Mesh not yet set for component " + uri().string() );
86  return *m_mesh;
87 }
88 
89 
91 {
92  if( is_null(m_solver) )
94  "Solver not yet set for component " + uri().string() );
95  return *m_solver;
96 }
97 
98 void ActionDirector::config_regions()
99 {
100  m_loop_regions.clear();
101 
102  const std::string regions_option_name("regions"); // for Intel Composer 2011...
103  boost_foreach(const common::URI region_uri, options().option(regions_option_name).value< std::vector<common::URI> >())
104  {
105  Handle<Component> comp;
106  if (region_uri.is_relative())
107  {
108  if ( is_null(m_mesh) )
109  throw common::SetupError(FromHere(), "First configure the mesh");
110  comp = m_mesh->access_component(region_uri);
111  }
112  else
113  {
114  comp = access_component(region_uri);
115  }
116 
117  if ( is_null(comp) )
118  {
120  "Could not find region with path [" + region_uri.path() +"]" );
121  }
122  Handle< Region > region = comp->handle<Region>();
123  if ( is_not_null(region) )
124  m_loop_regions.push_back( region );
125  else
127  "Component [" + region_uri.path() +"] is not of type Region" );
128  }
129 
130  on_regions_set();
131 }
132 
133 void ActionDirector::on_regions_set()
134 {
135 }
136 
137 
139 
140 } // solver
141 } // 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< solver::ActionDirector, common::ActionDirector, solver::LibSolver > SolverActionDirector_Builder
std::string path() const
Definition: URI.cpp:253
#define boost_foreach
lowercase version of BOOST_FOREACH
Definition: Foreach.hpp:16
common::URI uri(ComponentWrapper &self)
bool is_relative() const
Definition: URI.cpp:189
Handle< Component > access_component(const URI &path) const
Definition: Component.cpp:487
Uniform Resource Identifier (see http://en.wikipedia.org/wiki/Uniform_Resource_Identifier) ...
Basic Classes for Mesh applications used by COOLFluiD.
Top-level namespace for coolfluid.
Definition: Action.cpp:18
ActionDirector(const std::string &name)
Handle< Component > handle()
Get a handle to the component.
Definition: Component.hpp:179
Most basic kernel library.
Definition: Action.cpp:19
bool is_not_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:147
#define FromHere()
Send comments to:
COOLFluiD Web Admin