Skip to content

Commit

Permalink
+ energy particle collision with moving walls corrected
Browse files Browse the repository at this point in the history
+ restoring position in simulation parameters improved
  • Loading branch information
chrxh committed Aug 22, 2023
1 parent 64a3cf1 commit 4fe5c63
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 24 deletions.
2 changes: 1 addition & 1 deletion source/Base/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Const
{
std::string const ProgramVersion = "4.0.0.beta.40";
std::string const ProgramVersion = "4.0.0.beta.41";

std::string const BasePath = "resources/";

Expand Down
4 changes: 2 additions & 2 deletions source/EngineGpuKernels/ParticleProcessor.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ __inline__ __device__ void ParticleProcessor::collision(SimulationData& data)
} else {
if (auto cell = data.cellMap.getFirst(particle->absPos + particle->vel)) {
if (cell->barrier) {
auto vr = particle->vel;
auto vr = particle->vel - cell->vel;
auto r = data.cellMap.getCorrectedDirection(particle->absPos - cell->pos);
auto dot_vr_r = Math::dot(vr, r);
if (dot_vr_r < 0) {
particle->vel = vr - r * 2 * dot_vr_r / Math::lengthSquared(r);
particle->vel = vr - r * 2 * dot_vr_r / Math::lengthSquared(r) + cell->vel;
}
} else {
if (particle->lastAbsorbedCell == cell) {
Expand Down
3 changes: 2 additions & 1 deletion source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ void _SimulationParametersWindow::processBase(
.defaultValue(&origSimParameters.motionData.fluidMotion.smoothingLength)
.tooltip(std::string("The smoothing length determines the region of influence of the neighboring particles for the calculation of "
"density, pressure and viscosity. Values that are too small lead to numerical instabilities, while values that "
"are too large cause the particles to drift apart.")),
"are too large cause the particles to drift apart. In the case of using indestructible cells in a simulation, it "
"is advisable to consider a value of no less than 0.8")),
&simParameters.motionData.fluidMotion.smoothingLength);
AlienImGui::SliderFloat(
AlienImGui::SliderFloatParameters()
Expand Down
2 changes: 1 addition & 1 deletion source/Gui/StartupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace
{
std::chrono::milliseconds::rep const LogoDuration = 2500;
std::chrono::milliseconds::rep const LogoDuration = 3000;
std::chrono::milliseconds::rep const FadeOutDuration = 1500;
std::chrono::milliseconds::rep const FadeInDuration = 500;

Expand Down
21 changes: 2 additions & 19 deletions source/Gui/TemporalControlWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,6 @@ void _TemporalControlWindow::restorePosition(MovedObjectType& movedObject, Moved
auto origMovedObjectClone = origMovedObject;
auto movedObjectClone = movedObject;

origMovedObjectClone.posX = 0;
origMovedObjectClone.posY = 0;
movedObjectClone.posX = 0;
movedObjectClone.posY = 0;
if (origMovedObjectClone != movedObjectClone) {
return;
}

auto timestepDelta = toFloat(toDouble(_simController->getCurrentTimestep()) - toDouble(origTimestep));
auto projectedPos = RealVector2D(origMovedObject.posX, origMovedObject.posY) + RealVector2D(origMovedObject.velX, origMovedObject.velY) * timestepDelta;

SpaceCalculator space(_simController->getWorldSize());
projectedPos = space.getCorrectedPosition(projectedPos);

auto deviation = std::abs(movedObject.posX - projectedPos.x) + std::abs(movedObject.posY - projectedPos.y);
if (deviation < RestorePositionTolerance) {
movedObject.posX = origMovedObject.posX;
movedObject.posY = origMovedObject.posY;
}
movedObject.posX = origMovedObject.posX;
movedObject.posY = origMovedObject.posY;
}

0 comments on commit 4fe5c63

Please sign in to comment.