AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
SetScalar.hpp
Go to the documentation of this file.
1/*
2 * This file is part of AQUAgpusph, a free CFD program based on SPH.
3 * Copyright (C) 2012 Jose Luis Cercos Pita <jl.cercos@upm.es>
4 *
5 * AQUAgpusph is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * AQUAgpusph is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with AQUAgpusph. If not, see <http://www.gnu.org/licenses/>.
17 */
18
23
24#ifndef SETSCALAR_H_INCLUDED
25#define SETSCALAR_H_INCLUDED
26
27#include "CalcServer.hpp"
28#include "Tool.hpp"
29#include <vector>
30
31namespace Aqua {
32namespace CalcServer {
33
38{
39 public:
44 ScalarProfile(const std::string name, Tool* tool)
45 : Profile(name, tool)
46 {
47 }
48
52
56 inline void start() { _start = CalcServer::host_timer(); }
57
61 inline void end() { sample(_start, CalcServer::host_timer()); }
62
63 private:
65 cl_ulong _start;
66};
67
74{
75 public:
82 ScalarExpression(const std::string name,
83 const std::string expr,
84 const std::string type = "float",
85 bool once = false);
86
89
92 virtual void setup();
93
97 inline const std::string getOutputType() const { return _output_type; }
98
104 void setOutputType(const std::string type);
105
109 inline const std::string getExpression() const { return _value; }
110
114 inline const void* getValue() const { return _output; }
115
125 inline cl_event getUserEvent() const { return _user_event; }
126
136 void solve();
137
138 protected:
143 virtual cl_event _execute(const std::vector<cl_event> events);
144
150 virtual void _solve();
151
152 private:
155 void variables();
156
158 std::string _value;
159
161 std::vector<InputOutput::Variable*> _in_vars;
163 void* _output;
165 std::string _output_type;
166
169 cl_event _user_event;
170};
171
176{
177 public:
184 SetScalar(const std::string name,
185 const std::string var_name,
186 const std::string value,
187 bool once = false);
188
190 ~SetScalar();
191
194 void setup();
195
199 inline InputOutput::Variable* getOutputVariable() const { return _var; }
200
201 protected:
205 void _solve();
206
207 private:
216 InputOutput::Variable* variable(const std::string& name) const;
217
219 std::string _var_name;
220
223};
224
225}
226} // namespace
227
228#endif // SETSCALAR_H_INCLUDED
The calculation main entry point. (See Aqua::CalcServer::CalcServer for details)
Tools virtual environment to allow the user to define/manipulate the tools used to carry out the simu...
static cl_ulong host_timer()
Get the host timer.
Definition CalcServer.hpp:366
void name(const std::string tool_name)
Definition Tool.hpp:66
const std::string name() const
Get the name.
Definition Tool.hpp:71
Profiler subinstance base class.
Definition Tool.hpp:84
Profile(const std::string name, Tool *tool)
Constructor.
Definition Tool.hpp:90
void sample(cl_ulong start, cl_ulong end)
Add profiling info.
Definition Tool.cpp:43
Base class for tools that has to evaluate a scalar expression.
Definition SetScalar.hpp:74
ScalarExpression(const std::string name, const std::string expr, const std::string type="float", bool once=false)
Constructor.
Definition SetScalar.cpp:32
virtual void setup()
Initialize the tool.
Definition SetScalar.cpp:51
void setOutputType(const std::string type)
Set the output typesize.
Definition SetScalar.cpp:62
const std::string getExpression() const
Get the expression to evaluate.
Definition SetScalar.hpp:109
virtual cl_event _execute(const std::vector< cl_event > events)
Definition SetScalar.cpp:146
void solve()
Evaluate the expression and store the value.
Definition SetScalar.cpp:78
const void * getValue() const
Get the stored output value.
Definition SetScalar.hpp:114
cl_event getUserEvent() const
Get the user event generated by this tool to mark when is finished.
Definition SetScalar.hpp:125
~ScalarExpression()
Destructor.
Definition SetScalar.cpp:45
virtual void _solve()
Evaluate the expression and store the value.
Definition SetScalar.cpp:135
const std::string getOutputType() const
Get the output typesize.
Definition SetScalar.hpp:97
void start()
Start sampling.
Definition SetScalar.hpp:56
~ScalarProfile()
Definition SetScalar.hpp:51
ScalarProfile(const std::string name, Tool *tool)
Definition SetScalar.hpp:44
void end()
End sampling.
Definition SetScalar.hpp:61
void setup()
Initialize the tool.
Definition SetScalar.cpp:218
InputOutput::Variable * getOutputVariable() const
Get the output variable.
Definition SetScalar.hpp:199
void _solve()
Evaluate the expression and populate the value on the varaible Aqua::CalcServer::ScalarExpression::_v...
Definition SetScalar.cpp:235
SetScalar(const std::string name, const std::string var_name, const std::string value, bool once=false)
Constructor.
Definition SetScalar.cpp:205
~SetScalar()
Destructor.
Definition SetScalar.cpp:215
Tools base class.
Definition Tool.hpp:176
A generic variable. Almost useless, use the overloaded classes instead of this one.
Definition Variable.hpp:68
Calculation server name space.
Definition Assert.cpp:32
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50