Skip to content

Commit 683c064

Browse files
committed
Density clean up
1 parent b1fc9ba commit 683c064

File tree

3 files changed

+14
-55
lines changed

3 files changed

+14
-55
lines changed

SphWaterfall/SphWaterfall/src/simulation/SphManager.cpp

+6-46
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,6 @@ SphManager::~SphManager() {
2525

2626
}
2727

28-
void SphManager::initDensities() {
29-
/*
30-
std::vector<SphParticle> each_neighbour_particles;
31-
std::unordered_map <int, std::vector<SphParticle>> each_neighbour_static_rim_particles;
32-
33-
for (auto& each_domain : domains) {
34-
if (each_domain.second.hasStaticParticles()) {
35-
// gets neighbour particle map from domain
36-
each_neighbour_static_rim_particles = each_domain.second.getStaticNeighbourRimParticles();
37-
38-
for (auto& each_particle : each_domain.second.getStaticParticles()) {
39-
// gets particles of domain the particle is in
40-
each_neighbour_particles = each_domain.second.getStaticParticles();
41-
42-
for (auto& domain_id : neighbour_search->findRelevantNeighbourDomains(each_particle.position, domain_dimensions)) {
43-
// tests if domain of particle has neighbour particles for currently looked at neighbour domain
44-
if (each_neighbour_static_rim_particles.count(domain_id) != 0) {
45-
each_neighbour_particles.insert(each_neighbour_particles.end(),
46-
each_neighbour_static_rim_particles.at(domain_id).begin(),
47-
each_neighbour_static_rim_particles.at(domain_id).end());
48-
}
49-
}
50-
51-
each_neighbour_particles = neighbour_search->findNeigbours(each_particle.position, each_neighbour_particles);
52-
neighbour_particles.push_back(std::pair<SphParticle, std::vector<SphParticle>>(each_particle, each_neighbour_particles));
53-
}
54-
}
55-
}
56-
*/
57-
58-
for (auto& each_domain : domains) {
59-
for (auto& each_particle : each_domain.second.getStaticParticles()) {
60-
//computeLocalDensity(each_particle);
61-
each_particle.local_density = 10.0;
62-
}
63-
}
64-
}
65-
6628
void SphManager::simulate() {
6729
MPI_Comm_rank(slave_comm, &mpi_rank);
6830

@@ -79,8 +41,6 @@ void SphManager::simulate() {
7941
std::cout << "finished static rim exchange" << std::endl;
8042
}
8143

82-
initDensities();
83-
8444
MPI_Barrier(slave_comm);
8545

8646
if (mpi_rank == 0) {
@@ -262,12 +222,12 @@ void SphManager::computeLocalDensity(SphParticle& particle) {
262222
local_density += neighbour_particle.mass * kernel->computeKernelValue(particle.position - neighbour_particle.position);
263223
}
264224

265-
//if (local_density < FLUID_REFERENCE_DENSITY) {
266-
// particle.local_density = FLUID_REFERENCE_DENSITY;
267-
//}
268-
//else {
225+
if (local_density < FLUID_REFERENCE_DENSITY) {
226+
particle.local_density = FLUID_REFERENCE_DENSITY;
227+
}
228+
else {
269229
particle.local_density = local_density;
270-
//}
230+
}
271231
}
272232

273233
Vector3 SphManager::computeDensityAcceleration(SphParticle& particle) {
@@ -644,7 +604,7 @@ void SphManager::exportParticles() {
644604

645605
for (auto& each_domain : domains) {
646606
if (each_domain.second.hasFluidParticles()) {
647-
for (SphParticle& each_particle : each_domain.second.getParticles()) { // change getParticles to getFluidParticles later
607+
for (SphParticle& each_particle : each_domain.second.getFluidParticles()) { // change getParticles to getFluidParticles later
648608
particles_to_export.push_back(each_particle);
649609
}
650610
}

SphWaterfall/SphWaterfall/src/simulation/SphManager.h

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class SphManager {
4949
void cleanUpFluidParticles();
5050
void cleanUpStaticParticles();
5151

52-
void initDensities();
5352
void update();
5453
bool updateVelocity(SphParticle& particle);
5554
Vector3 computeAcceleration(SphParticle& particle);

cube_30.obj

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Blender v2.79 (sub 0) OBJ File: ''
22
# www.blender.org
33
o Cube_Cube.001
4-
v 0.000000 0.000000 0.000000
5-
v 0.000000 30.000000 0.000000
6-
v 0.000000 0.000000 30.000000
7-
v 0.000000 30.000000 30.000000
8-
v 30.000000 0.000000 0.000000
9-
v 30.000000 30.000000 0.000000
10-
v 30.000000 0.000000 30.000000
11-
v 30.000000 30.000000 30.000000
4+
v 0.000000 5.000000 0.000000
5+
v 0.000000 35.000000 0.000000
6+
v 0.000000 5.000000 30.000000
7+
v 0.000000 35.000000 30.000000
8+
v 30.000000 5.000000 0.000000
9+
v 30.000000 35.000000 0.000000
10+
v 30.000000 5.000000 30.000000
11+
v 30.000000 35.000000 30.000000
1212
s 1
1313
f 1 2 4
1414
f 1 4 3

0 commit comments

Comments
 (0)