Commit a2b90a8a authored by Nghia Truong's avatar Nghia Truong

REFAC: Remove ParallelReduce namespace

parent f911c88d
......@@ -129,7 +129,7 @@ main()
// Compute the scale factor to scale meshes such that meshes with different sizes are still visualized consistently
Vec3d lowerCorner, upperCorner;
const auto pointset = std::dynamic_pointer_cast<PointSet>(triMeshes.front());
ParallelUtils::ParallelReduce::findAABB(pointset->getVertexPositions(), lowerCorner, upperCorner);
ParallelUtils::findAABB(pointset->getVertexPositions(), lowerCorner, upperCorner);
const auto scaleFactor = 20.0 / (upperCorner - lowerCorner).norm();
for (const auto& mesh: triMeshes)
{
......@@ -197,7 +197,7 @@ main()
}
Vec3d lowerCorners, upperCorner;
ParallelUtils::ParallelReduce::findAABB(centers, lowerCorners, upperCorner);
ParallelUtils::findAABB(centers, lowerCorners, upperCorner);
if ((lowerCorners - upperCorner).norm() > 70.0)
{
for (size_t i = 0; i < dirs.size(); ++i)
......
......@@ -32,12 +32,6 @@ namespace imstk
namespace ParallelUtils
{
///
/// \brief The ParallelReduce class
/// \brief A class for executing reduce operations in parallel
///
class ParallelReduce
{
///
/// \brief Private helper class, providing operator() using in std::parallel_reduce
/// for finding max L2 norm of an array of Vec3r
///
......@@ -117,27 +111,27 @@ private:
const StdVectorOfVec3r& m_Data;
};
public:
///
/// \brief Find the maximum value of L2 norm from the input data array
///
static Real findMaxL2Norm(const StdVectorOfVec3r& data)
{
MaxL2NormFunctor pObj(data);
tbb::parallel_reduce(tbb::blocked_range<size_t>(0, data.size()), pObj);
return pObj.getResult();
}
///
/// \brief Find the maximum value of L2 norm from the input data array
///
inline Real
findMaxL2Norm(const StdVectorOfVec3r& data)
{
MaxL2NormFunctor pObj(data);
tbb::parallel_reduce(tbb::blocked_range<size_t>(0, data.size()), pObj);
return pObj.getResult();
}
///
/// \brief Find the bounding box of a point set
///
static void findAABB(const StdVectorOfVec3r& points, Vec3r& lowerCorner, Vec3r& upperCorner)
{
AABBFunctor pObj(points);
tbb::parallel_reduce(tbb::blocked_range<size_t>(0, points.size()), pObj);
lowerCorner = pObj.getLowerCorner();
upperCorner = pObj.getUpperCorner();
}
};
///
/// \brief Find the bounding box of a point set
///
inline void
findAABB(const StdVectorOfVec3r& points, Vec3r& lowerCorner, Vec3r& upperCorner)
{
AABBFunctor pObj(points);
tbb::parallel_reduce(tbb::blocked_range<size_t>(0, points.size()), pObj);
lowerCorner = pObj.getLowerCorner();
upperCorner = pObj.getUpperCorner();
}
} // end namespace ParallelUtils
} // end namespace imstk
......@@ -54,7 +54,7 @@ GridBasedNeighborSearch::getNeighbors(std::vector<std::vector<size_t>>& result,
// firstly compute the bounding box of points in setB
Vec3r lowerCorner;
Vec3r upperCorner;
ParallelUtils::ParallelReduce::findAABB(setB, lowerCorner, upperCorner);
ParallelUtils::findAABB(setB, lowerCorner, upperCorner);
// the upper corner need to be expanded a bit, to avoid round-off error during computation
upperCorner += Vec3d(m_SearchRadius, m_SearchRadius, m_SearchRadius) * Real(0.1);
......
......@@ -101,7 +101,7 @@ SPHModel::computeTimeStepSize()
Real
SPHModel::computeCFLTimeStepSize()
{
auto maxVel = ParallelUtils::ParallelReduce::findMaxL2Norm(getState().getVelocities());
auto maxVel = ParallelUtils::findMaxL2Norm(getState().getVelocities());
// dt = CFL * 2r / max{|| v ||}
Real timestep = maxVel > Real(1e-6) ? m_Parameters->m_CFLFactor * (Real(2.0) * m_Parameters->m_ParticleRadius / maxVel) : m_Parameters->m_MaxTimestep;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment