Skip to content

Commit

Permalink
clangformat
Browse files Browse the repository at this point in the history
  • Loading branch information
amartyads committed Sep 4, 2024
1 parent 6359485 commit 6f7632a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 35 deletions.
11 changes: 7 additions & 4 deletions src/parallel/boundaries/BoundaryHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ bool BoundaryHandler::isGlobalWall(int dimension) const {
return isGlobalWall(BoundaryUtils::convertLS1DimsToDimensionPos(dimension));
}

void BoundaryHandler::processGlobalWallLeavingParticles(ParticleContainer* moleculeContainer, double timestepLength) {
void BoundaryHandler::processGlobalWallLeavingParticles(
ParticleContainer *moleculeContainer, double timestepLength) {
double cutoff = moleculeContainer->getCutoff();
for (auto const &currentWall : _isGlobalWall) {
if (!currentWall.second) // not a global wall
Expand Down Expand Up @@ -188,8 +189,9 @@ void BoundaryHandler::processGlobalWallLeavingParticles(ParticleContainer* molec
BoundaryUtils::BoundaryType::REFLECTING) {
double currentVel = it->v(currentDim);
// reflect the velocity, such that when the leapfrog integrator adds
// nextStepVelAdjustment in the next integration step, the final result
// ends up being currentVel+nextStepVelAdjustment in the negative direction of travel
// nextStepVelAdjustment in the next integration step, the final
// result ends up being currentVel+nextStepVelAdjustment in the
// negative direction of travel
it->setv(currentDim, -currentVel - nextStepVelAdjustment -
nextStepVelAdjustment);
} else { // outflow, delete the particle if it would leave
Expand All @@ -207,7 +209,8 @@ void BoundaryHandler::processGlobalWallLeavingParticles(ParticleContainer* molec
}
}

void BoundaryHandler::removeNonPeriodicHalos(ParticleContainer* moleculeContainer) {
void BoundaryHandler::removeNonPeriodicHalos(
ParticleContainer *moleculeContainer) {
// get halo lengths in each dimension
double buffers[] = {
moleculeContainer->get_halo_L(0) + moleculeContainer->getSkin(),
Expand Down
65 changes: 37 additions & 28 deletions src/parallel/boundaries/BoundaryHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@

/**
* Class to handle boundary conditions, namely leaving and halo particles.
*
* The objects of this class store the local and global bounds of the subdomain in every process,
* and provide functions to deal with leaving particles, and delete halo particles.
*
* The internal walls of the subdomain, touching other subdomains are 'local' walls
* while the walls that are also the limits of the global domain are 'global' walls.
*
* Since the behaviour of 'local' walls are unchanged, they are assigned to 'PERIODIC'.
*
* The objects of this class store the local and global bounds of the subdomain
* in every process, and provide functions to deal with leaving particles, and
* delete halo particles.
*
* The internal walls of the subdomain, touching other subdomains are 'local'
* walls while the walls that are also the limits of the global domain are
* 'global' walls.
*
* Since the behaviour of 'local' walls are unchanged, they are assigned to
* 'PERIODIC'.
*/

class BoundaryHandler {
Expand All @@ -51,8 +54,9 @@ class BoundaryHandler {

/**
* Check if any of the global boundaries are non-periodic.
*
* This check helps bypass all boundary-related code if default behaviour (all periodic boundaries) is expected.
*
* This check helps bypass all boundary-related code if default behaviour
* (all periodic boundaries) is expected.
*/
bool hasNonPeriodicBoundary() const;

Expand All @@ -70,46 +74,51 @@ class BoundaryHandler {

/**
* Determine which walls in the local region are actually global walls.
*
* Should be called after changing global and local regions (typically after a rebalance).
*
* Should be called after changing global and local regions (typically after a
* rebalance).
*/
void findGlobalWallsInLocalRegion();

/* Check if the local wall in a particular dimension is actually a global wall. */
/* Check if the local wall in a particular dimension is actually a global
* wall. */
bool isGlobalWall(BoundaryUtils::DimensionType dimension) const;

/* Check if the local wall in a particular dimension is actually a global wall. */
/* Check if the local wall in a particular dimension is actually a global
* wall. */
bool isGlobalWall(int dimension) const;

/**
* Processes all particles that would leave the global domain.
*
*
* If a subdomain has no global walls, this function does nothing.
* For every global wall, the fucktion iterates through all particles that are one cutoff distance away
* from the wall. If these particles would leave the global box in the next simulation, the following is done:
*
* For every global wall, the fucktion iterates through all particles that are
* one cutoff distance away from the wall. If these particles would leave the
* global box in the next simulation, the following is done:
*
* PERIODIC - nop (default behaviour).
* REFLECTING - The particle's velocity is reversed normal to the wall it's leaving.
* OUTFLOW - The particle is deleted.
* REFLECTING - The particle's velocity is reversed normal to the wall it's
* leaving. OUTFLOW - The particle is deleted.
*/
void processGlobalWallLeavingParticles(ParticleContainer* moleculeContainer, double timestepLength);
void processGlobalWallLeavingParticles(ParticleContainer *moleculeContainer,
double timestepLength);

/**
* Processes all halo particles outside the global domain.
*
*
* If a subdomain has no global walls, this function does nothing.
* For every global wall, the fucktion iterates through all halo particles that are one cutoff distance away
* from the wall. The following is done for each particle:
*
* For every global wall, the fucktion iterates through all halo particles
* that are one cutoff distance away from the wall. The following is done for
* each particle:
*
* PERIODIC - nop (default behaviour).
* REFLECTING - The halo particle is deleted.
* OUTFLOW - The halo particle is deleted.
*/
void removeNonPeriodicHalos(ParticleContainer* moleculeContainer);
void removeNonPeriodicHalos(ParticleContainer *moleculeContainer);

private:

/* List of global boundary type per dimension. */
/* List of global boundary type per dimension. */
std::map<BoundaryUtils::DimensionType, BoundaryUtils::BoundaryType>
_boundaries;

Expand Down
8 changes: 5 additions & 3 deletions src/parallel/boundaries/BoundaryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ enum class BoundaryType { PERIODIC, OUTFLOW, REFLECTING, ERROR };

/**
* enum storing the axes and direction.
*
*
* The dimensions are POSX, NEGX, POSY, NEGY, POSZ and NEGZ.
*
* This is hardcoded for 3D, and ERROR is included for sanity checks.
Expand Down Expand Up @@ -124,10 +124,12 @@ getOuterBuffer(const std::array<double, 3> givenRegionBegin,
const std::array<double, 3> givenRegionEnd,
DimensionType dimension, double *regionWidth);

/* Returns the sign of a number, used for determining direction from a dimension. */
/* Returns the sign of a number, used for determining direction from a
* dimension. */
inline int findSign(int n) { return n < 0 ? -1 : 1; }

/* Returns the sign of a number, used for determining direction from a dimension. */
/* Returns the sign of a number, used for determining direction from a
* dimension. */
inline int findSign(DimensionType dimension) {
return findSign(convertDimensionToNumeric(dimension));
}
Expand Down

0 comments on commit 6f7632a

Please sign in to comment.