Skip to content

Commit

Permalink
Merge pull request #99 from ManuelLerchner/98-refactoring
Browse files Browse the repository at this point in the history
General Refactoring and Fixes
  • Loading branch information
ManuelLerchner authored Jan 22, 2024
2 parents 24b2840 + 7ec61bd commit ed8bd05
Show file tree
Hide file tree
Showing 31 changed files with 884 additions and 125 deletions.
9 changes: 6 additions & 3 deletions benchmarks/contest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ void execute2DRectBenchmark() {
LinkedCellsContainer::BoundaryCondition::OUTFLOW, LinkedCellsContainer::BoundaryCondition::OUTFLOW};

// Settings for the Cuboid spawner of task 2
CuboidSpawner spawner1({0.6, 2.0, 0.5}, {250, 20, 1}, 1.2, 1.0, {0.0, 0.0, 0.0}, static_cast<int>(0), 1.0, 1.2, false, false, 40);
CuboidSpawner spawner2({0.6, 27.0, 0.5}, {250, 20, 1}, 1.2, 2.0, {0.0, 0.0, 0.0}, static_cast<int>(1), 1.0, 1.1, false, false, 40);
CuboidSpawner spawner1({0.6, 2.0, 0.5}, {250, 20, 1}, 1.2, 1.0, {0.0, 0.0, 0.0}, static_cast<int>(0), 1.0, 1.2, LockState::UNLOCKED,
ThirdDimension::DISABLED, 40);
CuboidSpawner spawner2({0.6, 27.0, 0.5}, {250, 20, 1}, 1.2, 2.0, {0.0, 0.0, 0.0}, static_cast<int>(1), 1.0, 1.1, LockState::UNLOCKED,
ThirdDimension::DISABLED, 40);

std::vector<std::shared_ptr<PairwiseForceSource>> pairwise_forces;
std::vector<std::shared_ptr<SimpleForceSource>> simple_force_sources;
pairwise_forces.push_back(std::make_shared<LennardJonesForce>());
simple_force_sources.push_back(std::make_shared<GlobalDownwardsGravity>(12.44));

// Set the thermostat:
std::shared_ptr<Thermostat> thermostat = std::make_shared<AbsoluteThermostat>(40, std::numeric_limits<double>::infinity(), false);
std::shared_ptr<Thermostat> thermostat =
std::make_shared<AbsoluteThermostat>(40, std::numeric_limits<double>::infinity(), ThirdDimension::DISABLED);
std::vector<std::shared_ptr<SimulationInterceptor>> simulation_interceptors;
simulation_interceptors.push_back(std::make_shared<ThermostatInterceptor>(thermostat, 1000));

Expand Down
3 changes: 2 additions & 1 deletion input/membrane/membrane_periodic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<GlobalDownwardsGravity g="0.001" />
</forces>
<interceptors>
<FrameWriter output_format="vtu" fps="60" video_length_s="30" />
<FrameWriter output_format="vtu" fps="24" video_length_s="30" />
<FrameWriter output_format="chkpt" fps="10" video_length_s="1" />
</interceptors>
</settings>

Expand Down
14 changes: 8 additions & 6 deletions src/io/input/xml/XMLFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "io/output/chkpt/CheckPointWriter.h"
#include "io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.h"
#include "simulation/Simulation.h"
#include "utils/Enums.h"

std::string trim(const std::string& str) {
// skip whitespace and newlines
Expand Down Expand Up @@ -138,12 +139,13 @@ std::tuple<std::vector<Particle>, SimulationParams> prepareParticles(std::filesy
auto settings = config.settings();
auto particle_sources = config.particle_source();

ThirdDimension third_dimension = settings.third_dimension() ? ThirdDimension::ENABLED : ThirdDimension::DISABLED;

std::vector<Particle> particles;

auto container_type = XSDToInternalTypeAdapter::convertToParticleContainer(settings.particle_container());

auto interceptors =
XSDToInternalTypeAdapter::convertToSimulationInterceptors(settings.interceptors(), settings.third_dimension(), container_type);
auto interceptors = XSDToInternalTypeAdapter::convertToSimulationInterceptors(settings.interceptors(), third_dimension, container_type);

auto forces = XSDToInternalTypeAdapter::convertToForces(settings.forces(), container_type);

Expand Down Expand Up @@ -199,7 +201,7 @@ std::tuple<std::vector<Particle>, SimulationParams> prepareParticles(std::filesy
if (load_in_spawners) {
// Spawn particles specified in the XML file
for (auto cuboid_spawner : particle_sources.cuboid_spawner()) {
auto spawner = XSDToInternalTypeAdapter::convertToCuboidSpawner(cuboid_spawner, settings.third_dimension());
auto spawner = XSDToInternalTypeAdapter::convertToCuboidSpawner(cuboid_spawner, third_dimension);
int num_spawned = spawner.spawnParticles(particles);
Logger::logger->info("Spawned {} particles from cuboid spawner", num_spawned);
}
Expand All @@ -214,19 +216,19 @@ std::tuple<std::vector<Particle>, SimulationParams> prepareParticles(std::filesy
}
}

auto spawner = XSDToInternalTypeAdapter::convertToSoftBodyCuboidSpawner(soft_body_cuboid_spawner, settings.third_dimension());
auto spawner = XSDToInternalTypeAdapter::convertToSoftBodyCuboidSpawner(soft_body_cuboid_spawner, third_dimension);
int num_spawned = spawner.spawnParticles(particles);
Logger::logger->info("Spawned {} particles from soft body cuboid spawner", num_spawned);
}

for (auto sphere_spawner : particle_sources.sphere_spawner()) {
auto spawner = XSDToInternalTypeAdapter::convertToSphereSpawner(sphere_spawner, settings.third_dimension());
auto spawner = XSDToInternalTypeAdapter::convertToSphereSpawner(sphere_spawner, third_dimension);
int num_spawned = spawner.spawnParticles(particles);
Logger::logger->info("Spawned {} particles from sphere spawner", num_spawned);
}

for (auto single_particle_spawner : particle_sources.single_particle_spawner()) {
auto spawner = XSDToInternalTypeAdapter::convertToSingleParticleSpawner(single_particle_spawner, settings.third_dimension());
auto spawner = XSDToInternalTypeAdapter::convertToSingleParticleSpawner(single_particle_spawner, third_dimension);
int num_spawned = spawner.spawnParticles(particles);
Logger::logger->info("Spawned {} particles from single particle spawner", num_spawned);
}
Expand Down
Loading

0 comments on commit ed8bd05

Please sign in to comment.