Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psm #10

Open
wants to merge 4 commits into
base: LBM-DEM-coupling
Choose a base branch
from
Open

Psm #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Apps/LBM-DEM/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ lbm3d_dev_mpi :
$(MPICPP) $(CPPFLAGS) $(MAINCPP) ${MPLB_DIR}/evolution3d.cpp ${MPLB_DIR}/scheme.cpp ${MPLB_DIR}/scheme_wrapper.cpp ${MPLB_DIR}/configuration.cpp ${MPLB_DIR}/model.cpp ${MPLB_DIR}/model_wrapper.cpp ${MPLB_DIR}/block.cpp ${MPLB_DIR}/flowfield.cpp ${MPLB_DIR}/flowfield_wrapper.cpp ${MPLB_DIR}/boundary.cpp ${MPLB_DIR}/boundary_wrapper.cpp $(OPS_INC) $(HDF5_INC) $(MPLB_INC) $(OPS_LIB) $(MPLB_LIB) $(HDF5_LIB) -DOPS_3D -DOPS_MPI -DCPU -D$(LEVEL) -lops_hdf5_mpi -lops_mpi -lhdf5_hl -lhdf5 -lz -o lbm3d_dev_mpi

lbm3d_dem_mpi :
$(MPICPP) $(CPPFLAGS) $(MAINCPP) ${MPLB_DIR}/evolution.cpp ${MPLB_DIR}/scheme.cpp ${MPLB_DIR}/scheme_wrapper.cpp ${MPLB_DIR}/configuration.cpp ${MPLB_DIR}/model.cpp ${MPLB_DIR}/model_wrapper.cpp ${MPLB_DIR}/block.cpp ${MPLB_DIR}/flowfield.cpp ${MPLB_DIR}/flowfield_wrapper.cpp ${MPLB_DIR}/boundary.cpp ${MPLB_DIR}/boundary_wrapper.cpp dem_handle.cpp block_particle_helper.cpp block_particle_helper_wrapper.cpp block_particles.cpp particle_mapping.cpp mapping_particles.cpp particle.cpp mui_wrapper.cpp mui_interface.cpp fpi_functions.cpp fpi_data.cpp psm_wrapper.cpp particle_mapping_wrapper.cpp particle_shape.cpp grid_mapping_wrapper.cpp poros_spherical_wrapper.cpp force_fsi.cpp -Imui $(OPS_INC) $(HDF5_INC) $(MPLB_INC) $(OPS_LIB) $(MPLB_LIB) $(HDF5_LIB) -DOPS_3D -DOPS_MPI -DCPU -D$(LEVEL) -lops_hdf5_mpi -lops_mpi -lhdf5_hl -lhdf5 -lz -o lbm3d_dem_mpi

$(MPICPP) $(CPPFLAGS) $(MAINCPP) ${MPLB_DIR}/evolution.cpp ${MPLB_DIR}/scheme.cpp ${MPLB_DIR}/scheme_wrapper.cpp ${MPLB_DIR}/configuration.cpp ${MPLB_DIR}/model.cpp ${MPLB_DIR}/model_wrapper.cpp ${MPLB_DIR}/block.cpp ${MPLB_DIR}/flowfield.cpp ${MPLB_DIR}/flowfield_wrapper.cpp ${MPLB_DIR}/boundary.cpp ${MPLB_DIR}/boundary_wrapper.cpp dem_handle.cpp block_particle_helper.cpp block_particle_helper_wrapper.cpp block_particles.cpp particle_mapping.cpp mapping_particles.cpp particle.cpp mui_wrapper.cpp mui_interface.cpp fpi_functions.cpp fpi_data.cpp psm_wrapper.cpp particle_mapping_wrapper.cpp particle_shape.cpp grid_mapping_wrapper.cpp poros_spherical_wrapper.cpp force_fsi.cpp -Imui $(OPS_INC) $(HDF5_INC) $(MPLB_INC) $(OPS_LIB) $(MPLB_LIB) $(HDF5_LIB) -DOPS_3D -DOPS_MPI -DCPU -D$(LEVEL) -lops_hdf5_mpi -lops_mpi -lhdf5_hl -lhdf5 -lz -o lbm3d_dem_mpi
lbm2d_dem_mpi :
$(MPICPP) $(CPPFLAGS) $(MAINCPP) ${MPLB_DIR}/evolution.cpp ${MPLB_DIR}/scheme.cpp ${MPLB_DIR}/scheme_wrapper.cpp ${MPLB_DIR}/configuration.cpp ${MPLB_DIR}/model.cpp ${MPLB_DIR}/model_wrapper.cpp ${MPLB_DIR}/block.cpp ${MPLB_DIR}/flowfield.cpp ${MPLB_DIR}/flowfield_wrapper.cpp ${MPLB_DIR}/boundary.cpp ${MPLB_DIR}/boundary_wrapper.cpp dem_handle.cpp block_particle_helper.cpp block_particle_helper_wrapper.cpp block_particles.cpp particle_mapping.cpp mapping_particles.cpp particle.cpp mui_wrapper.cpp mui_interface.cpp fpi_functions.cpp fpi_data.cpp psm_wrapper.cpp particle_mapping_wrapper.cpp particle_shape.cpp grid_mapping_wrapper.cpp poros_spherical_wrapper.cpp force_fsi.cpp -Imui $(OPS_INC) $(HDF5_INC) $(MPLB_INC) $(OPS_LIB) $(MPLB_LIB) $(HDF5_LIB) -DOPS_2D -DOPS_MPI -DCPU -D$(LEVEL) -lops_hdf5_mpi -lops_mpi -lhdf5_hl -lhdf5 -lz -o lbm2d_dem_mpi
lbm3d_dev_mpi_lib :
$(MPICPP) $(MPIFLAGS) $(MAINCPP) $(OPS_INC) $(HDF5_INC) $(MPLB_INC) $(OPS_LIB) $(MPLB_LIB) -DOPS_MPI -DOPS_3D -DCPU -D$(LEVEL) -lmplb3d_mpi -lops_mpi -lops_hdf5_mpi $(HDF5_LIB) -o lbm3d_dev_mpi

Expand Down Expand Up @@ -332,5 +333,5 @@ openacc_error:
#

clean:
rm -f lbm2d_dev_seq lbm3d_dem_mpi lbm2d_seq lbm2d_dev_seq lbm2d_mpi lbm2d_dev_mpi lbm2d_openmp lbm2d_mpi_openmp lbm2d_cuda lbm2d_mpi_cuda lbm2d_openacc lbm2d_mpi_openacc lbm2d_opencl lbm2d_mpi_opencl ./CUDA/*.o ./OpenACC/*.o *.o lbm2d_opencl lbm3d_dev_seq lbm3d_seq lbm3d_dev_seq lbm3d_mpi lbm3d_dev_mpi./OpenCL/*.o *.o
rm -f lbm2d_dev_seq lbm3d_dem_mpi lbm2d_dem_mpi lbm2d_seq lbm2d_dev_seq lbm2d_mpi lbm2d_dev_mpi lbm2d_openmp lbm2d_mpi_openmp lbm2d_cuda lbm2d_mpi_cuda lbm2d_openacc lbm2d_mpi_openacc lbm2d_opencl lbm2d_mpi_opencl ./CUDA/*.o ./OpenACC/*.o *.o lbm2d_opencl lbm3d_dev_seq lbm3d_seq lbm3d_dev_seq lbm3d_mpi lbm3d_dev_mpi./OpenCL/*.o *.o

81 changes: 71 additions & 10 deletions Apps/LBM-DEM/block_particle_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,13 @@ void FluidParticleCollisions() {
//TODO need to obtain the id of the
ObtainData(fsi.second, velId,loop, tauRef, collisionModel, componentId, rhoId,
Tid);

#ifdef OPS_3D
PreDefinedCollision3D(velId, loop, tauRef, collisionModel, componentId, rhoId, Tid);
#endif

#ifdef OPS_2D
PreDefinedCollision(velId, loop, tauRef, collisionModel, componentId, rhoId, Tid);
#endif
}

}
Expand All @@ -296,15 +301,23 @@ void InitializeDragForce() {


}

#ifdef OPS_3D
void UpdateFPIVelocities3D() {

UpdateMacroVars3D();
PostVelocityFSIFunctions();


}
#endif

#ifdef OPS_2D
void UpdateFPIVelocities() {

UpdateMacroVars();
PostVelocityFSIFunctions();
}
#endif

void WriteFPIDataToHdf5(SizeType currentStep) {

Expand All @@ -316,23 +329,62 @@ void WriteFPIDataToHdf5(SizeType currentStep) {

}


#ifdef OPS_2D
void AssignParticleToBlocksSpheres2D(int Nparticles,Real* xTmp, Real* yTmp,
Real* radTmp, Real* uTmp, Real* vTmp, Real* ozTmp) {

int idx;
int spaceDim{2};
std::vector<Real> shape(1.0);
std::vector<Real> extra;
shape.reserve(1);
int ipx = 0;
int iIns = 0;
Real xParticle[spaceDim], uParticle[spaceDim], omParticle[spaceDim];
for (int iPar = 0; iPar < Nparticles; iPar++) {
ipx += 1;
xParticle[0] = xTmp[iPar];
xParticle[1] = yTmp[iPar];

uParticle[0] = uTmp[iPar];
uParticle[1] = vTmp[iPar];

omParticle[0] = ozTmp[iPar];
shape.at(0) = radTmp[iPar];
int ix = 0;
for (auto &blockParticle : BlockParticleList) {
ix = ix + 1;
idx = blockParticle.second.InsertParticle(xParticle, radTmp[iPar], shape,
uParticle, omParticle, extra);
if (idx > -1) {
iIns += 1;
#ifdef CPU
#if DebugLevel > 2
printf("Rank %d: Idx = %d for particle %d at [%f %f]\n", ops_get_proc(), idx, iPar, xParticle[0], xParticle[1] );
#endif
#endif
}
}
}

printf("Rank %d: %d particles inserted\n", ops_get_proc(), iIns);
}
#endif

#ifdef OPS_3D
void AssignParticlesToBlocksSpheres(int Nparticles,Real* xTmp, Real* yTmp,Real* zTmp,
Real* radTmp, Real* uTmp,Real* vTmp, Real* wTmp, Real* oxTmp,
Real* oyTmp, Real* ozTmp) {

int spaceDim;
#ifdef OPS_3D
spaceDim = 3;
#endif
int spaceDim{3};

#ifdef OPS_2D
spaceDim = 2;
#endif
int idx;
std::vector<Real> shape(1.0);
std::vector<Real> extra;
shape.reserve(1);
int ipx = 0;
int iIns = 0;
Real xParticle[spaceDim], uParticle[spaceDim], omParticle[spaceDim];
for (int iPar = 0; iPar < Nparticles; iPar++) {
ipx += 1;
Expand All @@ -351,12 +403,21 @@ void AssignParticlesToBlocksSpheres(int Nparticles,Real* xTmp, Real* yTmp,Real*
ix = ix + 1;
idx = blockParticle.second.InsertParticle(xParticle, radTmp[iPar], shape,
uParticle, omParticle, extra);
printf("Rank %d: Idx = %d for particle %d\n", ops_get_proc(), idx, iPar );
if (idx > -1) {
#ifdef CPU
#if DebugLevel > 2
printf("Rank %d: Idx = %d for particle %d\n", ops_get_proc(), idx, iPar );
#endif
#endif
iIns += 1;
}
}
}
printf("Rank %d: %d particles inserted\n", ops_get_proc(), iIns);


}
#endif

void DefineBlockOwnership() {

Expand Down
23 changes: 19 additions & 4 deletions Apps/LBM-DEM/block_particle_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ void UpdateOldParticleLocation();
void ParticleEnvelopes();


//3D wrapper functions
#ifdef OPS_3D
void UpdateFPIVelocities3D();
void AssignParticlesToBlocksSpheres(int Nparticles,Real* xTmp, Real* yTmp,Real* zTmp,
Real* radTmp, Real* uTmp,Real* vTmp, Real* wTmp, Real* oxTmp,
Real* oyTmp, Real* ozTmp);
#endif

#ifdef OPS_2D
void UpdateFPIVelocities();
void AssignParticleToBlocksSpheres2D(int Nparticles,Real* xTmp, Real* yTmp,
Real* radTmp, Real* uTmp, Real* vTmp, Real* ozTmp);
#endif


//Wrapper for FSI object functions
void PostVelocityFSIFunctions();
Expand All @@ -72,7 +86,9 @@ void PreDefineCollision3DFSI(int* velID, int* loop, Real tauRef, CollisionType c
void CalculateDragForce(Real dt, SizeType currentStep);
void InitializeDragForce();
void InitializeFSILists();
void UpdateFPIVelocities3D();



void WriteFPIDataToHdf5(SizeType currentStep);

void UpdateParticleMappingDragForceRestart(SizeType currentStep);
Expand All @@ -89,9 +105,8 @@ void DefineFsiModel(std::vector<FluidParticleModel> fsiModel, std::vector<int>


//PArticle assigning wrappers
void AssignParticlesToBlocksSpheres(int Nparticles,Real* xTmp, Real* yTmp,Real* zTmp,
Real* radTmp, Real* uTmp,Real* vTmp, Real* wTmp, Real* oxTmp,
Real* oyTmp, Real* ozTmp);



void DefineBlockOwnership();
void DefineLocalBoxBound();
Expand Down
12 changes: 11 additions & 1 deletion Apps/LBM-DEM/block_particle_helper_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,25 @@ void DefineLocalBoxBound() {


}


#ifdef CPU
#if DebugLevel >= 2
Real xBound[6];
Real xBound[2 * spaceDim];
for (auto& particleBlock : BlockParticleList) {
particleBlock.second.GetLocalBound(xBound);
#ifdef OPS_3D
printf("Rank %d, Block %d xLocal =[%f %f] x[ %f %f] x [%f %f]\n",
ops_get_proc(), particleBlock.second.GetBlock().ID(),
xBound[0], xBound[1], xBound[2], xBound[3],
xBound[4], xBound[5]);
#endif

#ifdef OPS_2D
printf("Rank %d, Block %d xLocal = [%f %f] x [%f %f]\n",
ops_get_proc(), particleBlock.second.GetBlock().ID(),
xBound[0], xBound[1], xBound[2], xBound[3]);
#endif
}
#endif
#endif
Expand Down
20 changes: 19 additions & 1 deletion Apps/LBM-DEM/block_particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,24 +201,40 @@ void BlockParticles::UpdateParticleVelocities(Real* uPart, Real* omegaT) {
int BlockParticles::InsertParticle(Real* xpos, Real radius, std::vector<Real> shape,
Real* uPart, Real* omegaT, std::vector<Real>& inputData) {



int idParticle;

bool flag = SphereParallepipedIntersection(xpos, radius);

if (flag) {

#ifdef CPU
#if DebugLevel >=2
printf("Rank %d: Particle [%f %f %f] will be inserted in the particleList\n",
#ifdef OPS_3D
printf("Rank %d: Particle [%f %f %f] is inserted to particleList\n",
ops_get_proc(), xpos[0], xpos[1], xpos[2]);
#endif

#ifdef OPS_2D
printf("Rank %d: Particle [%f %f] is inserted to particleList\n",
ops_get_proc(), xpos[0], xpos[1], xpos[2]);
#endif
#endif
#endif

idParticle = UpdateParticle(xpos, radius, shape);
UpdateParticleVelocities(uPart, omegaT);
if (hasExtraInputVariables)
GetAdditionalInputVariables(inputData, NParticles-1);


return idParticle;
}




return -1;
}

Expand Down Expand Up @@ -289,6 +305,8 @@ void BlockParticles::SetGlobalBound(Real* xBound) {
printf("[%f %f] ", xBoundGlobal[2 * iDim], xBoundGlobal[2* iDim + 1]);
#endif
#endif


}

void BlockParticles::GetOwnership() {
Expand Down
21 changes: 19 additions & 2 deletions Apps/LBM-DEM/cavity3d_kernel.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,29 @@
#ifndef CAVITY3D_KERNEL_INC
#define CAVITY3D_KERNEL_INC

void KerSetInitialMacroVars(ACC<Real>& rho, ACC<Real>& u, ACC<Real>& v,
#ifdef OPS_3D
void KerSetInitialMacroVars3D(ACC<Real>& rho, ACC<Real>& u, ACC<Real>& v,
ACC<Real>& w, const ACC<Real>& coordinates,
const int* idx) {
rho(0, 0, 0) = 1;

rho(0, 0, 0) = 1;
u(0, 0, 0) = 0;
v(0, 0, 0) = 0;
w(0, 0, 0) = 0;
}
#endif

#ifdef OPS_2D
void KerSetInitialMacroVars(ACC<Real>& rho, ACC<Real>& u, ACC<Real> &v,
const ACC<Real>& coordinates, const int* idx) {

rho(0, 0) = 1.0;
u(0, 0) = 0.0;
v(0, 0) = 0.0;

}
#endif



#endif // CAVITY3D_KERNEL_INC
4 changes: 3 additions & 1 deletion Apps/LBM-DEM/dem_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@


enum ParticleShapeDiscriptor{spherical=0, quadratic=1, mesh=2};
enum ParticleMappingModel{noMapping=0, sphericalMapping=1, gridSpherical=2, gridQuadratic=3, gridMesh=4, copyData=5};
enum ParticleMappingModel{noMapping=0, sphericalMapping=1, gridSpherical=2,
gridQuadratic=3, gridMesh=4, multipleSpheres=6,
copyData=7};
enum FluidParticleModel{noModel=0, PSM=1};

struct InteractionData {
Expand Down
Loading