Skip to content

Commit

Permalink
attemp at fixing KBC in disg
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahdhn committed Feb 22, 2024
1 parent 4d37ccb commit 5ba9e26
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 32 deletions.
17 changes: 10 additions & 7 deletions apps/lbmMultiResDisg/collide.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ inline Neon::set::Container collideBGKUnrolledFusedStore(Neon::domain::mGrid&
}


template <typename T, int Q>
template <typename T, int Q, bool atInterface>
inline Neon::set::Container collideKBCFusedStore(Neon::domain::mGrid& grid,
T omega0,
int level,
Expand All @@ -235,7 +235,7 @@ inline Neon::set::Container collideKBCFusedStore(Neon::domain::mGrid&
Neon::domain::mGrid::Field<T>& fout)
{
return grid.newContainer(
"CH" + std::to_string(level), level,
"CH" + std::to_string(level), level, !atInterface,
[&, level, omega0, numLevels](Neon::set::Loader& loader) {
const auto& type = cellType.load(loader, level, Neon::MultiResCompute::MAP);
const auto& in = fin.load(loader, level, Neon::MultiResCompute::MAP);
Expand Down Expand Up @@ -347,19 +347,22 @@ inline Neon::set::Container collideKBCFusedStore(Neon::domain::mGrid&
//gamma
T gamma = invBeta - (2.0 - invBeta) * e0 / (tiny + e1);

bool doStore = level < numLevels - 1;

//fout
for (int8_t q = 0; q < Q; ++q) {
const T deltaH = fneq[q] - deltaS[q];

const T res = ins[q] - beta * (2.0 * deltaS[q] + gamma * deltaH);

if (level < numLevels - 1) {
//store operation
store<T>(cell, out, q, res);
}

out(cell, q) = res;

if constexpr (atInterface) {
if (doStore) {
//store operation
store<T>(cell, out, q, res);
}
}
}
} else {
if (level != 0) {
Expand Down
13 changes: 9 additions & 4 deletions apps/lbmMultiResDisg/fusedFinest.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ inline Neon::set::Container collideBGKUnrolledFusedAll(Neon::domain::mGrid&
}


template <typename T, int Q>
template <typename T, int Q, bool atInterface>
inline Neon::set::Container collideKBCFusedAll(Neon::domain::mGrid& grid,
T omega0,
int level,
Expand All @@ -241,7 +241,7 @@ inline Neon::set::Container collideKBCFusedAll(Neon::domain::mGrid&
}

return grid.newContainer(
"CHSOE" + std::to_string(level), level,
"CHSOE" + std::to_string(level), level, !atInterface,
[&, level, omega0, numLevels, storeOut](Neon::set::Loader& loader) {
const auto type = cellType.load(loader, level, Neon::MultiResCompute::MAP);
const auto in = fin.load(loader, level, Neon::MultiResCompute::MAP);
Expand All @@ -258,6 +258,9 @@ inline Neon::set::Container collideKBCFusedAll(Neon::domain::mGrid&
return [=] NEON_CUDA_HOST_DEVICE(const typename Neon::domain::mGrid::Idx& cell) mutable {
if (type(cell, 0) == CellType::bulk) {

(void)storeOut;
(void)out;

constexpr T tiny = 1e-7;

// fin
Expand Down Expand Up @@ -360,10 +363,12 @@ inline Neon::set::Container collideKBCFusedAll(Neon::domain::mGrid&


// store operation
store<T>(cell, (storeOut) ? out : in, q, res);
if constexpr (atInterface) {
store<T>(cell, (storeOut) ? out : in, q, res);
}

// streaming (push)
stream<T>(cell, out, (storeOut) ? out : in, type, q, res);
stream<T, atInterface>(cell, out, (storeOut) ? out : in, type, q, res);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions apps/lbmMultiResDisg/lbmMultiRes.cu
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Neon/core/tools/clipp.h"

//#define BGK
#define KBC
#define BGK
//#define KBC

#include "Neon/Neon.h"
#include "Neon/Report.h"
Expand Down
56 changes: 37 additions & 19 deletions apps/lbmMultiResDisg/lbmMultiRes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ void collideStep(Neon::domain::mGrid& grid,
// collision for all voxels at level L = level fused with
// Storing fine (level) data for later "coalescence" pulled by the coarse(level)
#ifdef KBC
containers.push_back(collideKBCFusedStore<T, Q>(grid, omega0, level, numLevels, cellType, fin, fout));
containers.push_back(collideKBCFusedStore<T, Q, true>(grid, omega0, level, numLevels, cellType, fin, fout));
containers.push_back(collideKBCFusedStore<T, Q, false>(grid, omega0, level, numLevels, cellType, fin, fout));
#endif

#ifdef BGK
Expand Down Expand Up @@ -64,23 +65,41 @@ void collideFusedStreaming(Neon::domain::mGrid& grid,
{

#ifdef KBC
containers.push_back(collideKBCFusedAll<T, Q>(grid,
omega0,
level,
numLevels,
cellType,
fin,
fout,
true));

containers.push_back(collideKBCFusedAll<T, Q>(grid,
omega0,
level,
numLevels,
cellType,
fout,
fin,
false));
containers.push_back(collideKBCFusedAll<T, Q, true>(grid,
omega0,
level,
numLevels,
cellType,
fin,
fout,
true));

containers.push_back(collideKBCFusedAll<T, Q, false>(grid,
omega0,
level,
numLevels,
cellType,
fout,
fin,
true));

containers.push_back(collideKBCFusedAll<T, Q, true>(grid,
omega0,
level,
numLevels,
cellType,
fin,
fout,
false));

containers.push_back(collideKBCFusedAll<T, Q, false>(grid,
omega0,
level,
numLevels,
cellType,
fout,
fin,
false));
#endif

#ifdef BGK
Expand All @@ -102,7 +121,6 @@ void collideFusedStreaming(Neon::domain::mGrid& grid,
fout,
true));


//atInterface ??
containers.push_back(collideBGKUnrolledFusedAll<T, Q, true>(grid,
omega0,
Expand Down

0 comments on commit 5ba9e26

Please sign in to comment.