AQUAgpusph 5.0.4
Loading...
Searching...
No Matches
ProblemSetup.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 PROBLEMSETUP_H_INCLUDED
25#define PROBLEMSETUP_H_INCLUDED
26
30#define __NO_OUTPUT_MODE__ 0
35#define __FPS_MODE__ 1 << 0
40#define __IPF_MODE__ 1 << 1
45#define __TIME_MODE__ 1 << 0
50#define __ITER_MODE__ 1 << 1
55#define __FRAME_MODE__ 1 << 2
56
57#include "sphPrerequisites.hpp"
58
59#include <math.h>
60#include <string>
61#include <vector>
62#include <vector>
63#include <map>
64
65#if __APPLE__
66#include <OpenCL/cl.h>
67#else
68#include <CL/cl.h>
69#endif
70
71namespace Aqua {
72namespace InputOutput {
73
91{
92 public:
96
98 ProblemSetup(const ProblemSetup& p);
99
103
107 inline void dims(unsigned int n) { _dims = n; }
108
112 inline unsigned int dims() const { return _dims; }
113
119 inline void nCmdQueues(unsigned int n) { _n_cmd_queues = n; }
120
126 inline unsigned int nCmdQueues() const { return _n_cmd_queues; }
127
139 {
140 public:
142 sphSettings();
145
156
158 typedef enum _debug {
169 } debug_opts;
170
187
194 std::string base_path;
195
206 class device
207 {
208 public:
210 typedef enum _patch {
212 AUTO = 0,
217 } patch_state;
218
229 device(const unsigned int platform_index,
230 const unsigned int device_index,
231 const cl_device_type t = CL_DEVICE_TYPE_ALL,
232 const unsigned int bits = 32,
233 const std::string compile_flags = "")
234 : platform_id(platform_index)
235 , device_id(device_index)
236 , device_type(t)
237 , addr_bits(bits)
238 , compilation_flags(compile_flags)
239 , patches({{"nvidia_#4665567", patch_state::AUTO},
240 {"nvidia_#9999999", patch_state::AUTO},
241 })
242 {};
243
246
255 unsigned int platform_id;
256
269 unsigned int device_id;
270
279 cl_device_type device_type;
280
290 unsigned int addr_bits;
291
306 std::string compilation_flags;
307
330 std::map<std::string, int> patches;
331
337 inline bool isPatchEnabled(const std::string name) const
338 {
339 return patches.at(name) == patch_state::ENABLED;
340 }
341
347 inline bool isPatchDisabled(const std::string name) const
348 {
349 return patches.at(name) == patch_state::DISABLED;
350 }
351 };
352
362 std::vector<ProblemSetup::sphSettings::device> devices;
363
364 };
365
368
397 {
398 public:
403
405 std::vector<std::string> names;
407 std::vector<std::string> types;
409 std::vector<std::string> lengths;
411 std::vector<std::string> values;
412
426 void registerVariable(std::string name,
427 std::string type,
428 std::string length,
429 std::string value);
430 };
431
434
459 {
464
466 std::vector<std::string> names;
468 std::vector<std::string> values;
472 std::vector<bool> evaluations;
473
484 void define(const std::string name,
485 const std::string value,
486 const bool evaluate);
487
492 bool isDefined(std::string name);
493
497 void undefine(std::string name);
498 };
499
502
507 {
508 public:
512
516
521 void set(const std::string name, const std::string value);
522
527 const std::string get(const std::string name);
528
533 const std::string get(unsigned int index);
534
539 const std::string getName(unsigned int index);
540
544 unsigned int n() const { return _data.size(); }
545
546 private:
551 bool has(const std::string name);
552
554 std::map<std::string, std::string> _data;
555 };
556
558 std::vector<sphTool*> tools;
559
570 unsigned int toolInstances(ProblemSetup::sphTool* tool);
571
577 std::vector<sphTool*> reports;
578
595 {
611 unsigned int sim_end_mode;
612
624
636
648
667 unsigned int output_mode;
668
680
692
712 unsigned int dt_mode;
713 } time_opts;
714
737 {
738 public:
741
744
748 void n(size_t N) { _n = N; }
749
753 size_t n() const { return _n; }
754
760 void addScalar(std::string name, std::string value);
761
765 std::vector<std::string> scalarNames() const { return _snames; }
766
770 std::vector<std::string> scalarValues() const { return _svalues; }
771
785 void input(std::string path, std::string format, std::string fields);
786
791 const std::string inputPath() const { return _in_path; }
792
797 const std::string inputFormat() const { return _in_format; }
798
803 std::vector<std::string> inputFields() const { return _in_fields; }
804
823 void output(std::string path, std::string format, std::string fields);
824
829 const std::string outputPath() const { return _out_path; }
830
835 const std::string outputFormat() const { return _out_format; }
836
841 std::vector<std::string> outputFields() const { return _out_fields; }
842
843 private:
845 size_t _n;
846
848 std::vector<std::string> _snames;
850 std::vector<std::string> _svalues;
851
853 std::string _in_path;
854
856 std::string _in_format;
857
859 std::vector<std::string> _in_fields;
860
862 std::string _out_path;
863
865 std::string _out_format;
866
868 std::vector<std::string> _out_fields;
869 };
870
872 std::vector<sphParticlesSet*> sets;
873
874 private:
876 unsigned int _dims;
877
881 unsigned int _n_cmd_queues;
882
884 bool _copy;
885};
886
887}
888} // namespace
889
890#endif // PROBLEMSETUP_H_INCLUDED
static PyObject * get(PyObject UNUSED_PARAM *self, PyObject *args, PyObject *keywds)
Get a variable by its name.
Definition Python.cpp:73
static PyObject * set(PyObject UNUSED_PARAM *self, PyObject *args, PyObject *keywds)
Set a variable by its name.
Definition Python.cpp:108
size_t n() const
Get the number of particles.
Definition ProblemSetup.hpp:753
const std::string outputPath() const
Get the output file path.
Definition ProblemSetup.hpp:829
void n(size_t N)
Set the number of particles.
Definition ProblemSetup.hpp:748
const std::string inputPath() const
Get the file path from the particles would be read.
Definition ProblemSetup.hpp:791
std::vector< std::string > scalarValues() const
Get the scalar values list.
Definition ProblemSetup.hpp:770
const std::string outputFormat() const
Get the output file format.
Definition ProblemSetup.hpp:835
std::vector< std::string > scalarNames() const
Get the scalar names list.
Definition ProblemSetup.hpp:765
const std::string inputFormat() const
Get the input file format.
Definition ProblemSetup.hpp:797
std::vector< std::string > outputFields() const
Get the output file fields.
Definition ProblemSetup.hpp:841
sphParticlesSet()
Constructor.
Definition ProblemSetup.cpp:214
std::vector< std::string > inputFields() const
Get the input file fields.
Definition ProblemSetup.hpp:803
unsigned int platform_id
Index of the OpenCL platform to use.
Definition ProblemSetup.hpp:255
std::string compilation_flags
Extra flags considered by this device when compiling kernels.
Definition ProblemSetup.hpp:306
device(const unsigned int platform_index, const unsigned int device_index, const cl_device_type t=CL_DEVICE_TYPE_ALL, const unsigned int bits=32, const std::string compile_flags="")
Constructor.
Definition ProblemSetup.hpp:229
bool isPatchDisabled(const std::string name) const
Is the patch disabled?
Definition ProblemSetup.hpp:347
unsigned int device_id
Index of the OpenCL device to use in the platform platform_id.
Definition ProblemSetup.hpp:269
std::map< std::string, int > patches
List of patchs to be forcibly enabled/disabled.
Definition ProblemSetup.hpp:330
_patch
Possible patch enabling states.
Definition ProblemSetup.hpp:210
@ ENABLED
Enabled.
Definition ProblemSetup.hpp:214
@ DISABLED
Disabled.
Definition ProblemSetup.hpp:216
@ AUTO
Let AQUAgpusph decide.
Definition ProblemSetup.hpp:212
unsigned int addr_bits
Address bits of the device.
Definition ProblemSetup.hpp:290
cl_device_type device_type
Type of devices that will be considered in the platform platform_id.
Definition ProblemSetup.hpp:279
bool isPatchEnabled(const std::string name) const
Is the patch enabled?
Definition ProblemSetup.hpp:337
~device()
Destructor.
Definition ProblemSetup.hpp:245
General program settings.
Definition ProblemSetup.hpp:139
std::string base_path
AQUAgpusph root path.
Definition ProblemSetup.hpp:194
bool save_on_fail
Save the output in case of failure.
Definition ProblemSetup.hpp:155
~sphSettings()
Destructor.
Definition ProblemSetup.hpp:144
std::vector< ProblemSetup::sphSettings::device > devices
The list of devices to be considered.
Definition ProblemSetup.hpp:362
sphSettings()
Constructor.
Definition ProblemSetup.cpp:86
int debug_tools
Debugging mode.
Definition ProblemSetup.hpp:186
_debug
Possible debugging modes.
Definition ProblemSetup.hpp:158
@ DEBUG_ARGS
Print information about kernel arguments setting.
Definition ProblemSetup.hpp:164
@ DEBUG_SYNC
Wait for a tool to finish right after executing it.
Definition ProblemSetup.hpp:168
@ DEBUG_DEPS_SYNC
Wait for a tool dependencies to finish after executing it.
Definition ProblemSetup.hpp:166
@ DEBUG_EVENTS
Print information about the events and tools execution.
Definition ProblemSetup.hpp:162
@ NO_DEBUG
Do not debug.
Definition ProblemSetup.hpp:160
Tool to be executed.
Definition ProblemSetup.hpp:507
~sphTool()
Definition ProblemSetup.hpp:515
sphTool()
Definition ProblemSetup.hpp:511
unsigned int n() const
Definition ProblemSetup.hpp:544
Simulation variables registered.
Definition ProblemSetup.hpp:397
std::vector< std::string > values
Values.
Definition ProblemSetup.hpp:411
std::vector< std::string > types
Type of variables.
Definition ProblemSetup.hpp:407
void registerVariable(std::string name, std::string type, std::string length, std::string value)
Add a new variable.
Definition ProblemSetup.cpp:100
~sphVariables()
Destructor.
Definition ProblemSetup.hpp:402
std::vector< std::string > names
Name of the variables.
Definition ProblemSetup.hpp:405
sphVariables()
Constructor.
Definition ProblemSetup.hpp:400
std::vector< std::string > lengths
Lengths.
Definition ProblemSetup.hpp:409
std::vector< sphTool * > tools
Array of tools.
Definition ProblemSetup.hpp:558
sphVariables variables
Variables storage.
Definition ProblemSetup.hpp:433
unsigned int toolInstances(ProblemSetup::sphTool *tool)
Helper function to get the number of already defined instances of the same tool.
Definition ProblemSetup.cpp:203
unsigned int dims() const
Get the the number of dimensions.
Definition ProblemSetup.hpp:112
ProblemSetup()
Constructor.
Definition ProblemSetup.cpp:34
sphDefinitions definitions
Definitions storage.
Definition ProblemSetup.hpp:501
unsigned int nCmdQueues() const
Get the maximum number of main OpenCL queues to be spawned.
Definition ProblemSetup.hpp:126
std::vector< sphTool * > reports
Array of reports.
Definition ProblemSetup.hpp:577
void nCmdQueues(unsigned int n)
Set the maximum number of main OpenCL queues to be spawned.
Definition ProblemSetup.hpp:119
std::vector< sphParticlesSet * > sets
Array of particles sets.
Definition ProblemSetup.hpp:872
void dims(unsigned int n)
Set the number of dimensions.
Definition ProblemSetup.hpp:107
sphSettings settings
Stored settings.
Definition ProblemSetup.hpp:367
__kernel void fields(__global const unsigned int *iset, __global const uint *isplit, __global const usize *mybuffer, __global const unsigned int *ilevel, __global const float *split_weight, __global float *m0, __global float *m, __global vec *r, __global vec *u, __global vec *dudt, __global float *rho, __global float *drhodt, __constant float *dr_level0, usize N, LINKLIST_LOCAL_PARAMS)
Collect the children, and the seed itself, in order to compute the field values of the buffer partner...
Definition Coalesce.cl:426
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50
Set of definitions and macros related with the implementation.
#define DECLDIR
Prefix to export C functions on the compiled library.
Definition sphPrerequisites.hpp:65
OpenCL kernels compilation definitions.
Definition ProblemSetup.hpp:459
void undefine(std::string name)
Undefine a registered definition.
Definition ProblemSetup.cpp:138
sphDefinitions()
Constructor.
Definition ProblemSetup.hpp:461
~sphDefinitions()
Destructor.
Definition ProblemSetup.hpp:463
std::vector< std::string > names
Name of the definition.
Definition ProblemSetup.hpp:466
std::vector< std::string > values
Value of the definition, empty for named definitions.
Definition ProblemSetup.hpp:468
bool isDefined(std::string name)
Reports if a the required name has been already defined.
Definition ProblemSetup.cpp:126
std::vector< bool > evaluations
Definition ProblemSetup.hpp:472
void define(const std::string name, const std::string value, const bool evaluate)
Add a new definition.
Definition ProblemSetup.cpp:112
Simulation time flow options.
Definition ProblemSetup.hpp:595
unsigned int dt_mode
Time step computation method.
Definition ProblemSetup.hpp:712
unsigned int sim_end_mode
Simulation finish criteria to apply.
Definition ProblemSetup.hpp:611
int output_ipf
Particles output updating rate.
Definition ProblemSetup.hpp:691
float sim_end_time
Simulation finish time instant.
Definition ProblemSetup.hpp:623
int sim_end_step
Total number of time steps to compute.
Definition ProblemSetup.hpp:635
float output_fps
Particles output updating rate.
Definition ProblemSetup.hpp:679
unsigned int output_mode
Particles output updating criteria to apply.
Definition ProblemSetup.hpp:667
int sim_end_frame
Total number of output frames to write.
Definition ProblemSetup.hpp:647