Commit d2a2b88f authored by Andrew Wilson's avatar Andrew Wilson 🐘
Browse files

Merge branch 'PerfImprovements' into 'master'

BUG: Performance improvements to PBD and Dense LSM

See merge request !551
parents b0ed6693 70013502
Pipeline #221029 created
......@@ -216,25 +216,31 @@ LevelSetModel::evolve()
{
for (int x = 0; x < dim[0]; x++, i++)
{
// Center of voxel
//const Vec3d pos = Vec3d(x, y, z).cwiseProduct(spacing) + shift;
// Gradients
const Vec3d gradPos = m_forwardGrad(Vec3d(x, y, z));
const Vec3d gradNeg = m_backwardGrad(Vec3d(x, y, z));
//curvaturesPtr[i] = m_curvature(Vec3d(x, y, z));
// neg
gradientMagPtr[i * 2] =
std::pow(std::min(gradNeg[0], 0.0), 2) + std::pow(std::max(gradPos[0], 0.0), 2) +
std::pow(std::min(gradNeg[1], 0.0), 2) + std::pow(std::max(gradPos[1], 0.0), 2) +
std::pow(std::min(gradNeg[2], 0.0), 2) + std::pow(std::max(gradPos[2], 0.0), 2);
Vec3d gradNegMax = gradNeg.cwiseMax(0.0);
Vec3d gradNegMin = gradNeg.cwiseMin(0.0);
Vec3d gradPosMax = gradPos.cwiseMax(0.0);
Vec3d gradPosMin = gradPos.cwiseMin(0.0);
// Square them
gradNegMax = gradNegMax.cwiseProduct(gradNegMax);
gradNegMin = gradNegMin.cwiseProduct(gradNegMin);
gradPosMax = gradPosMax.cwiseProduct(gradPosMax);
gradPosMin = gradPosMin.cwiseProduct(gradPosMin);
// pos
// Pos
gradientMagPtr[i * 2 + 1] =
std::pow(std::max(gradNeg[0], 0.0), 2) + std::pow(std::min(gradPos[0], 0.0), 2) +
std::pow(std::max(gradNeg[1], 0.0), 2) + std::pow(std::min(gradPos[1], 0.0), 2) +
std::pow(std::max(gradNeg[2], 0.0), 2) + std::pow(std::min(gradPos[2], 0.0), 2);
gradNegMax[0] + gradNegMax[1] + gradNegMax[2] +
gradPosMin[0] + gradPosMin[1] + gradPosMin[2];
// Neg
gradientMagPtr[i * 2] =
gradNegMin[0] + gradNegMin[1] + gradNegMin[2] +
gradPosMax[0] + gradPosMax[1] + gradPosMax[2];
}
}
});
......
......@@ -108,6 +108,7 @@ PbdModel::initialize()
// Initialize constraints
{
m_constraints = std::make_shared<PBDConstraintVector>();
m_partitionedConstraints = std::make_shared<std::vector<PBDConstraintVector>>();
// Initialize FEM constraints
for (auto& constraint : m_parameters->m_FEMConstraints)
......@@ -167,11 +168,7 @@ PbdModel::initialize()
}
// Partition constraints for parallel computation
if (!m_partitioned)
{
this->partitionConstraints();
m_partitioned = true;
}
this->partitionConstraints();
}
// Setup the default pbd solver if none exists
......
......@@ -270,7 +270,6 @@ protected:
void initGraphEdges(std::shared_ptr<TaskNode> source, std::shared_ptr<TaskNode> sink) override;
protected:
bool m_partitioned = false; /// \todo this is used in initialize() as a temporary fix to problems on linux
size_t m_partitionThreshold = 16; ///> Threshold for constraint partitioning
std::shared_ptr<PbdSolver> m_pbdSolver = nullptr; ///> PBD solver
......
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