Skip to content
Snippets Groups Projects
Commit c38ab1f9 authored by brendan-waters's avatar brendan-waters
Browse files

Merge branch 'mr_fix_shifted_periodicity' into 'master'

Fix shifted periodicity

See merge request walberla/walberla!705
parents 04f9152d c9b97ee4
No related branches found
No related tags found
No related merge requests found
......@@ -96,10 +96,6 @@ class ShiftedPeriodicityBase {
// sanity checks
WALBERLA_CHECK_UNEQUAL( shiftDir_, normalDir_, "Direction of periodic shift and boundary normal must not coincide." )
WALBERLA_CHECK( sbf->isPeriodic(shiftDir_), "Blockforest must be periodic in direction " << shiftDir_ << "!" )
WALBERLA_CHECK( !sbf->isPeriodic(normalDir_), "Blockforest must NOT be periodic in direction " << normalDir_ << "!" )
}
Vector3<ShiftType> shift() const { return shift_; }
......@@ -116,6 +112,11 @@ class ShiftedPeriodicityBase {
// only setup send and receive information once at the beginning
if(!setupPeriodicity_){
// check once during setup if the domain's periodicity was well defined
WALBERLA_CHECK( sbf->isPeriodic(shiftDir_), "Blockforest must be periodic in direction " << shiftDir_ << "!" )
WALBERLA_CHECK( !sbf->isPeriodic(normalDir_), "Blockforest must NOT be periodic in direction " << normalDir_ << "!" )
setupPeriodicity();
setupPeriodicity_ = true;
}
......@@ -498,11 +499,14 @@ class ShiftedPeriodicityBase {
}
CellInterval globalAABBToLocalCI( const AABB & aabb, const std::shared_ptr<StructuredBlockForest> & sbf, IBlock * const block ) {
auto globalCI = CellInterval{toCellVector(aabb.min()), toCellVector(aabb.max()) - Vector3<cell_idx_t>(1, 1, 1)};
CellInterval localCI;
sbf->transformGlobalToBlockLocalCellInterval(localCI, *block, globalCI);
return localCI;
Vector3<real_t> local_min;
sbf->transformGlobalToBlockLocal(local_min , *block, aabb.min());
Vector3<real_t> local_max;
sbf->transformGlobalToBlockLocal(local_max , *block, aabb.max());
return CellInterval{toCellVector(local_min), toCellVector(local_max) - Vector3<cell_idx_t>(1, 1, 1)};
}
template< typename tPair >
......
......@@ -124,7 +124,29 @@ int main( int argc, char **argv ) {
logging::configureLogging(config);
// create the domain, flag field and vector field (non-uniform initialisation)
auto blocks = blockforest::createUniformBlockGridFromConfig(config->getBlock("DomainSetup"), nullptr, true);
auto configBlock = config->getBlock("DomainSetup");
const Vector3<bool> periodicity = configBlock.getParameter<Vector3<bool> >( "periodic" );
const Vector3<uint_t> cellsPerBlock = configBlock.getParameter<Vector3<uint_t> >( "cellsPerBlock" );
const Vector3<uint_t> nBlocks = configBlock.getParameter<Vector3<uint_t> >( "blocks" );
const bool zeroCenteredDomain = configBlock.getParameter<bool>( "zeroCenteredDomain" );
Vector3<real_t> domainSize{};
Vector3<real_t> domainCorner{};
for(uint_t d = 0; d < 3; ++d) {
domainSize[d] = real_c(nBlocks[d] * cellsPerBlock[d]);
domainCorner[d] = zeroCenteredDomain ? real_t(0) : - domainSize[d] / real_t(2);
}
auto blocks = blockforest::createUniformBlockGrid(
AABB(domainCorner, domainCorner + domainSize), // AABB spanning the entire domain
nBlocks[0], nBlocks[1], nBlocks[2], // number of blocks in x/y/z direction
cellsPerBlock[0], cellsPerBlock[1], cellsPerBlock[2], // cells per block in x/y/z direction
uint_t(0), // maximum number of blocks per process
true, false, // include but don't force Metis
periodicity[0], periodicity[1], periodicity[2], // periodicity
true // keep global block information
);
const auto fieldID = field::addToStorage< Field_T >(blocks, "test field", real_t(0), field::Layout::fzyx, fieldGhostLayers);
FieldInitialiser< Field_T > initialiser(blocks, fieldID);
......
......@@ -2,11 +2,12 @@ import waLBerla as wlb
class Scenario:
def __init__(self, normal_dir, shift_dir, shift_value, periodicity):
def __init__(self, normal_dir, shift_dir, shift_value, periodicity, zero_centered_domain):
self.normal_dir = normal_dir
self.shift_dir = shift_dir
self.shift_value = shift_value
self.periodicity = tuple(periodicity)
self.zero_centered_domain = zero_centered_domain
@wlb.member_callback
def config(self):
......@@ -17,6 +18,7 @@ class Scenario:
'cellsPerBlock': (4, 4, 4),
'cartesianSetup': 0,
'periodic': self.periodicity,
'zeroCenteredDomain': self.zero_centered_domain
},
'Boundaries': {
'ShiftedPeriodicity': {
......@@ -40,4 +42,5 @@ for normal_dir in (0, 1, 2):
periodicity = 3 * [0]
periodicity[shift_dir] = 1
for shift_value in (-3, 0, 2, 5, 8, 15):
scenarios.add(Scenario(normal_dir, shift_dir, shift_value, periodicity))
for zero_centered_domain in (True, False):
scenarios.add(Scenario(normal_dir, shift_dir, shift_value, periodicity, zero_centered_domain))
......@@ -127,7 +127,29 @@ int main( int argc, char **argv ) {
logging::configureLogging(config);
// create the domain, flag field and vector field (non-uniform initialisation)
auto blocks = blockforest::createUniformBlockGridFromConfig(config->getBlock("DomainSetup"), nullptr, true);
auto configBlock = config->getBlock("DomainSetup");
const Vector3<bool> periodicity = configBlock.getParameter<Vector3<bool> >( "periodic" );
const Vector3<uint_t> cellsPerBlock = configBlock.getParameter<Vector3<uint_t> >( "cellsPerBlock" );
const Vector3<uint_t> nBlocks = configBlock.getParameter<Vector3<uint_t> >( "blocks" );
const bool zeroCenteredDomain = configBlock.getParameter<bool>( "zeroCenteredDomain" );
Vector3<real_t> domainSize{};
Vector3<real_t> domainCorner{};
for(uint_t d = 0; d < 3; ++d) {
domainSize[d] = real_c(nBlocks[d] * cellsPerBlock[d]);
domainCorner[d] = zeroCenteredDomain ? real_t(0) : - domainSize[d] / real_t(2);
}
auto blocks = blockforest::createUniformBlockGrid(
AABB(domainCorner, domainCorner + domainSize), // AABB spanning the entire domain
nBlocks[0], nBlocks[1], nBlocks[2], // number of blocks in x/y/z direction
cellsPerBlock[0], cellsPerBlock[1], cellsPerBlock[2], // cells per block in x/y/z direction
uint_t(0), // maximum number of blocks per process
true, false, // include but don't force Metis
periodicity[0], periodicity[1], periodicity[2], // periodicity
true // keep global block information
);
const auto h_fieldID = field::addToStorage< Field_T >(blocks, "test field CPU", real_t(0), field::Layout::fzyx, fieldGhostLayers);
FieldInitialiser< Field_T > initialiser(blocks, h_fieldID);
......
......@@ -2,11 +2,12 @@ import waLBerla as wlb
class Scenario:
def __init__(self, normal_dir, shift_dir, shift_value, periodicity):
def __init__(self, normal_dir, shift_dir, shift_value, periodicity, zero_centered_domain):
self.normal_dir = normal_dir
self.shift_dir = shift_dir
self.shift_value = shift_value
self.periodicity = tuple(periodicity)
self.zero_centered_domain = zero_centered_domain
@wlb.member_callback
def config(self):
......@@ -17,6 +18,7 @@ class Scenario:
'cellsPerBlock': (4, 4, 4),
'cartesianSetup': 0,
'periodic': self.periodicity,
'zeroCenteredDomain': self.zero_centered_domain
},
'Boundaries': {
'ShiftedPeriodicity': {
......@@ -24,6 +26,9 @@ class Scenario:
'shiftValue': self.shift_value,
'normalDir': self.normal_dir
}
},
'Logging': {
'logLevel': "Info"
}
}
......@@ -37,4 +42,5 @@ for normal_dir in (0, 1, 2):
periodicity = 3 * [0]
periodicity[shift_dir] = 1
for shift_value in (-3, 0, 2, 5, 8, 15):
scenarios.add(Scenario(normal_dir, shift_dir, shift_value, periodicity))
for zero_centered_domain in (True, False):
scenarios.add(Scenario(normal_dir, shift_dir, shift_value, periodicity, zero_centered_domain))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment