Commit 80cba6da authored by Nghia Truong's avatar Nghia Truong
Browse files

BUG: Fix error due to c++11 standard

parent 6e2eb4b6
......@@ -70,7 +70,7 @@ void GridBasedNeighborSearch::getNeighbors(std::vector<std::vector<size_t>>&resu
m_Grid.initialize(lowerCorner, upperCorner, m_SearchRadius);
// clear all particle lists in each grid cell
m_Grid.loopAllCellData([](auto& list) { list.resize(0); });
m_Grid.loopAllCellData([](std::vector<size_t>& list) { list.resize(0); });
// collect particle indices of points in setB into their corresponding cells
for(size_t p = 0; p < setB.size(); ++p)
......
......@@ -76,12 +76,12 @@ public:
///
/// \brief Get number of grid cell in 3 dimensions: (num_cell_x, num_cell_y, num_cell_z)
///
auto getResolution() const { return m_Resolution; }
std::array<unsigned int, 3> getResolution() const { return m_Resolution; }
///
/// \brief Get number of total cells in the grid
///
auto getNumTotalCells() const { return m_NTotalCells; }
unsigned int getNumTotalCells() const { return m_NTotalCells; }
///
/// \brief Check if cell index in dimension d is valid (d = 0/1/2 => x/y/z dimension)
......@@ -187,7 +187,7 @@ private:
Real m_CellSize {1.0};
Real m_InvCellSize {1.0};
unsigned int m_Resolution[3] { 0u, 0u, 0u };
std::array<unsigned int, 3> m_Resolution { 0u, 0u, 0u };
unsigned int m_NTotalCells { 1u };
std::vector<CellData> m_CellData;
......
......@@ -199,7 +199,7 @@ protected:
template<int N>
class SPIkyKernel {
class SpikyKernel {
using VecXr = Eigen::Matrix<Real, N, 1>;
public:
......@@ -446,20 +446,20 @@ public:
void initialize(const Real kernelRadius)
{
m_poly6.setRadius(kernelRadius);
m_sPIky.setRadius(kernelRadius);
m_spiky.setRadius(kernelRadius);
m_viscosity.setRadius(kernelRadius);
m_cohesion.setRadius(kernelRadius);
}
auto W_zero() const { return m_poly6.W_zero(); }
auto W(const Vec3r& r) const { return m_poly6.W(r); }
auto gradW(const Vec3r& r) const { return m_sPIky.gradW(r); }
auto laplace(const Vec3r& r) const { return m_viscosity.laplace(r); }
auto cohesionW(const Vec3r& r) const { return m_cohesion.W(r); }
Real W_zero() const { return m_poly6.W_zero(); }
Real W(const Vec3r& r) const { return m_poly6.W(r); }
Vec3r gradW(const Vec3r& r) const { return m_spiky.gradW(r); }
Real laplace(const Vec3r& r) const { return m_viscosity.laplace(r); }
Real cohesionW(const Vec3r& r) const { return m_cohesion.W(r); }
protected:
SPH::Poly6Kernel<3> m_poly6;
SPH::SPIkyKernel<3> m_sPIky;
SPH::SpikyKernel<3> m_spiky;
SPH::ViscosityKernel<3> m_viscosity;
SPH::CohesionKernel<3> m_cohesion;
};
......
......@@ -180,7 +180,8 @@ void SPHModel::findParticleNeighbors()
void SPHModel::computeNeighborRelativePositions()
{
auto computeRelativePositions = [&](const auto& ppos, const auto& neighborList, const auto& allPositions, auto& neighborInfo) {
auto computeRelativePositions = [&](const Vec3r& ppos, const std::vector<size_t>& neighborList,
const StdVectorOfVec3r& allPositions, std::vector<NeighborInfo>& neighborInfo) {
for(size_t q : neighborList)
{
const Vec3r& qpos = allPositions[q];
......@@ -303,7 +304,7 @@ void SPHModel::normalizeDensity()
void SPHModel::computePressureAcceleration()
{
auto particlePressure = [&](auto density) {
auto particlePressure = [&](Real density) {
Real error = std::pow(density / m_Parameters->m_RestDensity, 7) - Real(1);
// clamp pressure error to zero to maintain stability
......
......@@ -169,20 +169,20 @@ public:
///
/// \brief Get the parameters
///
auto& getParameters() { assert(m_Parameters); return m_Parameters; }
const auto& getParameters() const { assert(m_Parameters); return m_Parameters; }
std::shared_ptr<SPHModelConfig>& getParameters() { assert(m_Parameters); return m_Parameters; }
const std::shared_ptr<SPHModelConfig>& getParameters() const { assert(m_Parameters); return m_Parameters; }
///
/// \brief Get the kinematics particle data (positions + velocities)
///
auto& getKinematicsState() { assert(this->m_currentState); return *this->m_currentState; }
const auto& getKinematicsState() const { assert(this->m_currentState); return *this->m_currentState; }
SPHKinematicState& getKinematicsState() { assert(this->m_currentState); return *this->m_currentState; }
const SPHKinematicState& getKinematicsState() const { assert(this->m_currentState); return *this->m_currentState; }
///
/// \brief Get particle simulation data
///
auto& getState() { return m_SimulationState; }
const auto& getState() const { return m_SimulationState; }
SPHSimulationState& getState() { return m_SimulationState; }
const SPHSimulationState& getState() const { return m_SimulationState; }
///
/// \brief Set the default time step size, valid only if using a fixed time step for integration
......
......@@ -46,6 +46,15 @@ void runLoop(IndexType size, Function&& func)
runLoop<IndexType, Function>(0, size, std::forward<Function>(func));
}
///
/// \brief The helper struct to store relative positions and densities of neighbor particlcles
///
struct NeighborInfo
{
Vec3r xpq; // relative position: xpq = x_p - x_q
Real density; // density of neighbor particle q
};
///
/// \class SPHKinematicState
/// \brief State of the SPH fluid particles
......@@ -72,14 +81,14 @@ public:
///
/// \brief Returns the vector of all particle positions
///
auto& getPositions() { return m_Positions; }
const auto& getPositions() const { return m_Positions; }
StdVectorOfVec3r& getPositions() { return m_Positions; }
const StdVectorOfVec3r& getPositions() const { return m_Positions; }
///
/// \brief Returns the vector of all particle velocities
///
auto& getVelocities() { return m_Velocities; }
const auto& getVelocities() const { return m_Velocities; }
StdVectorOfVec3r& getVelocities() { return m_Velocities; }
const StdVectorOfVec3r& getVelocities() const { return m_Velocities; }
///
/// \brief Set the state to a given one
......@@ -128,68 +137,68 @@ public:
///
/// \brief Returns the vector of all particle positions
///
auto& getPositions() { assert(m_KinematicState); return m_KinematicState->getPositions(); }
const auto& getPositions() const { assert(m_KinematicState); return m_KinematicState->getPositions(); }
StdVectorOfVec3r& getPositions() { assert(m_KinematicState); return m_KinematicState->getPositions(); }
const StdVectorOfVec3r& getPositions() const { assert(m_KinematicState); return m_KinematicState->getPositions(); }
///
/// \brief Returns the vector of all particle velocities
///
auto& getVelocities() { assert(m_KinematicState); return m_KinematicState->getVelocities(); }
const auto& getVelocities() const { assert(m_KinematicState); return m_KinematicState->getVelocities(); }
StdVectorOfVec3r& getVelocities() { assert(m_KinematicState); return m_KinematicState->getVelocities(); }
const StdVectorOfVec3r& getVelocities() const { assert(m_KinematicState); return m_KinematicState->getVelocities(); }
///
/// \brief Returns the vector of all particle positions
///
auto& getBoundaryParticlePositions() { return m_BDPositions; }
const auto& getBoundaryParticlePositions() const { return m_BDPositions; }
StdVectorOfVec3r& getBoundaryParticlePositions() { return m_BDPositions; }
const StdVectorOfVec3r& getBoundaryParticlePositions() const { return m_BDPositions; }
///
/// \brief Returns the vector of all particle surface normals
///
auto& getNormals() { return m_Normals; }
const auto& getNormals() const { return m_Normals; }
StdVectorOfVec3r& getNormals() { return m_Normals; }
const StdVectorOfVec3r& getNormals() const { return m_Normals; }
///
/// \brief Returns the vector of all particle densities
///
auto& getDensities() { return m_Densities; }
const auto& getDensities() const { return m_Densities; }
StdVectorOfReal& getDensities() { return m_Densities; }
const StdVectorOfReal& getDensities() const { return m_Densities; }
///
/// \brief Returns the vector of all particle densities
///
auto& getNormalizedDensities() { return m_NormalizedDensities; }
const auto& getNormalizedDensities() const { return m_NormalizedDensities; }
StdVectorOfReal& getNormalizedDensities() { return m_NormalizedDensities; }
const StdVectorOfReal& getNormalizedDensities() const { return m_NormalizedDensities; }
///
/// \brief Returns the vector of all particle accelerations
///
auto& getAccelerations() { return m_Accels; }
const auto& getAccelerations() const { return m_Accels; }
StdVectorOfVec3r& getAccelerations() { return m_Accels; }
const StdVectorOfVec3r& getAccelerations() const { return m_Accels; }
///
/// \brief Returns the vector of all velocity diffusion
///
auto& getDiffuseVelocities() { return m_DiffuseVelocities; }
const auto& getDiffuseVelocities() const { return m_DiffuseVelocities; }
StdVectorOfVec3r& getDiffuseVelocities() { return m_DiffuseVelocities; }
const StdVectorOfVec3r& getDiffuseVelocities() const { return m_DiffuseVelocities; }
///
/// \brief Returns the vector of neighbor fluid particles
///
auto& getFluidNeighborLists() { return m_NeighborLists; }
const auto& getFluidNeighborLists() const { return m_NeighborLists; }
std::vector<std::vector<size_t>>& getFluidNeighborLists() { return m_NeighborLists; }
const std::vector<std::vector<size_t>>& getFluidNeighborLists() const { return m_NeighborLists; }
///
/// \brief Returns the vector of neighbor of boundary particles
///
auto& getBoundaryNeighborLists() { return m_BDNeighborLists; }
const auto& getBoundaryNeighborLists() const { return m_BDNeighborLists; }
std::vector<std::vector<size_t>>& getBoundaryNeighborLists() { return m_BDNeighborLists; }
const std::vector<std::vector<size_t>>& getBoundaryNeighborLists() const { return m_BDNeighborLists; }
///
/// \brief Returns the vector of neighbor information ( {relative position, density} ), which is cached for other computation
///
auto& getNeighborInfo() { return m_NeighborInfo; }
const auto& getNeighborInfo() const { return m_NeighborInfo; }
std::vector<std::vector<NeighborInfo>>& getNeighborInfo() { return m_NeighborInfo; }
const std::vector<std::vector<NeighborInfo>>& getNeighborInfo() const { return m_NeighborInfo; }
private:
std::shared_ptr<SPHKinematicState> m_KinematicState; // basic state: positions + velocities
......@@ -202,12 +211,6 @@ private:
StdVectorOfVec3r m_DiffuseVelocities; // velocity diffusion, used for computing viscosity
std::vector<std::vector<size_t>> m_NeighborLists; // store a list of neighbors for each particle, updated each time step
std::vector<std::vector<size_t>> m_BDNeighborLists; // store a list of boundary particle neighbors for each particle, updated each time step
struct NeighborInfo
{
Vec3r xpq; // relative position: xpq = x_p - x_q
Real density; // density of neighbor particle q
};
std::vector<std::vector<NeighborInfo>> m_NeighborInfo; // store a list of Vec4r(Vec3r(relative position), density) for neighbors, including boundary particle
std::vector<std::vector<NeighborInfo>> m_NeighborInfo; // store a list of Vec4r(Vec3r(relative position), density) for neighbors, including boundary particle
};
} // end namespace imstk
......@@ -54,7 +54,7 @@ public:
///
/// \brief Get the SPH model of the object
///
const auto& getSPHModel() const { assert(m_SPHModel); return m_SPHModel; }
const std::shared_ptr<SPHModel>& getSPHModel() const { assert(m_SPHModel); return m_SPHModel; }
protected:
std::shared_ptr<SPHModel> m_SPHModel;
......
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