AQUAgpusph 4.1.2
Loading...
Searching...
No Matches
ProblemSetup.h
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
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.h>
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
115 {
116 public:
118 sphSettings();
121
132
145
152 std::string base_path;
153
164 class device
165 {
166 public:
174 device(const unsigned int platform_index,
175 const unsigned int device_index,
176 const cl_device_type t = CL_DEVICE_TYPE_ALL)
177 : platform_id(platform_index)
178 , device_id(device_index)
179 , device_type(t){};
180
183
192 unsigned int platform_id;
193
206 unsigned int device_id;
207
216 cl_device_type device_type;
217 };
218
228 std::vector<ProblemSetup::sphSettings::device> devices;
229 };
230
233
262 {
263 public:
268
270 std::vector<std::string> names;
272 std::vector<std::string> types;
274 std::vector<std::string> lengths;
276 std::vector<std::string> values;
277
291 void registerVariable(std::string name,
292 std::string type,
293 std::string length,
294 std::string value);
295 };
296
299
324 {
329
331 std::vector<std::string> names;
333 std::vector<std::string> values;
337 std::vector<bool> evaluations;
338
349 void define(const std::string name,
350 const std::string value,
351 const bool evaluate);
352
357 bool isDefined(std::string name);
358
362 void undefine(std::string name);
363 };
364
367
372 {
373 public:
377
381
386 void set(const std::string name, const std::string value);
387
392 const std::string get(const std::string name);
393
398 const std::string get(unsigned int index);
399
404 const std::string getName(unsigned int index);
405
409 unsigned int n() const { return _data.size(); }
410
411 private:
416 bool has(const std::string name);
417
419 std::map<std::string, std::string> _data;
420 };
421
423 std::vector<sphTool*> tools;
424
435 unsigned int toolInstances(ProblemSetup::sphTool* tool);
436
442 std::vector<sphTool*> reports;
443
460 {
476 unsigned int sim_end_mode;
477
489
501
513
532 unsigned int output_mode;
533
545
557
577 unsigned int dt_mode;
579
602 {
603 public:
606
609
613 void n(unsigned int N) { _n = N; }
614
618 unsigned int n() const { return _n; }
619
625 void addScalar(std::string name, std::string value);
626
630 std::vector<std::string> scalarNames() const { return _snames; }
631
635 std::vector<std::string> scalarValues() const { return _svalues; }
636
650 void input(std::string path, std::string format, std::string fields);
651
656 const std::string inputPath() const { return _in_path; }
657
662 const std::string inputFormat() const { return _in_format; }
663
668 std::vector<std::string> inputFields() const { return _in_fields; }
669
688 void output(std::string path, std::string format, std::string fields);
689
694 const std::string outputPath() const { return _out_path; }
695
700 const std::string outputFormat() const { return _out_format; }
701
706 std::vector<std::string> outputFields() const { return _out_fields; }
707
708 private:
710 unsigned int _n;
711
713 std::vector<std::string> _snames;
715 std::vector<std::string> _svalues;
716
718 std::string _in_path;
719
721 std::string _in_format;
722
724 std::vector<std::string> _in_fields;
725
727 std::string _out_path;
728
730 std::string _out_format;
731
733 std::vector<std::string> _out_fields;
734 };
735
737 std::vector<sphParticlesSet*> sets;
738
739 private:
741 bool _copy;
742};
743
744}
745} // namespace
746
747#endif // PROBLEMSETUP_H_INCLUDED
Particles set data.
Definition: ProblemSetup.h:602
void n(unsigned int N)
Set the number of particles.
Definition: ProblemSetup.h:613
void addScalar(std::string name, std::string value)
Add a scalar property for this particles set.
Definition: ProblemSetup.cpp:212
~sphParticlesSet()
Destructor.
Definition: ProblemSetup.cpp:209
const std::string outputPath() const
Get the output file path.
Definition: ProblemSetup.h:694
const std::string inputPath() const
Get the file path from the particles would be read.
Definition: ProblemSetup.h:656
void output(std::string path, std::string format, std::string fields)
Set the file path where the particles should be written.
Definition: ProblemSetup.cpp:234
std::vector< std::string > scalarValues() const
Get the scalar values list.
Definition: ProblemSetup.h:635
const std::string outputFormat() const
Get the output file format.
Definition: ProblemSetup.h:700
std::vector< std::string > scalarNames() const
Get the scalar names list.
Definition: ProblemSetup.h:630
const std::string inputFormat() const
Get the input file format.
Definition: ProblemSetup.h:662
std::vector< std::string > outputFields() const
Get the output file fields.
Definition: ProblemSetup.h:706
unsigned int n() const
Get the number of particles.
Definition: ProblemSetup.h:618
void input(std::string path, std::string format, std::string fields)
Set the file path from which the particles should be read.
Definition: ProblemSetup.cpp:219
sphParticlesSet()
Constructor.
Definition: ProblemSetup.cpp:204
std::vector< std::string > inputFields() const
Get the input file fields.
Definition: ProblemSetup.h:668
General program settings.
Definition: ProblemSetup.h:165
unsigned int platform_id
Index of the OpenCL platform to use.
Definition: ProblemSetup.h:192
unsigned int device_id
Index of the OpenCL device to use in the platform platform_id.
Definition: ProblemSetup.h:206
cl_device_type device_type
Type of devices that will be considered in the platform platform_id.
Definition: ProblemSetup.h:216
device(const unsigned int platform_index, const unsigned int device_index, const cl_device_type t=CL_DEVICE_TYPE_ALL)
Constructor.
Definition: ProblemSetup.h:174
~device()
Destructor.
Definition: ProblemSetup.h:182
General program settings.
Definition: ProblemSetup.h:115
std::string base_path
AQUAgpusph root path.
Definition: ProblemSetup.h:152
bool save_on_fail
Save the output in case of failure.
Definition: ProblemSetup.h:131
~sphSettings()
Destructor.
Definition: ProblemSetup.h:120
std::vector< ProblemSetup::sphSettings::device > devices
The list of devices to be considered.
Definition: ProblemSetup.h:228
sphSettings()
Constructor.
Definition: ProblemSetup.cpp:82
bool debug_tools
Setup the tools debugging mode.
Definition: ProblemSetup.h:144
Tool to be executed.
Definition: ProblemSetup.h:372
~sphTool()
Definition: ProblemSetup.h:380
sphTool()
Definition: ProblemSetup.h:376
const std::string get(const std::string name)
Definition: ProblemSetup.cpp:152
const std::string getName(unsigned int index)
Definition: ProblemSetup.cpp:171
void set(const std::string name, const std::string value)
Definition: ProblemSetup.cpp:142
unsigned int n() const
Definition: ProblemSetup.h:409
Simulation variables registered.
Definition: ProblemSetup.h:262
std::vector< std::string > values
Values.
Definition: ProblemSetup.h:276
std::vector< std::string > types
Type of variables.
Definition: ProblemSetup.h:272
void registerVariable(std::string name, std::string type, std::string length, std::string value)
Add a new variable.
Definition: ProblemSetup.cpp:90
~sphVariables()
Destructor.
Definition: ProblemSetup.h:267
std::vector< std::string > names
Name of the variables.
Definition: ProblemSetup.h:270
sphVariables()
Constructor.
Definition: ProblemSetup.h:265
std::vector< std::string > lengths
Lengths.
Definition: ProblemSetup.h:274
Simulation configuration data.
Definition: ProblemSetup.h:91
std::vector< sphTool * > tools
Array of tools.
Definition: ProblemSetup.h:423
sphVariables variables
Variables storage.
Definition: ProblemSetup.h:298
unsigned int toolInstances(ProblemSetup::sphTool *tool)
Helper function to get the number of already defined instances of the same tool.
Definition: ProblemSetup.cpp:193
ProblemSetup()
Constructor.
Definition: ProblemSetup.cpp:34
sphDefinitions definitions
Definitions storage.
Definition: ProblemSetup.h:366
std::vector< sphTool * > reports
Array of reports.
Definition: ProblemSetup.h:442
struct Aqua::InputOutput::ProblemSetup::sphTimingParameters time_opts
std::vector< sphParticlesSet * > sets
Array of particles sets.
Definition: ProblemSetup.h:737
sphSettings settings
Stored settings.
Definition: ProblemSetup.h:232
~ProblemSetup()
Destructor.
Definition: ProblemSetup.cpp:58
__kernel void fields(__global const unsigned int *iset, __global const uint *isplit, __global const uint *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, __global const uint *icell, __global const uint *ihoc, __constant float *dr_level0, unsigned int N, uivec4 n_cells)
Collect the children, and the seed itself, in order to compute the field values of the buffer partner...
Definition: Coalesce.cl:435
Main AQUAgpusph namespace.
Definition: ArgumentsManager.cpp:45
float length(vec v)
Compute the vector length.
Definition: AuxiliarMethods.cpp:521
Set of definitions and macros related with the implementation.
OpenCL kernels compilation definitions.
Definition: ProblemSetup.h:324
void undefine(std::string name)
Undefine a registered definition.
Definition: ProblemSetup.cpp:128
sphDefinitions()
Constructor.
Definition: ProblemSetup.h:326
~sphDefinitions()
Destructor.
Definition: ProblemSetup.h:328
std::vector< std::string > names
Name of the definition.
Definition: ProblemSetup.h:331
std::vector< std::string > values
Value of the definition, empty for named definitions.
Definition: ProblemSetup.h:333
bool isDefined(std::string name)
Reports if a the required name has been already defined.
Definition: ProblemSetup.cpp:116
std::vector< bool > evaluations
Definition: ProblemSetup.h:337
void define(const std::string name, const std::string value, const bool evaluate)
Add a new definition.
Definition: ProblemSetup.cpp:102
Simulation time flow options.
Definition: ProblemSetup.h:460
unsigned int dt_mode
Time step computation method.
Definition: ProblemSetup.h:577
unsigned int sim_end_mode
Simulation finish criteria to apply.
Definition: ProblemSetup.h:476
int output_ipf
Particles output updating rate.
Definition: ProblemSetup.h:556
float sim_end_time
Simulation finish time instant.
Definition: ProblemSetup.h:488
int sim_end_step
Total number of time steps to compute.
Definition: ProblemSetup.h:500
float output_fps
Particles output updating rate.
Definition: ProblemSetup.h:544
unsigned int output_mode
Particles output updating criteria to apply.
Definition: ProblemSetup.h:532
int sim_end_frame
Total number of output frames to write.
Definition: ProblemSetup.h:512