tadded ndem parameter, debugging fluid tests - sphere - GPU-based 3D discrete e… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 57d9c42669af9eb387f3053f3176a5ea9c3e4db4 | |
parent deafb0326af3ed38a97ea58293ef1bdced577fd1 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Wed, 30 Apr 2014 08:47:07 +0200 | |
added ndem parameter, debugging fluid tests | |
Diffstat: | |
M python/sphere.py | 42 ++++++++++++++++++++++++++---… | |
M src/constants.h | 3 +-- | |
M src/datatypes.h | 1 + | |
M src/file_io.cpp | 7 ++++--- | |
4 files changed, 42 insertions(+), 11 deletions(-) | |
--- | |
diff --git a/python/sphere.py b/python/sphere.py | |
t@@ -12,7 +12,7 @@ numpy.seterr(all='warn', over='raise') | |
# Sphere version number. This field should correspond to the value in | |
# `../src/constants.h`. | |
-VERSION=1.0 | |
+VERSION=1.01 | |
class sim: | |
''' | |
t@@ -321,6 +321,9 @@ class sim: | |
# The maximum number of iterations to perform per time step | |
self.maxiter = numpy.array(1e4) | |
+ # The number of DEM time steps to perform between CFD updates | |
+ self.ndem = numpy.array(1) | |
+ | |
def __cmp__(self, other): | |
''' | |
t@@ -573,6 +576,9 @@ class sim: | |
elif (self.maxiter != other.maxiter): | |
print(82) | |
return 82 | |
+ elif (self.ndem != other.ndem): | |
+ print(83) | |
+ return 83 | |
# All equal | |
return 0 | |
t@@ -899,6 +905,8 @@ class sim: | |
self.tolerance =\ | |
numpy.fromfile(fh, dtype=numpy.float64, count=1) | |
self.maxiter = numpy.fromfile(fh, dtype=numpy.uint32, count=1) | |
+ if (self.version >= 1.01): | |
+ self.ndem = numpy.fromfile(fh, dtype=numpy.uint32, count=1) | |
finally: | |
if fh is not None: | |
t@@ -1044,6 +1052,7 @@ class sim: | |
fh.write(self.beta.astype(numpy.float64)) | |
fh.write(self.tolerance.astype(numpy.float64)) | |
fh.write(self.maxiter.astype(numpy.uint32)) | |
+ fh.write(self.ndem.astype(numpy.uint32)) | |
finally: | |
if fh is not None: | |
t@@ -2363,6 +2372,7 @@ class sim: | |
self.beta = numpy.array(0.0) | |
self.tolerance = numpy.array(1.0e-8) | |
self.maxiter = numpy.array(1e4) | |
+ self.ndem = numpy.array(1) | |
def defaultParams(self, | |
mu_s = 0.4, | |
t@@ -3832,7 +3842,8 @@ class sim: | |
:type theta: float | |
Other solver parameter setting functions: :func:`setTheta()`, | |
- :func:`setBeta()`, :func:`setTolerance()` and :func:`setMaxIterations(… | |
+ :func:`setBeta()`, :func:`setTolerance()`, | |
+ :func:`setDEMstepsPerCFDstep()` and :func:`setMaxIterations()` | |
''' | |
self.gamma = numpy.asarray(gamma) | |
t@@ -3851,7 +3862,8 @@ class sim: | |
:type theta: float | |
Other solver parameter setting functions: :func:`setGamma()`, | |
- :func:`setBeta()`, :func:`setTolerance()` and :func:`setMaxIterations(… | |
+ :func:`setBeta()`, :func:`setTolerance()`, | |
+ :func:`setDEMstepsPerCFDstep()` and :func:`setMaxIterations()` | |
''' | |
self.theta = numpy.asarray(theta) | |
t@@ -3869,7 +3881,8 @@ class sim: | |
The default and recommended value is 0.0. | |
Other solver parameter setting functions: :func:`setGamma()`, | |
- :func:`setTheta()`, :func:`setTolerance()` and | |
+ :func:`setTheta()`, :func:`setTolerance()`, | |
+ :func:`setDEMstepsPerCFDstep()` and | |
:func:`setMaxIterations()` | |
''' | |
self.beta = numpy.asarray(beta) | |
t@@ -3887,7 +3900,7 @@ class sim: | |
:type tolerance: float | |
Other solver parameter setting functions: :func:`setGamma()`, | |
- :func:`setTheta()`, :func:`setBeta()` and | |
+ :func:`setTheta()`, :func:`setBeta()`, :func:`setDEMstepsPerCFDstep()`… | |
:func:`setMaxIterations()` | |
''' | |
self.tolerance = numpy.asarray(tolerance) | |
t@@ -3907,10 +3920,27 @@ class sim: | |
:type maxiter: int | |
Other solver parameter setting functions: :func:`setGamma()`, | |
- :func:`setTheta()`, :func:`setBeta()` and :func:`setTolerance()` | |
+ :func:`setTheta()`, :func:`setBeta()`, :func:`setDEMstepsPerCFDstep()` | |
+ and :func:`setTolerance()` | |
''' | |
self.maxiter = numpy.asarray(maxiter) | |
+ def setDEMstepsPerCFDstep(self, ndem): | |
+ ''' | |
+ A fluid solver parameter, the value of the maxiter parameter denotes t… | |
+ number of DEM time steps to be performed per CFD time step. | |
+ | |
+ The default value is 1. | |
+ | |
+ :param ndem: The DEM/CFD time step ratio | |
+ :type ndem: int | |
+ | |
+ Other solver parameter setting functions: :func:`setGamma()`, | |
+ :func:`setTheta()`, :func:`setBeta()`, :func:`setTolerance()` and | |
+ :func:`setMaxIterations()`. | |
+ ''' | |
+ self.ndem = numpy.asarray(ndem) | |
+ | |
def visualize(self, method = 'energy', savefig = True, outformat = 'png'): | |
''' | |
Visualize output from the simulation, where the temporal progress is | |
diff --git a/src/constants.h b/src/constants.h | |
t@@ -10,14 +10,13 @@ | |
// Define the max. number of walls | |
#define MAXWALLS 6 | |
- | |
const Float PI = 3.14159265358979; | |
// Number of dimensions (1 and 2 NOT functional) | |
const unsigned int ND = 3; | |
// Define source code version | |
-const double VERSION = 1.00; | |
+const double VERSION = 1.01; | |
// Max. number of contacts per particle | |
//const int NC = 16; | |
diff --git a/src/datatypes.h b/src/datatypes.h | |
t@@ -137,6 +137,7 @@ struct NavierStokes { | |
Float beta; // Solver parameter: Solution method | |
Float tolerance; // Solver parameter: Max residual tolerance | |
unsigned int maxiter; // Solver parameter: Max iterations to perform | |
+ unsigned int ndem; // Solver parameter: DEM time steps per CFD step | |
}; | |
// Image structure | |
diff --git a/src/file_io.cpp b/src/file_io.cpp | |
t@@ -84,7 +84,7 @@ void DEM::readbin(const char *target) | |
if (verbose == 1) | |
cout << " Allocating host memory: "; | |
// Allocate more host arrays | |
- k.x = new Float4[np]; | |
+ k.x = new Float4[np]; | |
k.xysum = new Float2[np]; | |
k.vel = new Float4[np]; | |
k.force = new Float4[np]; | |
t@@ -96,7 +96,7 @@ void DEM::readbin(const char *target) | |
e.es = new Float[np]; | |
e.ev_dot = new Float[np]; | |
e.ev = new Float[np]; | |
- e.p = new Float[np]; | |
+ e.p = new Float[np]; | |
if (verbose == 1) | |
cout << "Done\n"; | |
t@@ -289,6 +289,7 @@ void DEM::readbin(const char *target) | |
ifs.read(as_bytes(ns.beta), sizeof(Float)); | |
ifs.read(as_bytes(ns.tolerance), sizeof(Float)); | |
ifs.read(as_bytes(ns.maxiter), sizeof(unsigned int)); | |
+ ifs.read(as_bytes(ns.ndem), sizeof(unsigned int)); | |
if (verbose == 1) | |
cout << "Done" << std::endl; | |
t@@ -487,9 +488,9 @@ void DEM::writebin(const char *target) | |
ofs.write(as_bytes(ns.beta), sizeof(Float)); | |
ofs.write(as_bytes(ns.tolerance), sizeof(Float)); | |
ofs.write(as_bytes(ns.maxiter), sizeof(unsigned int)); | |
+ ofs.write(as_bytes(ns.ndem), sizeof(unsigned int)); | |
} | |
- | |
// Close file if it is still open | |
if (ofs.is_open()) | |
ofs.close(); |