CUDA for Free Energy Dynamics
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › CUDA for Free Energy Dynamics
- This topic has 1 reply, 2 voices, and was last updated 1 year, 5 months ago by Adrian.
-
AuthorPosts
-
April 26, 2023 at 6:49 pm #7431mehrdadvasheghanifarahaniParticipant
Hi OpenLB developers,
Would you please advise whether OpenLB 1.6 supports GPU usage via CUDA for Free Energy dynamics?
Thanks,
MehrdadApril 26, 2023 at 7:03 pm #7432AdrianKeymasterThe local dynamics used for the Free Energy model are adapted to the new style introduced in 1.5 so they will work on GPUs [1]. The only remaining obstacle is that the post processors used for the free energy boundary conditions are not yet adapted to the operator style. We’ll get around to it as we continue closing the remaining holes in our GPU support but this is mostly done alongside our active research projects as we require. So I can not give you a clear date on when this will become available.
If you want I can guide you in adapting the boundary conditions by yourself (this is mostly refactoring, i.e. extracting the per-cell logic to an generic
apply
functions and explicitly declaring all parameters). e.g. changingvoid FreeEnergyWallProcessor3D<T,DESCRIPTOR>:: processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) { int newX0, newX1, newY0, newY1, newZ0, newZ1; if ( util::intersect ( x0, x1, y0, y1, z0, z1, x0_, x1_, y0_, y1_, z0_, z1_, newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) { for (int iX=newX0; iX<=newX1; ++iX) { for (int iY=newY0; iY<=newY1; ++iY) { for (int iZ=newZ0; iZ<=newZ1; ++iZ) { T rhoBulk = blockLattice.get(iX-discreteNormalX, iY-discreteNormalY, iZ-discreteNormalZ).computeRho(); T rhoTmp = 0; for (int iPop = 1; iPop < DESCRIPTOR::q; ++iPop) { rhoTmp += blockLattice.get(iX,iY,iZ)[iPop]; } T rho = rhoBulk + addend; blockLattice.get(iX,iY,iZ)[0] = rho - rhoTmp - 1; } } } } }
to roughly
template <typename T, typename DESCRIPTOR, int normalX, int normalY, int normalZ> struct FreeEnergyWallProcessor3D { static constexpr OperatorScope scope = OperatorScope::PerCellWithParameters; using parameters = meta::list<ADDEND>(); template <typename CELL, typename PARAMETERS> void apply(CELL& cell, PARAMETERS& params) any_platform { T rhoBulk = cell.neighbor(normalX, normalY, normalZ).computeRho(); T rhoTmp = 0; for (int iPop = 1; iPop < DESCRIPTOR::q; ++iPop) { rhoTmp += cell[iPop]; } T rho = rhoBulk + params.template get<ADDEND>(); cell[0] = rho - rhoTmp - 1; } };
[1]: I just checked, we’ll need to add the
any_platform
macro to the methods insrc/dynamics/freeEnergyDynamics.h
-
AuthorPosts
- You must be logged in to reply to this topic.