timplement first attempt at adaptive meshing - sphere - GPU-based 3D discrete e… | |
git clone git://src.adamsgaard.dk/sphere | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 5adc4fde4fddd30f5591249a497353c17665df1b | |
parent de8f4eb1433514d7729abe95e9e1367161bb1ef6 | |
Author: Anders Damsgaard Christensen <[email protected]> | |
Date: Fri, 2 Sep 2016 15:39:29 -0700 | |
implement first attempt at adaptive meshing | |
Diffstat: | |
M src/datatypes.h | 1 + | |
M src/device.cu | 25 +++++++++++++++++++++++++ | |
M src/sphere.h | 3 +++ | |
3 files changed, 29 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/src/datatypes.h b/src/datatypes.h | |
t@@ -47,6 +47,7 @@ struct Grid { | |
Float L[ND]; // World dimensions | |
unsigned int num[ND]; // Neighbor-search cells along each axis | |
int periodic; // Behavior of boundaries at 1st and 2nd world edge | |
+ int adaptive; // Continuously rescale grid size to wall positions | |
}; | |
struct Sorting { | |
diff --git a/src/device.cu b/src/device.cu | |
t@@ -348,6 +348,25 @@ __host__ void DEM::transferToConstantDeviceMemory() | |
checkConstantMemory(); | |
} | |
+__host__ void DEM::updateGridSize() | |
+{ | |
+ Float Lz; | |
+ | |
+ // Get top wall position from dev_walls_nx[0].z | |
+ cudaMemcpy(&Lz, &dev_walls_nx[0].z, sizeof(Float), cudaMemcpyDeviceToHost); | |
+ | |
+ // Write value to grid.L[2] | |
+ grid.L[2] = Lz; | |
+ | |
+ // Write value to devC_grid.L[2] | |
+ cudaMemcpyToSymbol(devC_grid.L[2], &Lz, sizeof(Float)); | |
+ | |
+ checkForCudaErrors("After updating grid size"); | |
+ | |
+ // check value only during debugging | |
+ checkConstantMemory(); | |
+} | |
+ | |
// Allocate device memory for particle variables, | |
// tied to previously declared pointers in structures | |
t@@ -999,6 +1018,12 @@ __host__ void DEM::startTime() | |
checkForCudaErrorsIter("Post checkParticlePositions", iter); | |
#endif | |
+ // If the grid is adaptive, readjust the grid height to equal the | |
+ // positions of the dynamic walls | |
+ if (grid.adaptive == 1) { | |
+ updateGridSize(); | |
+ } | |
+ | |
// For each particle: | |
// Compute hash key (cell index) from position | |
// in the fine, uniform and homogenous grid. | |
diff --git a/src/sphere.h b/src/sphere.h | |
t@@ -138,6 +138,9 @@ class DEM { | |
const float imgw, | |
const float focalLength); | |
+ // Adjust grid size according to wall placement | |
+ void updateGridSize(); | |
+ | |
// Allocate global device memory to hold data | |
void allocateGlobalDeviceMemory(); | |
void rt_allocateGlobalDeviceMemory(); |