COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Solver.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 
9 #include "common/OptionT.hpp"
10 #include "common/OptionList.hpp"
11 #include "common/OptionURI.hpp"
12 #include "common/PropertyList.hpp"
13 #include "common/Signal.hpp"
14 
15 #include "math/VariableManager.hpp"
16 
17 #include "mesh/Domain.hpp"
18 #include "mesh/FieldManager.hpp"
19 
20 #include "physics/PhysModel.hpp"
21 
22 #include "solver/Solver.hpp"
23 #include "solver/Tags.hpp"
24 
25 namespace cf3 {
26 namespace solver {
27 
28 using namespace common;
29 using namespace mesh;
30 
32 
34 
36 
37  Implementation(Component& component) :
38  m_component(component),
39  m_field_manager(*component.create_static_component<FieldManager>("FieldManager"))
40  {
41  }
42 
44  {
45  // This will set the domain to null if the URI is invalid,
46  // errors are reported through domain() on access.
47  // Rationale: the URI may be set before the domain is created
48  m_domain = Handle<Domain>(m_component.access_component(m_domain_uri));
49  }
50 
51  // Checked access to the domain
53  {
54  if(is_null(m_domain))
55  {
56  Handle< Component > comp = m_component.access_component(m_domain_uri);
57 
58  if(!comp)
59  throw SetupError(FromHere(), "No component found at URI " + m_domain_uri.string() + " when acessing domain from " + m_component.uri().string());
60 
61  m_domain = Handle<Domain>(comp);
62 
63  if(is_null(m_domain))
64  throw SetupError(FromHere(), "Error while acessing domain from " + m_component.uri().string() + ": component at " + m_domain_uri.string() + " is not a domain");
65  }
66 
67  return *m_domain;
68  }
69 
74 };
75 
77 
78 Solver::Solver ( const std::string& name ) :
79  ActionDirector ( name ),
80  m_implementation(new Implementation(*this))
81 {
82  mark_basic();
83 
84  // properties
85 
86  properties()["brief"] = std::string("Solver");
87  properties()["description"] = std::string("");
88 
89  // options
90 
91  options().add(Tags::domain(), URI("cpath:../Domain"))
92  .description("Domain to solve")
93  .pretty_name("Domain")
94  .link_to(&m_implementation->m_domain_uri)
95  .attach_trigger(boost::bind(&Implementation::trigger_domain, m_implementation.get()));
96 
97  options().add(Tags::physical_model(), m_physics)
98  .pretty_name("Physical Model")
99  .description("Physical Model")
100  .link_to(&m_physics)
101  .attach_trigger(boost::bind(&Solver::trigger_physical_model, this));
102 }
103 
104 
105 
107 {
108 }
109 
110 
112 
114 
116 {
117  return m_implementation->m_field_manager;
118 }
119 
120 
122 {
123  return m_implementation->domain();
124 }
125 
127 {
128  if(is_null(m_physics))
129  throw SetupError(FromHere(), "No physical model configured for " + uri().string());
130 
131  return *m_physics;
132 }
133 
135 {
136  m_implementation->m_field_manager.options().set("variable_manager", m_physics->variable_manager().handle<math::VariableManager>());
137 }
138 
139 
140 
142 
143 } // solver
144 } // cf3
std::string name(ComponentWrapper &self)
bool is_null(T ptr)
predicate for comparison to nullptr
Definition: CF.hpp:151
RegistTypeInfo< Solver, LibSolver > regist_Solver_type
Definition: Solver.cpp:31
mesh::FieldManager & field_manager()
Access to the FieldManager, which is a static subcomponent of Solver.
Definition: Solver.cpp:115
Handle< physics::PhysModel > m_physics
Raw access to the physics.
Definition: Solver.hpp:64
URI uri() const
Construct the full path.
Definition: Component.cpp:248
physics::PhysModel & physics()
Checked access to the physical model.
Definition: Solver.cpp:126
void trigger_physical_model()
Definition: Solver.cpp:134
Implementation(Component &component)
Definition: Solver.cpp:37
PropertyList & properties()
Definition: Component.cpp:842
boost::scoped_ptr< Implementation > m_implementation
Definition: Solver.hpp:69
Top-level namespace for coolfluid.
Definition: Action.cpp:18
Solver(const std::string &name)
Definition: Solver.cpp:78
virtual void mesh_loaded(mesh::Mesh &mesh)
Called when a mesh is loaded into the domain that is associated with this solver. ...
Definition: Solver.cpp:111
virtual ~Solver()
Virtual destructor.
Definition: Solver.cpp:106
virtual void mesh_changed(mesh::Mesh &mesh)
Called when a mesh is changed into the domain that is associated with this solver.
Definition: Solver.cpp:113
mesh::Domain & domain()
Checked access to the domain (throws if domain is not properly configured)
Definition: Solver.cpp:121
Handle< Component > handle()
Get a handle to the component.
Definition: Component.hpp:179
math::VariableManager & variable_manager()
Access to the VariableManager.
Definition: PhysModel.cpp:42
OptionList & options()
Definition: Component.cpp:856
Component & mark_basic()
marks this component as basic.
Definition: Component.cpp:1076
SelectOptionType< T >::type & add(const std::string &name, const T &default_value=T())
Definition: OptionList.hpp:45
Base class for defining CF components.
Definition: Component.hpp:82
#define FromHere()
Send comments to:
COOLFluiD Web Admin