mantaflow  0.10
A framework for fluid simulation
fluidsolver.h
Go to the documentation of this file.
1 
2 /******************************************************************************
3  *
4  * MantaFlow fluid solver framework
5  * Copyright 2011 Tobias Pfaff, Nils Thuerey
6  *
7  * This program is free software, distributed under the terms of the
8  * GNU General Public License (GPL)
9  * http://www.gnu.org/licenses
10  *
11  * Main class for the fluid solver
12  *
13  ******************************************************************************/
14 
15 #ifndef _FLUIDSOLVER_H
16 #define _FLUIDSOLVER_H
17 
18 #include "manta.h"
19 #include "vectorbase.h"
20 #include "vector4d.h"
21 #include <vector>
22 #include <map>
23 
24 namespace Manta {
25 
28 PYTHON class FluidSolver : public PbClass {
29 public:
30  PYTHON() FluidSolver(Vec3i gridSize, int dim=3, int fourthDim=-1);
31  virtual ~FluidSolver();
32 
33  // accessors
34  PYTHON() Vec3i getGridSize() { return mGridSize; }
35  inline Real getDt() { return mDt; }
36  inline Real getDx() { return 1.0 / mGridSize.max(); }
37  inline Real getTime() { return mTimeTotal; }
38 
40  inline bool is2D() const { return mDim==2; }
42  inline bool is3D() const { return mDim==3; }
43 
44  PYTHON() void printMemInfo();
45 
47  PYTHON() void step();
48 
50  PYTHON() void adaptTimestep(Real maxVel);
51 
53  PYTHON() PbClass* create(PbType type, PbTypeVec T=PbTypeVec(),const std::string& name = "");
54 
55  // temp grid and plugin functions: you shouldn't call this manually
56  template<class T> T* getGridPointer();
57  template<class T> void freeGridPointer(T* ptr);
58 
60  PYTHON(name=timestep) Real mDt;
61  PYTHON(name=timeTotal) Real mTimeTotal;
62  PYTHON(name=frame) int mFrame;
64  PYTHON(name=cfl) Real mCflCond;
65  PYTHON(name=timestepMin) Real mDtMin;
66  PYTHON(name=timestepMax) Real mDtMax;
67  PYTHON(name=frameLength) Real mFrameLength;
68 
69 protected:
70  Vec3i mGridSize;
71  const int mDim;
72  Real mTimePerFrame;
73  bool mLockDt;
74 
77  template<class T> struct GridStorage {
78  GridStorage() : used(0) {}
79  T* get(Vec3i size);
80  void free();
81  void release(T* ptr);
82 
83  std::vector<T*> grids;
84  int used;
85  };
86 
89  GridStorage<Real> mGridsReal;
90  GridStorage<Vec3> mGridsVec;
91 
92 
94 
95 public:
97  inline bool supports4D() const { return mFourthDim>0; }
99  inline int getFourthDim() const { return mFourthDim; }
101  template<class T> T* getGrid4dPointer();
102  template<class T> void freeGrid4dPointer(T* ptr);
103 
104 protected:
105 
110 
113  GridStorage<int> mGrids4dInt;
114  GridStorage<Real> mGrids4dReal;
115  GridStorage<Vec3> mGrids4dVec;
116  GridStorage<Vec4> mGrids4dVec4;
117 };
118 
119 }
120 
121 #endif
122 
123 
int mFourthDim
Definition: fluidsolver.h:109
Definition: commonkernels.h:22
GridStorage< int > mGridsInt
memory for regular (3d) grids
Definition: fluidsolver.h:88
int getFourthDim() const
fourth dimension size
Definition: fluidsolver.h:99
Definition: fluidsolver.h:77
bool is3D() const
Check dimensionality (3d or above)
Definition: fluidsolver.h:42
Basic inlined vector class.
Definition: vectorbase.h:71
T * getGrid4dPointer()
4d data allocation
S max() const
Get biggest component.
Definition: vectorbase.h:172
bool supports4D() const
4d data section, only required for simulations working with space-time data
Definition: fluidsolver.h:97
GridStorage< Vec4 > mGridsVec4
4d grid storage
Definition: fluidsolver.h:112
Definition: fluidsolver.h:28
bool is2D() const
Check dimensionality.
Definition: fluidsolver.h:40