Skip to content

Commit

Permalink
minor tidy using the last
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertnash committed Mar 7, 2023
1 parent 9d20c4b commit 20d42ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
40 changes: 13 additions & 27 deletions Code/geometry/Domain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ namespace hemelb
for (unsigned int l = 1; l < latticeInfo.GetNumVectors(); l++)
{
// Find the neighbour site co-ords in this direction.
util::Vector3D<site_t> neighbourGlobalCoords = blockTraverser.GetCurrentLocation()
* readResult.GetBlockSize() + siteTraverser.GetCurrentLocation()
+ util::Vector3D<site_t>(latticeInfo.GetVector(l));
util::Vector3D<site_t> neighbourGlobalCoords =
blockTraverser.GetCurrentLocation() * readResult.GetBlockSize()
+ siteTraverser.GetCurrentLocation()
+ latticeInfo.GetVector(l).as<site_t>();

if (!neighbourGlobalCoords.IsInRange(
util::Vector3D<site_t>::Zero(),
Expand Down Expand Up @@ -355,23 +356,16 @@ namespace hemelb

void Domain::CollectGlobalSiteExtrema()
{
std::vector<site_t> localMins(3);
std::vector<site_t> localMaxes(3);

for (unsigned dim = 0; dim < 3; ++dim)
{
localMins[dim] = std::numeric_limits<site_t>::max();
localMaxes[dim] = 0;
}
auto localMins = util::Vector3D<site_t>::Largest();
auto localMaxes = util::Vector3D<site_t>::Zero();

for (BlockTraverser blockSet(*this); blockSet.CurrentLocationValid();
blockSet.TraverseOne())
{
auto const& block = blockSet.GetCurrentBlockData();
if (block.IsEmpty())
{
continue;
}

for (auto siteSet = blockSet.GetSiteTraverser();
siteSet.CurrentLocationValid(); siteSet.TraverseOne())
{
Expand All @@ -380,26 +374,18 @@ namespace hemelb
util::Vector3D<site_t> globalCoords = blockSet.GetCurrentLocation() * GetBlockSize()
+ siteSet.GetCurrentLocation();

for (unsigned dim = 0; dim < 3; ++dim)
{
localMins[dim] = hemelb::util::NumericalFunctions::min(localMins[dim],
globalCoords[dim]);
localMaxes[dim] = hemelb::util::NumericalFunctions::max(localMaxes[dim],
globalCoords[dim]);
}
localMins.UpdatePointwiseMin(globalCoords);
localMaxes.UpdatePointwiseMax(globalCoords);
}
}

}

std::vector<site_t> siteMins = comms.AllReduce(localMins, MPI_MIN);
std::vector<site_t> siteMaxes = comms.AllReduce(localMaxes, MPI_MAX);
comms.AllReduceInPlace(std::span(localMins.begin(), localMins.end()), MPI_MIN);
comms.AllReduceInPlace(std::span(localMins.begin(), localMins.end()), MPI_MAX);

for (unsigned ii = 0; ii < 3; ++ii)
{
globalSiteMins[ii] = siteMins[ii];
globalSiteMaxes[ii] = siteMaxes[ii];
}
globalSiteMins = localMins;
globalSiteMaxes = localMaxes;
}

void Domain::InitialiseNeighbourLookups()
Expand Down
2 changes: 1 addition & 1 deletion Code/geometry/VolumeTraverser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace hemelb::geometry
{
}

util::Vector3D<site_t> VolumeTraverser::GetCurrentLocation()
util::Vector3D<site_t>const& VolumeTraverser::GetCurrentLocation()
{
return mCurrentLocation;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/geometry/VolumeTraverser.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace hemelb::geometry
public:
virtual ~VolumeTraverser();

util::Vector3D<site_t> GetCurrentLocation();
util::Vector3D<site_t> const& GetCurrentLocation();

site_t GetCurrentIndex() const;

Expand Down

0 comments on commit 20d42ce

Please sign in to comment.