Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strong Fluid-Rigid Coupling #285

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2c69c38
Time Integration without rotation
KritiaSthovania Mar 29, 2023
acd4e31
Merge branch 'master' of github.com:KritiaSthovania/SPlisHSPlasH
KritiaSthovania Mar 29, 2023
4a29ca6
dynamic rigid body (cube only)
KritiaSthovania Apr 1, 2023
706bd69
added tab for boundary model
KritiaSthovania Apr 2, 2023
9ffac69
include bugs fix, more fields on GUI
KritiaSthovania Apr 3, 2023
f025d7d
more properties on GUI
KritiaSthovania Apr 9, 2023
3064ad1
change update of angular accelaration
KritiaSthovania Apr 20, 2023
30dc723
RigidBodyParticleExporter
KritiaSthovania Apr 21, 2023
008c921
Strong Couping Update for WCSPH
KritiaSthovania Apr 24, 2023
a2d5611
save boundary particles to dynamic rigid body
KritiaSthovania Apr 25, 2023
014ae94
move some properties to BoundaryModel_AKinci
KritiaSthovania Apr 26, 2023
bd5a0b7
compute source term
KritiaSthovania Apr 27, 2023
d96e854
RHS of the equation (RHS to the source term)
KritiaSthovania Apr 28, 2023
ccb919e
gui update and bug fix
KritiaSthovania Apr 30, 2023
7ffb13b
jacobi step, not working yet
KritiaSthovania May 1, 2023
870fe4a
bug fix and slight reconstruction, not working though
KritiaSthovania May 2, 2023
2c388f0
compute diagonal element (not correct yet)
KritiaSthovania May 3, 2023
310a719
changed computeDiagonalElement (still not correct)
KritiaSthovania May 4, 2023
8c9e2e8
refactorized
KritiaSthovania May 8, 2023
b8e0544
refactorized
KritiaSthovania May 10, 2023
54d6e2a
bug fix
KritiaSthovania May 12, 2023
457ffa0
to debug
KritiaSthovania May 24, 2023
ea19f5a
diagonal element fix
KritiaSthovania May 26, 2023
ce4f1f9
looks like correct
KritiaSthovania May 30, 2023
bb0239c
refactoring and UI update
KritiaSthovania May 31, 2023
6e01275
moved pressure solve iterations to boundary solver
KritiaSthovania Jun 3, 2023
0377a9a
test scene file
KritiaSthovania Jun 7, 2023
008b2e9
added enum BoundaryHandlingMethod::Gissler2019, integration in IISPH
KritiaSthovania Jun 15, 2023
e51e9ec
DFSPH integration
KritiaSthovania Jun 23, 2023
3956674
bugfix and friction
KritiaSthovania Jun 25, 2023
77d034a
volume integration
KritiaSthovania Jun 26, 2023
0397009
modified python bindings correspondingly
KritiaSthovania Jul 13, 2023
2237caf
pybinding fix
KritiaSthovania Aug 2, 2023
978be1d
boundary solver kernel on gui
KritiaSthovania Aug 21, 2023
9e827a7
the solver now only solves for rigid bodies which have contacts
KritiaSthovania Sep 2, 2023
0359e89
slightly modified structure
KritiaSthovania Sep 5, 2023
f34ea71
improved RigidBodyParticleExporter
KritiaSthovania Sep 10, 2023
5ae3eff
reset bug fix
KritiaSthovania Sep 13, 2023
ca5b4d0
small change
KritiaSthovania Oct 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 43 additions & 4 deletions SPlisHSPlasH/BoundaryModel_Akinci2012.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Utilities/Logger.h"
#include "NeighborhoodSearch.h"
#include "Simulation.h"
#include "StrongCouplingBoundarySolver.h"

using namespace SPH;

Expand All @@ -18,6 +19,11 @@ BoundaryModel_Akinci2012::BoundaryModel_Akinci2012() :
{
m_sorted = false;
m_pointSetIndex = 0;

addField({ "position", FieldType::Vector3, [&](const unsigned int i) -> Real* { return &getPosition(i)[0]; }, true });
addField({ "position0", FieldType::Vector3, [&](const unsigned int i) -> Real* { return &getPosition0(i)[0]; } });
addField({ "velocity", FieldType::Vector3, [&](const unsigned int i) -> Real* { return &getVelocity(i)[0]; }, true });
addField({ "volume", FieldType::Scalar, [&](const unsigned int i) -> Real* { return &getVolume(i); }, true });
}

BoundaryModel_Akinci2012::~BoundaryModel_Akinci2012(void)
Expand All @@ -36,7 +42,6 @@ void BoundaryModel_Akinci2012::reset()
// positions and velocities are already updated by updateBoundaryParticles
if (!m_rigidBody->isDynamic() && !m_rigidBody->isAnimated())
{
// reset velocities and accelerations
for (int j = 0; j < (int)numberOfParticles(); j++)
{
m_x[j] = m_x0[j];
Expand All @@ -45,27 +50,61 @@ void BoundaryModel_Akinci2012::reset()
}
}

void SPH::BoundaryModel_Akinci2012::addField(const FieldDescription& field) {
m_fields.push_back(field);
std::sort(m_fields.begin(), m_fields.end(), [](FieldDescription& i, FieldDescription& j) -> bool { return (i.name < j.name); });
}

const FieldDescription& SPH::BoundaryModel_Akinci2012::getField(const std::string& name) {
unsigned int index = 0;
for (auto i = 0; i < m_fields.size(); i++) {
if (m_fields[i].name == name) {
index = i;
break;
}
}
return m_fields[index];
}

void SPH::BoundaryModel_Akinci2012::removeFieldByName(const std::string& fieldName) {
for (auto it = m_fields.begin(); it != m_fields.end(); it++) {
if (it->name == fieldName) {
m_fields.erase(it);
break;
}
}
}

void BoundaryModel_Akinci2012::computeBoundaryVolume()
{
Simulation *sim = Simulation::getCurrent();
const unsigned int nFluids = sim->numberOfFluidModels();
NeighborhoodSearch *neighborhoodSearch = Simulation::getCurrent()->getNeighborhoodSearch();

StrongCouplingBoundarySolver* bs = StrongCouplingBoundarySolver::getCurrent();
const unsigned int numBoundaryParticles = numberOfParticles();

#pragma omp parallel default(shared)
{
#pragma omp for schedule(static)
for (int i = 0; i < (int)numBoundaryParticles; i++)
{
Real delta = sim->W_zero();
Real delta;
if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Gissler2019) {
delta = bs->W_zero();
} else {
delta = sim->W_zero();
}
for (unsigned int pid = nFluids; pid < sim->numberOfPointSets(); pid++)
{
BoundaryModel_Akinci2012 *bm_neighbor = static_cast<BoundaryModel_Akinci2012*>(sim->getBoundaryModelFromPointSet(pid));
for (unsigned int j = 0; j < neighborhoodSearch->point_set(m_pointSetIndex).n_neighbors(pid, i); j++)
{
const unsigned int neighborIndex = neighborhoodSearch->point_set(m_pointSetIndex).neighbor(pid, i, j);
delta += sim->W(getPosition(i) - bm_neighbor->getPosition(neighborIndex));
if (sim->getBoundaryHandlingMethod() == BoundaryHandlingMethods::Gissler2019) {
delta += bs->W(getPosition(i) - bm_neighbor->getPosition(neighborIndex));
} else {
delta += sim->W(getPosition(i) - bm_neighbor->getPosition(neighborIndex));
}
}
}
const Real volume = static_cast<Real>(1.0) / delta;
Expand Down
12 changes: 11 additions & 1 deletion SPlisHSPlasH/BoundaryModel_Akinci2012.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "BoundaryModel.h"
#include "SPHKernels.h"
#include "FluidModel.h"


namespace SPH
Expand Down Expand Up @@ -33,8 +34,16 @@ namespace SPH
std::vector<Vector3r> m_x;
std::vector<Vector3r> m_v;
std::vector<Real> m_V;
std::vector<FieldDescription> m_fields;

public:
void addField(const FieldDescription& field);
const std::vector<FieldDescription>& getFields() {return m_fields;}
const FieldDescription& getField(const unsigned int i) {return m_fields[i];}
const FieldDescription& getField(const std::string& name);
const unsigned int numberOfFields() {return static_cast<unsigned int>(m_fields.size());}
void removeFieldByName(const std::string& fieldName);

unsigned int numberOfParticles() const { return static_cast<unsigned int>(m_x.size()); }
unsigned int getPointSetIndex() const { return m_pointSetIndex; }
bool isSorted() const { return m_sorted; }
Expand All @@ -50,7 +59,8 @@ namespace SPH
virtual void loadState(BinaryFileReader &binReader);

void initModel(RigidBodyObject *rbo, const unsigned int numBoundaryParticles, Vector3r *boundaryParticles);



FORCE_INLINE Vector3r &getPosition0(const unsigned int i)
{
return m_x0[i];
Expand Down
3 changes: 3 additions & 0 deletions SPlisHSPlasH/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ add_library(SPlisHSPlasH
BoundaryModel_Bender2019.h
BoundaryModel_Koschier2017.cpp
BoundaryModel_Koschier2017.h
DynamicRigidBody.h
Emitter.cpp
Emitter.h
EmitterSystem.cpp
Expand All @@ -232,6 +233,8 @@ add_library(SPlisHSPlasH
NonPressureForceBase.h
XSPH.cpp
XSPH.h
StrongCouplingBoundarySolver.cpp
StrongCouplingBoundarySolver.h


${WCSPH_HEADER_FILES}
Expand Down
8 changes: 7 additions & 1 deletion SPlisHSPlasH/DFSPH/SimulationDataDFSPH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ SimulationDataDFSPH::SimulationDataDFSPH() :
m_pressure_rho2(),
m_pressure_rho2_V(),
m_pressureAccel(),
m_density_adv()
m_density_adv(),
m_density_adv_no_boundary()
{
}

Expand All @@ -29,6 +30,7 @@ void SimulationDataDFSPH::init()
m_pressure_rho2.resize(nModels);
m_pressure_rho2_V.resize(nModels);
m_pressureAccel.resize(nModels);
m_density_adv_no_boundary.resize(nModels);

for (unsigned int i = 0; i < nModels; i++)
{
Expand All @@ -38,6 +40,7 @@ void SimulationDataDFSPH::init()
m_pressure_rho2[i].resize(fm->numParticles(), 0.0);
m_pressure_rho2_V[i].resize(fm->numParticles(), 0.0);
m_pressureAccel[i].resize(fm->numParticles(), Vector3r::Zero());
m_density_adv_no_boundary[i].resize(fm->numParticles(), 0.0);
}
}

Expand All @@ -53,12 +56,14 @@ void SimulationDataDFSPH::cleanup()
m_pressure_rho2[i].clear();
m_pressure_rho2_V[i].clear();
m_pressureAccel[i].clear();
m_density_adv_no_boundary[i].clear();
}
m_factor.clear();
m_density_adv.clear();
m_pressure_rho2.clear();
m_pressure_rho2_V.clear();
m_pressureAccel.clear();
m_density_adv_no_boundary.clear();
}

void SimulationDataDFSPH::reset()
Expand All @@ -76,6 +81,7 @@ void SimulationDataDFSPH::reset()
m_pressure_rho2_V[i][j] = 0.0;
m_factor[i][j] = 0.0;
m_pressureAccel[i][j].setZero();
m_density_adv_no_boundary[i][j] = 0.0;
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions SPlisHSPlasH/DFSPH/SimulationDataDFSPH.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace SPH
std::vector<std::vector<Real>> m_factor;
/** \brief advected density */
std::vector<std::vector<Real>> m_density_adv;
/** \brief for strong coupling (Gissler2019) */
std::vector<std::vector<Real>> m_density_adv_no_boundary;

/** \brief stores \f$\frac{p}{\rho^2}\f$ value of the constant density solver */
std::vector<std::vector<Real>> m_pressure_rho2;
Expand Down Expand Up @@ -85,6 +87,18 @@ namespace SPH
m_density_adv[fluidIndex][i] = d;
}

FORCE_INLINE const Real getDensityAdvNoBoundary(const unsigned int fluidIndex, const unsigned int i) const {
return m_density_adv_no_boundary[fluidIndex][i];
}

FORCE_INLINE Real& getDensityAdvNoBoundary(const unsigned int fluidIndex, const unsigned int i) {
return m_density_adv_no_boundary[fluidIndex][i];
}

FORCE_INLINE void setDensityAdvNoBoundary(const unsigned int fluidIndex, const unsigned int i, const Real d) {
m_density_adv_no_boundary[fluidIndex][i] = d;
}

FORCE_INLINE const Real getPressureRho2(const unsigned int fluidIndex, const unsigned int i) const
{
return m_pressure_rho2[fluidIndex][i];
Expand Down
Loading