diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 17d24e54c..f74114bac 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -32,27 +32,9 @@ jobs: cmake .. make clangformat - - name: Quit if there are no changes + - name: Quit if there are no changes else exit with error run: | if [[ -z $(git status -s) ]]; then echo "No changes to the formatting." exit 0 - fi - - - name: Check if there are any changes - id: verify_diff - run: | - git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT - - - name: Commit changes - if: steps.verify_diff.outputs.changed == 'true' - run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git commit -am "Apply clang-format" - - - name: Push changes - if: steps.verify_diff.outputs.changed == 'true' - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} + fi && exit 1 diff --git a/Doxyfile b/Doxyfile index cee6dd5fc..99c2664d9 100644 --- a/Doxyfile +++ b/Doxyfile @@ -619,8 +619,9 @@ EXCLUDE_SYMLINKS = NO # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = *vtk-unstructured.* \ - *simulation_schema.* \ +EXCLUDE_PATTERNS = *vtu_file_schema.* \ + *simulation_input_schema.* \ + *checkpoint_schema.* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/docs/InputFileFormats.md b/docs/InputFileFormats.md index 817012d52..053861a33 100644 --- a/docs/InputFileFormats.md +++ b/docs/InputFileFormats.md @@ -80,7 +80,7 @@ An example file could look like this: ### .xml -The `.xml` file format can be used to specify all the input parameters for the simulation at once. Therefore it is preferred over the other file formats. +The `.xml` file format can be used to specify all the input parameters for the simulation at once. Therefore, it is preferred over the other file formats. Its definition is based on the [simulation_schema.xsd](simulation_schema.xsd) file, which is used to validate the input file. The file contains a single root element `` with the following child elements: diff --git a/docs/ParticleContainers.md b/docs/ParticleContainers.md index ed4ade08b..4037580e2 100644 --- a/docs/ParticleContainers.md +++ b/docs/ParticleContainers.md @@ -3,7 +3,7 @@ ## Overview -Currently there exist two different particle container implementations: +Currently, there exist two different particle container implementations: - DirectSumContainer: A naive implementation, which calculates the forces between all particles - LinkedCellsContainer: A more efficient implementation, which uses the linked cells algorithm to calculate the forces between particles @@ -26,7 +26,7 @@ The following graphs show the runtime of the two implementations for different n It is interesting to note, that it can be seen quite clearly, that the runtime of the DirectSumContainer increases quadratically with the number of particles, while the runtime of the LinkedCellsContainer increases linearly. -Additionally the benchmark was about twice as fast on an Intel Core i5-12600 CPU than on an AMD Ryzen 5 3600 CPU. +Additionally, the benchmark was about twice as fast on an Intel Core i5-12600 CPU than on an AMD Ryzen 5 3600 CPU. ### AMD Ryzen 5 3600 diff --git a/input/body_collision.xml b/input/body_collision.xml deleted file mode 100644 index 81b7ce647..000000000 --- a/input/body_collision.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - 24 - 30 - 0.0005 - 20.0 - true - - - - 30 - 30 - 30 - - 10 - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 100000000 - - - - - - - 15.0 - 15.0 - 15.0 - - - 3 - 3 - 3 - - 1.1225 - 0.1 - 1 - - 10.0 - 0.0 - 0.0 - - 0 - - - - - - - \ No newline at end of file diff --git a/input/body_collision.cub b/input/body_collision/body_collision_assignment2.cub similarity index 93% rename from input/body_collision.cub rename to input/body_collision/body_collision_assignment2.cub index 366031d4e..81d173f20 100644 --- a/input/body_collision.cub +++ b/input/body_collision/body_collision_assignment2.cub @@ -1,7 +1,7 @@ # Cube 1 0.0 0.0 0.0 # lower left 40 8 1 # grid dimensions -1.1225 # grid spacing +1.1225 # grid spacing 1.0 # mass 0.0 0.0 0.0 # velocity 0.1 # initial temperature (using brownian motion) diff --git a/input/body_collision_assignment3.xml b/input/body_collision/body_collision_assignment3.xml similarity index 77% rename from input/body_collision_assignment3.xml rename to input/body_collision/body_collision_assignment3.xml index 85d6d9780..33f11f537 100644 --- a/input/body_collision_assignment3.xml +++ b/input/body_collision/body_collision_assignment3.xml @@ -1,7 +1,7 @@ + xsi:noNamespaceSchemaLocation="../simulation_schema.xsd"> 24 @@ -18,27 +18,16 @@ 3.0 - - - - - - - - - - - - - - - - - - + Outflow + Outflow + Outflow + Outflow + Outflow + Outflow + LennardJones 0 0 @@ -46,7 +35,8 @@ - + + 20.0 @@ -91,6 +81,6 @@ 1 - + \ No newline at end of file diff --git a/input/equilibration/multiple_recursive_levels.xml b/input/equilibration/multiple_recursive_levels.xml new file mode 100644 index 000000000..d0a305e13 --- /dev/null +++ b/input/equilibration/multiple_recursive_levels.xml @@ -0,0 +1,58 @@ + + + + + 24 + 30 + 0.005 + 10.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + + + Top Left + + + ./subsimulations/top_left.xml + + + + + + Bottom Left + + + ./subsimulations/bottom_left.xml + + + + + + \ No newline at end of file diff --git a/input/equilibration/subsimulations/bottom_left.xml b/input/equilibration/subsimulations/bottom_left.xml new file mode 100644 index 000000000..d836ec04a --- /dev/null +++ b/input/equilibration/subsimulations/bottom_left.xml @@ -0,0 +1,57 @@ + + + + + 24 + 30 + 0.005 + 1.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 20.0 + 20.0 + 5 +
+ 5 + 1.1225 + 0.1 + 1.0 + + 0.0 + 0.0 + 0.0 + + 0 +
+
+ +
\ No newline at end of file diff --git a/input/equilibration/subsimulations/bottom_right.xml b/input/equilibration/subsimulations/bottom_right.xml new file mode 100644 index 000000000..d18160532 --- /dev/null +++ b/input/equilibration/subsimulations/bottom_right.xml @@ -0,0 +1,64 @@ + + + + + 24 + 30 + 0.005 + 1.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 80.0 + 20.0 + 5 +
+ 5 + 1.1225 + 0.1 + 1.0 + + 0.0 + 0.0 + 0.0 + + 0 +
+ + + Center Center + + ./center_center.xml + + +
+ +
\ No newline at end of file diff --git a/input/equilibration/subsimulations/center_center.xml b/input/equilibration/subsimulations/center_center.xml new file mode 100644 index 000000000..87b1fae63 --- /dev/null +++ b/input/equilibration/subsimulations/center_center.xml @@ -0,0 +1,57 @@ + + + + + 24 + 30 + 0.005 + 1.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 50.0 + 50.0 + 5 +
+ 5 + 1.1225 + 0.1 + 1.0 + + 0.0 + 0.0 + 0.0 + + 0 +
+
+ +
\ No newline at end of file diff --git a/input/equilibration/subsimulations/right_center.xml b/input/equilibration/subsimulations/right_center.xml new file mode 100644 index 000000000..bb63c676f --- /dev/null +++ b/input/equilibration/subsimulations/right_center.xml @@ -0,0 +1,73 @@ + + + + + 24 + 30 + 0.005 + 1.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 80.0 + 50.0 + 5 +
+ 5 + 1.1225 + 0.1 + 1.0 + + 0.0 + 0.0 + 0.0 + + 0 +
+ + + Top Right + + + ./top_right.xml + + + + + Bottom Right + + + ./bottom_right.xml + + +
+ +
\ No newline at end of file diff --git a/input/equilibration/subsimulations/top_left.xml b/input/equilibration/subsimulations/top_left.xml new file mode 100644 index 000000000..3663e9dda --- /dev/null +++ b/input/equilibration/subsimulations/top_left.xml @@ -0,0 +1,64 @@ + + + + + 24 + 30 + 0.005 + 1.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 20.0 + 80.0 + 5 +
+ 5 + 1.1225 + 0.1 + 1.0 + + 0.0 + 0.0 + 0.0 + + 0 +
+ + + Right Center + + ./right_center.xml + + +
+ +
\ No newline at end of file diff --git a/input/equilibration/subsimulations/top_right.xml b/input/equilibration/subsimulations/top_right.xml new file mode 100644 index 000000000..ab6a8f362 --- /dev/null +++ b/input/equilibration/subsimulations/top_right.xml @@ -0,0 +1,57 @@ + + + + + 24 + 30 + 0.005 + 1.0 + false + + + + 100 + 100 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 80.0 + 80.0 + 5 +
+ 5 + 1.1225 + 0.1 + 1.0 + + 0.0 + 0.0 + 0.0 + + 0 +
+
+ +
\ No newline at end of file diff --git a/input/falling_drop/falling_drop_assignment3.xml b/input/falling_drop/falling_drop_assignment3.xml new file mode 100644 index 000000000..ccd13bc29 --- /dev/null +++ b/input/falling_drop/falling_drop_assignment3.xml @@ -0,0 +1,58 @@ + + + + + 24 + 30 + 0.00005 + 10.0 + false + + + + 120 + 50 + 1 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 60.0 + 25.0 + 0.5 +
+ 15 + 1.1225 + 0.1 + 1.0 + + 0.0 + -10.0 + 0.0 + + 0 +
+ +
+ +
\ No newline at end of file diff --git a/input/falling_drop/falling_drop_equilibrated.xml b/input/falling_drop/falling_drop_equilibrated.xml new file mode 100644 index 000000000..1ee8f12fa --- /dev/null +++ b/input/falling_drop/falling_drop_equilibrated.xml @@ -0,0 +1,55 @@ + + + + + 24 + 30 + 0.005 + 10.0 + false + + + + 303 + 180 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + + + Basin + + ./subsimulations/basin.xml + + + + + + Sphere + + ./subsimulations/sphere.xml + + + + + \ No newline at end of file diff --git a/input/falling_drop/subsimulations/basin.xml b/input/falling_drop/subsimulations/basin.xml new file mode 100644 index 000000000..73d616591 --- /dev/null +++ b/input/falling_drop/subsimulations/basin.xml @@ -0,0 +1,61 @@ + + + + + 0 + 0 + 0.005 + 5 + false + + + + 303 + 180 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + + + 1.5 + 2 + 5 + + + 250 + 50 + 1 + + 1.2 + 0 + 1 + + 0 + 0 + 0 + + 0 + + + + \ No newline at end of file diff --git a/input/falling_drop/subsimulations/sphere.xml b/input/falling_drop/subsimulations/sphere.xml new file mode 100644 index 000000000..7232f80f4 --- /dev/null +++ b/input/falling_drop/subsimulations/sphere.xml @@ -0,0 +1,57 @@ + + + + + 0 + 0 + 0.005 + 5 + false + + + + 303 + 180 + 10 + + 3.0 + + Reflective + Reflective + Reflective + Reflective + Reflective + Reflective + + + + LennardJones + + 0 + 0 + 10000000 + + + + + +
+ 150 + 150 + 5 +
+ 20 + 1.2 + 0 + 1.0 + + 0.0 + 0.0 + 0.0 + + 1 +
+
+ +
\ No newline at end of file diff --git a/input/falling_drop_assignment3.xml b/input/falling_drop_assignment3.xml deleted file mode 100644 index bd67925ef..000000000 --- a/input/falling_drop_assignment3.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - 24 - 30 - 0.00005 - 10.0 - false - - - - 120 - 50 - 1 - - 3.0 - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 10000000 - - - - - -
- 60.0 - 25.0 - 0.5 -
- 15 - 1.1225 - 0.1 - 1.0 - - 0.0 - -10.0 - 0.0 - - 0 -
- -
- -
\ No newline at end of file diff --git a/input/eingabe-figure-8.ps b/input/periodic_system/eingabe-figure-8.ps similarity index 100% rename from input/eingabe-figure-8.ps rename to input/periodic_system/eingabe-figure-8.ps diff --git a/input/simulation_schema.xsd b/input/simulation_schema.xsd index 21ef0da69..f3091075d 120000 --- a/input/simulation_schema.xsd +++ b/input/simulation_schema.xsd @@ -1 +1 @@ -../src/io/input/xml/parser/simulation_schema.xsd \ No newline at end of file +../src/io/xml_schemas/simulation_input/simulation_input_schema.xsd \ No newline at end of file diff --git a/input/eingabe-sonne.ps b/input/solar_system/eingabe-sonne_assignment1.ps similarity index 100% rename from input/eingabe-sonne.ps rename to input/solar_system/eingabe-sonne_assignment1.ps diff --git a/src/MolSim.cpp b/src/MolSim.cpp index 25396ee82..9342be31c 100644 --- a/src/MolSim.cpp +++ b/src/MolSim.cpp @@ -1,138 +1,36 @@ -#include - #include "io/cli/CLIParser.h" #include "io/input/FileInputHandler.h" -#include "io/logger/Logger.h" -#include "particles/containers/ParticleContainer.h" -#include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/LennardJonesForce.h" #include "simulation/Simulation.h" -#include "simulation/SimulationOverview.h" #include "simulation/SimulationParams.h" -#include "spdlog/sinks/stdout_color_sinks.h" -#include "utils/FormatTime.h" - -const std::string ansi_blue_bold = "\e[34m\e[1m"; -const std::string ansi_yellow_bold = "\e[33m\e[1m"; -const std::string ansi_bright_white_bold = "\e[97m\e[1m"; -const std::string ansi_end = "\e[0m"; - -void print_simulation_input(const SimulationParams& simulation_params, size_t num_particles, - const std::vector>& forces); - -void print_simulation_overview(const SimulationOverview& overview, size_t num_particles); int main(int argc, char* argsv[]) { - // Create pointer for particle container - std::unique_ptr initial_particles; - // Parse CLI arguments SimulationParams params_cli = parse_arguments(argc, argsv); // Parse input file - SimulationParams params_xml = FileInputHandler::readFile(params_cli.input_file_path, initial_particles); + auto [initial_particles, simulation_arguments] = FileInputHandler::readFile(params_cli.input_file_path, params_cli.fresh); // Combine parameters from CLI and input file - SimulationParams simulation_params = merge_parameters(params_cli, params_xml); - - // Create all force sources acting on the particles - std::vector> forces; - forces.push_back(std::make_unique()); + SimulationParams simulation_params = merge_parameters(params_cli, simulation_arguments); + simulation_params.num_particles = initial_particles.size(); // Initialize simulation - Simulation simulation{initial_particles, forces, simulation_params}; + Simulation simulation{initial_particles, simulation_params}; // Print simulation info - size_t num_particles_start = initial_particles->size(); - print_simulation_input(simulation_params, num_particles_start, forces); + simulation_params.logSummary(); // Run simulation - if (simulation_params.performance_test) { - SimulationOverview overview = simulation.runSimulationPerfTest(); + auto overview = [simulation_params](Simulation& simulation) { + if (simulation_params.performance_test) { + return simulation.runSimulationPerfTest(); + } else { + return simulation.runSimulation(); + } + }(simulation); - // Print simulation overview - print_simulation_overview(overview, initial_particles->size()); - } else { - SimulationOverview overview = simulation.runSimulation(); - - // Print simulation info again (for convenience) - print_simulation_input(simulation_params, num_particles_start, forces); - // Print simulation overview - print_simulation_overview(overview, initial_particles->size()); - } + // Print simulation overview + overview.logSummary(); return 0; } - -void print_simulation_input(const SimulationParams& simulation_params, size_t num_particles, - const std::vector>& forces) { - // Print Simulation arguments - - Logger::logger->info(ansi_bright_white_bold + "════════════════════════════════════════" + ansi_end); - Logger::logger->info(ansi_blue_bold + "Simulation input" + ansi_end); - Logger::logger->info(""); - Logger::logger->info(ansi_yellow_bold + "Simulation arguments:" + ansi_end); - Logger::logger->info(" Input file path: {}", simulation_params.input_file_path); - Logger::logger->info(" Output directory path: {}", simulation_params.output_dir_path); - Logger::logger->info(" Delta_t: {}", simulation_params.delta_t); - Logger::logger->info(" End_time: {}", simulation_params.end_time); - - Logger::logger->info(ansi_yellow_bold + "Rendering arguments:" + ansi_end); - Logger::logger->info(" Frames per second: {}", simulation_params.fps); - Logger::logger->info(" Video length: {}", simulation_params.video_length); - - // Print Physical setup - Logger::logger->info(ansi_yellow_bold + "Physical setup:" + ansi_end); - Logger::logger->info(" Number of particles: {}", num_particles); - Logger::logger->info(" Number of forces: {}", forces.size()); - - std::string force_names = - std::accumulate(forces.begin(), forces.end(), std::string{}, - [](const std::string& acc, const std::unique_ptr& force) { return acc + std::string(*force) + ", "; }); - - Logger::logger->info(" Forces: {}", force_names); - - // Print Thermostat - Logger::logger->info(ansi_yellow_bold + "Thermostat:" + ansi_end); - Logger::logger->info(" Target temperature: {}", simulation_params.thermostat.getTargetTemperature()); - Logger::logger->info(" Max temperature change: {}", simulation_params.thermostat.getMaxTemperatureChange()); - Logger::logger->info(" Applied every {} iterations", simulation_params.thermostat.getApplicationInterval()); - - // Print Container Information - Logger::logger->info(ansi_yellow_bold + "Container:" + ansi_end); - if (std::holds_alternative(simulation_params.container_type)) { - auto lc_container = std::get(simulation_params.container_type); - - auto domain_size = lc_container.domain_size; - Logger::logger->info(" Linked Cells"); - Logger::logger->info(" Domain size: {} x {} x {}", domain_size[0], domain_size[1], domain_size[2]); - Logger::logger->info(" Cutoff radius: {}", lc_container.cutoff_radius); - Logger::logger->info(" Boundary conditions: "); - Logger::logger->info(" Left: {}", LinkedCellsContainer::boundaryConditionToString(lc_container.boundary_conditions[0])); - Logger::logger->info(" Right: {}", LinkedCellsContainer::boundaryConditionToString(lc_container.boundary_conditions[1])); - Logger::logger->info(" Bottom: {}", LinkedCellsContainer::boundaryConditionToString(lc_container.boundary_conditions[2])); - Logger::logger->info(" Top: {}", LinkedCellsContainer::boundaryConditionToString(lc_container.boundary_conditions[3])); - Logger::logger->info(" Back: {}", LinkedCellsContainer::boundaryConditionToString(lc_container.boundary_conditions[4])); - Logger::logger->info(" Front: {}", LinkedCellsContainer::boundaryConditionToString(lc_container.boundary_conditions[5])); - } else if (std::holds_alternative(simulation_params.container_type)) { - Logger::logger->info(" Direct Sum"); - } else { - Logger::logger->error("Unknown container type"); - exit(-1); - } - - Logger::logger->info(ansi_bright_white_bold + "════════════════════════════════════════" + ansi_end); -} - -void print_simulation_overview(const SimulationOverview& overview, size_t num_particles) { - Logger::logger->info(ansi_bright_white_bold + "════════════════════════════════════════" + ansi_end); - - Logger::logger->info(ansi_yellow_bold + "Simulation overview:" + ansi_end); - Logger::logger->info(" Simulation time: {}", format_seconds_total(overview.total_time_seconds)); - Logger::logger->info(" Number of iterations: {}", overview.total_iterations); - Logger::logger->info(" Average iteration time: {:.3f}ms", overview.average_time_per_iteration_millis); - Logger::logger->info(" Number of files written: {}", overview.files_written); - Logger::logger->info(" Number of particles left: {}", num_particles); - - Logger::logger->info(ansi_bright_white_bold + "════════════════════════════════════════" + ansi_end); -} \ No newline at end of file diff --git a/src/integration/IntegrationFunctor.h b/src/integration/IntegrationFunctor.h index 4731059cf..ce131cbf0 100644 --- a/src/integration/IntegrationFunctor.h +++ b/src/integration/IntegrationFunctor.h @@ -26,5 +26,5 @@ class IntegrationFunctor { * @param delta_t Time step */ virtual void step(std::unique_ptr& particle_container, - const std::vector>& force_sources, double delta_t) const = 0; + const std::vector>& force_sources, double delta_t) const = 0; }; \ No newline at end of file diff --git a/src/integration/VerletFunctor.cpp b/src/integration/VerletFunctor.cpp index 8b36f7fee..800bc346e 100644 --- a/src/integration/VerletFunctor.cpp +++ b/src/integration/VerletFunctor.cpp @@ -3,7 +3,7 @@ #include "utils/ArrayUtils.h" void VerletFunctor::step(std::unique_ptr& particle_container, - const std::vector>& force_sources, double delta_t) const { + const std::vector>& force_sources, double delta_t) const { for (auto& p : *particle_container) { // update position const std::array newX = p.getX() + delta_t * p.getV() + (delta_t * delta_t / (2 * p.getM())) * p.getF(); diff --git a/src/integration/VerletFunctor.h b/src/integration/VerletFunctor.h index e5599c778..7f8c16dce 100644 --- a/src/integration/VerletFunctor.h +++ b/src/integration/VerletFunctor.h @@ -17,6 +17,6 @@ class VerletFunctor : public IntegrationFunctor { * @param force_sources Vector of force sources which are used to calculate the new forces * @param delta_t Time step */ - void step(std::unique_ptr& particle_container, const std::vector>& force_sources, + void step(std::unique_ptr& particle_container, const std::vector>& force_sources, double delta_t) const override; }; \ No newline at end of file diff --git a/src/io/cli/CLIParser.cpp b/src/io/cli/CLIParser.cpp index a4e09b5d9..2e863ecbe 100644 --- a/src/io/cli/CLIParser.cpp +++ b/src/io/cli/CLIParser.cpp @@ -1,9 +1,9 @@ #include "CLIParser.h" #include +#include #include "io/logger/Logger.h" -#include "io/output/FileOutputHandler.h" #include "spdlog/sinks/rotating_file_sink.h" SimulationParams parse_arguments(int argc, char* argsv[]) { @@ -19,7 +19,10 @@ SimulationParams parse_arguments(int argc, char* argsv[]) { int fps = 0; int video_length = 0; + std::vector forces; + bool performance_test = false; + bool fresh = false; // choosing 0 as one of the parameters (end_time, delta_t, fps, video_length) is equivalent to choosing the default value boost::program_options::options_description options_desc("Allowed options"); @@ -38,14 +41,19 @@ SimulationParams parse_arguments(int argc, char* argsv[]) { "The number of frames per second at which the simulation will be saved"); options_desc.add_options()("video_length", boost::program_options::value(&video_length), "The total length of the simulation video in seconds"); + options_desc.add_options()("force", boost::program_options::value>(&forces)->multitoken(), + "The forces to be applied to the particles. Possible values: gravity, electrostatic, none"); options_desc.add_options()("log_level,l", boost::program_options::value(&log_level)->default_value("info"), "The log level. Possible values: trace, debug, info, warning, error, critical, off"); - options_desc.add_options()("output_format", boost::program_options::value(&output_format)->default_value("vtk"), - "The output format. Possible values: vtk, xyz, none"); + options_desc.add_options()("output_format", boost::program_options::value(&output_format)->default_value("vtu"), + "The output format. Possible values: vtu, xyz, none"); options_desc.add_options()("performance_test,p", "Run the simulation in performance test mode"); options_desc.add_options()( "log_output", boost::program_options::value(&log_output)->default_value("std"), "You can only choose between the output options std(only cl output) and file (only file output). Default: no file output"); + options_desc.add_options()( + "fresh", boost::program_options::bool_switch(&fresh)->default_value(false), + "Rerun the simulation from scratch without using any cached data. This will delete the whole output directory."); boost::program_options::positional_options_description positional_options_desc; positional_options_desc.add("input_file_path", -1); @@ -109,13 +117,19 @@ SimulationParams parse_arguments(int argc, char* argsv[]) { fps, video_length, SimulationParams::DirectSumType{}, - Thermostat{1, 1, 10000000}, + Thermostat{1, 1, std::numeric_limits::max()}, output_format, - performance_test}; + forces, + performance_test, + fresh}; } -SimulationParams merge_parameters(const SimulationParams& params_cli, const SimulationParams& params_xml) { - SimulationParams params = params_xml; +SimulationParams merge_parameters(const SimulationParams& params_cli, const std::optional& file_params) { + if (!file_params) { + return params_cli; + } + + SimulationParams params = *file_params; // Overwrite parameters from XML file with parameters from CLI if (params_cli.delta_t != 0) { @@ -130,10 +144,15 @@ SimulationParams merge_parameters(const SimulationParams& params_cli, const Simu if (params_cli.video_length != 0) { params.video_length = params_cli.video_length; } + if (!params_cli.forces.empty()) { + params.forces = params_cli.forces; + } // Always takes value from CLI params.output_dir_path = params_cli.output_dir_path; + params.fresh = params_cli.fresh; + // Must be given in the CLI params.output_format = params_cli.output_format; diff --git a/src/io/cli/CLIParser.h b/src/io/cli/CLIParser.h index be197543f..bd420e15f 100644 --- a/src/io/cli/CLIParser.h +++ b/src/io/cli/CLIParser.h @@ -21,9 +21,9 @@ SimulationParams parse_arguments(int argc, char* argsv[]); * priority. * * @param params_cli Simulation parameters retrieved via Command line arguments - * @param params_xml Simulation parameters retrieved via XML file + * @param file_params Simulation parameters retrieved via the parsed input file * @return SimulationParams containing the merged parameters. Command line arguments have priority. * - * Merges the command line arguments with the XML file and returns a tuple containing all the arguments. + * Merges the command line arguments with the parameters retrieved from the file. Command line arguments have priority. */ -SimulationParams merge_parameters(const SimulationParams& params_cli, const SimulationParams& params_xml); \ No newline at end of file +SimulationParams merge_parameters(const SimulationParams& params_cli, const std::optional& file_params); \ No newline at end of file diff --git a/src/io/input/FileInputHandler.cpp b/src/io/input/FileInputHandler.cpp index 31fa33c8d..76484db88 100644 --- a/src/io/input/FileInputHandler.cpp +++ b/src/io/input/FileInputHandler.cpp @@ -5,7 +5,8 @@ #include "io/logger/Logger.h" -SimulationParams FileInputHandler::readFile(const std::string& input_file_path, std::unique_ptr& particle_container) { +std::tuple, std::optional> FileInputHandler::readFile(const std::string& input_file_path, + bool fresh, bool allow_recursion) { if (!std::filesystem::exists(input_file_path)) { Logger::logger->error("Error: file '{}' does not exist.", input_file_path); exit(-1); @@ -32,16 +33,21 @@ SimulationParams FileInputHandler::readFile(const std::string& input_file_path, } else if (file_extension == ".cub") { file_reader = std::make_unique(); } else if (file_extension == ".xml") { - file_reader = std::make_unique(); + file_reader = std::make_unique(fresh, allow_recursion); + } else if (file_extension == ".chkpt") { + file_reader = std::make_unique(); + } else { + Logger::logger->error("Error: file extension '{}' is not supported.", file_extension); + exit(-1); } try { - return file_reader->readFile(input_file_path, particle_container); + auto [particles, config] = file_reader->readFile(input_file_path); + Logger::logger->info("Loaded {} particles from file {}", particles.size(), input_file_path); + return std::make_tuple(particles, config); } catch (const FileReader::FileFormatException& e) { Logger::logger->error("Error: file '{}' is not a valid {} file.", input_file_path, file_extension); Logger::logger->error("FileFormatException:\n{}", std::string(e.what())); exit(-1); } } - -std::set FileInputHandler::get_supported_input_file_extensions() { return {".ps", ".cub", ".xml"}; } \ No newline at end of file diff --git a/src/io/input/FileInputHandler.h b/src/io/input/FileInputHandler.h index 6121e1b72..a638ac690 100644 --- a/src/io/input/FileInputHandler.h +++ b/src/io/input/FileInputHandler.h @@ -3,6 +3,8 @@ #include #include +#include "io/input/InputFormats.h" +#include "io/input/chkpt/ChkptPointFileReader.h" #include "io/input/custom_formats/cub/CubFileReader.h" #include "io/input/custom_formats/ps/PsFileReader.h" #include "io/input/xml/XMLFileReader.h" @@ -21,26 +23,15 @@ class FileInputHandler { * SimulationParams object. * * @param input_file_path The path to the input file - * @param particle_container The ParticleContainer to store the particles in# - * @return SimulationParams containing the simulation parameters + * @param fresh Whether to start a fresh simulation or reuse cached data + * @param allow_recursion Whether to allow subsimulations to be started + * @return std::tuple, std::optional> Tuple containing the particles and the parameters of the + * file * - * Reads the input file and generate and stores particles in the given `ParticleContainer`. - * Other parameters are stored in a `SimulationParams` object and returned. + * Reads the input file, generates particles and returns them in a vector. + * Parameters are stored in a `SimulationParams` object and returned. * For more information about the output file formats, see \ref InputFileFormats "Input File Formats" */ - static SimulationParams readFile(const std::string& input_file_path, std::unique_ptr& particle_container); - - /** - * @brief Returns a list of supported input file extensions - * - * @return std::vector List of supported input file extensions - * - * Returns a list of supported input file extensions. - * Supported file formats are: - * - .ps - * - .cub - * - .xml - * For more information about the output file formats, see \ref InputFileFormats "Input File Formats" - */ - static std::set get_supported_input_file_extensions(); + static std::tuple, std::optional> readFile(const std::string& input_file_path, + bool fresh = false, bool allow_recursion = true); }; diff --git a/src/io/input/FileReader.h b/src/io/input/FileReader.h index 74b7e7ece..0f5b466e7 100644 --- a/src/io/input/FileReader.h +++ b/src/io/input/FileReader.h @@ -1,8 +1,11 @@ #pragma once +#include #include +#include +#include -#include "particles/containers/ParticleContainer.h" +#include "particles/Particle.h" #include "simulation/SimulationParams.h" /** @@ -16,13 +19,11 @@ class FileReader { virtual ~FileReader() = default; /** - * @brief Reads the file with the given path and fills the given ParticleContainer with the particle data stored in the file + * @brief Reads the file with the given path and returns a vector of particles * @param filepath Path to the file to be read - * @param particle_container ParticleContainer to be filled - * @return SimulationParams object containing the simulation parameters given in the file. Unspecified parameters are set to a default - * value. */ - virtual SimulationParams readFile(const std::string& filepath, std::unique_ptr& particle_container) const = 0; + [[nodiscard]] virtual std::tuple, std::optional> readFile( + const std::string& filepath) const = 0; /** * @brief Exception to be thrown when the file format is invalid diff --git a/src/io/input/InputFormats.cpp b/src/io/input/InputFormats.cpp new file mode 100644 index 000000000..c4184bed8 --- /dev/null +++ b/src/io/input/InputFormats.cpp @@ -0,0 +1,3 @@ +#include "InputFormats.h" + +std::set get_supported_input_file_extensions() { return {".ps", ".cub", ".xml", ".chkpt"}; } \ No newline at end of file diff --git a/src/io/input/InputFormats.h b/src/io/input/InputFormats.h new file mode 100644 index 000000000..2a4306ef4 --- /dev/null +++ b/src/io/input/InputFormats.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +/** + * @brief Returns a list of supported input file extensions + * + * @return std::vector List of supported input file extensions + * + * Returns a list of supported input file extensions. + * Supported file formats are: + * For more information about the output file formats, see \ref InputFileFormats "Input File Formats" + */ +std::set get_supported_input_file_extensions(); \ No newline at end of file diff --git a/src/io/input/chkpt/ChkptPointFileReader.cpp b/src/io/input/chkpt/ChkptPointFileReader.cpp new file mode 100644 index 000000000..f908d6970 --- /dev/null +++ b/src/io/input/chkpt/ChkptPointFileReader.cpp @@ -0,0 +1,39 @@ +#include "ChkptPointFileReader.h" + +#include + +#include "io/logger/Logger.h" +#include "io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.h" + +void summarizeMetadata(MetaDataDataType m) { + Logger::logger->info("Loaded checkpoint file with following metadata:"); + Logger::logger->info(" - Original file: {}", m.input_file()); + Logger::logger->info(" - Original file hash: {}", m.input_file_hash()); + Logger::logger->info(" - Original End time: {}", m.end_time()); + Logger::logger->info(" - Original Delta t: {}", m.delta_t()); +} + +std::tuple, std::optional> ChkptPointFileReader::readFile(const std::string& filepath) const { + try { + auto checkpoint = CheckPoint(filepath, xml_schema::flags::dont_validate); + + auto particleData = checkpoint->ParticleData(); + auto metaData = checkpoint->MetaData(); + + summarizeMetadata(metaData); + + std::vector particles; + + for (auto xsd_particle : particleData.particle()) { + auto particle = XSDToInternalTypeAdapter::convertToParticle(xsd_particle); + particles.push_back(std::move(particle)); + } + + return std::make_tuple(particles, std::nullopt); + } catch (const xml_schema::exception& e) { + std::stringstream error_message; + error_message << "Error: could not parse file '" << filepath << "'.\n"; + error_message << e << std::endl; + throw FileFormatException(error_message.str()); + } +} \ No newline at end of file diff --git a/src/io/input/chkpt/ChkptPointFileReader.h b/src/io/input/chkpt/ChkptPointFileReader.h new file mode 100644 index 000000000..a7821dafb --- /dev/null +++ b/src/io/input/chkpt/ChkptPointFileReader.h @@ -0,0 +1,18 @@ +#pragma once + +#include "io/input/FileReader.h" +#include "io/xml_schemas/checkpoint/checkpoint_schema.h" +#include "simulation/SimulationParams.h" + +/** + * @brief Class to read particle and simulation data from a '.xml' file + */ +class ChkptPointFileReader : public FileReader { + public: + /** + * @brief Reads particle data from a '.xml' file and returns a vector of particles + * + * @param filepath Path to the file to read + */ + [[nodiscard]] std::tuple, std::optional> readFile(const std::string& filepath) const override; +}; \ No newline at end of file diff --git a/src/io/input/custom_formats/cub/CubFileReader.cpp b/src/io/input/custom_formats/cub/CubFileReader.cpp index 4746e659f..428ab3c45 100644 --- a/src/io/input/custom_formats/cub/CubFileReader.cpp +++ b/src/io/input/custom_formats/cub/CubFileReader.cpp @@ -1,20 +1,17 @@ #include "CubFileReader.h" -#include +#include -#include "io/logger/Logger.h" -#include "particles/containers/directsum/DirectSumContainer.h" #include "particles/spawners/cuboid/CuboidSpawner.h" -SimulationParams CubFileReader::readFile(const std::string& filepath, std::unique_ptr& particle_container) const { +std::tuple, std::optional> CubFileReader::readFile(const std::string& filepath) const { FileLineReader input_file(filepath); if (!input_file.is_open()) { throw FileFormatException(fmt::format("Error: could not open file '{}'.", filepath)); } - // Initialize particle container - particle_container = std::make_unique(); + std::vector particles; while (!input_file.eof()) { while (input_file.peek() == '#' || input_file.peek() == '\n') { @@ -61,11 +58,10 @@ SimulationParams CubFileReader::readFile(const std::string& filepath, std::uniqu auto spawner = CuboidSpawner(lower_left_front_corner, grid_dimensions, grid_spacing, mass, initial_velocity, type); - particle_container->reserve(particle_container->size() + static_cast(nx) * ny * nz); - spawner.spawnParticles(particle_container); + spawner.spawnParticles(particles); } - return SimulationParams{filepath, "", 0.0002, 5, 24, 30, SimulationParams::DirectSumType(), Thermostat{0, 0}, "vtk"}; + return std::make_tuple(particles, std::nullopt); } void CubFileReader::checkAndReportInvalidEntry(FileLineReader& input_file, const std::string& expected_format) { diff --git a/src/io/input/custom_formats/cub/CubFileReader.h b/src/io/input/custom_formats/cub/CubFileReader.h index b33cf56ba..ba3189b00 100644 --- a/src/io/input/custom_formats/cub/CubFileReader.h +++ b/src/io/input/custom_formats/cub/CubFileReader.h @@ -9,15 +9,12 @@ class CubFileReader : public FileReader { public: /** - * @brief Reads the '.cub' file with the given path and fills the given ParticleContainer with a cuboid of particles - * using the arguments stored in the file (see \ref InputFileFormats "Input File Formats" for details on the .cub file format) + * @brief Reads the '.cub' file with the given path and returns a vector of particles + * (see \ref InputFileFormats "Input File Formats" for details on the .cub file format) * * @param filepath Path to the file to be read - * @param particle_container ParticleContainer to be filled - * @return Default SimulationParams object (.cub only contains particle data, but no simulation parameters). Necessary for the - * FileReader interface. */ - SimulationParams readFile(const std::string& filepath, std::unique_ptr& particle_container) const override; + [[nodiscard]] std::tuple, std::optional> readFile(const std::string& filepath) const override; private: /** diff --git a/src/io/input/custom_formats/ps/PsFileReader.cpp b/src/io/input/custom_formats/ps/PsFileReader.cpp index 85c6288b1..8219ef108 100644 --- a/src/io/input/custom_formats/ps/PsFileReader.cpp +++ b/src/io/input/custom_formats/ps/PsFileReader.cpp @@ -1,14 +1,11 @@ #include "PsFileReader.h" -#include +#include + #include -#include #include -#include "io/logger/Logger.h" -#include "particles/containers/directsum/DirectSumContainer.h" - -SimulationParams PsFileReader::readFile(const std::string& filepath, std::unique_ptr& particle_container) const { +std::tuple, std::optional> PsFileReader::readFile(const std::string& filepath) const { std::array x{}; std::array v{}; double m; @@ -28,11 +25,10 @@ SimulationParams PsFileReader::readFile(const std::string& filepath, std::unique } // Initialize particle container - particle_container = std::make_unique(); + std::vector particles; std::istringstream numstream(curr_line); numstream >> num_particles; - particle_container->reserve(num_particles); getline(input_file, curr_line); for (int i = 0; i < num_particles; i++) { @@ -49,10 +45,10 @@ SimulationParams PsFileReader::readFile(const std::string& filepath, std::unique } datastream >> m; - particle_container->addParticle(Particle{x, v, m, i}); + particles.emplace_back(x, v, m, i); getline(input_file, curr_line); } - return SimulationParams{filepath, "", 0.0002, 5, 24, 30, SimulationParams::DirectSumType(), Thermostat{0, 0}, "vtk"}; + return std::make_tuple(particles, std::nullopt); } diff --git a/src/io/input/custom_formats/ps/PsFileReader.h b/src/io/input/custom_formats/ps/PsFileReader.h index 17aaca897..f64f83d20 100644 --- a/src/io/input/custom_formats/ps/PsFileReader.h +++ b/src/io/input/custom_formats/ps/PsFileReader.h @@ -1,10 +1,6 @@ #pragma once -#include - #include "io/input/FileReader.h" -#include "particles/Particle.h" -#include "particles/containers/ParticleContainer.h" /** * @brief Class to read particle data from a '.ps' file @@ -12,13 +8,10 @@ class PsFileReader : public FileReader { public: /** - * @brief Reads the file with the given path and fills the given ParticleContainer with the particle data stored in the file + * @brief Reads the file with the given path and returns a vector of particles * (see \ref InputFileFormats "Input File Formats" for details on the .ps file format). * * @param filepath Path to the file to be read - * @param particle_container ParticleContainer to be filled - * @return Default SimulationParams object (.ps only contains particle data, but no simulation parameters). Necessary for the - * FileReader interface. */ - SimulationParams readFile(const std::string& filepath, std::unique_ptr& particle_container) const override; + [[nodiscard]] std::tuple, std::optional> readFile(const std::string& filepath) const override; }; diff --git a/src/io/input/xml/XMLFileReader.cpp b/src/io/input/xml/XMLFileReader.cpp index f9b7ea1fd..490802985 100644 --- a/src/io/input/xml/XMLFileReader.cpp +++ b/src/io/input/xml/XMLFileReader.cpp @@ -1,62 +1,283 @@ #include "XMLFileReader.h" +#include + +#include #include #include +#include "io/input/chkpt/ChkptPointFileReader.h" #include "io/logger/Logger.h" -#include "particles/containers/directsum/DirectSumContainer.h" -#include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "particles/spawners/cuboid/CuboidSpawner.h" +#include "io/output/FileOutputHandler.h" +#include "io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.h" +#include "simulation/Simulation.h" -SimulationParams XMLFileReader::readFile(const std::string& filepath, std::unique_ptr& particle_container) const { - try { - auto config = configuration_(filepath); - - auto settings = config->settings(); - auto particles = config->particles(); - - // Create particle container - auto container_type = XSDTypeAdapter::convertToParticleContainer(settings.particle_container()); - if (std::holds_alternative(container_type)) { - auto linked_cells = std::get(container_type); - particle_container = std::make_unique(linked_cells.domain_size, linked_cells.cutoff_radius, - linked_cells.boundary_conditions); - } else if (std::holds_alternative(container_type)) { - particle_container = std::make_unique(); - } else { - throw std::runtime_error("Unknown container type"); +std::string trim(const std::string& str) { + // skip whitespace and newlines + auto start = str.find_first_not_of(" \t\n\r\f\v"); + auto end = str.find_last_not_of(" \t\n\r\f\v"); + + if (start == std::string::npos) { + return ""; + } else { + return str.substr(start, end - start + 1); + } +} + +std::string sanitizePath(const std::string& text) { + std::string sanitized = text; + + // Replace all backslashes with forward slashes + std::replace(sanitized.begin(), sanitized.end(), '\\', '/'); + + // Remove trailing slashes + if (sanitized.back() == '/') { + sanitized.pop_back(); + } + + // replace spaces with underscores + std::replace(sanitized.begin(), sanitized.end(), ' ', '_'); + + // to lower case + std::transform(sanitized.begin(), sanitized.end(), sanitized.begin(), [](unsigned char c) { return std::tolower(c); }); + + return sanitized; +} + +std::string convertToPath(const std::string& base_path, const std::string& path) { + if (path.empty()) { + return ""; + } + + auto is_relative_path = path[0] != '/'; + + if (is_relative_path) { + return base_path + "/" + path; + } else { + return path; + } +} + +void loadCheckpointFile(std::vector& particles, const std::string& path) { + std::string file_extension = path.substr(path.find_last_of('.')); + if (file_extension != ".chkpt") { + Logger::logger->error("Error: file extension '{}' is not supported. Only .chkpt files can be used as checkpoints.", file_extension); + exit(-1); + } + + ChkptPointFileReader reader; + auto [loaded_particles, _] = reader.readFile(path); + particles.insert(particles.end(), loaded_particles.begin(), loaded_particles.end()); + + Logger::logger->info("Loaded {} particles from checkpoint file {}", loaded_particles.size(), path); +} + +std::optional getCheckPointFilePath(const std::string& base_path) { + if (!std::filesystem::exists(base_path)) { + return std::nullopt; + } + + std::optional checkPointPath = std::nullopt; + auto best_iteration = -1; + for (const auto& entry : std::filesystem::directory_iterator(base_path)) { + if (entry.path().extension() == ".chkpt") { + std::string current_file_path = entry.path().string(); + + auto num_start = current_file_path.find_first_of("0123456789"); + auto num_end = current_file_path.find_last_of("0123456789"); + + auto current_file_number = std::stoi(current_file_path.substr(num_start, num_end - num_start + 1)); + + if (current_file_number > best_iteration) { + best_iteration = current_file_number; + checkPointPath = current_file_path; + } } + } + + return checkPointPath; +} + +auto load_config(const SubSimulationType& sub_simulation, const std::string& curr_file_path, const std::string& base_path) { + if (sub_simulation.configuration()) { + // Configuration is diretly in the XML file + auto loaded_config = *sub_simulation.configuration(); + + return std::make_pair(loaded_config, curr_file_path + " |> Sub: " + sub_simulation.name()); + } else if (sub_simulation.file_name()) { + // Configuration is in a separate file + auto other_file_name = convertToPath(base_path, sub_simulation.file_name().get()); + + std::string file_extension = other_file_name.substr(other_file_name.find_last_of('.')); + if (file_extension != ".xml") { + Logger::logger->error("Error: file extension '{}' is not supported. Only .xml files can be used as sub simulations.", + file_extension); + exit(-1); + } + + return std::make_pair(*configuration(other_file_name), other_file_name); + } else { + Logger::logger->error("Error: sub simulation source must contain either a configuration or a file name."); + exit(-1); + } +} + +auto checkCheckPointHashIsValid(const std::string& path) { + auto checkpoint = CheckPoint(path, xml_schema::flags::dont_validate); + auto metaData = checkpoint->MetaData(); + + std::ifstream input_file(metaData.input_file()); + + auto buffer = std::stringstream(); + buffer << input_file.rdbuf(); + + std::hash hasher; + auto curr_hash = hasher(buffer.str()); - // Create thermostat - auto thermostat = XSDTypeAdapter::convertToThermostat(settings.thermostat(), settings.third_dimension()); + return curr_hash == metaData.input_file_hash(); +} - // Spawn particles specified in the XML file - for (auto xsd_cuboid : particles.cuboid_spawner()) { - auto spawner = XSDTypeAdapter::convertToCuboidSpawner(xsd_cuboid, settings.third_dimension()); - particle_container->reserve(particle_container->size() + spawner.getEstimatedNumberOfParticles()); - spawner.spawnParticles(particle_container); +std::tuple, SimulationParams> prepare_particles(std::string curr_file_path, ConfigurationType& config, bool fresh, + bool allow_recursion, std::string output_base_path = "", + int depth = 0) { + Logger::logger->info("Constructing configuration for file {} at depth {}", curr_file_path, depth); + + auto settings = config.settings(); + auto particle_sources = config.particle_source(); + + std::vector particles; + + auto container_type = XSDToInternalTypeAdapter::convertToParticleContainer(settings.particle_container()); + + auto thermostat = XSDToInternalTypeAdapter::convertToThermostat(settings.thermostat(), settings.third_dimension()); + + auto forces = XSDToInternalTypeAdapter::convertToForces(settings.force()); + + auto params = SimulationParams{curr_file_path, + "", + settings.delta_t(), + settings.end_time(), + static_cast(settings.fps()), + static_cast(settings.video_length()), + container_type, + thermostat, + "vtu", + forces, + false, + fresh, + output_base_path}; + + if (output_base_path.empty()) { + output_base_path = params.output_dir_path; + } + + auto curr_folder = std::filesystem::path(curr_file_path).parent_path().string(); + + // Spawn particles specified in the XML file + for (auto cuboid_spawner : particle_sources.cuboid_spawner()) { + auto spawner = XSDToInternalTypeAdapter::convertToCuboidSpawner(cuboid_spawner, settings.third_dimension()); + int num_spawned = spawner.spawnParticles(particles); + Logger::logger->info("Spawned {} particles from cuboid spawner", num_spawned); + } + + for (auto sphere_spawner : particle_sources.sphere_spawner()) { + auto spawner = XSDToInternalTypeAdapter::convertToSphereSpawner(sphere_spawner, settings.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()); + int num_spawned = spawner.spawnParticles(particles); + Logger::logger->info("Spawned {} particles from single particle spawner", num_spawned); + } + + for (auto checkPointLoader : particle_sources.check_point_loader()) { + auto path = convertToPath(curr_folder, checkPointLoader.file_name()); + loadCheckpointFile(particles, path); + } + + for (auto sub_simulation : particle_sources.sub_simulation()) { + if (!allow_recursion) { + Logger::logger->warn("Error: Recursion is disabled. Skipping sub simulation at depth {}", depth); + continue; } - for (auto xsd_sphere : particles.sphere_spawner()) { - auto spawner = XSDTypeAdapter::convertToSphereSpawner(xsd_sphere, settings.third_dimension()); - particle_container->reserve(particle_container->size() + spawner.getEstimatedNumberOfParticles()); - spawner.spawnParticles(particle_container); + auto name = trim(sub_simulation.name()); + + depth++; + Logger::logger->info("Found sub simulation {} at depth {}", name, depth); + + std::string new_output_base_path = output_base_path + "/" + sanitizePath(name); + + // Try to find a checkpoint file in the base directory + auto checkpoint_path = fresh ? std::nullopt : getCheckPointFilePath(new_output_base_path); + + // If no checkpoint file was found, run the sub simulation + if (checkpoint_path.has_value()) { + Logger::logger->info("Found checkpoint file for sub simulation {} at depth {}", name, depth); + + // checking if the hash of the input file is the same as the one in the checkpoint file + auto hash_valid = checkCheckPointHashIsValid(*checkpoint_path); + + if (!hash_valid) { + Logger::logger->warn( + "The input file for sub simulation {} at depth {} has changed since the checkpoint file was created. The simulation is " + "going to be repeated.", + name, depth); + checkpoint_path = std::nullopt; + } else { + Logger::logger->warn( + "Using cached result for sub simulation {} at depth {}. To force a rerun, delete the checkpoint file at {}", name, + depth, *checkpoint_path); + } } - for (auto xsd_particle : particles.single_particle()) { - auto particle = XSDTypeAdapter::convertToParticle(xsd_particle, settings.third_dimension()); - particle_container->addParticle(particle); + if (!checkpoint_path.has_value()) { + Logger::logger->info("Starting sub simulation {} at depth {}", name, depth); + + // Load the configuration from the sub simulation + auto [loaded_config, file_name] = load_config(sub_simulation, curr_file_path, curr_folder); + + // Create the initial conditions for the sub simulation + auto [sub_particles, sub_config] = + prepare_particles(file_name, loaded_config, fresh, allow_recursion, new_output_base_path, depth); + sub_config.output_dir_path = new_output_base_path; + sub_config.output_format = OutputFormat::NONE; + + // Run the sub simulation + Simulation simulation{sub_particles, sub_config}; + + sub_config.logSummary(depth); + auto result = simulation.runSimulation(); + result.logSummary(depth); + + // Write the checkpoint file + auto checkpoint_config = sub_config; + checkpoint_config.output_format = OutputFormat::CHKPT; + + FileOutputHandler file_output_handler{checkpoint_config}; + + checkpoint_path = file_output_handler.writeFile(result.total_iterations, result.resulting_particles); + + Logger::logger->info("Wrote {} particles to checkpoint file in: {}", result.resulting_particles.size(), + result.simulation_params.output_dir_path); } - return SimulationParams{filepath, - "", - settings.delta_t(), - settings.end_time(), - static_cast(settings.fps()), - static_cast(settings.video_length()), - container_type, - thermostat, - "vtk"}; + // Load the checkpoint file + loadCheckpointFile(particles, *checkpoint_path); + } + + params.num_particles = particles.size(); + + return std::make_tuple(particles, std::move(params)); +} + +std::tuple, std::optional> XMLFileReader::readFile(const std::string& filepath) const { + try { + auto config = configuration(filepath); + + return prepare_particles(filepath, *config, fresh, allow_recursion); } catch (const xml_schema::exception& e) { std::stringstream error_message; error_message << "Error: could not parse file '" << filepath << "'.\n"; diff --git a/src/io/input/xml/XMLFileReader.h b/src/io/input/xml/XMLFileReader.h index ce5ca8276..8342bc714 100644 --- a/src/io/input/xml/XMLFileReader.h +++ b/src/io/input/xml/XMLFileReader.h @@ -1,25 +1,25 @@ #pragma once -#include - #include "io/input/FileReader.h" -#include "io/input/xml/parser/XSDTypeAdapter.h" -#include "io/input/xml/parser/simulation_schema.h" -#include "particles/containers/ParticleContainer.h" +#include "io/xml_schemas/simulation_input/simulation_input_schema.h" #include "simulation/SimulationParams.h" /** * @brief Class to read particle and simulation data from a '.xml' file */ class XMLFileReader : public FileReader { + private: + bool fresh; + bool allow_recursion; + public: + explicit XMLFileReader(bool fresh, bool allow_recursion = true) : fresh(fresh), allow_recursion(allow_recursion) {} + /** - * @brief Reads particle data from a '.xml' file and fills the given particle container. Other simulation parameters are returned. + * @brief Reads particle data from a '.xml' file and returns a vector of particles + * Other simulation parameters are returned as an optional SimulationParams object. * * @param filepath Path to the file to read - * @param particle_container Particle container to store the particles in - * @return SimulationParams object containing the simulation parameters given in the file. Unspecified parameters are set to default - * values. */ - SimulationParams readFile(const std::string& filepath, std::unique_ptr& particle_container) const override; + [[nodiscard]] std::tuple, std::optional> readFile(const std::string& filepath) const override; }; \ No newline at end of file diff --git a/src/io/input/xml/parser/create_xsd_mapping.sh b/src/io/input/xml/parser/create_xsd_mapping.sh deleted file mode 100755 index f669d9336..000000000 --- a/src/io/input/xml/parser/create_xsd_mapping.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!sh - -xsd cxx-tree --std c++20 --hxx-suffix .h --cxx-suffix .cpp --generate-doxygen --generate-serialization simulation_schema.xsd diff --git a/src/io/input/xml/parser/simulation_schema.xsd b/src/io/input/xml/parser/simulation_schema.xsd deleted file mode 100644 index 455187613..000000000 --- a/src/io/input/xml/parser/simulation_schema.xsd +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/io/logger/Logger.cpp b/src/io/logger/Logger.cpp index 382b05e56..ae9e4c77d 100644 --- a/src/io/logger/Logger.cpp +++ b/src/io/logger/Logger.cpp @@ -30,17 +30,17 @@ std::shared_ptr Logger::init_logger(LogType log_type) { standard_out->set_color(spdlog::level::trace, standard_out->magenta); spdlog::init_thread_pool(8192, 1); - std::shared_ptr logger; + std::shared_ptr new_logger; if (log_type == LogType::FILE) { createDirectory("logs"); - logger = spdlog::rotating_logger_st("file_logger", "logs/log", 1048576 * 5, 3); + new_logger = spdlog::rotating_logger_st("file_logger", "logs/log", 1048576 * 5, 3); } else { - logger = + new_logger = std::make_shared("std_logger", standard_out, spdlog::thread_pool(), spdlog::async_overflow_policy::block); } - logger->set_level(spdlog::level::off); - logger->set_pattern("[%H:%M:%S] %^[%l]%$ %v"); + new_logger->set_level(spdlog::level::off); + new_logger->set_pattern("[%H:%M:%S] %^[%l]%$ %v"); - return logger; + return new_logger; } \ No newline at end of file diff --git a/src/io/logger/Logger.h b/src/io/logger/Logger.h index 47ef051d9..e3ec74574 100644 --- a/src/io/logger/Logger.h +++ b/src/io/logger/Logger.h @@ -3,6 +3,12 @@ #include #include +#include + +const std::string ansi_blue_bold = "\e[34m\e[1m"; +const std::string ansi_yellow_bold = "\e[33m\e[1m"; +const std::string ansi_bright_white_bold = "\e[97m\e[1m"; +const std::string ansi_end = "\e[0m"; /** * @brief Class as wrapper and initializer for a globally usable logger diff --git a/src/io/output/FileOutputHandler.cpp b/src/io/output/FileOutputHandler.cpp index 8e39615bb..8598d7f9d 100644 --- a/src/io/output/FileOutputHandler.cpp +++ b/src/io/output/FileOutputHandler.cpp @@ -1,35 +1,56 @@ #include "FileOutputHandler.h" #include -#include #include "io/logger/Logger.h" -FileOutputHandler::FileOutputHandler(const OutputFormat output_format, const std::string& output_dir_path) - : output_format(output_format), output_dir_path(output_dir_path) { - switch (output_format) { - case OutputFormat::VTK: - file_writer = std::make_unique(); +FileOutputHandler::FileOutputHandler(const SimulationParams& params) : params(params) { + switch (params.output_format) { + case OutputFormat::NONE: + break; + case OutputFormat::VTU: + file_writer = std::make_unique(); break; case OutputFormat::XYZ: file_writer = std::make_unique(); break; - case OutputFormat::NONE: - return; + case OutputFormat::CHKPT: + file_writer = std::make_unique(); + break; default: Logger::logger->error("Output format not implemented."); exit(1); } - if (std::filesystem::exists(output_dir_path)) { - std::filesystem::remove_all(output_dir_path); + if (std::filesystem::exists(params.output_dir_path)) { + auto supported = get_supported_output_formats(); + auto file_extension = std::find_if(supported.begin(), supported.end(), [params](const auto& pair) { + return pair.second == params.output_format; + })->first; + + auto count = 0; + for (const auto& entry : std::filesystem::directory_iterator(params.output_dir_path)) { + if (entry.path().extension() == "." + file_extension) { + std::filesystem::remove(entry.path()); + count++; + } + } + Logger::logger->warn("Removed {} files with targetted file extension {} from target directory {}", count, file_extension, + params.output_dir_path); + } else { + Logger::logger->info("Creating output directory '{}'.", params.output_dir_path); + std::filesystem::create_directories(params.output_dir_path); } - std::filesystem::create_directories(output_dir_path); } -void FileOutputHandler::writeFile(int iteration, const std::unique_ptr& particle_container) const { - if (output_format == OutputFormat::NONE) { - return; +std::optional FileOutputHandler::writeFile(size_t iteration, const std::vector& particles) const { + if (params.output_format == OutputFormat::NONE) { + return std::nullopt; } - file_writer->writeFile(output_dir_path, iteration, particle_container); + return file_writer->writeFile(params, iteration, particles); +} + +std::optional FileOutputHandler::writeFile(size_t iteration, + const std::unique_ptr& particle_container) const { + return writeFile(iteration, particle_container->getParticles()); } diff --git a/src/io/output/FileOutputHandler.h b/src/io/output/FileOutputHandler.h index 590d11796..74f3fc257 100644 --- a/src/io/output/FileOutputHandler.h +++ b/src/io/output/FileOutputHandler.h @@ -3,33 +3,24 @@ #include #include -#include "io/output/vtk/VTKWriter.h" +#include "io/output/FileWriter.h" +#include "io/output/chkpt/CheckPointWriter.h" +#include "io/output/vtu/VTUWriter.h" #include "io/output/xyz/XYZWriter.h" #include "particles/containers/ParticleContainer.h" /** * @brief Wrapper class to abstract the writing of output files * - * Currently there are two supported output formats: VTK and XYZ. Additionally a 'NONE' format is available, which does not write any + * Currently there are two supported output formats: VTU and XYZ. Additionally a 'NONE' format is available, which does not write any * output. */ class FileOutputHandler { - public: - /** - * @brief Enum class to specify the output format - */ - enum class OutputFormat { VTK, XYZ, NONE }; - private: /** - * @brief Saves the output format given + * @brief SimulationParams object which provides the output directory path */ - const OutputFormat output_format; - - /** - * @brief Path to the directory in which to save the output - */ - const std::string output_dir_path; + const SimulationParams& params; /** * @brief Pointer to the FileWriter object to use @@ -40,16 +31,27 @@ class FileOutputHandler { /** * @brief Construct a new FileOutputHandler object * - * @param output_format The format of the output files - * @param output_dir_path The path to the directory in which to save the output; + * @param params SimulationParams object which provides the output directory path */ - explicit FileOutputHandler(OutputFormat output_format, const std::string& output_dir_path = "./output"); + explicit FileOutputHandler(const SimulationParams& params); /** * @brief Writes the given ParticleContainers particle data to a file * * @param iteration The current iteration number of the simulation * @param particle_container The ParticleContainer to write to the file + * + * @return The path to the written file + */ + std::optional writeFile(size_t iteration, const std::unique_ptr& particle_container) const; + + /** + * @brief Writes the given ParticleContainers particle data to a file + * + * @param iteration The current iteration number of the simulation + * @param particles A vector of particles to write to the file + * + * @return The path to the written file */ - void writeFile(int iteration, const std::unique_ptr& particle_container) const; + std::optional writeFile(size_t iteration, const std::vector& particles) const; }; \ No newline at end of file diff --git a/src/io/output/FileWriter.h b/src/io/output/FileWriter.h index eb95517bd..2c507598b 100644 --- a/src/io/output/FileWriter.h +++ b/src/io/output/FileWriter.h @@ -1,8 +1,10 @@ #pragma once -#include +#include +#include -#include "particles/containers/ParticleContainer.h" +#include "particles/Particle.h" +#include "simulation/SimulationParams.h" /** * @brief Abstract base class for all file writers @@ -17,10 +19,11 @@ class FileWriter { /** * @brief Writes the file to the given path, uses the given ParticleContainer and the current iteration * - * @param output_dir_path Path to the directory in which to save the output + * @param params SimulationParams object which provides the output directory path * @param iteration The current iteration number - * @param particle_container ParticleContainer which provides the data to be written + * @param particles A vector of particles to write to the file + * + * @return The path to the written file */ - virtual void writeFile(const std::string& output_dir_path, int iteration, - const std::unique_ptr& particle_container) const = 0; + virtual const std::string writeFile(const SimulationParams& params, size_t iteration, const std::vector& particles) const = 0; }; \ No newline at end of file diff --git a/src/io/output/OutputFormats.cpp b/src/io/output/OutputFormats.cpp new file mode 100644 index 000000000..a0230ab0a --- /dev/null +++ b/src/io/output/OutputFormats.cpp @@ -0,0 +1,5 @@ +#include "OutputFormats.h" + +std::map get_supported_output_formats() { + return {{"vtu", OutputFormat::VTU}, {"xyz", OutputFormat::XYZ}, {"chkpt", OutputFormat::CHKPT}, {"none", OutputFormat::NONE}}; +} \ No newline at end of file diff --git a/src/io/output/OutputFormats.h b/src/io/output/OutputFormats.h new file mode 100644 index 000000000..872096483 --- /dev/null +++ b/src/io/output/OutputFormats.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +/** + * @brief Enum class to specify the output format + */ +enum class OutputFormat { VTU, XYZ, CHKPT, NONE }; + +/** + * @brief Returns a mappping of supported output formats + * + * @return std::map Mapping of supported output formats + */ +std::map get_supported_output_formats(); \ No newline at end of file diff --git a/src/io/output/chkpt/CheckPointWriter.cpp b/src/io/output/chkpt/CheckPointWriter.cpp new file mode 100644 index 000000000..262e2af8e --- /dev/null +++ b/src/io/output/chkpt/CheckPointWriter.cpp @@ -0,0 +1,36 @@ +#include "CheckPointWriter.h" + +#include +#include +#include +#include + +#include "io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.h" + +const std::string CheckPointWriter::writeFile(const SimulationParams& params, size_t iteration, + const std::vector& particles) const { + auto file_base = params.output_dir_path + "/" + "MD_CHKPT"; + + std::stringstream strstr; + strstr << file_base << "_" << std::setfill('0') << std::setw(4) << iteration << ".chkpt"; + + MetaDataDataType meta_data{params.input_file_path, params.input_file_hash, params.end_time, params.delta_t}; + + CheckPointFileType::ParticleData_type xsd_particles{}; + + xsd_particles.particle().reserve(particles.size()); + + for (const Particle& particle : particles) { + xsd_particles.particle().push_back(InternalToXSDTypeAdapter::convertToParticle(particle)); + } + + CheckPointFileType checkpointfile(meta_data, xsd_particles); + + auto file_name = strstr.str(); + + std::ofstream file(file_name.c_str()); + CheckPoint(file, checkpointfile); + file.close(); + + return file_name; +} \ No newline at end of file diff --git a/src/io/output/chkpt/CheckPointWriter.h b/src/io/output/chkpt/CheckPointWriter.h new file mode 100644 index 000000000..b79e231c6 --- /dev/null +++ b/src/io/output/chkpt/CheckPointWriter.h @@ -0,0 +1,22 @@ +#pragma once + +#include "io/output/FileWriter.h" +#include "io/xml_schemas/checkpoint/checkpoint_schema.h" +#include "particles/Particle.h" + +/** + * @brief Class to write particle data to a .chkpt file + */ +class CheckPointWriter : public FileWriter { + public: + /** + * @brief Writes the data of the given ParticleContainer to a .vtu file + * + * @param params SimulationParams object which provides the output directory path + * @param iteration The current iteration number + * @param particles A vector of particles to write to the file + * + * @return The path to the written file + */ + const std::string writeFile(const SimulationParams& params, size_t iteration, const std::vector& particles) const override; +}; diff --git a/src/io/output/vtk/parser/create_xsd_mapping.sh b/src/io/output/vtk/parser/create_xsd_mapping.sh deleted file mode 100755 index 821638f8d..000000000 --- a/src/io/output/vtk/parser/create_xsd_mapping.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!sh - -xsd cxx-tree --std c++20 --hxx-suffix .h --cxx-suffix .cpp --generate-doxygen --generate-serialization vtk-unstructured.xsd diff --git a/src/io/output/vtk/VTKWriter.cpp b/src/io/output/vtu/VTUWriter.cpp similarity index 63% rename from src/io/output/vtk/VTKWriter.cpp rename to src/io/output/vtu/VTUWriter.cpp index df636d008..b7fcb3662 100644 --- a/src/io/output/vtk/VTKWriter.cpp +++ b/src/io/output/vtu/VTUWriter.cpp @@ -1,17 +1,12 @@ +#include "VTUWriter.h" - -#include "VTKWriter.h" - -#include #include #include #include #include -#include "io/logger/Logger.h" - -VTKFile_t VTKWriter::initializeOutput(int numParticles) { - VTKFile_t vtkFile("UnstructuredGrid"); +VTKFile_t VTUWriter::initializeOutput(int numParticles) { + VTKFile_t vtuFile("UnstructuredGrid"); // per point, we add type, position, velocity and force PointData pointData; @@ -38,18 +33,13 @@ VTKFile_t VTKWriter::initializeOutput(int numParticles) { PieceUnstructuredGrid_t piece(pointData, cellData, points, cells, numParticles, 0); UnstructuredGrid_t unstructuredGrid(piece); - vtkFile.UnstructuredGrid(unstructuredGrid); + vtuFile.UnstructuredGrid(unstructuredGrid); - return vtkFile; + return vtuFile; } -void VTKWriter::plotParticle(VTKFile_t& vtkFile, const Particle& p) { - if (!vtkFile.UnstructuredGrid().present()) { - Logger::logger->error("VTKWriter: No UnstructuredGrid present"); - exit(-1); - } - - PointData::DataArray_sequence& pointDataSequence = vtkFile.UnstructuredGrid()->Piece().PointData().DataArray(); +void VTUWriter::plotParticle(VTKFile_t& vtuFile, const Particle& p) { + PointData::DataArray_sequence& pointDataSequence = vtuFile.UnstructuredGrid()->Piece().PointData().DataArray(); PointData::DataArray_iterator dataIterator = pointDataSequence.begin(); dataIterator->push_back(p.getM()); @@ -67,27 +57,30 @@ void VTKWriter::plotParticle(VTKFile_t& vtkFile, const Particle& p) { dataIterator++; dataIterator->push_back(p.getType()); - Points::DataArray_sequence& pointsSequence = vtkFile.UnstructuredGrid()->Piece().Points().DataArray(); + Points::DataArray_sequence& pointsSequence = vtuFile.UnstructuredGrid()->Piece().Points().DataArray(); Points::DataArray_iterator pointsIterator = pointsSequence.begin(); pointsIterator->push_back(p.getX()[0]); pointsIterator->push_back(p.getX()[1]); pointsIterator->push_back(p.getX()[2]); } -void VTKWriter::writeFile(const std::string& output_dir_path, int iteration, - const std::unique_ptr& particle_container) const { - auto filename = output_dir_path + "/" + "MD_VTK"; +const std::string VTUWriter::writeFile(const SimulationParams& params, size_t iteration, const std::vector& particles) const { + auto file_base = params.output_dir_path + "/" + "MD_VTU"; std::stringstream strstr; - strstr << filename << "_" << std::setfill('0') << std::setw(4) << iteration << ".vtu"; + strstr << file_base << "_" << std::setfill('0') << std::setw(4) << iteration << ".vtu"; - auto vtkFile = initializeOutput(static_cast(particle_container->size())); + auto vtuFile = initializeOutput(static_cast(particles.size())); - for (const Particle& particle : *particle_container) { - plotParticle(vtkFile, particle); + for (const Particle& particle : particles) { + plotParticle(vtuFile, particle); } - std::ofstream file(strstr.str().c_str()); - VTKFile(file, vtkFile); + auto file_name = strstr.str(); + + std::ofstream file(file_name.c_str()); + VTKFile(file, vtuFile); file.close(); + + return file_name; } diff --git a/src/io/output/vtk/VTKWriter.h b/src/io/output/vtu/VTUWriter.h similarity index 52% rename from src/io/output/vtk/VTKWriter.h rename to src/io/output/vtu/VTUWriter.h index 43f480b49..f4f7db2f6 100644 --- a/src/io/output/vtk/VTKWriter.h +++ b/src/io/output/vtu/VTUWriter.h @@ -1,41 +1,38 @@ - - #pragma once -#include - #include "io/output/FileWriter.h" -#include "io/output/vtk/parser/vtk-unstructured.h" +#include "io/xml_schemas/vtu_file/vtu_file_schema.h" #include "particles/Particle.h" /** - * @brief Class to write particle data to a .vtk file + * @brief Class to write particle data to a .vtu file */ -class VTKWriter : public FileWriter { +class VTUWriter : public FileWriter { public: /** - * @brief Writes the data of the given ParticleContainer to a .vtk file + * @brief Writes the data of the given ParticleContainer to a .vtu file * - * @param output_dir_path Path to the directory in which to save the output file + * @param params SimulationParams object which provides the output directory path * @param iteration The current iteration number - * @param particle_container ParticleContainer whose particles are to be written + * @param particles A vector of particles to write to the file + * + * @return The path to the written file */ - void writeFile(const std::string& output_dir_path, int iteration, - const std::unique_ptr& particle_container) const override; + const std::string writeFile(const SimulationParams& params, size_t iteration, const std::vector& particles) const override; private: /** * @brief Creates a VTKFile_t object with the given number of particles. * * @param numParticles Number of particles to be plotted - * @return VTKFile_t object with the given number of particles + * @return VTUFile_t object with the given number of particles */ [[nodiscard]] static VTKFile_t initializeOutput(int numParticles); /** * @brief Writes a given particle to the given VTKFile_t object. * - * @param file VTKFile_t object to write to + * @param file VTUFile_t object to write to * @param p Particle to be written */ static void plotParticle(VTKFile_t& file, const Particle& p); diff --git a/src/io/output/xyz/XYZWriter.cpp b/src/io/output/xyz/XYZWriter.cpp index ec9e56edd..fb4ae267d 100644 --- a/src/io/output/xyz/XYZWriter.cpp +++ b/src/io/output/xyz/XYZWriter.cpp @@ -1,23 +1,23 @@ - #include "XYZWriter.h" #include #include -void XYZWriter::writeFile(const std::string& output_dir_path, int iteration, - const std::unique_ptr& particle_container) const { - auto filename = output_dir_path + "/" + "MD_XYZ"; +const std::string XYZWriter::writeFile(const SimulationParams& params, size_t iteration, const std::vector& particles) const { + auto file_base = params.output_dir_path + "/" + "MD_XYZ"; std::stringstream strstr; - strstr << filename << "_" << std::setfill('0') << std::setw(4) << iteration << ".xyz"; + strstr << file_base << "_" << std::setfill('0') << std::setw(4) << iteration << ".xyz"; std::ofstream file; + auto file_name = strstr.str(); + file.open(strstr.str().c_str()); - file << particle_container->size() << std::endl; + file << particles.size() << std::endl; file << "Generated by MolSim. See http://openbabel.org/wiki/XYZ_(format) for file format doku." << std::endl; - for (auto& p : *particle_container) { + for (auto& p : particles) { std::array x = p.getX(); file << "Ar "; file.setf(std::ios_base::showpoint); @@ -30,4 +30,6 @@ void XYZWriter::writeFile(const std::string& output_dir_path, int iteration, } file.close(); + + return file_name; } diff --git a/src/io/output/xyz/XYZWriter.h b/src/io/output/xyz/XYZWriter.h index 3fa62b9db..b911f6e6e 100644 --- a/src/io/output/xyz/XYZWriter.h +++ b/src/io/output/xyz/XYZWriter.h @@ -15,10 +15,11 @@ class XYZWriter : public FileWriter { /** * @brief Writes the data of the given ParticleContainer to a .xyz file * - * @param output_dir_path Path to the directory in which to save the output + * @param params SimulationParams object which provides the output directory path * @param iteration The current iteration - * @param particle_container ParticleContainer to be used + * @param particles A vector of particles to write to the file + * + * @return The path to the written file */ - void writeFile(const std::string& output_dir_path, int iteration, - const std::unique_ptr& particle_container) const override; + const std::string writeFile(const SimulationParams& params, size_t iteration, const std::vector& particles) const override; }; diff --git a/src/io/xml_schemas/checkpoint/checkpoint_schema.cpp b/src/io/xml_schemas/checkpoint/checkpoint_schema.cpp new file mode 100644 index 000000000..885244e95 --- /dev/null +++ b/src/io/xml_schemas/checkpoint/checkpoint_schema.cpp @@ -0,0 +1,898 @@ +// Copyright (c) 2005-2023 Code Synthesis. +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis gives permission +// to link this program with the Xerces-C++ library (or with modified +// versions of Xerces-C++ that use the same license as Xerces-C++), and +// distribute linked combinations including the two. You must obey the GNU +// General Public License version 2 in all respects for all of the code +// used other than Xerces-C++. If you modify this copy of the program, you +// may extend this exception to your version of the program, but you are +// not obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. +// +// Furthermore, Code Synthesis makes a special exception for the Free/Libre +// and Open Source Software (FLOSS) which is described in the accompanying +// FLOSSE file. +// + +// Begin prologue. +// +// +// End prologue. + +#include "checkpoint_schema.h" + +#include + +// CheckPointFileType +// + +const CheckPointFileType::MetaData_type& CheckPointFileType::MetaData() const { return this->MetaData_.get(); } + +CheckPointFileType::MetaData_type& CheckPointFileType::MetaData() { return this->MetaData_.get(); } + +void CheckPointFileType::MetaData(const MetaData_type& x) { this->MetaData_.set(x); } + +void CheckPointFileType::MetaData(::std::unique_ptr x) { this->MetaData_.set(std::move(x)); } + +const CheckPointFileType::ParticleData_type& CheckPointFileType::ParticleData() const { return this->ParticleData_.get(); } + +CheckPointFileType::ParticleData_type& CheckPointFileType::ParticleData() { return this->ParticleData_.get(); } + +void CheckPointFileType::ParticleData(const ParticleData_type& x) { this->ParticleData_.set(x); } + +void CheckPointFileType::ParticleData(::std::unique_ptr x) { this->ParticleData_.set(std::move(x)); } + +// MetaDataDataType +// + +const MetaDataDataType::input_file_type& MetaDataDataType::input_file() const { return this->input_file_.get(); } + +MetaDataDataType::input_file_type& MetaDataDataType::input_file() { return this->input_file_.get(); } + +void MetaDataDataType::input_file(const input_file_type& x) { this->input_file_.set(x); } + +void MetaDataDataType::input_file(::std::unique_ptr x) { this->input_file_.set(std::move(x)); } + +const MetaDataDataType::input_file_hash_type& MetaDataDataType::input_file_hash() const { return this->input_file_hash_.get(); } + +MetaDataDataType::input_file_hash_type& MetaDataDataType::input_file_hash() { return this->input_file_hash_.get(); } + +void MetaDataDataType::input_file_hash(const input_file_hash_type& x) { this->input_file_hash_.set(x); } + +const MetaDataDataType::end_time_type& MetaDataDataType::end_time() const { return this->end_time_.get(); } + +MetaDataDataType::end_time_type& MetaDataDataType::end_time() { return this->end_time_.get(); } + +void MetaDataDataType::end_time(const end_time_type& x) { this->end_time_.set(x); } + +const MetaDataDataType::delta_t_type& MetaDataDataType::delta_t() const { return this->delta_t_.get(); } + +MetaDataDataType::delta_t_type& MetaDataDataType::delta_t() { return this->delta_t_.get(); } + +void MetaDataDataType::delta_t(const delta_t_type& x) { this->delta_t_.set(x); } + +// ParticleDataType +// + +const ParticleDataType::particle_sequence& ParticleDataType::particle() const { return this->particle_; } + +ParticleDataType::particle_sequence& ParticleDataType::particle() { return this->particle_; } + +void ParticleDataType::particle(const particle_sequence& s) { this->particle_ = s; } + +// ParticleType +// + +const ParticleType::position_type& ParticleType::position() const { return this->position_.get(); } + +ParticleType::position_type& ParticleType::position() { return this->position_.get(); } + +void ParticleType::position(const position_type& x) { this->position_.set(x); } + +void ParticleType::position(::std::unique_ptr x) { this->position_.set(std::move(x)); } + +const ParticleType::velocity_type& ParticleType::velocity() const { return this->velocity_.get(); } + +ParticleType::velocity_type& ParticleType::velocity() { return this->velocity_.get(); } + +void ParticleType::velocity(const velocity_type& x) { this->velocity_.set(x); } + +void ParticleType::velocity(::std::unique_ptr x) { this->velocity_.set(std::move(x)); } + +const ParticleType::force_type& ParticleType::force() const { return this->force_.get(); } + +ParticleType::force_type& ParticleType::force() { return this->force_.get(); } + +void ParticleType::force(const force_type& x) { this->force_.set(x); } + +void ParticleType::force(::std::unique_ptr x) { this->force_.set(std::move(x)); } + +const ParticleType::old_force_type& ParticleType::old_force() const { return this->old_force_.get(); } + +ParticleType::old_force_type& ParticleType::old_force() { return this->old_force_.get(); } + +void ParticleType::old_force(const old_force_type& x) { this->old_force_.set(x); } + +void ParticleType::old_force(::std::unique_ptr x) { this->old_force_.set(std::move(x)); } + +const ParticleType::mass_type& ParticleType::mass() const { return this->mass_.get(); } + +ParticleType::mass_type& ParticleType::mass() { return this->mass_.get(); } + +void ParticleType::mass(const mass_type& x) { this->mass_.set(x); } + +const ParticleType::type_type& ParticleType::type() const { return this->type_.get(); } + +ParticleType::type_type& ParticleType::type() { return this->type_.get(); } + +void ParticleType::type(const type_type& x) { this->type_.set(x); } + +#include + +// CheckPointFileType +// + +CheckPointFileType::CheckPointFileType(const MetaData_type& MetaData, const ParticleData_type& ParticleData) + : ::xml_schema::type(), MetaData_(MetaData, this), ParticleData_(ParticleData, this) {} + +CheckPointFileType::CheckPointFileType(::std::unique_ptr MetaData, ::std::unique_ptr ParticleData) + : ::xml_schema::type(), MetaData_(std::move(MetaData), this), ParticleData_(std::move(ParticleData), this) {} + +CheckPointFileType::CheckPointFileType(const CheckPointFileType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), MetaData_(x.MetaData_, f, this), ParticleData_(x.ParticleData_, f, this) {} + +CheckPointFileType::CheckPointFileType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), MetaData_(this), ParticleData_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void CheckPointFileType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // MetaData + // + if (n.name() == "MetaData" && n.namespace_().empty()) { + ::std::unique_ptr r(MetaData_traits::create(i, f, this)); + + if (!MetaData_.present()) { + this->MetaData_.set(::std::move(r)); + continue; + } + } + + // ParticleData + // + if (n.name() == "ParticleData" && n.namespace_().empty()) { + ::std::unique_ptr r(ParticleData_traits::create(i, f, this)); + + if (!ParticleData_.present()) { + this->ParticleData_.set(::std::move(r)); + continue; + } + } + + break; + } + + if (!MetaData_.present()) { + throw ::xsd::cxx::tree::expected_element("MetaData", ""); + } + + if (!ParticleData_.present()) { + throw ::xsd::cxx::tree::expected_element("ParticleData", ""); + } +} + +CheckPointFileType* CheckPointFileType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class CheckPointFileType(*this, f, c); +} + +CheckPointFileType& CheckPointFileType::operator=(const CheckPointFileType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->MetaData_ = x.MetaData_; + this->ParticleData_ = x.ParticleData_; + } + + return *this; +} + +CheckPointFileType::~CheckPointFileType() {} + +// MetaDataDataType +// + +MetaDataDataType::MetaDataDataType(const input_file_type& input_file, const input_file_hash_type& input_file_hash, + const end_time_type& end_time, const delta_t_type& delta_t) + : ::xml_schema::type(), + input_file_(input_file, this), + input_file_hash_(input_file_hash, this), + end_time_(end_time, this), + delta_t_(delta_t, this) {} + +MetaDataDataType::MetaDataDataType(const MetaDataDataType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), + input_file_(x.input_file_, f, this), + input_file_hash_(x.input_file_hash_, f, this), + end_time_(x.end_time_, f, this), + delta_t_(x.delta_t_, f, this) {} + +MetaDataDataType::MetaDataDataType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), input_file_(this), input_file_hash_(this), end_time_(this), delta_t_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void MetaDataDataType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // input_file + // + if (n.name() == "input_file" && n.namespace_().empty()) { + ::std::unique_ptr r(input_file_traits::create(i, f, this)); + + if (!input_file_.present()) { + this->input_file_.set(::std::move(r)); + continue; + } + } + + // input_file_hash + // + if (n.name() == "input_file_hash" && n.namespace_().empty()) { + if (!input_file_hash_.present()) { + this->input_file_hash_.set(input_file_hash_traits::create(i, f, this)); + continue; + } + } + + // end_time + // + if (n.name() == "end_time" && n.namespace_().empty()) { + if (!end_time_.present()) { + this->end_time_.set(end_time_traits::create(i, f, this)); + continue; + } + } + + // delta_t + // + if (n.name() == "delta_t" && n.namespace_().empty()) { + if (!delta_t_.present()) { + this->delta_t_.set(delta_t_traits::create(i, f, this)); + continue; + } + } + + break; + } + + if (!input_file_.present()) { + throw ::xsd::cxx::tree::expected_element("input_file", ""); + } + + if (!input_file_hash_.present()) { + throw ::xsd::cxx::tree::expected_element("input_file_hash", ""); + } + + if (!end_time_.present()) { + throw ::xsd::cxx::tree::expected_element("end_time", ""); + } + + if (!delta_t_.present()) { + throw ::xsd::cxx::tree::expected_element("delta_t", ""); + } +} + +MetaDataDataType* MetaDataDataType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class MetaDataDataType(*this, f, c); +} + +MetaDataDataType& MetaDataDataType::operator=(const MetaDataDataType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->input_file_ = x.input_file_; + this->input_file_hash_ = x.input_file_hash_; + this->end_time_ = x.end_time_; + this->delta_t_ = x.delta_t_; + } + + return *this; +} + +MetaDataDataType::~MetaDataDataType() {} + +// ParticleDataType +// + +ParticleDataType::ParticleDataType() : ::xml_schema::type(), particle_(this) {} + +ParticleDataType::ParticleDataType(const ParticleDataType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), particle_(x.particle_, f, this) {} + +ParticleDataType::ParticleDataType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), particle_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void ParticleDataType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // particle + // + if (n.name() == "particle" && n.namespace_().empty()) { + ::std::unique_ptr r(particle_traits::create(i, f, this)); + + this->particle_.push_back(::std::move(r)); + continue; + } + + break; + } +} + +ParticleDataType* ParticleDataType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class ParticleDataType(*this, f, c); +} + +ParticleDataType& ParticleDataType::operator=(const ParticleDataType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->particle_ = x.particle_; + } + + return *this; +} + +ParticleDataType::~ParticleDataType() {} + +// ParticleType +// + +ParticleType::ParticleType(const position_type& position, const velocity_type& velocity, const force_type& force, + const old_force_type& old_force, const mass_type& mass, const type_type& type) + : ::xml_schema::type(), + position_(position, this), + velocity_(velocity, this), + force_(force, this), + old_force_(old_force, this), + mass_(mass, this), + type_(type, this) {} + +ParticleType::ParticleType(::std::unique_ptr position, ::std::unique_ptr velocity, + ::std::unique_ptr force, ::std::unique_ptr old_force, const mass_type& mass, + const type_type& type) + : ::xml_schema::type(), + position_(std::move(position), this), + velocity_(std::move(velocity), this), + force_(std::move(force), this), + old_force_(std::move(old_force), this), + mass_(mass, this), + type_(type, this) {} + +ParticleType::ParticleType(const ParticleType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), + position_(x.position_, f, this), + velocity_(x.velocity_, f, this), + force_(x.force_, f, this), + old_force_(x.old_force_, f, this), + mass_(x.mass_, f, this), + type_(x.type_, f, this) {} + +ParticleType::ParticleType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), + position_(this), + velocity_(this), + force_(this), + old_force_(this), + mass_(this), + type_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void ParticleType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // position + // + if (n.name() == "position" && n.namespace_().empty()) { + ::std::unique_ptr r(position_traits::create(i, f, this)); + + if (!position_.present()) { + this->position_.set(::std::move(r)); + continue; + } + } + + // velocity + // + if (n.name() == "velocity" && n.namespace_().empty()) { + ::std::unique_ptr r(velocity_traits::create(i, f, this)); + + if (!velocity_.present()) { + this->velocity_.set(::std::move(r)); + continue; + } + } + + // force + // + if (n.name() == "force" && n.namespace_().empty()) { + ::std::unique_ptr r(force_traits::create(i, f, this)); + + if (!force_.present()) { + this->force_.set(::std::move(r)); + continue; + } + } + + // old_force + // + if (n.name() == "old_force" && n.namespace_().empty()) { + ::std::unique_ptr r(old_force_traits::create(i, f, this)); + + if (!old_force_.present()) { + this->old_force_.set(::std::move(r)); + continue; + } + } + + // mass + // + if (n.name() == "mass" && n.namespace_().empty()) { + if (!mass_.present()) { + this->mass_.set(mass_traits::create(i, f, this)); + continue; + } + } + + // type + // + if (n.name() == "type" && n.namespace_().empty()) { + if (!type_.present()) { + this->type_.set(type_traits::create(i, f, this)); + continue; + } + } + + break; + } + + if (!position_.present()) { + throw ::xsd::cxx::tree::expected_element("position", ""); + } + + if (!velocity_.present()) { + throw ::xsd::cxx::tree::expected_element("velocity", ""); + } + + if (!force_.present()) { + throw ::xsd::cxx::tree::expected_element("force", ""); + } + + if (!old_force_.present()) { + throw ::xsd::cxx::tree::expected_element("old_force", ""); + } + + if (!mass_.present()) { + throw ::xsd::cxx::tree::expected_element("mass", ""); + } + + if (!type_.present()) { + throw ::xsd::cxx::tree::expected_element("type", ""); + } +} + +ParticleType* ParticleType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class ParticleType(*this, f, c); } + +ParticleType& ParticleType::operator=(const ParticleType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->position_ = x.position_; + this->velocity_ = x.velocity_; + this->force_ = x.force_; + this->old_force_ = x.old_force_; + this->mass_ = x.mass_; + this->type_ = x.type_; + } + + return *this; +} + +ParticleType::~ParticleType() {} + +#include +#include +#include + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::std::string& u, ::xml_schema::flags f, const ::xml_schema::properties& p) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); + + ::xsd::cxx::tree::error_handler h; + + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(u, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing >(); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::std::string& u, ::xml_schema::error_handler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); + + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(u, h, p, f)); + + if (!d.get()) throw ::xsd::cxx::tree::parsing(); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::std::string& u, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(u, h, p, f)); + + if (!d.get()) throw ::xsd::cxx::tree::parsing(); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, ::xml_schema::flags f, const ::xml_schema::properties& p) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc(is); + return ::CheckPoint(isrc, f, p); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, ::xml_schema::error_handler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc(is); + return ::CheckPoint(isrc, h, f, p); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xsd::cxx::xml::sax::std_input_source isrc(is); + return ::CheckPoint(isrc, h, f, p); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, const ::std::string& sid, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc(is, sid); + return ::CheckPoint(isrc, f, p); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, const ::std::string& sid, ::xml_schema::error_handler& h, + ::xml_schema::flags f, const ::xml_schema::properties& p) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); + + ::xsd::cxx::xml::sax::std_input_source isrc(is, sid); + return ::CheckPoint(isrc, h, f, p); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, const ::std::string& sid, ::xercesc::DOMErrorHandler& h, + ::xml_schema::flags f, const ::xml_schema::properties& p) { + ::xsd::cxx::xml::sax::std_input_source isrc(is, sid); + return ::CheckPoint(isrc, h, f, p); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xercesc::InputSource& i, ::xml_schema::flags f, const ::xml_schema::properties& p) { + ::xsd::cxx::tree::error_handler h; + + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(i, h, p, f)); + + h.throw_if_failed< ::xsd::cxx::tree::parsing >(); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xercesc::InputSource& i, ::xml_schema::error_handler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(i, h, p, f)); + + if (!d.get()) throw ::xsd::cxx::tree::parsing(); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xercesc::InputSource& i, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(i, h, p, f)); + + if (!d.get()) throw ::xsd::cxx::tree::parsing(); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::xercesc::DOMDocument& doc, ::xml_schema::flags f, + const ::xml_schema::properties& p) { + if (f & ::xml_schema::flags::keep_dom) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(static_cast< ::xercesc::DOMDocument*>(doc.cloneNode(true))); + + return ::std::unique_ptr< ::CheckPointFileType>(::CheckPoint(std::move(d), f | ::xml_schema::flags::own_dom, p)); + } + + const ::xercesc::DOMElement& e(*doc.getDocumentElement()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(e)); + + if (n.name() == "CheckPoint" && n.namespace_() == "") { + ::std::unique_ptr< ::CheckPointFileType> r(::xsd::cxx::tree::traits< ::CheckPointFileType, char>::create(e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element(n.name(), n.namespace_(), "CheckPoint", ""); +} + +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d, ::xml_schema::flags f, + const ::xml_schema::properties&) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> c(((f & ::xml_schema::flags::keep_dom) && !(f & ::xml_schema::flags::own_dom)) + ? static_cast< ::xercesc::DOMDocument*>(d->cloneNode(true)) + : 0); + + ::xercesc::DOMDocument& doc(c.get() ? *c : *d); + const ::xercesc::DOMElement& e(*doc.getDocumentElement()); + + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(e)); + + if (f & ::xml_schema::flags::keep_dom) doc.setUserData(::xml_schema::dom::tree_node_key, (c.get() ? &c : &d), 0); + + if (n.name() == "CheckPoint" && n.namespace_() == "") { + ::std::unique_ptr< ::CheckPointFileType> r(::xsd::cxx::tree::traits< ::CheckPointFileType, char>::create(e, f, 0)); + return r; + } + + throw ::xsd::cxx::tree::unexpected_element(n.name(), n.namespace_(), "CheckPoint", ""); +} + +#include +#include +#include + +void CheckPoint(::std::ostream& o, const ::CheckPointFileType& s, const ::xml_schema::namespace_infomap& m, const ::std::string& e, + ::xml_schema::flags f) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0); + + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::CheckPoint(s, m, f)); + + ::xsd::cxx::tree::error_handler h; + + ::xsd::cxx::xml::dom::ostream_format_target t(o); + if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { + h.throw_if_failed< ::xsd::cxx::tree::serialization >(); + } +} + +void CheckPoint(::std::ostream& o, const ::CheckPointFileType& s, ::xml_schema::error_handler& h, const ::xml_schema::namespace_infomap& m, + const ::std::string& e, ::xml_schema::flags f) { + ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0); + + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::CheckPoint(s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t(o); + if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { + throw ::xsd::cxx::tree::serialization(); + } +} + +void CheckPoint(::std::ostream& o, const ::CheckPointFileType& s, ::xercesc::DOMErrorHandler& h, const ::xml_schema::namespace_infomap& m, + const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::CheckPoint(s, m, f)); + ::xsd::cxx::xml::dom::ostream_format_target t(o); + if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { + throw ::xsd::cxx::tree::serialization(); + } +} + +void CheckPoint(::xercesc::XMLFormatTarget& t, const ::CheckPointFileType& s, const ::xml_schema::namespace_infomap& m, + const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::CheckPoint(s, m, f)); + + ::xsd::cxx::tree::error_handler h; + + if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { + h.throw_if_failed< ::xsd::cxx::tree::serialization >(); + } +} + +void CheckPoint(::xercesc::XMLFormatTarget& t, const ::CheckPointFileType& s, ::xml_schema::error_handler& h, + const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::CheckPoint(s, m, f)); + if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { + throw ::xsd::cxx::tree::serialization(); + } +} + +void CheckPoint(::xercesc::XMLFormatTarget& t, const ::CheckPointFileType& s, ::xercesc::DOMErrorHandler& h, + const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::CheckPoint(s, m, f)); + if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { + throw ::xsd::cxx::tree::serialization(); + } +} + +void CheckPoint(::xercesc::DOMDocument& d, const ::CheckPointFileType& s, ::xml_schema::flags) { + ::xercesc::DOMElement& e(*d.getDocumentElement()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(e)); + + if (n.name() == "CheckPoint" && n.namespace_() == "") { + e << s; + } else { + throw ::xsd::cxx::tree::unexpected_element(n.name(), n.namespace_(), "CheckPoint", ""); + } +} + +::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> CheckPoint(const ::CheckPointFileType& s, const ::xml_schema::namespace_infomap& m, + ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::serialize("CheckPoint", "", m, f)); + + ::CheckPoint(*d, s, f); + return d; +} + +void operator<<(::xercesc::DOMElement& e, const CheckPointFileType& i) { + e << static_cast(i); + + // MetaData + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("MetaData", e)); + + s << i.MetaData(); + } + + // ParticleData + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("ParticleData", e)); + + s << i.ParticleData(); + } +} + +void operator<<(::xercesc::DOMElement& e, const MetaDataDataType& i) { + e << static_cast(i); + + // input_file + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("input_file", e)); + + s << i.input_file(); + } + + // input_file_hash + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("input_file_hash", e)); + + s << i.input_file_hash(); + } + + // end_time + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("end_time", e)); + + s << ::xml_schema::as_double(i.end_time()); + } + + // delta_t + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("delta_t", e)); + + s << ::xml_schema::as_double(i.delta_t()); + } +} + +void operator<<(::xercesc::DOMElement& e, const ParticleDataType& i) { + e << static_cast(i); + + // particle + // + for (ParticleDataType::particle_const_iterator b(i.particle().begin()), n(i.particle().end()); b != n; ++b) { + const ParticleDataType::particle_type& x(*b); + + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("particle", e)); + + s << x; + } +} + +void operator<<(::xercesc::DOMElement& e, const ParticleType& i) { + e << static_cast(i); + + // position + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("position", e)); + + s << i.position(); + } + + // velocity + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("velocity", e)); + + s << i.velocity(); + } + + // force + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("force", e)); + + s << i.force(); + } + + // old_force + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("old_force", e)); + + s << i.old_force(); + } + + // mass + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("mass", e)); + + s << ::xml_schema::as_double(i.mass()); + } + + // type + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("type", e)); + + s << i.type(); + } +} + +#include + +// Begin epilogue. +// +// +// End epilogue. diff --git a/src/io/xml_schemas/checkpoint/checkpoint_schema.h b/src/io/xml_schemas/checkpoint/checkpoint_schema.h new file mode 100644 index 000000000..1d4f95fa9 --- /dev/null +++ b/src/io/xml_schemas/checkpoint/checkpoint_schema.h @@ -0,0 +1,2012 @@ +// Copyright (c) 2005-2023 Code Synthesis. +// +// This program was generated by CodeSynthesis XSD, an XML Schema to +// C++ data binding compiler. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// +// In addition, as a special exception, Code Synthesis gives permission +// to link this program with the Xerces-C++ library (or with modified +// versions of Xerces-C++ that use the same license as Xerces-C++), and +// distribute linked combinations including the two. You must obey the GNU +// General Public License version 2 in all respects for all of the code +// used other than Xerces-C++. If you modify this copy of the program, you +// may extend this exception to your version of the program, but you are +// not obligated to do so. If you do not wish to do so, delete this +// exception statement from your version. +// +// Furthermore, Code Synthesis makes a special exception for the Free/Libre +// and Open Source Software (FLOSS) which is described in the accompanying +// FLOSSE file. +// + +/** + * @file + * @brief Generated from checkpoint_schema.xsd. + */ + +#ifndef CHECKPOINT_SCHEMA_H +#define CHECKPOINT_SCHEMA_H + +#ifndef XSD_CXX11 +#define XSD_CXX11 +#endif + +#ifndef XSD_USE_CHAR +#define XSD_USE_CHAR +#endif + +#ifndef XSD_CXX_TREE_USE_CHAR +#define XSD_CXX_TREE_USE_CHAR +#endif + +// Begin prologue. +// +// +// End prologue. + +#include + +#if (LIBXSD_VERSION != 400002000000000L) +#error XSD runtime version mismatch +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @brief C++ namespace for the %http://www.w3.org/2001/XMLSchema + * schema namespace. + */ +namespace xml_schema { +// anyType and anySimpleType. +// + +/** + * @brief C++ type corresponding to the anyType XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::type type; + +/** + * @brief C++ type corresponding to the anySimpleType XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::simple_type simple_type; + +/** + * @brief Alias for the anyType type. + */ +typedef ::xsd::cxx::tree::type container; + +// 8-bit +// + +/** + * @brief C++ type corresponding to the byte XML Schema + * built-in type. + */ +typedef signed char byte; + +/** + * @brief C++ type corresponding to the unsignedByte XML Schema + * built-in type. + */ +typedef unsigned char unsigned_byte; + +// 16-bit +// + +/** + * @brief C++ type corresponding to the short XML Schema + * built-in type. + */ +typedef short short_; + +/** + * @brief C++ type corresponding to the unsignedShort XML Schema + * built-in type. + */ +typedef unsigned short unsigned_short; + +// 32-bit +// + +/** + * @brief C++ type corresponding to the int XML Schema + * built-in type. + */ +typedef int int_; + +/** + * @brief C++ type corresponding to the unsignedInt XML Schema + * built-in type. + */ +typedef unsigned int unsigned_int; + +// 64-bit +// + +/** + * @brief C++ type corresponding to the long XML Schema + * built-in type. + */ +typedef long long long_; + +/** + * @brief C++ type corresponding to the unsignedLong XML Schema + * built-in type. + */ +typedef unsigned long long unsigned_long; + +// Supposed to be arbitrary-length integral types. +// + +/** + * @brief C++ type corresponding to the integer XML Schema + * built-in type. + */ +typedef long long integer; + +/** + * @brief C++ type corresponding to the nonPositiveInteger XML Schema + * built-in type. + */ +typedef long long non_positive_integer; + +/** + * @brief C++ type corresponding to the nonNegativeInteger XML Schema + * built-in type. + */ +typedef unsigned long long non_negative_integer; + +/** + * @brief C++ type corresponding to the positiveInteger XML Schema + * built-in type. + */ +typedef unsigned long long positive_integer; + +/** + * @brief C++ type corresponding to the negativeInteger XML Schema + * built-in type. + */ +typedef long long negative_integer; + +// Boolean. +// + +/** + * @brief C++ type corresponding to the boolean XML Schema + * built-in type. + */ +typedef bool boolean; + +// Floating-point types. +// + +/** + * @brief C++ type corresponding to the float XML Schema + * built-in type. + */ +typedef float float_; + +/** + * @brief C++ type corresponding to the double XML Schema + * built-in type. + */ +typedef double double_; + +/** + * @brief C++ type corresponding to the decimal XML Schema + * built-in type. + */ +typedef double decimal; + +// String types. +// + +/** + * @brief C++ type corresponding to the string XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::string string; + +/** + * @brief C++ type corresponding to the normalizedString XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::normalized_string normalized_string; + +/** + * @brief C++ type corresponding to the token XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::token token; + +/** + * @brief C++ type corresponding to the Name XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::name name; + +/** + * @brief C++ type corresponding to the NMTOKEN XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::nmtoken nmtoken; + +/** + * @brief C++ type corresponding to the NMTOKENS XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::nmtokens nmtokens; + +/** + * @brief C++ type corresponding to the NCName XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::ncname ncname; + +/** + * @brief C++ type corresponding to the language XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::language language; + +// ID/IDREF. +// + +/** + * @brief C++ type corresponding to the ID XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::id id; + +/** + * @brief C++ type corresponding to the IDREF XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::idref idref; + +/** + * @brief C++ type corresponding to the IDREFS XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::idrefs idrefs; + +// URI. +// + +/** + * @brief C++ type corresponding to the anyURI XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::uri uri; + +// Qualified name. +// + +/** + * @brief C++ type corresponding to the QName XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::qname qname; + +// Binary. +// + +/** + * @brief Binary buffer type. + */ +typedef ::xsd::cxx::tree::buffer buffer; + +/** + * @brief C++ type corresponding to the base64Binary XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::base64_binary base64_binary; + +/** + * @brief C++ type corresponding to the hexBinary XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::hex_binary hex_binary; + +// Date/time. +// + +/** + * @brief Time zone type. + */ +typedef ::xsd::cxx::tree::time_zone time_zone; + +/** + * @brief C++ type corresponding to the date XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::date date; + +/** + * @brief C++ type corresponding to the dateTime XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::date_time date_time; + +/** + * @brief C++ type corresponding to the duration XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::duration duration; + +/** + * @brief C++ type corresponding to the gDay XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::gday gday; + +/** + * @brief C++ type corresponding to the gMonth XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::gmonth gmonth; + +/** + * @brief C++ type corresponding to the gMonthDay XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::gmonth_day gmonth_day; + +/** + * @brief C++ type corresponding to the gYear XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::gyear gyear; + +/** + * @brief C++ type corresponding to the gYearMonth XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::gyear_month gyear_month; + +/** + * @brief C++ type corresponding to the time XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::time time; + +// Entity. +// + +/** + * @brief C++ type corresponding to the ENTITY XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::entity entity; + +/** + * @brief C++ type corresponding to the ENTITIES XML Schema + * built-in type. + */ +typedef ::xsd::cxx::tree::entities entities; + +/** + * @brief Content order sequence entry. + */ +typedef ::xsd::cxx::tree::content_order content_order; +// Namespace information and list stream. Used in +// serialization functions. +// +/** + * @brief Namespace serialization information. + */ +typedef ::xsd::cxx::xml::dom::namespace_info namespace_info; + +/** + * @brief Namespace serialization information map. + */ +typedef ::xsd::cxx::xml::dom::namespace_infomap namespace_infomap; + +/** + * @brief List serialization stream. + */ +typedef ::xsd::cxx::tree::list_stream list_stream; + +/** + * @brief Serialization wrapper for the %double type. + */ +typedef ::xsd::cxx::tree::as_double as_double; + +/** + * @brief Serialization wrapper for the %decimal type. + */ +typedef ::xsd::cxx::tree::as_decimal as_decimal; + +/** + * @brief Simple type facet. + */ +typedef ::xsd::cxx::tree::facet facet; + +// Flags and properties. +// + +/** + * @brief Parsing and serialization flags. + */ +typedef ::xsd::cxx::tree::flags flags; + +/** + * @brief Parsing properties. + */ +typedef ::xsd::cxx::tree::properties properties; + +// Parsing/serialization diagnostics. +// + +/** + * @brief Error severity. + */ +typedef ::xsd::cxx::tree::severity severity; + +/** + * @brief Error condition. + */ +typedef ::xsd::cxx::tree::error error; + +/** + * @brief List of %error conditions. + */ +typedef ::xsd::cxx::tree::diagnostics diagnostics; + +// Exceptions. +// + +/** + * @brief Root of the C++/Tree %exception hierarchy. + */ +typedef ::xsd::cxx::tree::exception exception; + +/** + * @brief Exception indicating that the size argument exceeds + * the capacity argument. + */ +typedef ::xsd::cxx::tree::bounds bounds; + +/** + * @brief Exception indicating that a duplicate ID value + * was encountered in the object model. + */ +typedef ::xsd::cxx::tree::duplicate_id duplicate_id; + +/** + * @brief Exception indicating a parsing failure. + */ +typedef ::xsd::cxx::tree::parsing parsing; + +/** + * @brief Exception indicating that an expected element + * was not encountered. + */ +typedef ::xsd::cxx::tree::expected_element expected_element; + +/** + * @brief Exception indicating that an unexpected element + * was encountered. + */ +typedef ::xsd::cxx::tree::unexpected_element unexpected_element; + +/** + * @brief Exception indicating that an expected attribute + * was not encountered. + */ +typedef ::xsd::cxx::tree::expected_attribute expected_attribute; + +/** + * @brief Exception indicating that an unexpected enumerator + * was encountered. + */ +typedef ::xsd::cxx::tree::unexpected_enumerator unexpected_enumerator; + +/** + * @brief Exception indicating that the text content was + * expected for an element. + */ +typedef ::xsd::cxx::tree::expected_text_content expected_text_content; + +/** + * @brief Exception indicating that a prefix-namespace + * mapping was not provided. + */ +typedef ::xsd::cxx::tree::no_prefix_mapping no_prefix_mapping; + +/** + * @brief Exception indicating a serialization failure. + */ +typedef ::xsd::cxx::tree::serialization serialization; + +/** + * @brief Error handler callback interface. + */ +typedef ::xsd::cxx::xml::error_handler error_handler; + +/** + * @brief DOM interaction. + */ +namespace dom { +/** + * @brief Automatic pointer for DOMDocument. + */ +using ::xsd::cxx::xml::dom::unique_ptr; + +#ifndef XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA +#define XSD_CXX_TREE_TREE_NODE_KEY__XML_SCHEMA +/** + * @brief DOM user data key for back pointers to tree nodes. + */ +const XMLCh* const tree_node_key = ::xsd::cxx::tree::user_data_keys::node; +#endif +} // namespace dom +} // namespace xml_schema + +// Forward declarations. +// +class CheckPointFileType; +class MetaDataDataType; +class ParticleDataType; +class ParticleType; + +#include // std::binary_search +#include // std::numeric_limits +#include // ::std::unique_ptr +#include // std::move +#include +#include +#include +#include +#include +#include + +#include "../simulation_input/simulation_input_schema.h" + +/** + * @brief Class corresponding to the %CheckPointFileType schema type. + * + * @nosubgrouping + */ +class CheckPointFileType : public ::xml_schema::type { + public: + /** + * @name MetaData + * + * @brief Accessor and modifier functions for the %MetaData + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::MetaDataDataType MetaData_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits MetaData_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const MetaData_type& MetaData() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + MetaData_type& MetaData(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void MetaData(const MetaData_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void MetaData(::std::unique_ptr p); + + //@} + + /** + * @name ParticleData + * + * @brief Accessor and modifier functions for the %ParticleData + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::ParticleDataType ParticleData_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits ParticleData_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const ParticleData_type& ParticleData() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + ParticleData_type& ParticleData(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void ParticleData(const ParticleData_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void ParticleData(::std::unique_ptr p); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + CheckPointFileType(const MetaData_type&, const ParticleData_type&); + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes + * (::std::unique_ptr version). + * + * This constructor will try to use the passed values directly + * instead of making copies. + */ + CheckPointFileType(::std::unique_ptr, ::std::unique_ptr); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + CheckPointFileType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + CheckPointFileType(const CheckPointFileType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual CheckPointFileType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + CheckPointFileType& operator=(const CheckPointFileType& x); + + //@} + + /** + * @brief Destructor. + */ + virtual ~CheckPointFileType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + ::xsd::cxx::tree::one MetaData_; + ::xsd::cxx::tree::one ParticleData_; + + //@endcond +}; + +/** + * @brief Class corresponding to the %MetaDataDataType schema type. + * + * @nosubgrouping + */ +class MetaDataDataType : public ::xml_schema::type { + public: + /** + * @name input_file + * + * @brief Accessor and modifier functions for the %input_file + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::uri input_file_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits input_file_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const input_file_type& input_file() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + input_file_type& input_file(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void input_file(const input_file_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void input_file(::std::unique_ptr p); + + //@} + + /** + * @name input_file_hash + * + * @brief Accessor and modifier functions for the %input_file_hash + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::unsigned_long input_file_hash_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits input_file_hash_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const input_file_hash_type& input_file_hash() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + input_file_hash_type& input_file_hash(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void input_file_hash(const input_file_hash_type& x); + + //@} + + /** + * @name end_time + * + * @brief Accessor and modifier functions for the %end_time + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::double_ end_time_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits end_time_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const end_time_type& end_time() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + end_time_type& end_time(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void end_time(const end_time_type& x); + + //@} + + /** + * @name delta_t + * + * @brief Accessor and modifier functions for the %delta_t + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::double_ delta_t_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits delta_t_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const delta_t_type& delta_t() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + delta_t_type& delta_t(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void delta_t(const delta_t_type& x); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + MetaDataDataType(const input_file_type&, const input_file_hash_type&, const end_time_type&, const delta_t_type&); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + MetaDataDataType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + MetaDataDataType(const MetaDataDataType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual MetaDataDataType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + MetaDataDataType& operator=(const MetaDataDataType& x); + + //@} + + /** + * @brief Destructor. + */ + virtual ~MetaDataDataType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + ::xsd::cxx::tree::one input_file_; + ::xsd::cxx::tree::one input_file_hash_; + ::xsd::cxx::tree::one end_time_; + ::xsd::cxx::tree::one delta_t_; + + //@endcond +}; + +/** + * @brief Class corresponding to the %ParticleDataType schema type. + * + * @nosubgrouping + */ +class ParticleDataType : public ::xml_schema::type { + public: + /** + * @name particle + * + * @brief Accessor and modifier functions for the %particle + * sequence element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::ParticleType particle_type; + + /** + * @brief Element sequence container type. + */ + typedef ::xsd::cxx::tree::sequence particle_sequence; + + /** + * @brief Element iterator type. + */ + typedef particle_sequence::iterator particle_iterator; + + /** + * @brief Element constant iterator type. + */ + typedef particle_sequence::const_iterator particle_const_iterator; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits particle_traits; + + /** + * @brief Return a read-only (constant) reference to the element + * sequence. + * + * @return A constant reference to the sequence container. + */ + const particle_sequence& particle() const; + + /** + * @brief Return a read-write reference to the element sequence. + * + * @return A reference to the sequence container. + */ + particle_sequence& particle(); + + /** + * @brief Copy elements from a given sequence. + * + * @param s A sequence to copy elements from. + * + * For each element in @a s this function makes a copy and adds it + * to the sequence. Note that this operation completely changes the + * sequence and all old elements will be lost. + */ + void particle(const particle_sequence& s); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + ParticleDataType(); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ParticleDataType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + ParticleDataType(const ParticleDataType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual ParticleDataType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + ParticleDataType& operator=(const ParticleDataType& x); + + //@} + + /** + * @brief Destructor. + */ + virtual ~ParticleDataType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + particle_sequence particle_; + + //@endcond +}; + +/** + * @brief Class corresponding to the %ParticleType schema type. + * + * @nosubgrouping + */ +class ParticleType : public ::xml_schema::type { + public: + /** + * @name position + * + * @brief Accessor and modifier functions for the %position + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::DoubleVec3Type position_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits position_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const position_type& position() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + position_type& position(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void position(const position_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void position(::std::unique_ptr p); + + //@} + + /** + * @name velocity + * + * @brief Accessor and modifier functions for the %velocity + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::DoubleVec3Type velocity_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits velocity_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const velocity_type& velocity() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + velocity_type& velocity(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void velocity(const velocity_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void velocity(::std::unique_ptr p); + + //@} + + /** + * @name force + * + * @brief Accessor and modifier functions for the %force + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::DoubleVec3Type force_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits force_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const force_type& force() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + force_type& force(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void force(const force_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void force(::std::unique_ptr p); + + //@} + + /** + * @name old_force + * + * @brief Accessor and modifier functions for the %old_force + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::DoubleVec3Type old_force_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits old_force_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const old_force_type& old_force() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + old_force_type& old_force(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void old_force(const old_force_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void old_force(::std::unique_ptr p); + + //@} + + /** + * @name mass + * + * @brief Accessor and modifier functions for the %mass + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::double_ mass_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits mass_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const mass_type& mass() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + mass_type& mass(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void mass(const mass_type& x); + + //@} + + /** + * @name type + * + * @brief Accessor and modifier functions for the %type + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::integer type_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits type_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const type_type& type() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + type_type& type(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void type(const type_type& x); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + ParticleType(const position_type&, const velocity_type&, const force_type&, const old_force_type&, const mass_type&, const type_type&); + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes + * (::std::unique_ptr version). + * + * This constructor will try to use the passed values directly + * instead of making copies. + */ + ParticleType(::std::unique_ptr, ::std::unique_ptr, ::std::unique_ptr, + ::std::unique_ptr, const mass_type&, const type_type&); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ParticleType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + ParticleType(const ParticleType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual ParticleType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + ParticleType& operator=(const ParticleType& x); + + //@} + + /** + * @brief Destructor. + */ + virtual ~ParticleType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + ::xsd::cxx::tree::one position_; + ::xsd::cxx::tree::one velocity_; + ::xsd::cxx::tree::one force_; + ::xsd::cxx::tree::one old_force_; + ::xsd::cxx::tree::one mass_; + ::xsd::cxx::tree::one type_; + + //@endcond +}; + +#include +#include +#include +#include + +/** + * @name Parsing functions for the %CheckPoint document root. + * + * This is the schema for the checkpoint file. + */ +//@{ + +/** + * @brief Parse a URI or a local file. + * + * @param uri A URI or a local file name. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function uses exceptions to report parsing errors. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::std::string& uri, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a URI or a local file with an error handler. + * + * @param uri A URI or a local file name. + * @param eh An error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::std::string& uri, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a URI or a local file with a Xerces-C++ DOM error + * handler. + * + * @param uri A URI or a local file name. + * @param eh A Xerces-C++ DOM error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::std::string& uri, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a standard input stream. + * + * @param is A standrad input stream. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function uses exceptions to report parsing errors. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a standard input stream with an error handler. + * + * @param is A standrad input stream. + * @param eh An error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a standard input stream with a Xerces-C++ DOM error + * handler. + * + * @param is A standrad input stream. + * @param eh A Xerces-C++ DOM error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a standard input stream with a resource id. + * + * @param is A standrad input stream. + * @param id A resource id. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * The resource id is used to identify the document being parsed in + * diagnostics as well as to resolve relative paths. + * + * This function uses exceptions to report parsing errors. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, const ::std::string& id, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a standard input stream with a resource id and an + * error handler. + * + * @param is A standrad input stream. + * @param id A resource id. + * @param eh An error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * The resource id is used to identify the document being parsed in + * diagnostics as well as to resolve relative paths. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, const ::std::string& id, ::xml_schema::error_handler& eh, + ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a standard input stream with a resource id and a + * Xerces-C++ DOM error handler. + * + * @param is A standrad input stream. + * @param id A resource id. + * @param eh A Xerces-C++ DOM error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * The resource id is used to identify the document being parsed in + * diagnostics as well as to resolve relative paths. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::std::istream& is, const ::std::string& id, ::xercesc::DOMErrorHandler& eh, + ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a Xerces-C++ input source. + * + * @param is A Xerces-C++ input source. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function uses exceptions to report parsing errors. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xercesc::InputSource& is, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a Xerces-C++ input source with an error handler. + * + * @param is A Xerces-C++ input source. + * @param eh An error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xercesc::InputSource& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a Xerces-C++ input source with a Xerces-C++ DOM + * error handler. + * + * @param is A Xerces-C++ input source. + * @param eh A Xerces-C++ DOM error handler. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function reports parsing errors by calling the error handler. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xercesc::InputSource& is, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a Xerces-C++ DOM document. + * + * @param d A Xerces-C++ DOM document. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(const ::xercesc::DOMDocument& d, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +/** + * @brief Parse a Xerces-C++ DOM document. + * + * @param d A pointer to the Xerces-C++ DOM document. + * @param f Parsing flags. + * @param p Parsing properties. + * @return A pointer to the root of the object model. + * + * This function is normally used together with the keep_dom and + * own_dom parsing flags to assign ownership of the DOM document + * to the object model. + */ +::std::unique_ptr< ::CheckPointFileType> CheckPoint(::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); + +//@} + +#include +#include +#include +#include +#include + +/** + * @name Serialization functions for the %CheckPoint document root. + * + * This is the schema for the checkpoint file. + */ +//@{ + +/** + * @brief Serialize to a standard output stream. + * + * @param os A standrad output stream. + * @param x An object model to serialize. + * @param m A namespace information map. + * @param e A character encoding to produce XML in. + * @param f Serialization flags. + * + * This function uses exceptions to report serialization errors. + */ +void CheckPoint(::std::ostream& os, const ::CheckPointFileType& x, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); + +/** + * @brief Serialize to a standard output stream with an error handler. + * + * @param os A standrad output stream. + * @param x An object model to serialize. + * @param eh An error handler. + * @param m A namespace information map. + * @param e A character encoding to produce XML in. + * @param f Serialization flags. + * + * This function reports serialization errors by calling the error + * handler. + */ +void CheckPoint(::std::ostream& os, const ::CheckPointFileType& x, ::xml_schema::error_handler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); + +/** + * @brief Serialize to a standard output stream with a Xerces-C++ DOM + * error handler. + * + * @param os A standrad output stream. + * @param x An object model to serialize. + * @param eh A Xerces-C++ DOM error handler. + * @param m A namespace information map. + * @param e A character encoding to produce XML in. + * @param f Serialization flags. + * + * This function reports serialization errors by calling the error + * handler. + */ +void CheckPoint(::std::ostream& os, const ::CheckPointFileType& x, ::xercesc::DOMErrorHandler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); + +/** + * @brief Serialize to a Xerces-C++ XML format target. + * + * @param ft A Xerces-C++ XML format target. + * @param x An object model to serialize. + * @param m A namespace information map. + * @param e A character encoding to produce XML in. + * @param f Serialization flags. + * + * This function uses exceptions to report serialization errors. + */ +void CheckPoint(::xercesc::XMLFormatTarget& ft, const ::CheckPointFileType& x, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); + +/** + * @brief Serialize to a Xerces-C++ XML format target with an error + * handler. + * + * @param ft A Xerces-C++ XML format target. + * @param x An object model to serialize. + * @param eh An error handler. + * @param m A namespace information map. + * @param e A character encoding to produce XML in. + * @param f Serialization flags. + * + * This function reports serialization errors by calling the error + * handler. + */ +void CheckPoint(::xercesc::XMLFormatTarget& ft, const ::CheckPointFileType& x, ::xml_schema::error_handler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); + +/** + * @brief Serialize to a Xerces-C++ XML format target with a + * Xerces-C++ DOM error handler. + * + * @param ft A Xerces-C++ XML format target. + * @param x An object model to serialize. + * @param eh A Xerces-C++ DOM error handler. + * @param m A namespace information map. + * @param e A character encoding to produce XML in. + * @param f Serialization flags. + * + * This function reports serialization errors by calling the error + * handler. + */ +void CheckPoint(::xercesc::XMLFormatTarget& ft, const ::CheckPointFileType& x, ::xercesc::DOMErrorHandler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); + +/** + * @brief Serialize to an existing Xerces-C++ DOM document. + * + * @param d A Xerces-C++ DOM document. + * @param x An object model to serialize. + * @param f Serialization flags. + * + * Note that it is your responsibility to create the DOM document + * with the correct root element as well as set the necessary + * namespace mapping attributes. + */ +void CheckPoint(::xercesc::DOMDocument& d, const ::CheckPointFileType& x, ::xml_schema::flags f = 0); + +/** + * @brief Serialize to a new Xerces-C++ DOM document. + * + * @param x An object model to serialize. + * @param m A namespace information map. + * @param f Serialization flags. + * @return A pointer to the new Xerces-C++ DOM document. + */ +::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> CheckPoint( + const ::CheckPointFileType& x, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), ::xml_schema::flags f = 0); + +//@} + +void operator<<(::xercesc::DOMElement&, const CheckPointFileType&); + +void operator<<(::xercesc::DOMElement&, const MetaDataDataType&); + +void operator<<(::xercesc::DOMElement&, const ParticleDataType&); + +void operator<<(::xercesc::DOMElement&, const ParticleType&); + +#include + +// Begin epilogue. +// +// +// End epilogue. + +#endif // CHECKPOINT_SCHEMA_H diff --git a/src/io/xml_schemas/checkpoint/checkpoint_schema.xsd b/src/io/xml_schemas/checkpoint/checkpoint_schema.xsd new file mode 100644 index 000000000..63632a43d --- /dev/null +++ b/src/io/xml_schemas/checkpoint/checkpoint_schema.xsd @@ -0,0 +1,52 @@ + + + + + + + This is the schema for the checkpoint file. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/io/xml_schemas/create_xsd_mapping.sh b/src/io/xml_schemas/create_xsd_mapping.sh new file mode 100755 index 000000000..03e63da97 --- /dev/null +++ b/src/io/xml_schemas/create_xsd_mapping.sh @@ -0,0 +1,6 @@ +#!sh + +# get input file +file=$1 + +xsd cxx-tree --std c++20 --hxx-suffix .h --cxx-suffix .cpp --generate-doxygen --generate-serialization $file diff --git a/src/io/input/xml/parser/simulation_schema.cpp b/src/io/xml_schemas/simulation_input/simulation_input_schema.cpp similarity index 69% rename from src/io/input/xml/parser/simulation_schema.cpp rename to src/io/xml_schemas/simulation_input/simulation_input_schema.cpp index 35a16a6b7..4cdf1b9c1 100644 --- a/src/io/input/xml/parser/simulation_schema.cpp +++ b/src/io/xml_schemas/simulation_input/simulation_input_schema.cpp @@ -36,10 +36,29 @@ // // End prologue. -#include "simulation_schema.h" +#include "simulation_input_schema.h" #include +// ConfigurationType +// + +const ConfigurationType::settings_type& ConfigurationType::settings() const { return this->settings_.get(); } + +ConfigurationType::settings_type& ConfigurationType::settings() { return this->settings_.get(); } + +void ConfigurationType::settings(const settings_type& x) { this->settings_.set(x); } + +void ConfigurationType::settings(::std::unique_ptr x) { this->settings_.set(std::move(x)); } + +const ConfigurationType::particle_source_type& ConfigurationType::particle_source() const { return this->particle_source_.get(); } + +ConfigurationType::particle_source_type& ConfigurationType::particle_source() { return this->particle_source_.get(); } + +void ConfigurationType::particle_source(const particle_source_type& x) { this->particle_source_.set(x); } + +void ConfigurationType::particle_source(::std::unique_ptr x) { this->particle_source_.set(std::move(x)); } + // DoubleVec3Type // @@ -149,6 +168,29 @@ void LinkedCellsContainerType::boundary_conditions(::std::unique_ptrboundary_conditions_.set(std::move(x)); } +// ThermostatType +// + +const ThermostatType::target_temperature_type& ThermostatType::target_temperature() const { return this->target_temperature_.get(); } + +ThermostatType::target_temperature_type& ThermostatType::target_temperature() { return this->target_temperature_.get(); } + +void ThermostatType::target_temperature(const target_temperature_type& x) { this->target_temperature_.set(x); } + +const ThermostatType::max_temperature_change_type& ThermostatType::max_temperature_change() const { + return this->max_temperature_change_.get(); +} + +ThermostatType::max_temperature_change_type& ThermostatType::max_temperature_change() { return this->max_temperature_change_.get(); } + +void ThermostatType::max_temperature_change(const max_temperature_change_type& x) { this->max_temperature_change_.set(x); } + +const ThermostatType::application_interval_type& ThermostatType::application_interval() const { return this->application_interval_.get(); } + +ThermostatType::application_interval_type& ThermostatType::application_interval() { return this->application_interval_.get(); } + +void ThermostatType::application_interval(const application_interval_type& x) { this->application_interval_.set(x); } + // BoundaryConditionsType // @@ -203,55 +245,22 @@ void BoundaryConditionsType::front(::std::unique_ptr x) { this->fron // BoundaryType // -const BoundaryType::outflow_optional& BoundaryType::outflow() const { return this->outflow_; } - -BoundaryType::outflow_optional& BoundaryType::outflow() { return this->outflow_; } - -void BoundaryType::outflow(const outflow_type& x) { this->outflow_.set(x); } - -void BoundaryType::outflow(const outflow_optional& x) { this->outflow_ = x; } - -void BoundaryType::outflow(::std::unique_ptr x) { this->outflow_.set(std::move(x)); } - -const BoundaryType::reflective_optional& BoundaryType::reflective() const { return this->reflective_; } - -BoundaryType::reflective_optional& BoundaryType::reflective() { return this->reflective_; } +BoundaryType::BoundaryType(value v) : ::xml_schema::string(_xsd_BoundaryType_literals_[v]) {} -void BoundaryType::reflective(const reflective_type& x) { this->reflective_.set(x); } +BoundaryType::BoundaryType(const char* v) : ::xml_schema::string(v) {} -void BoundaryType::reflective(const reflective_optional& x) { this->reflective_ = x; } +BoundaryType::BoundaryType(const ::std::string& v) : ::xml_schema::string(v) {} -void BoundaryType::reflective(::std::unique_ptr x) { this->reflective_.set(std::move(x)); } +BoundaryType::BoundaryType(const ::xml_schema::string& v) : ::xml_schema::string(v) {} -// OutflowBoundaryType -// - -// ReflectiveBoundaryType -// +BoundaryType::BoundaryType(const BoundaryType& v, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string(v, f, c) {} -// ThermostatType -// - -const ThermostatType::target_temperature_type& ThermostatType::target_temperature() const { return this->target_temperature_.get(); } +BoundaryType& BoundaryType::operator=(value v) { + static_cast< ::xml_schema::string&>(*this) = ::xml_schema::string(_xsd_BoundaryType_literals_[v]); -ThermostatType::target_temperature_type& ThermostatType::target_temperature() { return this->target_temperature_.get(); } - -void ThermostatType::target_temperature(const target_temperature_type& x) { this->target_temperature_.set(x); } - -const ThermostatType::max_temperature_change_type& ThermostatType::max_temperature_change() const { - return this->max_temperature_change_.get(); + return *this; } -ThermostatType::max_temperature_change_type& ThermostatType::max_temperature_change() { return this->max_temperature_change_.get(); } - -void ThermostatType::max_temperature_change(const max_temperature_change_type& x) { this->max_temperature_change_.set(x); } - -const ThermostatType::application_interval_type& ThermostatType::application_interval() const { return this->application_interval_.get(); } - -ThermostatType::application_interval_type& ThermostatType::application_interval() { return this->application_interval_.get(); } - -void ThermostatType::application_interval(const application_interval_type& x) { this->application_interval_.set(x); } - // CuboidSpawnerType // @@ -358,134 +367,273 @@ SphereSpawnerType::type_type& SphereSpawnerType::type() { return this->type_.get void SphereSpawnerType::type(const type_type& x) { this->type_.set(x); } -// ParticleType +// SingleParticleSpawnerType // -const ParticleType::position_type& ParticleType::position() const { return this->position_.get(); } +const SingleParticleSpawnerType::position_type& SingleParticleSpawnerType::position() const { return this->position_.get(); } + +SingleParticleSpawnerType::position_type& SingleParticleSpawnerType::position() { return this->position_.get(); } + +void SingleParticleSpawnerType::position(const position_type& x) { this->position_.set(x); } -ParticleType::position_type& ParticleType::position() { return this->position_.get(); } +void SingleParticleSpawnerType::position(::std::unique_ptr x) { this->position_.set(std::move(x)); } -void ParticleType::position(const position_type& x) { this->position_.set(x); } +const SingleParticleSpawnerType::temperature_type& SingleParticleSpawnerType::temperature() const { return this->temperature_.get(); } -void ParticleType::position(::std::unique_ptr x) { this->position_.set(std::move(x)); } +SingleParticleSpawnerType::temperature_type& SingleParticleSpawnerType::temperature() { return this->temperature_.get(); } -const ParticleType::temperature_type& ParticleType::temperature() const { return this->temperature_.get(); } +void SingleParticleSpawnerType::temperature(const temperature_type& x) { this->temperature_.set(x); } -ParticleType::temperature_type& ParticleType::temperature() { return this->temperature_.get(); } +const SingleParticleSpawnerType::mass_type& SingleParticleSpawnerType::mass() const { return this->mass_.get(); } -void ParticleType::temperature(const temperature_type& x) { this->temperature_.set(x); } +SingleParticleSpawnerType::mass_type& SingleParticleSpawnerType::mass() { return this->mass_.get(); } -const ParticleType::mass_type& ParticleType::mass() const { return this->mass_.get(); } +void SingleParticleSpawnerType::mass(const mass_type& x) { this->mass_.set(x); } -ParticleType::mass_type& ParticleType::mass() { return this->mass_.get(); } +const SingleParticleSpawnerType::velocity_type& SingleParticleSpawnerType::velocity() const { return this->velocity_.get(); } -void ParticleType::mass(const mass_type& x) { this->mass_.set(x); } +SingleParticleSpawnerType::velocity_type& SingleParticleSpawnerType::velocity() { return this->velocity_.get(); } -const ParticleType::velocity_type& ParticleType::velocity() const { return this->velocity_.get(); } +void SingleParticleSpawnerType::velocity(const velocity_type& x) { this->velocity_.set(x); } -ParticleType::velocity_type& ParticleType::velocity() { return this->velocity_.get(); } +void SingleParticleSpawnerType::velocity(::std::unique_ptr x) { this->velocity_.set(std::move(x)); } -void ParticleType::velocity(const velocity_type& x) { this->velocity_.set(x); } +const SingleParticleSpawnerType::type_type& SingleParticleSpawnerType::type() const { return this->type_.get(); } -void ParticleType::velocity(::std::unique_ptr x) { this->velocity_.set(std::move(x)); } +SingleParticleSpawnerType::type_type& SingleParticleSpawnerType::type() { return this->type_.get(); } -const ParticleType::type_type& ParticleType::type() const { return this->type_.get(); } +void SingleParticleSpawnerType::type(const type_type& x) { this->type_.set(x); } -ParticleType::type_type& ParticleType::type() { return this->type_.get(); } +// CheckPointLoaderType +// + +const CheckPointLoaderType::file_name_type& CheckPointLoaderType::file_name() const { return this->file_name_.get(); } + +CheckPointLoaderType::file_name_type& CheckPointLoaderType::file_name() { return this->file_name_.get(); } + +void CheckPointLoaderType::file_name(const file_name_type& x) { this->file_name_.set(x); } -void ParticleType::type(const type_type& x) { this->type_.set(x); } +void CheckPointLoaderType::file_name(::std::unique_ptr x) { this->file_name_.set(std::move(x)); } -// configuration +// SubSimulationType // -const configuration::settings_type& configuration::settings() const { return this->settings_.get(); } +const SubSimulationType::name_type& SubSimulationType::name() const { return this->name_.get(); } + +SubSimulationType::name_type& SubSimulationType::name() { return this->name_.get(); } + +void SubSimulationType::name(const name_type& x) { this->name_.set(x); } + +void SubSimulationType::name(::std::unique_ptr x) { this->name_.set(std::move(x)); } -configuration::settings_type& configuration::settings() { return this->settings_.get(); } +const SubSimulationType::configuration_optional& SubSimulationType::configuration() const { return this->configuration_; } -void configuration::settings(const settings_type& x) { this->settings_.set(x); } +SubSimulationType::configuration_optional& SubSimulationType::configuration() { return this->configuration_; } -void configuration::settings(::std::unique_ptr x) { this->settings_.set(std::move(x)); } +void SubSimulationType::configuration(const configuration_type& x) { this->configuration_.set(x); } -const configuration::particles_type& configuration::particles() const { return this->particles_.get(); } +void SubSimulationType::configuration(const configuration_optional& x) { this->configuration_ = x; } -configuration::particles_type& configuration::particles() { return this->particles_.get(); } +void SubSimulationType::configuration(::std::unique_ptr x) { this->configuration_.set(std::move(x)); } -void configuration::particles(const particles_type& x) { this->particles_.set(x); } +const SubSimulationType::file_name_optional& SubSimulationType::file_name() const { return this->file_name_; } -void configuration::particles(::std::unique_ptr x) { this->particles_.set(std::move(x)); } +SubSimulationType::file_name_optional& SubSimulationType::file_name() { return this->file_name_; } -// settings +void SubSimulationType::file_name(const file_name_type& x) { this->file_name_.set(x); } + +void SubSimulationType::file_name(const file_name_optional& x) { this->file_name_ = x; } + +void SubSimulationType::file_name(::std::unique_ptr x) { this->file_name_.set(std::move(x)); } + +// SettingsType // -const settings::fps_type& settings::fps() const { return this->fps_.get(); } +const SettingsType::fps_type& SettingsType::fps() const { return this->fps_.get(); } + +SettingsType::fps_type& SettingsType::fps() { return this->fps_.get(); } + +void SettingsType::fps(const fps_type& x) { this->fps_.set(x); } + +const SettingsType::video_length_type& SettingsType::video_length() const { return this->video_length_.get(); } -settings::fps_type& settings::fps() { return this->fps_.get(); } +SettingsType::video_length_type& SettingsType::video_length() { return this->video_length_.get(); } -void settings::fps(const fps_type& x) { this->fps_.set(x); } +void SettingsType::video_length(const video_length_type& x) { this->video_length_.set(x); } -const settings::video_length_type& settings::video_length() const { return this->video_length_.get(); } +const SettingsType::delta_t_type& SettingsType::delta_t() const { return this->delta_t_.get(); } -settings::video_length_type& settings::video_length() { return this->video_length_.get(); } +SettingsType::delta_t_type& SettingsType::delta_t() { return this->delta_t_.get(); } -void settings::video_length(const video_length_type& x) { this->video_length_.set(x); } +void SettingsType::delta_t(const delta_t_type& x) { this->delta_t_.set(x); } -const settings::delta_t_type& settings::delta_t() const { return this->delta_t_.get(); } +const SettingsType::end_time_type& SettingsType::end_time() const { return this->end_time_.get(); } -settings::delta_t_type& settings::delta_t() { return this->delta_t_.get(); } +SettingsType::end_time_type& SettingsType::end_time() { return this->end_time_.get(); } -void settings::delta_t(const delta_t_type& x) { this->delta_t_.set(x); } +void SettingsType::end_time(const end_time_type& x) { this->end_time_.set(x); } -const settings::end_time_type& settings::end_time() const { return this->end_time_.get(); } +const SettingsType::third_dimension_type& SettingsType::third_dimension() const { return this->third_dimension_.get(); } -settings::end_time_type& settings::end_time() { return this->end_time_.get(); } +SettingsType::third_dimension_type& SettingsType::third_dimension() { return this->third_dimension_.get(); } -void settings::end_time(const end_time_type& x) { this->end_time_.set(x); } +void SettingsType::third_dimension(const third_dimension_type& x) { this->third_dimension_.set(x); } -const settings::third_dimension_type& settings::third_dimension() const { return this->third_dimension_.get(); } +SettingsType::third_dimension_type SettingsType::third_dimension_default_value() { return third_dimension_type(true); } -settings::third_dimension_type& settings::third_dimension() { return this->third_dimension_.get(); } +const SettingsType::particle_container_type& SettingsType::particle_container() const { return this->particle_container_.get(); } -void settings::third_dimension(const third_dimension_type& x) { this->third_dimension_.set(x); } +SettingsType::particle_container_type& SettingsType::particle_container() { return this->particle_container_.get(); } -const settings::particle_container_type& settings::particle_container() const { return this->particle_container_.get(); } +void SettingsType::particle_container(const particle_container_type& x) { this->particle_container_.set(x); } -settings::particle_container_type& settings::particle_container() { return this->particle_container_.get(); } +void SettingsType::particle_container(::std::unique_ptr x) { this->particle_container_.set(std::move(x)); } -void settings::particle_container(const particle_container_type& x) { this->particle_container_.set(x); } +const SettingsType::thermostat_type& SettingsType::thermostat() const { return this->thermostat_.get(); } -void settings::particle_container(::std::unique_ptr x) { this->particle_container_.set(std::move(x)); } +SettingsType::thermostat_type& SettingsType::thermostat() { return this->thermostat_.get(); } -const settings::thermostat_type& settings::thermostat() const { return this->thermostat_.get(); } +void SettingsType::thermostat(const thermostat_type& x) { this->thermostat_.set(x); } -settings::thermostat_type& settings::thermostat() { return this->thermostat_.get(); } +void SettingsType::thermostat(::std::unique_ptr x) { this->thermostat_.set(std::move(x)); } -void settings::thermostat(const thermostat_type& x) { this->thermostat_.set(x); } +const SettingsType::force_sequence& SettingsType::force() const { return this->force_; } -void settings::thermostat(::std::unique_ptr x) { this->thermostat_.set(std::move(x)); } +SettingsType::force_sequence& SettingsType::force() { return this->force_; } -// particles +void SettingsType::force(const force_sequence& s) { this->force_ = s; } + +// ForcesType // -const particles::cuboid_spawner_sequence& particles::cuboid_spawner() const { return this->cuboid_spawner_; } +ForcesType::ForcesType(value v) : ::xml_schema::string(_xsd_ForcesType_literals_[v]) {} + +ForcesType::ForcesType(const char* v) : ::xml_schema::string(v) {} -particles::cuboid_spawner_sequence& particles::cuboid_spawner() { return this->cuboid_spawner_; } +ForcesType::ForcesType(const ::std::string& v) : ::xml_schema::string(v) {} -void particles::cuboid_spawner(const cuboid_spawner_sequence& s) { this->cuboid_spawner_ = s; } +ForcesType::ForcesType(const ::xml_schema::string& v) : ::xml_schema::string(v) {} -const particles::sphere_spawner_sequence& particles::sphere_spawner() const { return this->sphere_spawner_; } +ForcesType::ForcesType(const ForcesType& v, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string(v, f, c) {} -particles::sphere_spawner_sequence& particles::sphere_spawner() { return this->sphere_spawner_; } +ForcesType& ForcesType::operator=(value v) { + static_cast< ::xml_schema::string&>(*this) = ::xml_schema::string(_xsd_ForcesType_literals_[v]); + + return *this; +} + +// particle_source +// -void particles::sphere_spawner(const sphere_spawner_sequence& s) { this->sphere_spawner_ = s; } +const particle_source::cuboid_spawner_sequence& particle_source::cuboid_spawner() const { return this->cuboid_spawner_; } -const particles::single_particle_sequence& particles::single_particle() const { return this->single_particle_; } +particle_source::cuboid_spawner_sequence& particle_source::cuboid_spawner() { return this->cuboid_spawner_; } + +void particle_source::cuboid_spawner(const cuboid_spawner_sequence& s) { this->cuboid_spawner_ = s; } + +const particle_source::sphere_spawner_sequence& particle_source::sphere_spawner() const { return this->sphere_spawner_; } + +particle_source::sphere_spawner_sequence& particle_source::sphere_spawner() { return this->sphere_spawner_; } + +void particle_source::sphere_spawner(const sphere_spawner_sequence& s) { this->sphere_spawner_ = s; } + +const particle_source::single_particle_spawner_sequence& particle_source::single_particle_spawner() const { + return this->single_particle_spawner_; +} -particles::single_particle_sequence& particles::single_particle() { return this->single_particle_; } +particle_source::single_particle_spawner_sequence& particle_source::single_particle_spawner() { return this->single_particle_spawner_; } -void particles::single_particle(const single_particle_sequence& s) { this->single_particle_ = s; } +void particle_source::single_particle_spawner(const single_particle_spawner_sequence& s) { this->single_particle_spawner_ = s; } + +const particle_source::check_point_loader_sequence& particle_source::check_point_loader() const { return this->check_point_loader_; } + +particle_source::check_point_loader_sequence& particle_source::check_point_loader() { return this->check_point_loader_; } + +void particle_source::check_point_loader(const check_point_loader_sequence& s) { this->check_point_loader_ = s; } + +const particle_source::sub_simulation_sequence& particle_source::sub_simulation() const { return this->sub_simulation_; } + +particle_source::sub_simulation_sequence& particle_source::sub_simulation() { return this->sub_simulation_; } + +void particle_source::sub_simulation(const sub_simulation_sequence& s) { this->sub_simulation_ = s; } #include +// ConfigurationType +// + +ConfigurationType::ConfigurationType(const settings_type& settings, const particle_source_type& particle_source) + : ::xml_schema::type(), settings_(settings, this), particle_source_(particle_source, this) {} + +ConfigurationType::ConfigurationType(::std::unique_ptr settings, ::std::unique_ptr particle_source) + : ::xml_schema::type(), settings_(std::move(settings), this), particle_source_(std::move(particle_source), this) {} + +ConfigurationType::ConfigurationType(const ConfigurationType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), settings_(x.settings_, f, this), particle_source_(x.particle_source_, f, this) {} + +ConfigurationType::ConfigurationType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), settings_(this), particle_source_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void ConfigurationType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // settings + // + if (n.name() == "settings" && n.namespace_().empty()) { + ::std::unique_ptr r(settings_traits::create(i, f, this)); + + if (!settings_.present()) { + this->settings_.set(::std::move(r)); + continue; + } + } + + // particle_source + // + if (n.name() == "particle_source" && n.namespace_().empty()) { + ::std::unique_ptr r(particle_source_traits::create(i, f, this)); + + if (!particle_source_.present()) { + this->particle_source_.set(::std::move(r)); + continue; + } + } + + break; + } + + if (!settings_.present()) { + throw ::xsd::cxx::tree::expected_element("settings", ""); + } + + if (!particle_source_.present()) { + throw ::xsd::cxx::tree::expected_element("particle_source", ""); + } +} + +ConfigurationType* ConfigurationType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class ConfigurationType(*this, f, c); +} + +ConfigurationType& ConfigurationType::operator=(const ConfigurationType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->settings_ = x.settings_; + this->particle_source_ = x.particle_source_; + } + + return *this; +} + +ConfigurationType::~ConfigurationType() {} + // DoubleVec3Type // @@ -836,6 +984,98 @@ LinkedCellsContainerType& LinkedCellsContainerType::operator=(const LinkedCellsC LinkedCellsContainerType::~LinkedCellsContainerType() {} +// ThermostatType +// + +ThermostatType::ThermostatType(const target_temperature_type& target_temperature, const max_temperature_change_type& max_temperature_change, + const application_interval_type& application_interval) + : ::xml_schema::type(), + target_temperature_(target_temperature, this), + max_temperature_change_(max_temperature_change, this), + application_interval_(application_interval, this) {} + +ThermostatType::ThermostatType(const ThermostatType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), + target_temperature_(x.target_temperature_, f, this), + max_temperature_change_(x.max_temperature_change_, f, this), + application_interval_(x.application_interval_, f, this) {} + +ThermostatType::ThermostatType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), + target_temperature_(this), + max_temperature_change_(this), + application_interval_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void ThermostatType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // target_temperature + // + if (n.name() == "target_temperature" && n.namespace_().empty()) { + if (!target_temperature_.present()) { + this->target_temperature_.set(target_temperature_traits::create(i, f, this)); + continue; + } + } + + // max_temperature_change + // + if (n.name() == "max_temperature_change" && n.namespace_().empty()) { + if (!max_temperature_change_.present()) { + this->max_temperature_change_.set(max_temperature_change_traits::create(i, f, this)); + continue; + } + } + + // application_interval + // + if (n.name() == "application_interval" && n.namespace_().empty()) { + if (!application_interval_.present()) { + this->application_interval_.set(application_interval_traits::create(i, f, this)); + continue; + } + } + + break; + } + + if (!target_temperature_.present()) { + throw ::xsd::cxx::tree::expected_element("target_temperature", ""); + } + + if (!max_temperature_change_.present()) { + throw ::xsd::cxx::tree::expected_element("max_temperature_change", ""); + } + + if (!application_interval_.present()) { + throw ::xsd::cxx::tree::expected_element("application_interval", ""); + } +} + +ThermostatType* ThermostatType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class ThermostatType(*this, f, c); +} + +ThermostatType& ThermostatType::operator=(const ThermostatType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->target_temperature_ = x.target_temperature_; + this->max_temperature_change_ = x.max_temperature_change_; + this->application_interval_ = x.application_interval_; + } + + return *this; +} + +ThermostatType::~ThermostatType() {} + // BoundaryConditionsType // @@ -849,17 +1089,6 @@ BoundaryConditionsType::BoundaryConditionsType(const left_type& left, const righ back_(back, this), front_(front, this) {} -BoundaryConditionsType::BoundaryConditionsType(::std::unique_ptr left, ::std::unique_ptr right, - ::std::unique_ptr bottom, ::std::unique_ptr top, - ::std::unique_ptr back, ::std::unique_ptr front) - : ::xml_schema::type(), - left_(std::move(left), this), - right_(std::move(right), this), - bottom_(std::move(bottom), this), - top_(std::move(top), this), - back_(std::move(back), this), - front_(std::move(front), this) {} - BoundaryConditionsType::BoundaryConditionsType(const BoundaryConditionsType& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type(x, f, c), left_(x.left_, f, this), @@ -966,242 +1195,75 @@ void BoundaryConditionsType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_ } if (!bottom_.present()) { - throw ::xsd::cxx::tree::expected_element("bottom", ""); - } - - if (!top_.present()) { - throw ::xsd::cxx::tree::expected_element("top", ""); - } - - if (!back_.present()) { - throw ::xsd::cxx::tree::expected_element("back", ""); - } - - if (!front_.present()) { - throw ::xsd::cxx::tree::expected_element("front", ""); - } -} - -BoundaryConditionsType* BoundaryConditionsType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { - return new class BoundaryConditionsType(*this, f, c); -} - -BoundaryConditionsType& BoundaryConditionsType::operator=(const BoundaryConditionsType& x) { - if (this != &x) { - static_cast< ::xml_schema::type&>(*this) = x; - this->left_ = x.left_; - this->right_ = x.right_; - this->bottom_ = x.bottom_; - this->top_ = x.top_; - this->back_ = x.back_; - this->front_ = x.front_; - } - - return *this; -} - -BoundaryConditionsType::~BoundaryConditionsType() {} - -// BoundaryType -// - -BoundaryType::BoundaryType() : ::xml_schema::type(), outflow_(this), reflective_(this) {} - -BoundaryType::BoundaryType(const BoundaryType& x, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(x, f, c), outflow_(x.outflow_, f, this), reflective_(x.reflective_, f, this) {} - -BoundaryType::BoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), outflow_(this), reflective_(this) { - if ((f & ::xml_schema::flags::base) == 0) { - ::xsd::cxx::xml::dom::parser p(e, true, false, false); - this->parse(p, f); - } -} - -void BoundaryType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { - for (; p.more_content(); p.next_content(false)) { - const ::xercesc::DOMElement& i(p.cur_element()); - const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); - - // outflow - // - if (n.name() == "outflow" && n.namespace_().empty()) { - ::std::unique_ptr r(outflow_traits::create(i, f, this)); - - if (!this->outflow_) { - this->outflow_.set(::std::move(r)); - continue; - } - } - - // reflective - // - if (n.name() == "reflective" && n.namespace_().empty()) { - ::std::unique_ptr r(reflective_traits::create(i, f, this)); - - if (!this->reflective_) { - this->reflective_.set(::std::move(r)); - continue; - } - } - - break; - } -} - -BoundaryType* BoundaryType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class BoundaryType(*this, f, c); } - -BoundaryType& BoundaryType::operator=(const BoundaryType& x) { - if (this != &x) { - static_cast< ::xml_schema::type&>(*this) = x; - this->outflow_ = x.outflow_; - this->reflective_ = x.reflective_; - } - - return *this; -} - -BoundaryType::~BoundaryType() {} - -// OutflowBoundaryType -// - -OutflowBoundaryType::OutflowBoundaryType() : ::xml_schema::type() {} - -OutflowBoundaryType::OutflowBoundaryType(const OutflowBoundaryType& x, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(x, f, c) {} - -OutflowBoundaryType::OutflowBoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(e, f, c) {} - -OutflowBoundaryType::OutflowBoundaryType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(a, f, c) {} - -OutflowBoundaryType::OutflowBoundaryType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f, - ::xml_schema::container* c) - : ::xml_schema::type(s, e, f, c) {} - -OutflowBoundaryType* OutflowBoundaryType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { - return new class OutflowBoundaryType(*this, f, c); -} - -OutflowBoundaryType::~OutflowBoundaryType() {} - -// ReflectiveBoundaryType -// - -ReflectiveBoundaryType::ReflectiveBoundaryType() : ::xml_schema::type() {} - -ReflectiveBoundaryType::ReflectiveBoundaryType(const ReflectiveBoundaryType& x, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(x, f, c) {} - -ReflectiveBoundaryType::ReflectiveBoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(e, f, c) {} - -ReflectiveBoundaryType::ReflectiveBoundaryType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(a, f, c) {} - -ReflectiveBoundaryType::ReflectiveBoundaryType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f, - ::xml_schema::container* c) - : ::xml_schema::type(s, e, f, c) {} - -ReflectiveBoundaryType* ReflectiveBoundaryType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { - return new class ReflectiveBoundaryType(*this, f, c); -} - -ReflectiveBoundaryType::~ReflectiveBoundaryType() {} - -// ThermostatType -// - -ThermostatType::ThermostatType(const target_temperature_type& target_temperature, const max_temperature_change_type& max_temperature_change, - const application_interval_type& application_interval) - : ::xml_schema::type(), - target_temperature_(target_temperature, this), - max_temperature_change_(max_temperature_change, this), - application_interval_(application_interval, this) {} - -ThermostatType::ThermostatType(const ThermostatType& x, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(x, f, c), - target_temperature_(x.target_temperature_, f, this), - max_temperature_change_(x.max_temperature_change_, f, this), - application_interval_(x.application_interval_, f, this) {} - -ThermostatType::ThermostatType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), - target_temperature_(this), - max_temperature_change_(this), - application_interval_(this) { - if ((f & ::xml_schema::flags::base) == 0) { - ::xsd::cxx::xml::dom::parser p(e, true, false, false); - this->parse(p, f); - } -} - -void ThermostatType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { - for (; p.more_content(); p.next_content(false)) { - const ::xercesc::DOMElement& i(p.cur_element()); - const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); - - // target_temperature - // - if (n.name() == "target_temperature" && n.namespace_().empty()) { - if (!target_temperature_.present()) { - this->target_temperature_.set(target_temperature_traits::create(i, f, this)); - continue; - } - } - - // max_temperature_change - // - if (n.name() == "max_temperature_change" && n.namespace_().empty()) { - if (!max_temperature_change_.present()) { - this->max_temperature_change_.set(max_temperature_change_traits::create(i, f, this)); - continue; - } - } - - // application_interval - // - if (n.name() == "application_interval" && n.namespace_().empty()) { - if (!application_interval_.present()) { - this->application_interval_.set(application_interval_traits::create(i, f, this)); - continue; - } - } - - break; + throw ::xsd::cxx::tree::expected_element("bottom", ""); } - if (!target_temperature_.present()) { - throw ::xsd::cxx::tree::expected_element("target_temperature", ""); + if (!top_.present()) { + throw ::xsd::cxx::tree::expected_element("top", ""); } - if (!max_temperature_change_.present()) { - throw ::xsd::cxx::tree::expected_element("max_temperature_change", ""); + if (!back_.present()) { + throw ::xsd::cxx::tree::expected_element("back", ""); } - if (!application_interval_.present()) { - throw ::xsd::cxx::tree::expected_element("application_interval", ""); + if (!front_.present()) { + throw ::xsd::cxx::tree::expected_element("front", ""); } } -ThermostatType* ThermostatType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { - return new class ThermostatType(*this, f, c); +BoundaryConditionsType* BoundaryConditionsType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class BoundaryConditionsType(*this, f, c); } -ThermostatType& ThermostatType::operator=(const ThermostatType& x) { +BoundaryConditionsType& BoundaryConditionsType::operator=(const BoundaryConditionsType& x) { if (this != &x) { static_cast< ::xml_schema::type&>(*this) = x; - this->target_temperature_ = x.target_temperature_; - this->max_temperature_change_ = x.max_temperature_change_; - this->application_interval_ = x.application_interval_; + this->left_ = x.left_; + this->right_ = x.right_; + this->bottom_ = x.bottom_; + this->top_ = x.top_; + this->back_ = x.back_; + this->front_ = x.front_; } return *this; } -ThermostatType::~ThermostatType() {} +BoundaryConditionsType::~BoundaryConditionsType() {} + +// BoundaryType +// + +BoundaryType::BoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::string(e, f, c) { + _xsd_BoundaryType_convert(); +} + +BoundaryType::BoundaryType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string(a, f, c) { + _xsd_BoundaryType_convert(); +} + +BoundaryType::BoundaryType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::string(s, e, f, c) { + _xsd_BoundaryType_convert(); +} + +BoundaryType* BoundaryType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class BoundaryType(*this, f, c); } + +BoundaryType::value BoundaryType::_xsd_BoundaryType_convert() const { + ::xsd::cxx::tree::enum_comparator c(_xsd_BoundaryType_literals_); + const value* i(::std::lower_bound(_xsd_BoundaryType_indexes_, _xsd_BoundaryType_indexes_ + 2, *this, c)); + + if (i == _xsd_BoundaryType_indexes_ + 2 || _xsd_BoundaryType_literals_[*i] != *this) { + throw ::xsd::cxx::tree::unexpected_enumerator(*this); + } + + return *i; +} + +const char* const BoundaryType::_xsd_BoundaryType_literals_[2] = {"Outflow", "Reflective"}; + +const BoundaryType::value BoundaryType::_xsd_BoundaryType_indexes_[2] = {::BoundaryType::Outflow, ::BoundaryType::Reflective}; // CuboidSpawnerType // @@ -1560,11 +1622,11 @@ SphereSpawnerType& SphereSpawnerType::operator=(const SphereSpawnerType& x) { SphereSpawnerType::~SphereSpawnerType() {} -// ParticleType +// SingleParticleSpawnerType // -ParticleType::ParticleType(const position_type& position, const temperature_type& temperature, const mass_type& mass, - const velocity_type& velocity, const type_type& type) +SingleParticleSpawnerType::SingleParticleSpawnerType(const position_type& position, const temperature_type& temperature, + const mass_type& mass, const velocity_type& velocity, const type_type& type) : ::xml_schema::type(), position_(position, this), temperature_(temperature, this), @@ -1572,8 +1634,9 @@ ParticleType::ParticleType(const position_type& position, const temperature_type velocity_(velocity, this), type_(type, this) {} -ParticleType::ParticleType(::std::unique_ptr position, const temperature_type& temperature, const mass_type& mass, - ::std::unique_ptr velocity, const type_type& type) +SingleParticleSpawnerType::SingleParticleSpawnerType(::std::unique_ptr position, const temperature_type& temperature, + const mass_type& mass, ::std::unique_ptr velocity, + const type_type& type) : ::xml_schema::type(), position_(std::move(position), this), temperature_(temperature, this), @@ -1581,7 +1644,7 @@ ParticleType::ParticleType(::std::unique_ptr position, const temp velocity_(std::move(velocity), this), type_(type, this) {} -ParticleType::ParticleType(const ParticleType& x, ::xml_schema::flags f, ::xml_schema::container* c) +SingleParticleSpawnerType::SingleParticleSpawnerType(const SingleParticleSpawnerType& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type(x, f, c), position_(x.position_, f, this), temperature_(x.temperature_, f, this), @@ -1589,7 +1652,7 @@ ParticleType::ParticleType(const ParticleType& x, ::xml_schema::flags f, ::xml_s velocity_(x.velocity_, f, this), type_(x.type_, f, this) {} -ParticleType::ParticleType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) +SingleParticleSpawnerType::SingleParticleSpawnerType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), position_(this), temperature_(this), @@ -1602,7 +1665,7 @@ ParticleType::ParticleType(const ::xercesc::DOMElement& e, ::xml_schema::flags f } } -void ParticleType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { +void SingleParticleSpawnerType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { for (; p.more_content(); p.next_content(false)) { const ::xercesc::DOMElement& i(p.cur_element()); const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); @@ -1680,9 +1743,11 @@ void ParticleType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::fl } } -ParticleType* ParticleType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class ParticleType(*this, f, c); } +SingleParticleSpawnerType* SingleParticleSpawnerType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class SingleParticleSpawnerType(*this, f, c); +} -ParticleType& ParticleType::operator=(const ParticleType& x) { +SingleParticleSpawnerType& SingleParticleSpawnerType::operator=(const SingleParticleSpawnerType& x) { if (this != &x) { static_cast< ::xml_schema::type&>(*this) = x; this->position_ = x.position_; @@ -1695,89 +1760,149 @@ ParticleType& ParticleType::operator=(const ParticleType& x) { return *this; } -ParticleType::~ParticleType() {} +SingleParticleSpawnerType::~SingleParticleSpawnerType() {} -// configuration +// CheckPointLoaderType // -configuration::configuration(const settings_type& settings, const particles_type& particles) - : ::xml_schema::type(), settings_(settings, this), particles_(particles, this) {} +CheckPointLoaderType::CheckPointLoaderType(const file_name_type& file_name) : ::xml_schema::type(), file_name_(file_name, this) {} + +CheckPointLoaderType::CheckPointLoaderType(const CheckPointLoaderType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), file_name_(x.file_name_, f, this) {} + +CheckPointLoaderType::CheckPointLoaderType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), file_name_(this) { + if ((f & ::xml_schema::flags::base) == 0) { + ::xsd::cxx::xml::dom::parser p(e, true, false, false); + this->parse(p, f); + } +} + +void CheckPointLoaderType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { + for (; p.more_content(); p.next_content(false)) { + const ::xercesc::DOMElement& i(p.cur_element()); + const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); + + // file_name + // + if (n.name() == "file_name" && n.namespace_().empty()) { + ::std::unique_ptr r(file_name_traits::create(i, f, this)); + + if (!file_name_.present()) { + this->file_name_.set(::std::move(r)); + continue; + } + } + + break; + } + + if (!file_name_.present()) { + throw ::xsd::cxx::tree::expected_element("file_name", ""); + } +} + +CheckPointLoaderType* CheckPointLoaderType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class CheckPointLoaderType(*this, f, c); +} + +CheckPointLoaderType& CheckPointLoaderType::operator=(const CheckPointLoaderType& x) { + if (this != &x) { + static_cast< ::xml_schema::type&>(*this) = x; + this->file_name_ = x.file_name_; + } + + return *this; +} + +CheckPointLoaderType::~CheckPointLoaderType() {} + +// SubSimulationType +// -configuration::configuration(::std::unique_ptr settings, ::std::unique_ptr particles) - : ::xml_schema::type(), settings_(std::move(settings), this), particles_(std::move(particles), this) {} +SubSimulationType::SubSimulationType(const name_type& name) + : ::xml_schema::type(), name_(name, this), configuration_(this), file_name_(this) {} -configuration::configuration(const configuration& x, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(x, f, c), settings_(x.settings_, f, this), particles_(x.particles_, f, this) {} +SubSimulationType::SubSimulationType(const SubSimulationType& x, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(x, f, c), name_(x.name_, f, this), configuration_(x.configuration_, f, this), file_name_(x.file_name_, f, this) {} -configuration::configuration(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), settings_(this), particles_(this) { +SubSimulationType::SubSimulationType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), name_(this), configuration_(this), file_name_(this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser p(e, true, false, false); this->parse(p, f); } } -void configuration::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { +void SubSimulationType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { for (; p.more_content(); p.next_content(false)) { const ::xercesc::DOMElement& i(p.cur_element()); const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); - // settings + // name // - if (n.name() == "settings" && n.namespace_().empty()) { - ::std::unique_ptr r(settings_traits::create(i, f, this)); + if (n.name() == "name" && n.namespace_().empty()) { + ::std::unique_ptr r(name_traits::create(i, f, this)); - if (!settings_.present()) { - this->settings_.set(::std::move(r)); + if (!name_.present()) { + this->name_.set(::std::move(r)); continue; } } - // particles + // configuration // - if (n.name() == "particles" && n.namespace_().empty()) { - ::std::unique_ptr r(particles_traits::create(i, f, this)); + if (n.name() == "configuration" && n.namespace_().empty()) { + ::std::unique_ptr r(configuration_traits::create(i, f, this)); - if (!particles_.present()) { - this->particles_.set(::std::move(r)); + if (!this->configuration_) { + this->configuration_.set(::std::move(r)); continue; } } - break; - } + // file_name + // + if (n.name() == "file_name" && n.namespace_().empty()) { + ::std::unique_ptr r(file_name_traits::create(i, f, this)); - if (!settings_.present()) { - throw ::xsd::cxx::tree::expected_element("settings", ""); + if (!this->file_name_) { + this->file_name_.set(::std::move(r)); + continue; + } + } + + break; } - if (!particles_.present()) { - throw ::xsd::cxx::tree::expected_element("particles", ""); + if (!name_.present()) { + throw ::xsd::cxx::tree::expected_element("name", ""); } } -configuration* configuration::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { - return new class configuration(*this, f, c); +SubSimulationType* SubSimulationType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class SubSimulationType(*this, f, c); } -configuration& configuration::operator=(const configuration& x) { +SubSimulationType& SubSimulationType::operator=(const SubSimulationType& x) { if (this != &x) { static_cast< ::xml_schema::type&>(*this) = x; - this->settings_ = x.settings_; - this->particles_ = x.particles_; + this->name_ = x.name_; + this->configuration_ = x.configuration_; + this->file_name_ = x.file_name_; } return *this; } -configuration::~configuration() {} +SubSimulationType::~SubSimulationType() {} -// settings +// SettingsType // -settings::settings(const fps_type& fps, const video_length_type& video_length, const delta_t_type& delta_t, const end_time_type& end_time, - const third_dimension_type& third_dimension, const particle_container_type& particle_container, - const thermostat_type& thermostat) +SettingsType::SettingsType(const fps_type& fps, const video_length_type& video_length, const delta_t_type& delta_t, + const end_time_type& end_time, const third_dimension_type& third_dimension, + const particle_container_type& particle_container, const thermostat_type& thermostat) : ::xml_schema::type(), fps_(fps, this), video_length_(video_length, this), @@ -1785,11 +1910,12 @@ settings::settings(const fps_type& fps, const video_length_type& video_length, c end_time_(end_time, this), third_dimension_(third_dimension, this), particle_container_(particle_container, this), - thermostat_(thermostat, this) {} + thermostat_(thermostat, this), + force_(this) {} -settings::settings(const fps_type& fps, const video_length_type& video_length, const delta_t_type& delta_t, const end_time_type& end_time, - const third_dimension_type& third_dimension, ::std::unique_ptr particle_container, - ::std::unique_ptr thermostat) +SettingsType::SettingsType(const fps_type& fps, const video_length_type& video_length, const delta_t_type& delta_t, + const end_time_type& end_time, const third_dimension_type& third_dimension, + ::std::unique_ptr particle_container, ::std::unique_ptr thermostat) : ::xml_schema::type(), fps_(fps, this), video_length_(video_length, this), @@ -1797,9 +1923,10 @@ settings::settings(const fps_type& fps, const video_length_type& video_length, c end_time_(end_time, this), third_dimension_(third_dimension, this), particle_container_(std::move(particle_container), this), - thermostat_(std::move(thermostat), this) {} + thermostat_(std::move(thermostat), this), + force_(this) {} -settings::settings(const settings& x, ::xml_schema::flags f, ::xml_schema::container* c) +SettingsType::SettingsType(const SettingsType& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type(x, f, c), fps_(x.fps_, f, this), video_length_(x.video_length_, f, this), @@ -1807,9 +1934,10 @@ settings::settings(const settings& x, ::xml_schema::flags f, ::xml_schema::conta end_time_(x.end_time_, f, this), third_dimension_(x.third_dimension_, f, this), particle_container_(x.particle_container_, f, this), - thermostat_(x.thermostat_, f, this) {} + thermostat_(x.thermostat_, f, this), + force_(x.force_, f, this) {} -settings::settings(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) +SettingsType::SettingsType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), fps_(this), video_length_(this), @@ -1817,14 +1945,15 @@ settings::settings(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_ end_time_(this), third_dimension_(this), particle_container_(this), - thermostat_(this) { + thermostat_(this), + force_(this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser p(e, true, false, false); this->parse(p, f); } } -void settings::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { +void SettingsType::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { for (; p.more_content(); p.next_content(false)) { const ::xercesc::DOMElement& i(p.cur_element()); const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); @@ -1896,6 +2025,15 @@ void settings::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags } } + // force + // + if (n.name() == "force" && n.namespace_().empty()) { + ::std::unique_ptr r(force_traits::create(i, f, this)); + + this->force_.push_back(::std::move(r)); + continue; + } + break; } @@ -1928,9 +2066,9 @@ void settings::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags } } -settings* settings::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class settings(*this, f, c); } +SettingsType* SettingsType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class SettingsType(*this, f, c); } -settings& settings::operator=(const settings& x) { +SettingsType& SettingsType::operator=(const SettingsType& x) { if (this != &x) { static_cast< ::xml_schema::type&>(*this) = x; this->fps_ = x.fps_; @@ -1940,33 +2078,80 @@ settings& settings::operator=(const settings& x) { this->third_dimension_ = x.third_dimension_; this->particle_container_ = x.particle_container_; this->thermostat_ = x.thermostat_; + this->force_ = x.force_; } return *this; } -settings::~settings() {} +SettingsType::~SettingsType() {} + +// ForcesType +// + +ForcesType::ForcesType(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string(e, f, c) { + _xsd_ForcesType_convert(); +} + +ForcesType::ForcesType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::string(a, f, c) { + _xsd_ForcesType_convert(); +} + +ForcesType::ForcesType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::string(s, e, f, c) { + _xsd_ForcesType_convert(); +} + +ForcesType* ForcesType::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class ForcesType(*this, f, c); } + +ForcesType::value ForcesType::_xsd_ForcesType_convert() const { + ::xsd::cxx::tree::enum_comparator c(_xsd_ForcesType_literals_); + const value* i(::std::lower_bound(_xsd_ForcesType_indexes_, _xsd_ForcesType_indexes_ + 2, *this, c)); + + if (i == _xsd_ForcesType_indexes_ + 2 || _xsd_ForcesType_literals_[*i] != *this) { + throw ::xsd::cxx::tree::unexpected_enumerator(*this); + } + + return *i; +} + +const char* const ForcesType::_xsd_ForcesType_literals_[2] = {"LennardJones", "ParticleGravity"}; + +const ForcesType::value ForcesType::_xsd_ForcesType_indexes_[2] = {::ForcesType::LennardJones, ::ForcesType::ParticleGravity}; -// particles +// particle_source // -particles::particles() : ::xml_schema::type(), cuboid_spawner_(this), sphere_spawner_(this), single_particle_(this) {} +particle_source::particle_source() + : ::xml_schema::type(), + cuboid_spawner_(this), + sphere_spawner_(this), + single_particle_spawner_(this), + check_point_loader_(this), + sub_simulation_(this) {} -particles::particles(const particles& x, ::xml_schema::flags f, ::xml_schema::container* c) +particle_source::particle_source(const particle_source& x, ::xml_schema::flags f, ::xml_schema::container* c) : ::xml_schema::type(x, f, c), cuboid_spawner_(x.cuboid_spawner_, f, this), sphere_spawner_(x.sphere_spawner_, f, this), - single_particle_(x.single_particle_, f, this) {} + single_particle_spawner_(x.single_particle_spawner_, f, this), + check_point_loader_(x.check_point_loader_, f, this), + sub_simulation_(x.sub_simulation_, f, this) {} -particles::particles(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) - : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), cuboid_spawner_(this), sphere_spawner_(this), single_particle_(this) { +particle_source::particle_source(const ::xercesc::DOMElement& e, ::xml_schema::flags f, ::xml_schema::container* c) + : ::xml_schema::type(e, f | ::xml_schema::flags::base, c), + cuboid_spawner_(this), + sphere_spawner_(this), + single_particle_spawner_(this), + check_point_loader_(this), + sub_simulation_(this) { if ((f & ::xml_schema::flags::base) == 0) { ::xsd::cxx::xml::dom::parser p(e, true, false, false); this->parse(p, f); } } -void particles::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { +void particle_source::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags f) { for (; p.more_content(); p.next_content(false)) { const ::xercesc::DOMElement& i(p.cur_element()); const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(i)); @@ -1989,12 +2174,30 @@ void particles::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags continue; } - // single_particle + // single_particle_spawner + // + if (n.name() == "single_particle_spawner" && n.namespace_().empty()) { + ::std::unique_ptr r(single_particle_spawner_traits::create(i, f, this)); + + this->single_particle_spawner_.push_back(::std::move(r)); + continue; + } + + // check_point_loader + // + if (n.name() == "check_point_loader" && n.namespace_().empty()) { + ::std::unique_ptr r(check_point_loader_traits::create(i, f, this)); + + this->check_point_loader_.push_back(::std::move(r)); + continue; + } + + // sub_simulation // - if (n.name() == "single_particle" && n.namespace_().empty()) { - ::std::unique_ptr r(single_particle_traits::create(i, f, this)); + if (n.name() == "sub_simulation" && n.namespace_().empty()) { + ::std::unique_ptr r(sub_simulation_traits::create(i, f, this)); - this->single_particle_.push_back(::std::move(r)); + this->sub_simulation_.push_back(::std::move(r)); continue; } @@ -2002,26 +2205,30 @@ void particles::parse(::xsd::cxx::xml::dom::parser& p, ::xml_schema::flags } } -particles* particles::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { return new class particles(*this, f, c); } +particle_source* particle_source::_clone(::xml_schema::flags f, ::xml_schema::container* c) const { + return new class particle_source(*this, f, c); +} -particles& particles::operator=(const particles& x) { +particle_source& particle_source::operator=(const particle_source& x) { if (this != &x) { static_cast< ::xml_schema::type&>(*this) = x; this->cuboid_spawner_ = x.cuboid_spawner_; this->sphere_spawner_ = x.sphere_spawner_; - this->single_particle_ = x.single_particle_; + this->single_particle_spawner_ = x.single_particle_spawner_; + this->check_point_loader_ = x.check_point_loader_; + this->sub_simulation_ = x.sub_simulation_; } return *this; } -particles::~particles() {} +particle_source::~particle_source() {} #include #include #include -::std::unique_ptr< ::configuration> configuration_(const ::std::string& u, ::xml_schema::flags f, const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(const ::std::string& u, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::tree::error_handler h; @@ -2030,121 +2237,121 @@ ::std::unique_ptr< ::configuration> configuration_(const ::std::string& u, ::xml h.throw_if_failed< ::xsd::cxx::tree::parsing >(); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } -::std::unique_ptr< ::configuration> configuration_(const ::std::string& u, ::xml_schema::error_handler& h, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(const ::std::string& u, ::xml_schema::error_handler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(u, h, p, f)); if (!d.get()) throw ::xsd::cxx::tree::parsing(); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } -::std::unique_ptr< ::configuration> configuration_(const ::std::string& u, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(const ::std::string& u, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(u, h, p, f)); if (!d.get()) throw ::xsd::cxx::tree::parsing(); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xml_schema::flags f, const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc(is); - return ::configuration_(isrc, f, p); + return ::configuration(isrc, f, p); } -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xml_schema::error_handler& h, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, ::xml_schema::error_handler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc(is); - return ::configuration_(isrc, h, f, p); + return ::configuration(isrc, h, f, p); } -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xsd::cxx::xml::sax::std_input_source isrc(is); - return ::configuration_(isrc, h, f, p); + return ::configuration(isrc, h, f, p); } -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::std::string& sid, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, const ::std::string& sid, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc(is, sid); - return ::configuration_(isrc, f, p); + return ::configuration(isrc, f, p); } -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::std::string& sid, ::xml_schema::error_handler& h, - ::xml_schema::flags f, const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, const ::std::string& sid, ::xml_schema::error_handler& h, + ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0, (f & ::xml_schema::flags::keep_dom) == 0); ::xsd::cxx::xml::sax::std_input_source isrc(is, sid); - return ::configuration_(isrc, h, f, p); + return ::configuration(isrc, h, f, p); } -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::std::string& sid, ::xercesc::DOMErrorHandler& h, - ::xml_schema::flags f, const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, const ::std::string& sid, ::xercesc::DOMErrorHandler& h, + ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::xml::sax::std_input_source isrc(is, sid); - return ::configuration_(isrc, h, f, p); + return ::configuration(isrc, h, f, p); } -::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& i, ::xml_schema::flags f, const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::xercesc::InputSource& i, ::xml_schema::flags f, const ::xml_schema::properties& p) { ::xsd::cxx::tree::error_handler h; ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(i, h, p, f)); h.throw_if_failed< ::xsd::cxx::tree::parsing >(); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } -::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& i, ::xml_schema::error_handler& h, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::xercesc::InputSource& i, ::xml_schema::error_handler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(i, h, p, f)); if (!d.get()) throw ::xsd::cxx::tree::parsing(); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } -::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& i, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(::xercesc::InputSource& i, ::xercesc::DOMErrorHandler& h, ::xml_schema::flags f, + const ::xml_schema::properties& p) { ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::parse(i, h, p, f)); if (!d.get()) throw ::xsd::cxx::tree::parsing(); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } -::std::unique_ptr< ::configuration> configuration_(const ::xercesc::DOMDocument& doc, ::xml_schema::flags f, - const ::xml_schema::properties& p) { +::std::unique_ptr< ::ConfigurationType> configuration(const ::xercesc::DOMDocument& doc, ::xml_schema::flags f, + const ::xml_schema::properties& p) { if (f & ::xml_schema::flags::keep_dom) { ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(static_cast< ::xercesc::DOMDocument*>(doc.cloneNode(true))); - return ::std::unique_ptr< ::configuration>(::configuration_(std::move(d), f | ::xml_schema::flags::own_dom, p)); + return ::std::unique_ptr< ::ConfigurationType>(::configuration(std::move(d), f | ::xml_schema::flags::own_dom, p)); } const ::xercesc::DOMElement& e(*doc.getDocumentElement()); const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(e)); if (n.name() == "configuration" && n.namespace_() == "") { - ::std::unique_ptr< ::configuration> r(::xsd::cxx::tree::traits< ::configuration, char>::create(e, f, 0)); + ::std::unique_ptr< ::ConfigurationType> r(::xsd::cxx::tree::traits< ::ConfigurationType, char>::create(e, f, 0)); return r; } throw ::xsd::cxx::tree::unexpected_element(n.name(), n.namespace_(), "configuration", ""); } -::std::unique_ptr< ::configuration> configuration_(::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d, ::xml_schema::flags f, - const ::xml_schema::properties&) { +::std::unique_ptr< ::ConfigurationType> configuration(::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d, ::xml_schema::flags f, + const ::xml_schema::properties&) { ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> c(((f & ::xml_schema::flags::keep_dom) && !(f & ::xml_schema::flags::own_dom)) ? static_cast< ::xercesc::DOMDocument*>(d->cloneNode(true)) : 0); @@ -2157,7 +2364,7 @@ ::std::unique_ptr< ::configuration> configuration_(::xml_schema::dom::unique_ptr if (f & ::xml_schema::flags::keep_dom) doc.setUserData(::xml_schema::dom::tree_node_key, (c.get() ? &c : &d), 0); if (n.name() == "configuration" && n.namespace_() == "") { - ::std::unique_ptr< ::configuration> r(::xsd::cxx::tree::traits< ::configuration, char>::create(e, f, 0)); + ::std::unique_ptr< ::ConfigurationType> r(::xsd::cxx::tree::traits< ::ConfigurationType, char>::create(e, f, 0)); return r; } @@ -2168,11 +2375,11 @@ ::std::unique_ptr< ::configuration> configuration_(::xml_schema::dom::unique_ptr #include #include -void configuration_(::std::ostream& o, const ::configuration& s, const ::xml_schema::namespace_infomap& m, const ::std::string& e, - ::xml_schema::flags f) { +void configuration(::std::ostream& o, const ::ConfigurationType& s, const ::xml_schema::namespace_infomap& m, const ::std::string& e, + ::xml_schema::flags f) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0); - ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration_(s, m, f)); + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration(s, m, f)); ::xsd::cxx::tree::error_handler h; @@ -2182,29 +2389,29 @@ void configuration_(::std::ostream& o, const ::configuration& s, const ::xml_sch } } -void configuration_(::std::ostream& o, const ::configuration& s, ::xml_schema::error_handler& h, const ::xml_schema::namespace_infomap& m, - const ::std::string& e, ::xml_schema::flags f) { +void configuration(::std::ostream& o, const ::ConfigurationType& s, ::xml_schema::error_handler& h, + const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { ::xsd::cxx::xml::auto_initializer i((f & ::xml_schema::flags::dont_initialize) == 0); - ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration_(s, m, f)); + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration(s, m, f)); ::xsd::cxx::xml::dom::ostream_format_target t(o); if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization(); } } -void configuration_(::std::ostream& o, const ::configuration& s, ::xercesc::DOMErrorHandler& h, const ::xml_schema::namespace_infomap& m, - const ::std::string& e, ::xml_schema::flags f) { - ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration_(s, m, f)); +void configuration(::std::ostream& o, const ::ConfigurationType& s, ::xercesc::DOMErrorHandler& h, const ::xml_schema::namespace_infomap& m, + const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration(s, m, f)); ::xsd::cxx::xml::dom::ostream_format_target t(o); if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization(); } } -void configuration_(::xercesc::XMLFormatTarget& t, const ::configuration& s, const ::xml_schema::namespace_infomap& m, - const ::std::string& e, ::xml_schema::flags f) { - ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration_(s, m, f)); +void configuration(::xercesc::XMLFormatTarget& t, const ::ConfigurationType& s, const ::xml_schema::namespace_infomap& m, + const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration(s, m, f)); ::xsd::cxx::tree::error_handler h; @@ -2213,23 +2420,23 @@ void configuration_(::xercesc::XMLFormatTarget& t, const ::configuration& s, con } } -void configuration_(::xercesc::XMLFormatTarget& t, const ::configuration& s, ::xml_schema::error_handler& h, - const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { - ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration_(s, m, f)); +void configuration(::xercesc::XMLFormatTarget& t, const ::ConfigurationType& s, ::xml_schema::error_handler& h, + const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration(s, m, f)); if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization(); } } -void configuration_(::xercesc::XMLFormatTarget& t, const ::configuration& s, ::xercesc::DOMErrorHandler& h, - const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { - ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration_(s, m, f)); +void configuration(::xercesc::XMLFormatTarget& t, const ::ConfigurationType& s, ::xercesc::DOMErrorHandler& h, + const ::xml_schema::namespace_infomap& m, const ::std::string& e, ::xml_schema::flags f) { + ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::configuration(s, m, f)); if (!::xsd::cxx::xml::dom::serialize(t, *d, e, h, f)) { throw ::xsd::cxx::tree::serialization(); } } -void configuration_(::xercesc::DOMDocument& d, const ::configuration& s, ::xml_schema::flags) { +void configuration(::xercesc::DOMDocument& d, const ::ConfigurationType& s, ::xml_schema::flags) { ::xercesc::DOMElement& e(*d.getDocumentElement()); const ::xsd::cxx::xml::qualified_name n(::xsd::cxx::xml::dom::name(e)); @@ -2240,14 +2447,34 @@ void configuration_(::xercesc::DOMDocument& d, const ::configuration& s, ::xml_s } } -::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> configuration_(const ::configuration& s, const ::xml_schema::namespace_infomap& m, - ::xml_schema::flags f) { +::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> configuration(const ::ConfigurationType& s, const ::xml_schema::namespace_infomap& m, + ::xml_schema::flags f) { ::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d(::xsd::cxx::xml::dom::serialize("configuration", "", m, f)); - ::configuration_(*d, s, f); + ::configuration(*d, s, f); return d; } +void operator<<(::xercesc::DOMElement& e, const ConfigurationType& i) { + e << static_cast(i); + + // settings + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("settings", e)); + + s << i.settings(); + } + + // particle_source + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("particle_source", e)); + + s << i.particle_source(); + } +} + void operator<<(::xercesc::DOMElement& e, const DoubleVec3Type& i) { e << static_cast(i); @@ -2358,6 +2585,34 @@ void operator<<(::xercesc::DOMElement& e, const LinkedCellsContainerType& i) { } } +void operator<<(::xercesc::DOMElement& e, const ThermostatType& i) { + e << static_cast(i); + + // target_temperature + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("target_temperature", e)); + + s << ::xml_schema::as_double(i.target_temperature()); + } + + // max_temperature_change + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("max_temperature_change", e)); + + s << ::xml_schema::as_double(i.max_temperature_change()); + } + + // application_interval + // + { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("application_interval", e)); + + s << i.application_interval(); + } +} + void operator<<(::xercesc::DOMElement& e, const BoundaryConditionsType& i) { e << static_cast(i); @@ -2410,65 +2665,11 @@ void operator<<(::xercesc::DOMElement& e, const BoundaryConditionsType& i) { } } -void operator<<(::xercesc::DOMElement& e, const BoundaryType& i) { - e << static_cast(i); - - // outflow - // - if (i.outflow()) { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("outflow", e)); - - s << *i.outflow(); - } - - // reflective - // - if (i.reflective()) { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("reflective", e)); - - s << *i.reflective(); - } -} - -void operator<<(::xercesc::DOMElement& e, const OutflowBoundaryType& i) { e << static_cast(i); } - -void operator<<(::xercesc::DOMAttr&, const OutflowBoundaryType&) {} - -void operator<<(::xml_schema::list_stream&, const OutflowBoundaryType&) {} +void operator<<(::xercesc::DOMElement& e, const BoundaryType& i) { e << static_cast(i); } -void operator<<(::xercesc::DOMElement& e, const ReflectiveBoundaryType& i) { e << static_cast(i); } +void operator<<(::xercesc::DOMAttr& a, const BoundaryType& i) { a << static_cast(i); } -void operator<<(::xercesc::DOMAttr&, const ReflectiveBoundaryType&) {} - -void operator<<(::xml_schema::list_stream&, const ReflectiveBoundaryType&) {} - -void operator<<(::xercesc::DOMElement& e, const ThermostatType& i) { - e << static_cast(i); - - // target_temperature - // - { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("target_temperature", e)); - - s << ::xml_schema::as_double(i.target_temperature()); - } - - // max_temperature_change - // - { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("max_temperature_change", e)); - - s << ::xml_schema::as_double(i.max_temperature_change()); - } - - // application_interval - // - { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("application_interval", e)); - - s << i.application_interval(); - } -} +void operator<<(::xml_schema::list_stream& l, const BoundaryType& i) { l << static_cast(i); } void operator<<(::xercesc::DOMElement& e, const CuboidSpawnerType& i) { e << static_cast(i); @@ -2590,7 +2791,7 @@ void operator<<(::xercesc::DOMElement& e, const SphereSpawnerType& i) { } } -void operator<<(::xercesc::DOMElement& e, const ParticleType& i) { +void operator<<(::xercesc::DOMElement& e, const SingleParticleSpawnerType& i) { e << static_cast(i); // position @@ -2634,27 +2835,47 @@ void operator<<(::xercesc::DOMElement& e, const ParticleType& i) { } } -void operator<<(::xercesc::DOMElement& e, const configuration& i) { +void operator<<(::xercesc::DOMElement& e, const CheckPointLoaderType& i) { e << static_cast(i); - // settings + // file_name // { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("settings", e)); + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("file_name", e)); - s << i.settings(); + s << i.file_name(); } +} + +void operator<<(::xercesc::DOMElement& e, const SubSimulationType& i) { + e << static_cast(i); - // particles + // name // { - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("particles", e)); + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("name", e)); + + s << i.name(); + } + + // configuration + // + if (i.configuration()) { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("configuration", e)); + + s << *i.configuration(); + } + + // file_name + // + if (i.file_name()) { + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("file_name", e)); - s << i.particles(); + s << *i.file_name(); } } -void operator<<(::xercesc::DOMElement& e, const settings& i) { +void operator<<(::xercesc::DOMElement& e, const SettingsType& i) { e << static_cast(i); // fps @@ -2712,15 +2933,31 @@ void operator<<(::xercesc::DOMElement& e, const settings& i) { s << i.thermostat(); } + + // force + // + for (SettingsType::force_const_iterator b(i.force().begin()), n(i.force().end()); b != n; ++b) { + const SettingsType::force_type& x(*b); + + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("force", e)); + + s << x; + } } -void operator<<(::xercesc::DOMElement& e, const particles& i) { +void operator<<(::xercesc::DOMElement& e, const ForcesType& i) { e << static_cast(i); } + +void operator<<(::xercesc::DOMAttr& a, const ForcesType& i) { a << static_cast(i); } + +void operator<<(::xml_schema::list_stream& l, const ForcesType& i) { l << static_cast(i); } + +void operator<<(::xercesc::DOMElement& e, const particle_source& i) { e << static_cast(i); // cuboid_spawner // - for (particles::cuboid_spawner_const_iterator b(i.cuboid_spawner().begin()), n(i.cuboid_spawner().end()); b != n; ++b) { - const particles::cuboid_spawner_type& x(*b); + for (particle_source::cuboid_spawner_const_iterator b(i.cuboid_spawner().begin()), n(i.cuboid_spawner().end()); b != n; ++b) { + const particle_source::cuboid_spawner_type& x(*b); ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("cuboid_spawner", e)); @@ -2729,20 +2966,43 @@ void operator<<(::xercesc::DOMElement& e, const particles& i) { // sphere_spawner // - for (particles::sphere_spawner_const_iterator b(i.sphere_spawner().begin()), n(i.sphere_spawner().end()); b != n; ++b) { - const particles::sphere_spawner_type& x(*b); + for (particle_source::sphere_spawner_const_iterator b(i.sphere_spawner().begin()), n(i.sphere_spawner().end()); b != n; ++b) { + const particle_source::sphere_spawner_type& x(*b); ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("sphere_spawner", e)); s << x; } - // single_particle + // single_particle_spawner + // + for (particle_source::single_particle_spawner_const_iterator b(i.single_particle_spawner().begin()), + n(i.single_particle_spawner().end()); + b != n; ++b) { + const particle_source::single_particle_spawner_type& x(*b); + + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("single_particle_spawner", e)); + + s << x; + } + + // check_point_loader + // + for (particle_source::check_point_loader_const_iterator b(i.check_point_loader().begin()), n(i.check_point_loader().end()); b != n; + ++b) { + const particle_source::check_point_loader_type& x(*b); + + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("check_point_loader", e)); + + s << x; + } + + // sub_simulation // - for (particles::single_particle_const_iterator b(i.single_particle().begin()), n(i.single_particle().end()); b != n; ++b) { - const particles::single_particle_type& x(*b); + for (particle_source::sub_simulation_const_iterator b(i.sub_simulation().begin()), n(i.sub_simulation().end()); b != n; ++b) { + const particle_source::sub_simulation_type& x(*b); - ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("single_particle", e)); + ::xercesc::DOMElement& s(::xsd::cxx::xml::dom::create_element("sub_simulation", e)); s << x; } diff --git a/src/io/input/xml/parser/simulation_schema.h b/src/io/xml_schemas/simulation_input/simulation_input_schema.h similarity index 82% rename from src/io/input/xml/parser/simulation_schema.h rename to src/io/xml_schemas/simulation_input/simulation_input_schema.h index 2ab7a24f9..1f8256062 100644 --- a/src/io/input/xml/parser/simulation_schema.h +++ b/src/io/xml_schemas/simulation_input/simulation_input_schema.h @@ -33,11 +33,11 @@ /** * @file - * @brief Generated from simulation_schema.xsd. + * @brief Generated from simulation_input_schema.xsd. */ -#ifndef SIMULATION_SCHEMA_H -#define SIMULATION_SCHEMA_H +#ifndef SIMULATION_INPUT_SCHEMA_H +#define SIMULATION_INPUT_SCHEMA_H #ifndef XSD_CXX11 #define XSD_CXX11 @@ -592,22 +592,23 @@ const XMLCh* const tree_node_key = ::xsd::cxx::tree::user_data_keys::node; // Forward declarations. // +class ConfigurationType; class DoubleVec3Type; class IntVec3Type; class ParticleContainerType; class DirectSumContainerType; class LinkedCellsContainerType; +class ThermostatType; class BoundaryConditionsType; class BoundaryType; -class OutflowBoundaryType; -class ReflectiveBoundaryType; -class ThermostatType; class CuboidSpawnerType; class SphereSpawnerType; -class ParticleType; -class configuration; -class settings; -class particles; +class SingleParticleSpawnerType; +class CheckPointLoaderType; +class SubSimulationType; +class SettingsType; +class ForcesType; +class particle_source; #include // std::binary_search #include // std::numeric_limits @@ -620,6 +621,208 @@ class particles; #include #include +/** + * @brief Class corresponding to the %ConfigurationType schema type. + * + * @nosubgrouping + */ +class ConfigurationType : public ::xml_schema::type { + public: + /** + * @name settings + * + * @brief Accessor and modifier functions for the %settings + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::SettingsType settings_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits settings_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const settings_type& settings() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + settings_type& settings(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void settings(const settings_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void settings(::std::unique_ptr p); + + //@} + + /** + * @name particle_source + * + * @brief Accessor and modifier functions for the %particle_source + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::particle_source particle_source_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits particle_source_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const particle_source_type& particle_source() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + particle_source_type& particle_source(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void particle_source(const particle_source_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void particle_source(::std::unique_ptr p); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + ConfigurationType(const settings_type&, const particle_source_type&); + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes + * (::std::unique_ptr version). + * + * This constructor will try to use the passed values directly + * instead of making copies. + */ + ConfigurationType(::std::unique_ptr, ::std::unique_ptr); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ConfigurationType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + ConfigurationType(const ConfigurationType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual ConfigurationType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + ConfigurationType& operator=(const ConfigurationType& x); + + //@} + + /** + * @brief Destructor. + */ + virtual ~ConfigurationType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + ::xsd::cxx::tree::one settings_; + ::xsd::cxx::tree::one particle_source_; + + //@endcond +}; + /** * @brief Class corresponding to the %DoubleVec3Type schema type. * @@ -1614,16 +1817,16 @@ class LinkedCellsContainerType : public ::xml_schema::type { }; /** - * @brief Class corresponding to the %BoundaryConditionsType schema type. + * @brief Class corresponding to the %ThermostatType schema type. * * @nosubgrouping */ -class BoundaryConditionsType : public ::xml_schema::type { +class ThermostatType : public ::xml_schema::type { public: /** - * @name left + * @name target_temperature * - * @brief Accessor and modifier functions for the %left + * @brief Accessor and modifier functions for the %target_temperature * required element. */ //@{ @@ -1631,26 +1834,26 @@ class BoundaryConditionsType : public ::xml_schema::type { /** * @brief Element type. */ - typedef ::BoundaryType left_type; + typedef ::xml_schema::double_ target_temperature_type; /** * @brief Element traits type. */ - typedef ::xsd::cxx::tree::traits left_traits; + typedef ::xsd::cxx::tree::traits target_temperature_traits; /** * @brief Return a read-only (constant) reference to the element. * * @return A constant reference to the element. */ - const left_type& left() const; + const target_temperature_type& target_temperature() const; /** * @brief Return a read-write reference to the element. * * @return A reference to the element. */ - left_type& left(); + target_temperature_type& target_temperature(); /** * @brief Set the element value. @@ -1660,24 +1863,14 @@ class BoundaryConditionsType : public ::xml_schema::type { * This function makes a copy of its argument and sets it as * the new value of the element. */ - void left(const left_type& x); - - /** - * @brief Set the element value without copying. - * - * @param p A new value to use. - * - * This function will try to use the passed value directly - * instead of making a copy. - */ - void left(::std::unique_ptr p); + void target_temperature(const target_temperature_type& x); //@} /** - * @name right + * @name max_temperature_change * - * @brief Accessor and modifier functions for the %right + * @brief Accessor and modifier functions for the %max_temperature_change * required element. */ //@{ @@ -1685,26 +1878,27 @@ class BoundaryConditionsType : public ::xml_schema::type { /** * @brief Element type. */ - typedef ::BoundaryType right_type; + typedef ::xml_schema::double_ max_temperature_change_type; /** * @brief Element traits type. */ - typedef ::xsd::cxx::tree::traits right_traits; + typedef ::xsd::cxx::tree::traits + max_temperature_change_traits; /** * @brief Return a read-only (constant) reference to the element. * * @return A constant reference to the element. */ - const right_type& right() const; + const max_temperature_change_type& max_temperature_change() const; /** * @brief Return a read-write reference to the element. * * @return A reference to the element. */ - right_type& right(); + max_temperature_change_type& max_temperature_change(); /** * @brief Set the element value. @@ -1714,24 +1908,14 @@ class BoundaryConditionsType : public ::xml_schema::type { * This function makes a copy of its argument and sets it as * the new value of the element. */ - void right(const right_type& x); - - /** - * @brief Set the element value without copying. - * - * @param p A new value to use. - * - * This function will try to use the passed value directly - * instead of making a copy. - */ - void right(::std::unique_ptr p); + void max_temperature_change(const max_temperature_change_type& x); //@} /** - * @name bottom + * @name application_interval * - * @brief Accessor and modifier functions for the %bottom + * @brief Accessor and modifier functions for the %application_interval * required element. */ //@{ @@ -1739,26 +1923,26 @@ class BoundaryConditionsType : public ::xml_schema::type { /** * @brief Element type. */ - typedef ::BoundaryType bottom_type; + typedef ::xml_schema::integer application_interval_type; /** * @brief Element traits type. */ - typedef ::xsd::cxx::tree::traits bottom_traits; + typedef ::xsd::cxx::tree::traits application_interval_traits; /** * @brief Return a read-only (constant) reference to the element. * * @return A constant reference to the element. */ - const bottom_type& bottom() const; + const application_interval_type& application_interval() const; /** * @brief Return a read-write reference to the element. * * @return A reference to the element. */ - bottom_type& bottom(); + application_interval_type& application_interval(); /** * @brief Set the element value. @@ -1768,11 +1952,248 @@ class BoundaryConditionsType : public ::xml_schema::type { * This function makes a copy of its argument and sets it as * the new value of the element. */ - void bottom(const bottom_type& x); + void application_interval(const application_interval_type& x); + + //@} /** - * @brief Set the element value without copying. - * + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + ThermostatType(const target_temperature_type&, const max_temperature_change_type&, const application_interval_type&); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ThermostatType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + ThermostatType(const ThermostatType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual ThermostatType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + ThermostatType& operator=(const ThermostatType& x); + + //@} + + /** + * @brief Destructor. + */ + virtual ~ThermostatType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + ::xsd::cxx::tree::one target_temperature_; + ::xsd::cxx::tree::one max_temperature_change_; + ::xsd::cxx::tree::one application_interval_; + + //@endcond +}; + +/** + * @brief Class corresponding to the %BoundaryConditionsType schema type. + * + * @nosubgrouping + */ +class BoundaryConditionsType : public ::xml_schema::type { + public: + /** + * @name left + * + * @brief Accessor and modifier functions for the %left + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::BoundaryType left_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits left_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const left_type& left() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + left_type& left(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void left(const left_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void left(::std::unique_ptr p); + + //@} + + /** + * @name right + * + * @brief Accessor and modifier functions for the %right + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::BoundaryType right_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits right_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const right_type& right() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + right_type& right(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void right(const right_type& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly + * instead of making a copy. + */ + void right(::std::unique_ptr p); + + //@} + + /** + * @name bottom + * + * @brief Accessor and modifier functions for the %bottom + * required element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::BoundaryType bottom_type; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits bottom_traits; + + /** + * @brief Return a read-only (constant) reference to the element. + * + * @return A constant reference to the element. + */ + const bottom_type& bottom() const; + + /** + * @brief Return a read-write reference to the element. + * + * @return A reference to the element. + */ + bottom_type& bottom(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void bottom(const bottom_type& x); + + /** + * @brief Set the element value without copying. + * * @param p A new value to use. * * This function will try to use the passed value directly @@ -1955,17 +2376,6 @@ class BoundaryConditionsType : public ::xml_schema::type { */ BoundaryConditionsType(const left_type&, const right_type&, const bottom_type&, const top_type&, const back_type&, const front_type&); - /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes - * (::std::unique_ptr version). - * - * This constructor will try to use the passed values directly - * instead of making copies. - */ - BoundaryConditionsType(::std::unique_ptr, ::std::unique_ptr, ::std::unique_ptr, - ::std::unique_ptr, ::std::unique_ptr, ::std::unique_ptr); - /** * @brief Create an instance from a DOM element. * @@ -2037,164 +2447,43 @@ class BoundaryConditionsType : public ::xml_schema::type { }; /** - * @brief Class corresponding to the %BoundaryType schema type. - * - * @nosubgrouping + * @brief Enumeration class corresponding to the %BoundaryType + * schema type. */ -class BoundaryType : public ::xml_schema::type { +class BoundaryType : public ::xml_schema::string { public: /** - * @name outflow - * - * @brief Accessor and modifier functions for the %outflow - * optional element. + * @brief Underlying enum type. */ - //@{ + enum value { Outflow, Reflective }; /** - * @brief Element type. + * @brief Create an instance from the underlying enum value. + * + * @param v A enum value. */ - typedef ::OutflowBoundaryType outflow_type; + BoundaryType(value v); /** - * @brief Element optional container type. + * @brief Create an instance from a C string. + * + * @param v A string value. */ - typedef ::xsd::cxx::tree::optional outflow_optional; + BoundaryType(const char* v); /** - * @brief Element traits type. - */ - typedef ::xsd::cxx::tree::traits outflow_traits; - - /** - * @brief Return a read-only (constant) reference to the element - * container. - * - * @return A constant reference to the optional container. - */ - const outflow_optional& outflow() const; - - /** - * @brief Return a read-write reference to the element container. - * - * @return A reference to the optional container. - */ - outflow_optional& outflow(); - - /** - * @brief Set the element value. - * - * @param x A new value to set. - * - * This function makes a copy of its argument and sets it as - * the new value of the element. - */ - void outflow(const outflow_type& x); - - /** - * @brief Set the element value. - * - * @param x An optional container with the new value to set. - * - * If the value is present in @a x then this function makes a copy - * of this value and sets it as the new value of the element. - * Otherwise the element container is set the 'not present' state. - */ - void outflow(const outflow_optional& x); - - /** - * @brief Set the element value without copying. + * @brief Create an instance from a string. * - * @param p A new value to use. - * - * This function will try to use the passed value directly instead - * of making a copy. + * @param v A string value. */ - void outflow(::std::unique_ptr p); - - //@} + BoundaryType(const ::std::string& v); /** - * @name reflective + * @brief Create an instance from the base value. * - * @brief Accessor and modifier functions for the %reflective - * optional element. + * @param v A base value. */ - //@{ - - /** - * @brief Element type. - */ - typedef ::ReflectiveBoundaryType reflective_type; - - /** - * @brief Element optional container type. - */ - typedef ::xsd::cxx::tree::optional reflective_optional; - - /** - * @brief Element traits type. - */ - typedef ::xsd::cxx::tree::traits reflective_traits; - - /** - * @brief Return a read-only (constant) reference to the element - * container. - * - * @return A constant reference to the optional container. - */ - const reflective_optional& reflective() const; - - /** - * @brief Return a read-write reference to the element container. - * - * @return A reference to the optional container. - */ - reflective_optional& reflective(); - - /** - * @brief Set the element value. - * - * @param x A new value to set. - * - * This function makes a copy of its argument and sets it as - * the new value of the element. - */ - void reflective(const reflective_type& x); - - /** - * @brief Set the element value. - * - * @param x An optional container with the new value to set. - * - * If the value is present in @a x then this function makes a copy - * of this value and sets it as the new value of the element. - * Otherwise the element container is set the 'not present' state. - */ - void reflective(const reflective_optional& x); - - /** - * @brief Set the element value without copying. - * - * @param p A new value to use. - * - * This function will try to use the passed value directly instead - * of making a copy. - */ - void reflective(::std::unique_ptr p); - - //@} - - /** - * @name Constructors - */ - //@{ - - /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes. - */ - BoundaryType(); + BoundaryType(const ::xml_schema::string& v); /** * @brief Create an instance from a DOM element. @@ -2206,393 +2495,26 @@ class BoundaryType : public ::xml_schema::type { */ BoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - /** - * @brief Copy constructor. - * - * @param x An instance to make a copy of. - * @param f Flags to create the copy with. - * @param c A pointer to the object that will contain the copy. - * - * For polymorphic object models use the @c _clone function instead. - */ - BoundaryType(const BoundaryType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Copy the instance polymorphically. - * - * @param f Flags to create the copy with. - * @param c A pointer to the object that will contain the copy. - * @return A pointer to the dynamically allocated copy. - * - * This function ensures that the dynamic type of the instance is - * used for copying and should be used for polymorphic object - * models instead of the copy constructor. - */ - virtual BoundaryType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; - - /** - * @brief Copy assignment operator. - * - * @param x An instance to make a copy of. - * @return A reference to itself. - * - * For polymorphic object models use the @c _clone function instead. - */ - BoundaryType& operator=(const BoundaryType& x); - - //@} - - /** - * @brief Destructor. - */ - virtual ~BoundaryType(); - - // Implementation. - // - - //@cond - - protected: - void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); - - protected: - outflow_optional outflow_; - reflective_optional reflective_; - - //@endcond -}; - -/** - * @brief Class corresponding to the %OutflowBoundaryType schema type. - * - * @nosubgrouping - */ -class OutflowBoundaryType : public ::xml_schema::type { - public: - /** - * @name Constructors - */ - //@{ - - /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes. - */ - OutflowBoundaryType(); - - /** - * @brief Create an instance from a DOM element. - * - * @param e A DOM element to extract the data from. - * @param f Flags to create the new instance with. - * @param c A pointer to the object that will contain the new - * instance. - */ - OutflowBoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Create an instance from a DOM attribute. - * - * @param a A DOM attribute to extract the data from. - * @param f Flags to create the new instance with. - * @param c A pointer to the object that will contain the new - * instance. - */ - OutflowBoundaryType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Create an instance from a string fragment. - * - * @param s A string fragment to extract the data from. - * @param e A pointer to DOM element containing the string fragment. - * @param f Flags to create the new instance with. - * @param c A pointer to the object that will contain the new - * instance. - */ - OutflowBoundaryType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Copy constructor. - * - * @param x An instance to make a copy of. - * @param f Flags to create the copy with. - * @param c A pointer to the object that will contain the copy. - * - * For polymorphic object models use the @c _clone function instead. - */ - OutflowBoundaryType(const OutflowBoundaryType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Copy the instance polymorphically. - * - * @param f Flags to create the copy with. - * @param c A pointer to the object that will contain the copy. - * @return A pointer to the dynamically allocated copy. - * - * This function ensures that the dynamic type of the instance is - * used for copying and should be used for polymorphic object - * models instead of the copy constructor. - */ - virtual OutflowBoundaryType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; - - //@} - -#ifdef XSD_CXX11 - OutflowBoundaryType& operator=(const OutflowBoundaryType&) = default; -#endif - - /** - * @brief Destructor. - */ - virtual ~OutflowBoundaryType(); -}; - -/** - * @brief Class corresponding to the %ReflectiveBoundaryType schema type. - * - * @nosubgrouping - */ -class ReflectiveBoundaryType : public ::xml_schema::type { - public: - /** - * @name Constructors - */ - //@{ - - /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes. - */ - ReflectiveBoundaryType(); - - /** - * @brief Create an instance from a DOM element. - * - * @param e A DOM element to extract the data from. - * @param f Flags to create the new instance with. - * @param c A pointer to the object that will contain the new - * instance. - */ - ReflectiveBoundaryType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Create an instance from a DOM attribute. - * - * @param a A DOM attribute to extract the data from. - * @param f Flags to create the new instance with. - * @param c A pointer to the object that will contain the new - * instance. - */ - ReflectiveBoundaryType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Create an instance from a string fragment. - * - * @param s A string fragment to extract the data from. - * @param e A pointer to DOM element containing the string fragment. - * @param f Flags to create the new instance with. - * @param c A pointer to the object that will contain the new - * instance. - */ - ReflectiveBoundaryType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f = 0, - ::xml_schema::container* c = 0); - - /** - * @brief Copy constructor. - * - * @param x An instance to make a copy of. - * @param f Flags to create the copy with. - * @param c A pointer to the object that will contain the copy. - * - * For polymorphic object models use the @c _clone function instead. - */ - ReflectiveBoundaryType(const ReflectiveBoundaryType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); - - /** - * @brief Copy the instance polymorphically. - * - * @param f Flags to create the copy with. - * @param c A pointer to the object that will contain the copy. - * @return A pointer to the dynamically allocated copy. - * - * This function ensures that the dynamic type of the instance is - * used for copying and should be used for polymorphic object - * models instead of the copy constructor. - */ - virtual ReflectiveBoundaryType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; - - //@} - -#ifdef XSD_CXX11 - ReflectiveBoundaryType& operator=(const ReflectiveBoundaryType&) = default; -#endif - - /** - * @brief Destructor. - */ - virtual ~ReflectiveBoundaryType(); -}; - -/** - * @brief Class corresponding to the %ThermostatType schema type. - * - * @nosubgrouping - */ -class ThermostatType : public ::xml_schema::type { - public: - /** - * @name target_temperature - * - * @brief Accessor and modifier functions for the %target_temperature - * required element. - */ - //@{ - - /** - * @brief Element type. - */ - typedef ::xml_schema::double_ target_temperature_type; - - /** - * @brief Element traits type. - */ - typedef ::xsd::cxx::tree::traits target_temperature_traits; - - /** - * @brief Return a read-only (constant) reference to the element. - * - * @return A constant reference to the element. - */ - const target_temperature_type& target_temperature() const; - - /** - * @brief Return a read-write reference to the element. - * - * @return A reference to the element. - */ - target_temperature_type& target_temperature(); - - /** - * @brief Set the element value. - * - * @param x A new value to set. - * - * This function makes a copy of its argument and sets it as - * the new value of the element. - */ - void target_temperature(const target_temperature_type& x); - - //@} - - /** - * @name max_temperature_change - * - * @brief Accessor and modifier functions for the %max_temperature_change - * required element. - */ - //@{ - - /** - * @brief Element type. - */ - typedef ::xml_schema::double_ max_temperature_change_type; - - /** - * @brief Element traits type. - */ - typedef ::xsd::cxx::tree::traits - max_temperature_change_traits; - - /** - * @brief Return a read-only (constant) reference to the element. - * - * @return A constant reference to the element. - */ - const max_temperature_change_type& max_temperature_change() const; - - /** - * @brief Return a read-write reference to the element. - * - * @return A reference to the element. - */ - max_temperature_change_type& max_temperature_change(); - - /** - * @brief Set the element value. - * - * @param x A new value to set. - * - * This function makes a copy of its argument and sets it as - * the new value of the element. - */ - void max_temperature_change(const max_temperature_change_type& x); - - //@} - - /** - * @name application_interval - * - * @brief Accessor and modifier functions for the %application_interval - * required element. - */ - //@{ - - /** - * @brief Element type. - */ - typedef ::xml_schema::integer application_interval_type; - - /** - * @brief Element traits type. - */ - typedef ::xsd::cxx::tree::traits application_interval_traits; - - /** - * @brief Return a read-only (constant) reference to the element. - * - * @return A constant reference to the element. - */ - const application_interval_type& application_interval() const; - - /** - * @brief Return a read-write reference to the element. - * - * @return A reference to the element. - */ - application_interval_type& application_interval(); - - /** - * @brief Set the element value. - * - * @param x A new value to set. - * - * This function makes a copy of its argument and sets it as - * the new value of the element. - */ - void application_interval(const application_interval_type& x); - - //@} - - /** - * @name Constructors - */ - //@{ - - /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes. + /** + * @brief Create an instance from a DOM attribute. + * + * @param a A DOM attribute to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. */ - ThermostatType(const target_temperature_type&, const max_temperature_change_type&, const application_interval_type&); + BoundaryType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** - * @brief Create an instance from a DOM element. + * @brief Create an instance from a string fragment. * - * @param e A DOM element to extract the data from. + * @param s A string fragment to extract the data from. + * @param e A pointer to DOM element containing the string fragment. * @param f Flags to create the new instance with. * @param c A pointer to the object that will contain the new * instance. */ - ThermostatType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + BoundaryType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy constructor. @@ -2603,7 +2525,11 @@ class ThermostatType : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - ThermostatType(const ThermostatType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + BoundaryType(const BoundaryType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + +#ifdef XSD_CXX11 + BoundaryType& operator=(const BoundaryType&) = default; +#endif /** * @brief Copy the instance polymorphically. @@ -2616,37 +2542,32 @@ class ThermostatType : public ::xml_schema::type { * used for copying and should be used for polymorphic object * models instead of the copy constructor. */ - virtual ThermostatType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + virtual BoundaryType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; /** - * @brief Copy assignment operator. - * - * @param x An instance to make a copy of. - * @return A reference to itself. + * @brief Assign the underlying enum value. * - * For polymorphic object models use the @c _clone function instead. + * @param v A enum value. + * @return A refernce to the instance. */ - ThermostatType& operator=(const ThermostatType& x); - - //@} + BoundaryType& operator=(value v); /** - * @brief Destructor. + * @brief Implicit conversion operator to the underlying + * enum value. + * + * @return A enum value. */ - virtual ~ThermostatType(); - - // Implementation. - // + virtual operator value() const { return _xsd_BoundaryType_convert(); } //@cond protected: - void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + value _xsd_BoundaryType_convert() const; - protected: - ::xsd::cxx::tree::one target_temperature_; - ::xsd::cxx::tree::one max_temperature_change_; - ::xsd::cxx::tree::one application_interval_; + public: + static const char* const _xsd_BoundaryType_literals_[2]; + static const value _xsd_BoundaryType_indexes_[2]; //@endcond }; @@ -3520,11 +3441,11 @@ class SphereSpawnerType : public ::xml_schema::type { }; /** - * @brief Class corresponding to the %ParticleType schema type. + * @brief Class corresponding to the %SingleParticleSpawnerType schema type. * * @nosubgrouping */ -class ParticleType : public ::xml_schema::type { +class SingleParticleSpawnerType : public ::xml_schema::type { public: /** * @name position @@ -3775,7 +3696,7 @@ class ParticleType : public ::xml_schema::type { * @brief Create an instance from the ultimate base and * initializers for required elements and attributes. */ - ParticleType(const position_type&, const temperature_type&, const mass_type&, const velocity_type&, const type_type&); + SingleParticleSpawnerType(const position_type&, const temperature_type&, const mass_type&, const velocity_type&, const type_type&); /** * @brief Create an instance from the ultimate base and @@ -3785,8 +3706,8 @@ class ParticleType : public ::xml_schema::type { * This constructor will try to use the passed values directly * instead of making copies. */ - ParticleType(::std::unique_ptr, const temperature_type&, const mass_type&, ::std::unique_ptr, - const type_type&); + SingleParticleSpawnerType(::std::unique_ptr, const temperature_type&, const mass_type&, ::std::unique_ptr, + const type_type&); /** * @brief Create an instance from a DOM element. @@ -3796,7 +3717,7 @@ class ParticleType : public ::xml_schema::type { * @param c A pointer to the object that will contain the new * instance. */ - ParticleType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + SingleParticleSpawnerType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy constructor. @@ -3807,7 +3728,7 @@ class ParticleType : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - ParticleType(const ParticleType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + SingleParticleSpawnerType(const SingleParticleSpawnerType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy the instance polymorphically. @@ -3820,7 +3741,7 @@ class ParticleType : public ::xml_schema::type { * used for copying and should be used for polymorphic object * models instead of the copy constructor. */ - virtual ParticleType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + virtual SingleParticleSpawnerType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; /** * @brief Copy assignment operator. @@ -3830,14 +3751,14 @@ class ParticleType : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - ParticleType& operator=(const ParticleType& x); + SingleParticleSpawnerType& operator=(const SingleParticleSpawnerType& x); //@} /** * @brief Destructor. */ - virtual ~ParticleType(); + virtual ~SingleParticleSpawnerType(); // Implementation. // @@ -3858,16 +3779,16 @@ class ParticleType : public ::xml_schema::type { }; /** - * @brief Class corresponding to the %configuration schema type. + * @brief Class corresponding to the %CheckPointLoaderType schema type. * * @nosubgrouping */ -class configuration : public ::xml_schema::type { +class CheckPointLoaderType : public ::xml_schema::type { public: /** - * @name settings + * @name file_name * - * @brief Accessor and modifier functions for the %settings + * @brief Accessor and modifier functions for the %file_name * required element. */ //@{ @@ -3875,26 +3796,26 @@ class configuration : public ::xml_schema::type { /** * @brief Element type. */ - typedef ::settings settings_type; + typedef ::xml_schema::uri file_name_type; /** * @brief Element traits type. */ - typedef ::xsd::cxx::tree::traits settings_traits; + typedef ::xsd::cxx::tree::traits file_name_traits; /** * @brief Return a read-only (constant) reference to the element. * * @return A constant reference to the element. */ - const settings_type& settings() const; + const file_name_type& file_name() const; /** * @brief Return a read-write reference to the element. * * @return A reference to the element. */ - settings_type& settings(); + file_name_type& file_name(); /** * @brief Set the element value. @@ -3904,7 +3825,7 @@ class configuration : public ::xml_schema::type { * This function makes a copy of its argument and sets it as * the new value of the element. */ - void settings(const settings_type& x); + void file_name(const file_name_type& x); /** * @brief Set the element value without copying. @@ -3914,14 +3835,97 @@ class configuration : public ::xml_schema::type { * This function will try to use the passed value directly * instead of making a copy. */ - void settings(::std::unique_ptr p); + void file_name(::std::unique_ptr p); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. + */ + CheckPointLoaderType(const file_name_type&); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + CheckPointLoaderType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + CheckPointLoaderType(const CheckPointLoaderType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual CheckPointLoaderType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Copy assignment operator. + * + * @param x An instance to make a copy of. + * @return A reference to itself. + * + * For polymorphic object models use the @c _clone function instead. + */ + CheckPointLoaderType& operator=(const CheckPointLoaderType& x); //@} /** - * @name particles + * @brief Destructor. + */ + virtual ~CheckPointLoaderType(); + + // Implementation. + // + + //@cond + + protected: + void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); + + protected: + ::xsd::cxx::tree::one file_name_; + + //@endcond +}; + +/** + * @brief Class corresponding to the %SubSimulationType schema type. + * + * @nosubgrouping + */ +class SubSimulationType : public ::xml_schema::type { + public: + /** + * @name name * - * @brief Accessor and modifier functions for the %particles + * @brief Accessor and modifier functions for the %name * required element. */ //@{ @@ -3929,26 +3933,26 @@ class configuration : public ::xml_schema::type { /** * @brief Element type. */ - typedef ::particles particles_type; + typedef ::xml_schema::string name_type; /** * @brief Element traits type. */ - typedef ::xsd::cxx::tree::traits particles_traits; + typedef ::xsd::cxx::tree::traits name_traits; /** * @brief Return a read-only (constant) reference to the element. * * @return A constant reference to the element. */ - const particles_type& particles() const; + const name_type& name() const; /** * @brief Return a read-write reference to the element. * * @return A reference to the element. */ - particles_type& particles(); + name_type& name(); /** * @brief Set the element value. @@ -3958,7 +3962,7 @@ class configuration : public ::xml_schema::type { * This function makes a copy of its argument and sets it as * the new value of the element. */ - void particles(const particles_type& x); + void name(const name_type& x); /** * @brief Set the element value without copying. @@ -3968,30 +3972,162 @@ class configuration : public ::xml_schema::type { * This function will try to use the passed value directly * instead of making a copy. */ - void particles(::std::unique_ptr p); + void name(::std::unique_ptr p); //@} /** - * @name Constructors + * @name configuration + * + * @brief Accessor and modifier functions for the %configuration + * optional element. */ //@{ /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes. + * @brief Element type. */ - configuration(const settings_type&, const particles_type&); + typedef ::ConfigurationType configuration_type; /** - * @brief Create an instance from the ultimate base and - * initializers for required elements and attributes - * (::std::unique_ptr version). + * @brief Element optional container type. + */ + typedef ::xsd::cxx::tree::optional configuration_optional; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits configuration_traits; + + /** + * @brief Return a read-only (constant) reference to the element + * container. * - * This constructor will try to use the passed values directly - * instead of making copies. + * @return A constant reference to the optional container. + */ + const configuration_optional& configuration() const; + + /** + * @brief Return a read-write reference to the element container. + * + * @return A reference to the optional container. + */ + configuration_optional& configuration(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void configuration(const configuration_type& x); + + /** + * @brief Set the element value. + * + * @param x An optional container with the new value to set. + * + * If the value is present in @a x then this function makes a copy + * of this value and sets it as the new value of the element. + * Otherwise the element container is set the 'not present' state. + */ + void configuration(const configuration_optional& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly instead + * of making a copy. + */ + void configuration(::std::unique_ptr p); + + //@} + + /** + * @name file_name + * + * @brief Accessor and modifier functions for the %file_name + * optional element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::xml_schema::uri file_name_type; + + /** + * @brief Element optional container type. + */ + typedef ::xsd::cxx::tree::optional file_name_optional; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits file_name_traits; + + /** + * @brief Return a read-only (constant) reference to the element + * container. + * + * @return A constant reference to the optional container. + */ + const file_name_optional& file_name() const; + + /** + * @brief Return a read-write reference to the element container. + * + * @return A reference to the optional container. + */ + file_name_optional& file_name(); + + /** + * @brief Set the element value. + * + * @param x A new value to set. + * + * This function makes a copy of its argument and sets it as + * the new value of the element. + */ + void file_name(const file_name_type& x); + + /** + * @brief Set the element value. + * + * @param x An optional container with the new value to set. + * + * If the value is present in @a x then this function makes a copy + * of this value and sets it as the new value of the element. + * Otherwise the element container is set the 'not present' state. + */ + void file_name(const file_name_optional& x); + + /** + * @brief Set the element value without copying. + * + * @param p A new value to use. + * + * This function will try to use the passed value directly instead + * of making a copy. + */ + void file_name(::std::unique_ptr p); + + //@} + + /** + * @name Constructors + */ + //@{ + + /** + * @brief Create an instance from the ultimate base and + * initializers for required elements and attributes. */ - configuration(::std::unique_ptr, ::std::unique_ptr); + SubSimulationType(const name_type&); /** * @brief Create an instance from a DOM element. @@ -4001,7 +4137,7 @@ class configuration : public ::xml_schema::type { * @param c A pointer to the object that will contain the new * instance. */ - configuration(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + SubSimulationType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy constructor. @@ -4012,7 +4148,7 @@ class configuration : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - configuration(const configuration& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + SubSimulationType(const SubSimulationType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy the instance polymorphically. @@ -4025,7 +4161,7 @@ class configuration : public ::xml_schema::type { * used for copying and should be used for polymorphic object * models instead of the copy constructor. */ - virtual configuration* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + virtual SubSimulationType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; /** * @brief Copy assignment operator. @@ -4035,14 +4171,14 @@ class configuration : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - configuration& operator=(const configuration& x); + SubSimulationType& operator=(const SubSimulationType& x); //@} /** * @brief Destructor. */ - virtual ~configuration(); + virtual ~SubSimulationType(); // Implementation. // @@ -4053,18 +4189,19 @@ class configuration : public ::xml_schema::type { void parse(::xsd::cxx::xml::dom::parser&, ::xml_schema::flags); protected: - ::xsd::cxx::tree::one settings_; - ::xsd::cxx::tree::one particles_; + ::xsd::cxx::tree::one name_; + configuration_optional configuration_; + file_name_optional file_name_; //@endcond }; /** - * @brief Class corresponding to the %settings schema type. + * @brief Class corresponding to the %SettingsType schema type. * * @nosubgrouping */ -class settings : public ::xml_schema::type { +class SettingsType : public ::xml_schema::type { public: /** * @name fps @@ -4282,7 +4419,14 @@ class settings : public ::xml_schema::type { * This function makes a copy of its argument and sets it as * the new value of the element. */ - void third_dimension(const third_dimension_type& x); + void third_dimension(const third_dimension_type& x); + + /** + * @brief Return the default value for the element. + * + * @return The element's default value. + */ + static third_dimension_type third_dimension_default_value(); //@} @@ -4394,6 +4538,67 @@ class settings : public ::xml_schema::type { //@} + /** + * @name force + * + * @brief Accessor and modifier functions for the %force + * sequence element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::ForcesType force_type; + + /** + * @brief Element sequence container type. + */ + typedef ::xsd::cxx::tree::sequence force_sequence; + + /** + * @brief Element iterator type. + */ + typedef force_sequence::iterator force_iterator; + + /** + * @brief Element constant iterator type. + */ + typedef force_sequence::const_iterator force_const_iterator; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits force_traits; + + /** + * @brief Return a read-only (constant) reference to the element + * sequence. + * + * @return A constant reference to the sequence container. + */ + const force_sequence& force() const; + + /** + * @brief Return a read-write reference to the element sequence. + * + * @return A reference to the sequence container. + */ + force_sequence& force(); + + /** + * @brief Copy elements from a given sequence. + * + * @param s A sequence to copy elements from. + * + * For each element in @a s this function makes a copy and adds it + * to the sequence. Note that this operation completely changes the + * sequence and all old elements will be lost. + */ + void force(const force_sequence& s); + + //@} + /** * @name Constructors */ @@ -4403,8 +4608,8 @@ class settings : public ::xml_schema::type { * @brief Create an instance from the ultimate base and * initializers for required elements and attributes. */ - settings(const fps_type&, const video_length_type&, const delta_t_type&, const end_time_type&, const third_dimension_type&, - const particle_container_type&, const thermostat_type&); + SettingsType(const fps_type&, const video_length_type&, const delta_t_type&, const end_time_type&, const third_dimension_type&, + const particle_container_type&, const thermostat_type&); /** * @brief Create an instance from the ultimate base and @@ -4414,8 +4619,8 @@ class settings : public ::xml_schema::type { * This constructor will try to use the passed values directly * instead of making copies. */ - settings(const fps_type&, const video_length_type&, const delta_t_type&, const end_time_type&, const third_dimension_type&, - ::std::unique_ptr, ::std::unique_ptr); + SettingsType(const fps_type&, const video_length_type&, const delta_t_type&, const end_time_type&, const third_dimension_type&, + ::std::unique_ptr, ::std::unique_ptr); /** * @brief Create an instance from a DOM element. @@ -4425,7 +4630,7 @@ class settings : public ::xml_schema::type { * @param c A pointer to the object that will contain the new * instance. */ - settings(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + SettingsType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy constructor. @@ -4436,7 +4641,7 @@ class settings : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - settings(const settings& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + SettingsType(const SettingsType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy the instance polymorphically. @@ -4449,7 +4654,7 @@ class settings : public ::xml_schema::type { * used for copying and should be used for polymorphic object * models instead of the copy constructor. */ - virtual settings* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + virtual SettingsType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; /** * @brief Copy assignment operator. @@ -4459,14 +4664,14 @@ class settings : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - settings& operator=(const settings& x); + SettingsType& operator=(const SettingsType& x); //@} /** * @brief Destructor. */ - virtual ~settings(); + virtual ~SettingsType(); // Implementation. // @@ -4484,16 +4689,143 @@ class settings : public ::xml_schema::type { ::xsd::cxx::tree::one third_dimension_; ::xsd::cxx::tree::one particle_container_; ::xsd::cxx::tree::one thermostat_; + force_sequence force_; + + //@endcond +}; + +/** + * @brief Enumeration class corresponding to the %ForcesType + * schema type. + */ +class ForcesType : public ::xml_schema::string { + public: + /** + * @brief Underlying enum type. + */ + enum value { LennardJones, ParticleGravity }; + + /** + * @brief Create an instance from the underlying enum value. + * + * @param v A enum value. + */ + ForcesType(value v); + + /** + * @brief Create an instance from a C string. + * + * @param v A string value. + */ + ForcesType(const char* v); + + /** + * @brief Create an instance from a string. + * + * @param v A string value. + */ + ForcesType(const ::std::string& v); + + /** + * @brief Create an instance from the base value. + * + * @param v A base value. + */ + ForcesType(const ::xml_schema::string& v); + + /** + * @brief Create an instance from a DOM element. + * + * @param e A DOM element to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ForcesType(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Create an instance from a DOM attribute. + * + * @param a A DOM attribute to extract the data from. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ForcesType(const ::xercesc::DOMAttr& a, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Create an instance from a string fragment. + * + * @param s A string fragment to extract the data from. + * @param e A pointer to DOM element containing the string fragment. + * @param f Flags to create the new instance with. + * @param c A pointer to the object that will contain the new + * instance. + */ + ForcesType(const ::std::string& s, const ::xercesc::DOMElement* e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + + /** + * @brief Copy constructor. + * + * @param x An instance to make a copy of. + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * + * For polymorphic object models use the @c _clone function instead. + */ + ForcesType(const ForcesType& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + +#ifdef XSD_CXX11 + ForcesType& operator=(const ForcesType&) = default; +#endif + + /** + * @brief Copy the instance polymorphically. + * + * @param f Flags to create the copy with. + * @param c A pointer to the object that will contain the copy. + * @return A pointer to the dynamically allocated copy. + * + * This function ensures that the dynamic type of the instance is + * used for copying and should be used for polymorphic object + * models instead of the copy constructor. + */ + virtual ForcesType* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + + /** + * @brief Assign the underlying enum value. + * + * @param v A enum value. + * @return A refernce to the instance. + */ + ForcesType& operator=(value v); + + /** + * @brief Implicit conversion operator to the underlying + * enum value. + * + * @return A enum value. + */ + virtual operator value() const { return _xsd_ForcesType_convert(); } + + //@cond + + protected: + value _xsd_ForcesType_convert() const; + + public: + static const char* const _xsd_ForcesType_literals_[2]; + static const value _xsd_ForcesType_indexes_[2]; //@endcond }; /** - * @brief Class corresponding to the %particles schema type. + * @brief Class corresponding to the %particle_source schema type. * * @nosubgrouping */ -class particles : public ::xml_schema::type { +class particle_source : public ::xml_schema::type { public: /** * @name cuboid_spawner @@ -4618,9 +4950,131 @@ class particles : public ::xml_schema::type { //@} /** - * @name single_particle + * @name single_particle_spawner + * + * @brief Accessor and modifier functions for the %single_particle_spawner + * sequence element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::SingleParticleSpawnerType single_particle_spawner_type; + + /** + * @brief Element sequence container type. + */ + typedef ::xsd::cxx::tree::sequence single_particle_spawner_sequence; + + /** + * @brief Element iterator type. + */ + typedef single_particle_spawner_sequence::iterator single_particle_spawner_iterator; + + /** + * @brief Element constant iterator type. + */ + typedef single_particle_spawner_sequence::const_iterator single_particle_spawner_const_iterator; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits single_particle_spawner_traits; + + /** + * @brief Return a read-only (constant) reference to the element + * sequence. + * + * @return A constant reference to the sequence container. + */ + const single_particle_spawner_sequence& single_particle_spawner() const; + + /** + * @brief Return a read-write reference to the element sequence. + * + * @return A reference to the sequence container. + */ + single_particle_spawner_sequence& single_particle_spawner(); + + /** + * @brief Copy elements from a given sequence. + * + * @param s A sequence to copy elements from. + * + * For each element in @a s this function makes a copy and adds it + * to the sequence. Note that this operation completely changes the + * sequence and all old elements will be lost. + */ + void single_particle_spawner(const single_particle_spawner_sequence& s); + + //@} + + /** + * @name check_point_loader + * + * @brief Accessor and modifier functions for the %check_point_loader + * sequence element. + */ + //@{ + + /** + * @brief Element type. + */ + typedef ::CheckPointLoaderType check_point_loader_type; + + /** + * @brief Element sequence container type. + */ + typedef ::xsd::cxx::tree::sequence check_point_loader_sequence; + + /** + * @brief Element iterator type. + */ + typedef check_point_loader_sequence::iterator check_point_loader_iterator; + + /** + * @brief Element constant iterator type. + */ + typedef check_point_loader_sequence::const_iterator check_point_loader_const_iterator; + + /** + * @brief Element traits type. + */ + typedef ::xsd::cxx::tree::traits check_point_loader_traits; + + /** + * @brief Return a read-only (constant) reference to the element + * sequence. + * + * @return A constant reference to the sequence container. + */ + const check_point_loader_sequence& check_point_loader() const; + + /** + * @brief Return a read-write reference to the element sequence. + * + * @return A reference to the sequence container. + */ + check_point_loader_sequence& check_point_loader(); + + /** + * @brief Copy elements from a given sequence. + * + * @param s A sequence to copy elements from. + * + * For each element in @a s this function makes a copy and adds it + * to the sequence. Note that this operation completely changes the + * sequence and all old elements will be lost. + */ + void check_point_loader(const check_point_loader_sequence& s); + + //@} + + /** + * @name sub_simulation * - * @brief Accessor and modifier functions for the %single_particle + * @brief Accessor and modifier functions for the %sub_simulation * sequence element. */ //@{ @@ -4628,27 +5082,27 @@ class particles : public ::xml_schema::type { /** * @brief Element type. */ - typedef ::ParticleType single_particle_type; + typedef ::SubSimulationType sub_simulation_type; /** * @brief Element sequence container type. */ - typedef ::xsd::cxx::tree::sequence single_particle_sequence; + typedef ::xsd::cxx::tree::sequence sub_simulation_sequence; /** * @brief Element iterator type. */ - typedef single_particle_sequence::iterator single_particle_iterator; + typedef sub_simulation_sequence::iterator sub_simulation_iterator; /** * @brief Element constant iterator type. */ - typedef single_particle_sequence::const_iterator single_particle_const_iterator; + typedef sub_simulation_sequence::const_iterator sub_simulation_const_iterator; /** * @brief Element traits type. */ - typedef ::xsd::cxx::tree::traits single_particle_traits; + typedef ::xsd::cxx::tree::traits sub_simulation_traits; /** * @brief Return a read-only (constant) reference to the element @@ -4656,14 +5110,14 @@ class particles : public ::xml_schema::type { * * @return A constant reference to the sequence container. */ - const single_particle_sequence& single_particle() const; + const sub_simulation_sequence& sub_simulation() const; /** * @brief Return a read-write reference to the element sequence. * * @return A reference to the sequence container. */ - single_particle_sequence& single_particle(); + sub_simulation_sequence& sub_simulation(); /** * @brief Copy elements from a given sequence. @@ -4674,7 +5128,7 @@ class particles : public ::xml_schema::type { * to the sequence. Note that this operation completely changes the * sequence and all old elements will be lost. */ - void single_particle(const single_particle_sequence& s); + void sub_simulation(const sub_simulation_sequence& s); //@} @@ -4687,7 +5141,7 @@ class particles : public ::xml_schema::type { * @brief Create an instance from the ultimate base and * initializers for required elements and attributes. */ - particles(); + particle_source(); /** * @brief Create an instance from a DOM element. @@ -4697,7 +5151,7 @@ class particles : public ::xml_schema::type { * @param c A pointer to the object that will contain the new * instance. */ - particles(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + particle_source(const ::xercesc::DOMElement& e, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy constructor. @@ -4708,7 +5162,7 @@ class particles : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - particles(const particles& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); + particle_source(const particle_source& x, ::xml_schema::flags f = 0, ::xml_schema::container* c = 0); /** * @brief Copy the instance polymorphically. @@ -4721,7 +5175,7 @@ class particles : public ::xml_schema::type { * used for copying and should be used for polymorphic object * models instead of the copy constructor. */ - virtual particles* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; + virtual particle_source* _clone(::xml_schema::flags f = 0, ::xml_schema::container* c = 0) const; /** * @brief Copy assignment operator. @@ -4731,14 +5185,14 @@ class particles : public ::xml_schema::type { * * For polymorphic object models use the @c _clone function instead. */ - particles& operator=(const particles& x); + particle_source& operator=(const particle_source& x); //@} /** * @brief Destructor. */ - virtual ~particles(); + virtual ~particle_source(); // Implementation. // @@ -4751,7 +5205,9 @@ class particles : public ::xml_schema::type { protected: cuboid_spawner_sequence cuboid_spawner_; sphere_spawner_sequence sphere_spawner_; - single_particle_sequence single_particle_; + single_particle_spawner_sequence single_particle_spawner_; + check_point_loader_sequence check_point_loader_; + sub_simulation_sequence sub_simulation_; //@endcond }; @@ -4776,8 +5232,8 @@ class particles : public ::xml_schema::type { * * This function uses exceptions to report parsing errors. */ -::std::unique_ptr< ::configuration> configuration_(const ::std::string& uri, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(const ::std::string& uri, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a URI or a local file with an error handler. @@ -4790,8 +5246,8 @@ ::std::unique_ptr< ::configuration> configuration_(const ::std::string& uri, ::x * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(const ::std::string& uri, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(const ::std::string& uri, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a URI or a local file with a Xerces-C++ DOM error @@ -4805,8 +5261,8 @@ ::std::unique_ptr< ::configuration> configuration_(const ::std::string& uri, ::x * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(const ::std::string& uri, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(const ::std::string& uri, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a standard input stream. @@ -4818,8 +5274,8 @@ ::std::unique_ptr< ::configuration> configuration_(const ::std::string& uri, ::x * * This function uses exceptions to report parsing errors. */ -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a standard input stream with an error handler. @@ -4832,8 +5288,8 @@ ::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xml_sch * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a standard input stream with a Xerces-C++ DOM error @@ -4847,8 +5303,8 @@ ::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xml_sch * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a standard input stream with a resource id. @@ -4864,8 +5320,8 @@ ::std::unique_ptr< ::configuration> configuration_(::std::istream& is, ::xercesc * * This function uses exceptions to report parsing errors. */ -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::std::string& id, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, const ::std::string& id, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a standard input stream with a resource id and an @@ -4883,9 +5339,9 @@ ::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::s * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::std::string& id, ::xml_schema::error_handler& eh, - ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, const ::std::string& id, ::xml_schema::error_handler& eh, + ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a standard input stream with a resource id and a @@ -4903,9 +5359,9 @@ ::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::s * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::std::string& id, ::xercesc::DOMErrorHandler& eh, - ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::std::istream& is, const ::std::string& id, ::xercesc::DOMErrorHandler& eh, + ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a Xerces-C++ input source. @@ -4917,8 +5373,8 @@ ::std::unique_ptr< ::configuration> configuration_(::std::istream& is, const ::s * * This function uses exceptions to report parsing errors. */ -::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& is, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::xercesc::InputSource& is, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a Xerces-C++ input source with an error handler. @@ -4931,8 +5387,9 @@ ::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& is, : * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& is, ::xml_schema::error_handler& eh, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::xercesc::InputSource& is, ::xml_schema::error_handler& eh, + ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a Xerces-C++ input source with a Xerces-C++ DOM @@ -4946,8 +5403,8 @@ ::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& is, : * * This function reports parsing errors by calling the error handler. */ -::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& is, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::xercesc::InputSource& is, ::xercesc::DOMErrorHandler& eh, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a Xerces-C++ DOM document. @@ -4957,8 +5414,8 @@ ::std::unique_ptr< ::configuration> configuration_(::xercesc::InputSource& is, : * @param p Parsing properties. * @return A pointer to the root of the object model. */ -::std::unique_ptr< ::configuration> configuration_(const ::xercesc::DOMDocument& d, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(const ::xercesc::DOMDocument& d, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); /** * @brief Parse a Xerces-C++ DOM document. @@ -4972,8 +5429,8 @@ ::std::unique_ptr< ::configuration> configuration_(const ::xercesc::DOMDocument& * own_dom parsing flags to assign ownership of the DOM document * to the object model. */ -::std::unique_ptr< ::configuration> configuration_(::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d, ::xml_schema::flags f = 0, - const ::xml_schema::properties& p = ::xml_schema::properties()); +::std::unique_ptr< ::ConfigurationType> configuration(::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> d, ::xml_schema::flags f = 0, + const ::xml_schema::properties& p = ::xml_schema::properties()); //@} @@ -4999,9 +5456,9 @@ ::std::unique_ptr< ::configuration> configuration_(::xml_schema::dom::unique_ptr * * This function uses exceptions to report serialization errors. */ -void configuration_(::std::ostream& os, const ::configuration& x, - const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", - ::xml_schema::flags f = 0); +void configuration(::std::ostream& os, const ::ConfigurationType& x, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); /** * @brief Serialize to a standard output stream with an error handler. @@ -5016,9 +5473,9 @@ void configuration_(::std::ostream& os, const ::configuration& x, * This function reports serialization errors by calling the error * handler. */ -void configuration_(::std::ostream& os, const ::configuration& x, ::xml_schema::error_handler& eh, - const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", - ::xml_schema::flags f = 0); +void configuration(::std::ostream& os, const ::ConfigurationType& x, ::xml_schema::error_handler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); /** * @brief Serialize to a standard output stream with a Xerces-C++ DOM @@ -5034,9 +5491,9 @@ void configuration_(::std::ostream& os, const ::configuration& x, ::xml_schema:: * This function reports serialization errors by calling the error * handler. */ -void configuration_(::std::ostream& os, const ::configuration& x, ::xercesc::DOMErrorHandler& eh, - const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", - ::xml_schema::flags f = 0); +void configuration(::std::ostream& os, const ::ConfigurationType& x, ::xercesc::DOMErrorHandler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); /** * @brief Serialize to a Xerces-C++ XML format target. @@ -5049,9 +5506,9 @@ void configuration_(::std::ostream& os, const ::configuration& x, ::xercesc::DOM * * This function uses exceptions to report serialization errors. */ -void configuration_(::xercesc::XMLFormatTarget& ft, const ::configuration& x, - const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", - ::xml_schema::flags f = 0); +void configuration(::xercesc::XMLFormatTarget& ft, const ::ConfigurationType& x, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); /** * @brief Serialize to a Xerces-C++ XML format target with an error @@ -5067,9 +5524,9 @@ void configuration_(::xercesc::XMLFormatTarget& ft, const ::configuration& x, * This function reports serialization errors by calling the error * handler. */ -void configuration_(::xercesc::XMLFormatTarget& ft, const ::configuration& x, ::xml_schema::error_handler& eh, - const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", - ::xml_schema::flags f = 0); +void configuration(::xercesc::XMLFormatTarget& ft, const ::ConfigurationType& x, ::xml_schema::error_handler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); /** * @brief Serialize to a Xerces-C++ XML format target with a @@ -5085,9 +5542,9 @@ void configuration_(::xercesc::XMLFormatTarget& ft, const ::configuration& x, :: * This function reports serialization errors by calling the error * handler. */ -void configuration_(::xercesc::XMLFormatTarget& ft, const ::configuration& x, ::xercesc::DOMErrorHandler& eh, - const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", - ::xml_schema::flags f = 0); +void configuration(::xercesc::XMLFormatTarget& ft, const ::ConfigurationType& x, ::xercesc::DOMErrorHandler& eh, + const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), const ::std::string& e = "UTF-8", + ::xml_schema::flags f = 0); /** * @brief Serialize to an existing Xerces-C++ DOM document. @@ -5100,7 +5557,7 @@ void configuration_(::xercesc::XMLFormatTarget& ft, const ::configuration& x, :: * with the correct root element as well as set the necessary * namespace mapping attributes. */ -void configuration_(::xercesc::DOMDocument& d, const ::configuration& x, ::xml_schema::flags f = 0); +void configuration(::xercesc::DOMDocument& d, const ::ConfigurationType& x, ::xml_schema::flags f = 0); /** * @brief Serialize to a new Xerces-C++ DOM document. @@ -5110,11 +5567,13 @@ void configuration_(::xercesc::DOMDocument& d, const ::configuration& x, ::xml_s * @param f Serialization flags. * @return A pointer to the new Xerces-C++ DOM document. */ -::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> configuration_( - const ::configuration& x, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), ::xml_schema::flags f = 0); +::xml_schema::dom::unique_ptr< ::xercesc::DOMDocument> configuration( + const ::ConfigurationType& x, const ::xml_schema::namespace_infomap& m = ::xml_schema::namespace_infomap(), ::xml_schema::flags f = 0); //@} +void operator<<(::xercesc::DOMElement&, const ConfigurationType&); + void operator<<(::xercesc::DOMElement&, const DoubleVec3Type&); void operator<<(::xercesc::DOMElement&, const IntVec3Type&); @@ -5129,35 +5588,35 @@ void operator<<(::xml_schema::list_stream&, const DirectSumContainerType&); void operator<<(::xercesc::DOMElement&, const LinkedCellsContainerType&); +void operator<<(::xercesc::DOMElement&, const ThermostatType&); + void operator<<(::xercesc::DOMElement&, const BoundaryConditionsType&); void operator<<(::xercesc::DOMElement&, const BoundaryType&); -void operator<<(::xercesc::DOMElement&, const OutflowBoundaryType&); +void operator<<(::xercesc::DOMAttr&, const BoundaryType&); -void operator<<(::xercesc::DOMAttr&, const OutflowBoundaryType&); +void operator<<(::xml_schema::list_stream&, const BoundaryType&); -void operator<<(::xml_schema::list_stream&, const OutflowBoundaryType&); - -void operator<<(::xercesc::DOMElement&, const ReflectiveBoundaryType&); +void operator<<(::xercesc::DOMElement&, const CuboidSpawnerType&); -void operator<<(::xercesc::DOMAttr&, const ReflectiveBoundaryType&); +void operator<<(::xercesc::DOMElement&, const SphereSpawnerType&); -void operator<<(::xml_schema::list_stream&, const ReflectiveBoundaryType&); +void operator<<(::xercesc::DOMElement&, const SingleParticleSpawnerType&); -void operator<<(::xercesc::DOMElement&, const ThermostatType&); +void operator<<(::xercesc::DOMElement&, const CheckPointLoaderType&); -void operator<<(::xercesc::DOMElement&, const CuboidSpawnerType&); +void operator<<(::xercesc::DOMElement&, const SubSimulationType&); -void operator<<(::xercesc::DOMElement&, const SphereSpawnerType&); +void operator<<(::xercesc::DOMElement&, const SettingsType&); -void operator<<(::xercesc::DOMElement&, const ParticleType&); +void operator<<(::xercesc::DOMElement&, const ForcesType&); -void operator<<(::xercesc::DOMElement&, const configuration&); +void operator<<(::xercesc::DOMAttr&, const ForcesType&); -void operator<<(::xercesc::DOMElement&, const settings&); +void operator<<(::xml_schema::list_stream&, const ForcesType&); -void operator<<(::xercesc::DOMElement&, const particles&); +void operator<<(::xercesc::DOMElement&, const particle_source&); #include @@ -5166,4 +5625,4 @@ void operator<<(::xercesc::DOMElement&, const particles&); // // End epilogue. -#endif // SIMULATION_SCHEMA_H +#endif // SIMULATION_INPUT_SCHEMA_H diff --git a/src/io/xml_schemas/simulation_input/simulation_input_schema.xsd b/src/io/xml_schemas/simulation_input/simulation_input_schema.xsd new file mode 100644 index 000000000..bad82c029 --- /dev/null +++ b/src/io/xml_schemas/simulation_input/simulation_input_schema.xsd @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/io/output/vtk/parser/vtk-unstructured.cpp b/src/io/xml_schemas/vtu_file/vtu_file_schema.cpp similarity index 99% rename from src/io/output/vtk/parser/vtk-unstructured.cpp rename to src/io/xml_schemas/vtu_file/vtu_file_schema.cpp index e5904e817..07eb51529 100644 --- a/src/io/output/vtk/parser/vtk-unstructured.cpp +++ b/src/io/xml_schemas/vtu_file/vtu_file_schema.cpp @@ -36,7 +36,7 @@ // // End prologue. -#include "vtk-unstructured.h" +#include "vtu_file_schema.h" #include diff --git a/src/io/output/vtk/parser/vtk-unstructured.h b/src/io/xml_schemas/vtu_file/vtu_file_schema.h similarity index 99% rename from src/io/output/vtk/parser/vtk-unstructured.h rename to src/io/xml_schemas/vtu_file/vtu_file_schema.h index ab2431b2e..be307d50d 100644 --- a/src/io/output/vtk/parser/vtk-unstructured.h +++ b/src/io/xml_schemas/vtu_file/vtu_file_schema.h @@ -33,11 +33,11 @@ /** * @file - * @brief Generated from vtk-unstructured.xsd. + * @brief Generated from vtu_file_schema.xsd. */ -#ifndef VTK_UNSTRUCTURED_H -#define VTK_UNSTRUCTURED_H +#ifndef VTU_FILE_SCHEMA_H +#define VTU_FILE_SCHEMA_H #ifndef XSD_CXX11 #define XSD_CXX11 @@ -1753,8 +1753,9 @@ class PolyData_t : public ::xml_schema::type { /** * @brief Class corresponding to the %VTKFile_t schema type. * - * The hello_t type consists of a greeting phrase and a - * collection of names to which this greeting applies. + * The hello_t type consists of a greeting phrase and a collection of + * names + * to which this greeting applies. * * @nosubgrouping */ @@ -2818,8 +2819,9 @@ class Cells : public ::xml_schema::type { /** * @name Parsing functions for the %VTKFile document root. * - * The hello element is a root of the Hello XML vocabulary. - * Every conforming document should start with this element. + * The hello element is a root of the Hello XML vocabulary. Every + * conforming + * document should start with this element. */ //@{ @@ -3057,8 +3059,9 @@ void operator<<(::xercesc::DOMElement&, const VTKFile_t&); /** * @name Serialization functions for the %VTKFile document root. * - * The hello element is a root of the Hello XML vocabulary. - * Every conforming document should start with this element. + * The hello element is a root of the Hello XML vocabulary. Every + * conforming + * document should start with this element. */ //@{ @@ -3210,4 +3213,4 @@ void operator<<(::xercesc::DOMElement&, const Cells&); // // End epilogue. -#endif // VTK_UNSTRUCTURED_H +#endif // VTU_FILE_SCHEMA_H diff --git a/src/io/output/vtk/parser/vtk-unstructured.xsd b/src/io/xml_schemas/vtu_file/vtu_file_schema.xsd similarity index 54% rename from src/io/output/vtk/parser/vtk-unstructured.xsd rename to src/io/xml_schemas/vtu_file/vtu_file_schema.xsd index cd8faf230..587751fea 100644 --- a/src/io/output/vtk/parser/vtk-unstructured.xsd +++ b/src/io/xml_schemas/vtu_file/vtu_file_schema.xsd @@ -10,42 +10,42 @@ copyright : not copyrighted - public domain - - - - + + + + - + - - - - - - - - - - + + + + + + + + + + - - - - + + + + @@ -56,74 +56,70 @@ copyright : not copyrighted - public domain - + - + - + - + - - - - + + + + - + - - - + + + - - The hello_t type consists of a greeting phrase and a - collection of names to which this greeting applies. - + The hello_t type consists of a greeting phrase and a collection of names + to which this greeting applies. - + - - + + - - - - + + + + - - The hello element is a root of the Hello XML vocabulary. - Every conforming document should start with this element. - + The hello element is a root of the Hello XML vocabulary. Every conforming + document should start with this element. - + \ No newline at end of file diff --git a/src/io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.cpp b/src/io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.cpp new file mode 100644 index 000000000..4e30786da --- /dev/null +++ b/src/io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.cpp @@ -0,0 +1,16 @@ +#include "InternalToXSDTypeAdapter.h" + +ParticleType InternalToXSDTypeAdapter::convertToParticle(const Particle& particle) { + auto position = convertToVector(particle.getX()); + auto velocity = convertToVector(particle.getV()); + auto force = convertToVector(particle.getF()); + auto old_force = convertToVector(particle.getOldF()); + auto mass = particle.getM(); + auto type = particle.getType(); + + return ParticleType{position, velocity, force, old_force, mass, type}; +} + +DoubleVec3Type InternalToXSDTypeAdapter::convertToVector(const std::array& vector) { + return DoubleVec3Type{vector[0], vector[1], vector[2]}; +} diff --git a/src/io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.h b/src/io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.h new file mode 100644 index 000000000..7685be4e1 --- /dev/null +++ b/src/io/xml_schemas/xsd_type_adaptors/InternalToXSDTypeAdapter.h @@ -0,0 +1,11 @@ +#pragma once + +#include "io/xml_schemas/checkpoint/checkpoint_schema.h" +#include "particles/Particle.h" + +class InternalToXSDTypeAdapter { + public: + static ParticleType convertToParticle(const Particle& particle); + + static DoubleVec3Type convertToVector(const std::array& vector); +}; \ No newline at end of file diff --git a/src/io/input/xml/parser/XSDTypeAdapter.cpp b/src/io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.cpp similarity index 60% rename from src/io/input/xml/parser/XSDTypeAdapter.cpp rename to src/io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.cpp index 4924eed0b..489d84a35 100644 --- a/src/io/input/xml/parser/XSDTypeAdapter.cpp +++ b/src/io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.cpp @@ -1,12 +1,8 @@ -#include "XSDTypeAdapter.h" - -#include +#include "XSDToInternalTypeAdapter.h" #include "io/logger/Logger.h" -#include "utils/ArrayUtils.h" -#include "utils/MaxwellBoltzmannDistribution.h" -CuboidSpawner XSDTypeAdapter::convertToCuboidSpawner(const particles::cuboid_spawner_type& cuboid, bool third_dimension) { +CuboidSpawner XSDToInternalTypeAdapter::convertToCuboidSpawner(const CuboidSpawnerType& cuboid, bool third_dimension) { auto lower_left_front_corner = convertToVector(cuboid.lower_left_front_corner()); auto grid_dimensions = convertToVector(cuboid.grid_dim()); auto initial_velocity = convertToVector(cuboid.velocity()); @@ -45,7 +41,7 @@ CuboidSpawner XSDTypeAdapter::convertToCuboidSpawner(const particles::cuboid_spa initial_velocity, static_cast(type), third_dimension, temperature}; } -SphereSpawner XSDTypeAdapter::convertToSphereSpawner(const particles::sphere_spawner_type& sphere, bool third_dimension) { +SphereSpawner XSDToInternalTypeAdapter::convertToSphereSpawner(const SphereSpawnerType& sphere, bool third_dimension) { auto center = convertToVector(sphere.center()); auto initial_velocity = convertToVector(sphere.velocity()); @@ -79,27 +75,26 @@ SphereSpawner XSDTypeAdapter::convertToSphereSpawner(const particles::sphere_spa initial_velocity, static_cast(type), third_dimension, temperature}; } -Particle XSDTypeAdapter::convertToParticle(const particles::single_particle_type& particle, bool third_dimension) { +CuboidSpawner XSDToInternalTypeAdapter::convertToSingleParticleSpawner(const SingleParticleSpawnerType& particle, bool third_dimension) { auto position = convertToVector(particle.position()); - auto initial_velocity = - convertToVector(particle.velocity()) + maxwellBoltzmannDistributedVelocity(particle.temperature(), third_dimension ? 3 : 2); + auto initial_velocity = convertToVector(particle.velocity()); auto mass = particle.mass(); auto type = particle.type(); - return Particle{position, initial_velocity, mass, static_cast(type)}; + return CuboidSpawner{position, {1, 1, 1}, 0, mass, initial_velocity, static_cast(type), third_dimension, particle.temperature()}; } -std::variant XSDTypeAdapter::convertToParticleContainer( - const settings::particle_container_type& particle_container) { +std::variant XSDToInternalTypeAdapter::convertToParticleContainer( + const ParticleContainerType& particle_container) { std::variant container; if (particle_container.linkedcells_container().present()) { auto container_data = *particle_container.linkedcells_container(); - auto domain_size = XSDTypeAdapter::convertToVector(container_data.domain_size()); + auto domain_size = XSDToInternalTypeAdapter::convertToVector(container_data.domain_size()); auto cutoff_radius = container_data.cutoff_radius(); - auto boundary_conditions = XSDTypeAdapter::convertToBoundaryConditionsArray(container_data.boundary_conditions()); + auto boundary_conditions = XSDToInternalTypeAdapter::convertToBoundaryConditionsArray(container_data.boundary_conditions()); container = SimulationParams::LinkedCellsType(domain_size, cutoff_radius, boundary_conditions); } else if (particle_container.directsum_container().present()) { @@ -112,7 +107,7 @@ std::variant return container; } -std::array XSDTypeAdapter::convertToBoundaryConditionsArray( +std::array XSDToInternalTypeAdapter::convertToBoundaryConditionsArray( const BoundaryConditionsType& boundary) { std::array boundary_conditions; @@ -126,18 +121,19 @@ std::array XSDTypeAdapter::convertTo return boundary_conditions; } -LinkedCellsContainer::BoundaryCondition XSDTypeAdapter::convertToBoundaryCondition(const BoundaryType& boundary) { - if (boundary.outflow().present()) { - return LinkedCellsContainer::BoundaryCondition::OUTFLOW; - } else if (boundary.reflective().present()) { - return LinkedCellsContainer::BoundaryCondition::REFLECTIVE; - } else { - Logger::logger->error("Invalid boundary condition"); - exit(-1); +LinkedCellsContainer::BoundaryCondition XSDToInternalTypeAdapter::convertToBoundaryCondition(const BoundaryType& boundary) { + switch (boundary) { + case BoundaryType::value::Outflow: + return LinkedCellsContainer::BoundaryCondition::OUTFLOW; + case BoundaryType::value::Reflective: + return LinkedCellsContainer::BoundaryCondition::REFLECTIVE; + default: + Logger::logger->error("Boundary condition not implemented"); + exit(-1); } } -Thermostat XSDTypeAdapter::convertToThermostat(const ThermostatType& thermostat, bool third_dimension) { +Thermostat XSDToInternalTypeAdapter::convertToThermostat(const ThermostatType& thermostat, bool third_dimension) { auto target_temperature = thermostat.target_temperature(); auto max_temperature_change = thermostat.max_temperature_change(); auto application_interval = thermostat.application_interval(); @@ -160,6 +156,36 @@ Thermostat XSDTypeAdapter::convertToThermostat(const ThermostatType& thermostat, return Thermostat{target_temperature, max_temperature_change, static_cast(application_interval), third_dimension}; } -std::array XSDTypeAdapter::convertToVector(const DoubleVec3Type& vector) { return {vector.x(), vector.y(), vector.z()}; } +Particle XSDToInternalTypeAdapter::convertToParticle(const ParticleType& particle) { + auto position = XSDToInternalTypeAdapter::convertToVector(particle.position()); + auto velocity = XSDToInternalTypeAdapter::convertToVector(particle.velocity()); + auto force = XSDToInternalTypeAdapter::convertToVector(particle.force()); + auto old_force = XSDToInternalTypeAdapter::convertToVector(particle.old_force()); + auto type = particle.type(); + auto mass = particle.mass(); + + if (mass <= 0) { + Logger::logger->error("Particle mass must be positive"); + exit(-1); + } + + return Particle{position, velocity, force, old_force, mass, static_cast(type)}; +} + +std::vector XSDToInternalTypeAdapter::convertToForces(const SettingsType::force_sequence& forces) { + std::vector force_sources; + + for (ForcesType force : forces) { + std::string force_name = ForcesType::_xsd_ForcesType_literals_[force]; + + force_sources.push_back(force_name); + } + + return force_sources; +} + +std::array XSDToInternalTypeAdapter::convertToVector(const DoubleVec3Type& vector) { + return {vector.x(), vector.y(), vector.z()}; +} -std::array XSDTypeAdapter::convertToVector(const IntVec3Type& vector) { return {vector.x(), vector.y(), vector.z()}; } \ No newline at end of file +std::array XSDToInternalTypeAdapter::convertToVector(const IntVec3Type& vector) { return {vector.x(), vector.y(), vector.z()}; } diff --git a/src/io/input/xml/parser/XSDTypeAdapter.h b/src/io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.h similarity index 73% rename from src/io/input/xml/parser/XSDTypeAdapter.h rename to src/io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.h index b6c404c82..2d062897c 100644 --- a/src/io/input/xml/parser/XSDTypeAdapter.h +++ b/src/io/xml_schemas/xsd_type_adaptors/XSDToInternalTypeAdapter.h @@ -1,8 +1,10 @@ #pragma once +#include #include -#include "io/input/xml/parser/simulation_schema.h" +#include "io/xml_schemas/checkpoint/checkpoint_schema.h" +#include "io/xml_schemas/simulation_input/simulation_input_schema.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" #include "particles/spawners/cuboid/CuboidSpawner.h" #include "particles/spawners/sphere/SphereSpawner.h" @@ -11,7 +13,7 @@ /** * @brief Class to convert XSD types to internal types */ -class XSDTypeAdapter { +class XSDToInternalTypeAdapter { public: /** * @brief Converts a cuboid from the XSD format to the internal format @@ -20,7 +22,7 @@ class XSDTypeAdapter { * @param third_dimension Whether the third dimension is enabled * @return CuboidSpawner parsed from the given cuboid in the XSD format */ - static CuboidSpawner convertToCuboidSpawner(const particles::cuboid_spawner_type& cuboid, bool third_dimension); + static CuboidSpawner convertToCuboidSpawner(const CuboidSpawnerType& cuboid, bool third_dimension); /** * @brief Converts a sphere from the XSD format to the internal format @@ -29,7 +31,7 @@ class XSDTypeAdapter { * @param third_dimension Whether the third dimension is enabled * @return SphereSpawner parsed from the given sphere in the XSD format */ - static SphereSpawner convertToSphereSpawner(const particles::sphere_spawner_type& sphere, bool third_dimension); + static SphereSpawner convertToSphereSpawner(const SphereSpawnerType& sphere, bool third_dimension); /** * @brief Converts a particle from the XSD format to the internal format @@ -38,7 +40,7 @@ class XSDTypeAdapter { * @param third_dimension Whether the third dimension is enabled * @return Particle parsed from the given particle in the XSD format */ - static Particle convertToParticle(const particles::single_particle_type& particle, bool third_dimension); + static CuboidSpawner convertToSingleParticleSpawner(const SingleParticleSpawnerType& particle, bool third_dimension); /** * @brief Converts a container type from the XSD format to the internal format @@ -47,7 +49,7 @@ class XSDTypeAdapter { * @return ContainerType parsed from the given container type in the XSD format */ static std::variant convertToParticleContainer( - const settings::particle_container_type& container_type); + const ParticleContainerType& container_type); /** * @brief Converts a boundary conditions type from the XSD format to the internal format @@ -74,6 +76,22 @@ class XSDTypeAdapter { */ static Thermostat convertToThermostat(const ThermostatType& thermostat, bool third_dimension); + /** + * @brief Converts a particle type from the XSD format to the internal format + * + * @param particle Particle in the XSD format + * @return Particle parsed from the given particle in the XSD format + */ + static Particle convertToParticle(const ParticleType& particle); + + /** + * @brief Converts a force type from the XSD format to the internal format + * + * @param forces List of forces in the XSD format + * @return ForceSource in string format parsed from the given force type in the XSD format + */ + static std::vector convertToForces(const SettingsType::force_sequence& forces); + /** * @brief Converts a double vector from the XSD format to the internal format * diff --git a/src/particles/Particle.cpp b/src/particles/Particle.cpp index 1bbe4eeb9..69c9fddd0 100644 --- a/src/particles/Particle.cpp +++ b/src/particles/Particle.cpp @@ -39,6 +39,17 @@ Particle::Particle(std::array x_arg, std::array v_arg, dou Logger::logger->debug("Particle created"); } +Particle::Particle(std::array x_arg, std::array v_arg, std::array f_arg, std::array old_f_arg, + double m_arg, int type_arg) { + x = x_arg; + v = v_arg; + f = f_arg; + old_f = old_f_arg; + m = m_arg; + type = type_arg; + Logger::logger->debug("Particle created"); +} + Particle::~Particle() { Logger::logger->debug("Particle destroyed"); } void Particle::setX(const std::array& x_arg) { x = x_arg; } diff --git a/src/particles/Particle.h b/src/particles/Particle.h index fc14b13ab..9fa4f6d78 100644 --- a/src/particles/Particle.h +++ b/src/particles/Particle.h @@ -55,10 +55,10 @@ class Particle { Particle(const Particle& other); - Particle( - // for visualization, we need always 3 coordinates - // -> in case of 2d, we use only the first and the second - std::array x_arg, std::array v_arg, double m_arg, int type = 0); + Particle(std::array x_arg, std::array v_arg, double m_arg, int type = 0); + + Particle(std::array x_arg, std::array v_arg, std::array f_arg, std::array old_f_arg, + double m_arg, int type = 0); virtual ~Particle(); diff --git a/src/particles/containers/ParticleContainer.h b/src/particles/containers/ParticleContainer.h index cd9842c03..72f8f57dc 100644 --- a/src/particles/containers/ParticleContainer.h +++ b/src/particles/containers/ParticleContainer.h @@ -45,7 +45,7 @@ class ParticleContainer { * Applies the given force sources to the particles in the container. * Uses newton's third law to calculate the forces between the particles in an optimized way. */ - virtual void applyPairwiseForces(const std::vector>& force_sources) = 0; + virtual void applyPairwiseForces(const std::vector>& force_sources) = 0; /** * @brief Reserves space for n particles @@ -96,4 +96,10 @@ class ParticleContainer { * @return Const iterator to the end of the container */ [[nodiscard]] virtual std::vector::const_iterator end() const = 0; + + /** + * @brief Returns a vector of all particles in the container + * @return Vector of all particles in the container + */ + [[nodiscard]] virtual const std::vector& getParticles() const = 0; }; \ No newline at end of file diff --git a/src/particles/containers/directsum/DirectSumContainer.cpp b/src/particles/containers/directsum/DirectSumContainer.cpp index 43cbb6547..bdd939ee4 100644 --- a/src/particles/containers/directsum/DirectSumContainer.cpp +++ b/src/particles/containers/directsum/DirectSumContainer.cpp @@ -24,7 +24,9 @@ std::vector::const_iterator DirectSumContainer::begin() const { return std::vector::const_iterator DirectSumContainer::end() const { return particles.end(); } -void DirectSumContainer::applyPairwiseForces(const std::vector>& force_sources) { +const std::vector& DirectSumContainer::getParticles() const { return particles; } + +void DirectSumContainer::applyPairwiseForces(const std::vector>& force_sources) { for (auto it1 = particles.begin(); it1 != particles.end(); ++it1) { for (auto it2 = (it1 + 1); it2 != particles.end(); ++it2) { std::array total_force{0, 0, 0}; diff --git a/src/particles/containers/directsum/DirectSumContainer.h b/src/particles/containers/directsum/DirectSumContainer.h index b6e80c005..c282e540b 100644 --- a/src/particles/containers/directsum/DirectSumContainer.h +++ b/src/particles/containers/directsum/DirectSumContainer.h @@ -3,9 +3,7 @@ #include #include -#include "particles/Particle.h" #include "particles/containers/ParticleContainer.h" -#include "physics/forces/ForceSource.h" /** * @brief Wrapper class for a set of particles @@ -127,6 +125,12 @@ class DirectSumContainer : public ParticleContainer { */ [[nodiscard]] std::vector::const_iterator end() const override; + /** + * @brief Returns a vector of all particles in the container + * @return Vector of all particles in the container + */ + [[nodiscard]] const std::vector& getParticles() const override; + /** * @brief Applies the given force sources to the particles * @@ -135,5 +139,5 @@ class DirectSumContainer : public ParticleContainer { * Applies the given force sources to the particles in the container. * Uses newton's third law to calculate the forces between the particles in a more optimized way. */ - void applyPairwiseForces(const std::vector>& force_sources) override; + void applyPairwiseForces(const std::vector>& force_sources) override; }; diff --git a/src/particles/containers/linkedcells/LinkedCellsContainer.cpp b/src/particles/containers/linkedcells/LinkedCellsContainer.cpp index 77a9e4634..2015c79cb 100644 --- a/src/particles/containers/linkedcells/LinkedCellsContainer.cpp +++ b/src/particles/containers/linkedcells/LinkedCellsContainer.cpp @@ -94,6 +94,8 @@ LinkedCellsContainer::LinkedCellsContainer(const std::array& _domain_ // reserve the memory for the particles to prevent reallocation during insertion particles.reserve(_n); + Logger::logger->info("Created LinkedCellsContainer with boundaries [{}, {}, {}] and cutoff radius {}", domain_size[0], domain_size[1], + domain_size[2], cutoff_radius); Logger::logger->info("Created LinkedCellsContainer with {} domain cells (of which {} are at the boundary) and {} halo cells", domain_cell_references.size(), boundary_cell_references.size(), halo_cell_references.size()); Logger::logger->info("Cells per dimension: [{}, {}, {}]", domain_num_cells[0], domain_num_cells[1], domain_num_cells[2]); @@ -104,12 +106,12 @@ void LinkedCellsContainer::addParticle(const Particle& p) { Cell* cell = particlePosToCell(p.getX()); if (cell == nullptr) { - Logger::logger->error("Particle to insert is out of bounds"); - return; + Logger::logger->error("Particle to insert is out of bounds, position: [{}, {}, {}]", p.getX()[0], p.getX()[1], p.getX()[2]); + throw std::runtime_error("Attempted to insert particle out of bounds"); } if (cell->getCellType() == Cell::CellType::HALO) { - Logger::logger->warn("Particle to insert is in halo cell"); - return; + Logger::logger->warn("Particle to insert is in halo cell. Position: [{}, {}, {}]", p.getX()[0], p.getX()[1], p.getX()[2]); + throw std::runtime_error("Attempted to insert particle into halo cell"); } size_t old_capacity = particles.capacity(); @@ -126,12 +128,12 @@ void LinkedCellsContainer::addParticle(Particle&& p) { Cell* cell = particlePosToCell(p.getX()); if (cell == nullptr) { - Logger::logger->warn("Particle to insert is out of bounds"); - return; + Logger::logger->error("Particle to insert is outside of cells. Position: [{}, {}, {}]", p.getX()[0], p.getX()[1], p.getX()[2]); + throw std::runtime_error("Attempted to insert particle out of bounds"); } if (cell->getCellType() == Cell::CellType::HALO) { - Logger::logger->warn("Particle to insert is in halo cell"); - return; + Logger::logger->warn("Particle to insert is in halo cell. Position: [{}, {}, {}]", p.getX()[0], p.getX()[1], p.getX()[2]); + throw std::runtime_error("Attempted to insert particle into halo cell"); } size_t old_capacity = particles.capacity(); @@ -144,7 +146,7 @@ void LinkedCellsContainer::addParticle(Particle&& p) { } } -void LinkedCellsContainer::applyPairwiseForces(const std::vector>& force_sources) { +void LinkedCellsContainer::applyPairwiseForces(const std::vector>& force_sources) { // remove all particles in the halo cells from the particles vector deleteHaloParticles(); @@ -186,7 +188,7 @@ void LinkedCellsContainer::applyPairwiseForces(const std::vectorgetParticleReferences()) { if (ArrayUtils::L2Norm(p->getX() - neighbour_particle->getX()) > cutoff_radius) continue; - for (const std::unique_ptr& force_source : force_sources) { + for (const auto& force_source : force_sources) { std::array force = force_source->calculateForce(*p, *neighbour_particle); p->setF(p->getF() + force); neighbour_particle->setF(neighbour_particle->getF() - force); @@ -222,6 +224,8 @@ std::vector::const_iterator LinkedCellsContainer::begin() const { retu std::vector::const_iterator LinkedCellsContainer::end() const { return particles.end(); } +const std::vector& LinkedCellsContainer::getParticles() const { return particles; } + const std::array& LinkedCellsContainer::getDomainSize() const { return domain_size; } double LinkedCellsContainer::getCutoffRadius() const { return cutoff_radius; } @@ -250,8 +254,8 @@ Cell* LinkedCellsContainer::particlePosToCell(double x, double y, double z) { int cell_index = cellCoordToCellIndex(cx, cy, cz); if (cell_index == -1) { - Logger::logger->error("Particle not in cells"); - return nullptr; + Logger::logger->error("Particle is outside of cells. Position: [{}, {}, {}]", x, y, z); + throw std::runtime_error("A particle is outside of the cells"); } return &cells[cell_index]; @@ -359,11 +363,6 @@ void LinkedCellsContainer::updateCellsParticleReferences() { for (Particle& p : particles) { Cell* cell = particlePosToCell(p.getX()); - if (cell == nullptr) { - Logger::logger->error("Particle reference update: Particle is out of bounds"); - continue; - } - occupied_cells_references.insert(cell); cell->addParticleReference(&p); } diff --git a/src/particles/containers/linkedcells/LinkedCellsContainer.h b/src/particles/containers/linkedcells/LinkedCellsContainer.h index 19bf7d12a..976b3c20b 100644 --- a/src/particles/containers/linkedcells/LinkedCellsContainer.h +++ b/src/particles/containers/linkedcells/LinkedCellsContainer.h @@ -106,7 +106,7 @@ class LinkedCellsContainer : public ParticleContainer { */ std::unordered_set occupied_cells_references; - // Boundary cell references with respect to x axis pointing to the right, y axis pointing up and z axis pointing out of the screen + // Boundary cell references with respect to x-axis pointing to the right, y-axis pointing up and z axis pointing out of the screen /** * @brief References to the boundary cells on the left (x = 0) @@ -209,7 +209,7 @@ class LinkedCellsContainer : public ParticleContainer { * Additionally to the functionality of the `ParticleContainer` class, this method uses the internal cell structure to * reduce the number of force calculations necessary, depending on the cutoff radius. */ - void applyPairwiseForces(const std::vector>& force_sources) override; + void applyPairwiseForces(const std::vector>& force_sources) override; /** * @brief Reserves space for n particles. This is useful if the number of particles is known in advance @@ -262,6 +262,12 @@ class LinkedCellsContainer : public ParticleContainer { */ std::vector::const_iterator end() const override; + /** + * @brief Returns a vector of all particles in the container + * @return Vector of all particles in the container + */ + [[nodiscard]] const std::vector& getParticles() const override; + /** * @brief Returns the domain size * diff --git a/src/particles/spawners/ParticleSpawner.h b/src/particles/spawners/ParticleSpawner.h index 2ad69dde2..732981531 100644 --- a/src/particles/spawners/ParticleSpawner.h +++ b/src/particles/spawners/ParticleSpawner.h @@ -1,6 +1,8 @@ #pragma once -#include "particles/containers/ParticleContainer.h" +#include + +#include "particles/Particle.h" /** * @brief Interface for particle spawner classes @@ -12,11 +14,11 @@ class ParticleSpawner { public: /** * @brief Spawns particles in the given container - * @param particle_container Container to spawn particles in - * + * @param particles A vector of particles to spawn + * @return Number of particles spawned * Spawns particles in the given container. */ - virtual void spawnParticles(std::unique_ptr& particle_container) const = 0; + virtual int spawnParticles(std::vector& particles) const = 0; /** * @brief Estimate the number of particles to be spawned diff --git a/src/particles/spawners/cuboid/CuboidSpawner.cpp b/src/particles/spawners/cuboid/CuboidSpawner.cpp index 761f49fe4..cc3acfac2 100644 --- a/src/particles/spawners/cuboid/CuboidSpawner.cpp +++ b/src/particles/spawners/cuboid/CuboidSpawner.cpp @@ -3,7 +3,6 @@ #include "particles/Particle.h" #include "physics/thermostats/Thermostat.h" #include "utils/ArrayUtils.h" -#include "utils/MaxwellBoltzmannDistribution.h" CuboidSpawner::CuboidSpawner(const std::array& lower_left_corner, const std::array& grid_dimensions, double grid_spacing, double mass, const std::array& initial_velocity, int type, bool third_dimension, @@ -17,7 +16,9 @@ CuboidSpawner::CuboidSpawner(const std::array& lower_left_corner, con third_dimension(third_dimension), initial_temperature(initial_temperature) {} -void CuboidSpawner::spawnParticles(std::unique_ptr& particle_container) const { +int CuboidSpawner::spawnParticles(std::vector& particles) const { + particles.reserve(particles.size() + getEstimatedNumberOfParticles()); + int num_particles_spawned = 0; for (int i = 0; i < grid_dimensions[0]; i++) { for (int j = 0; j < grid_dimensions[1]; j++) { for (int k = 0; k < grid_dimensions[2]; k++) { @@ -27,10 +28,11 @@ void CuboidSpawner::spawnParticles(std::unique_ptr& particle_ Particle particle(x, initial_velocity, mass, type); Thermostat::setParticleTemperature(initial_temperature, particle, third_dimension ? 3 : 2); - particle_container->addParticle(std::move(particle)); + particles.push_back(std::move(particle)); } } } + return num_particles_spawned; } size_t CuboidSpawner::getEstimatedNumberOfParticles() const { diff --git a/src/particles/spawners/cuboid/CuboidSpawner.h b/src/particles/spawners/cuboid/CuboidSpawner.h index 7116f769d..f70854ad1 100644 --- a/src/particles/spawners/cuboid/CuboidSpawner.h +++ b/src/particles/spawners/cuboid/CuboidSpawner.h @@ -73,11 +73,11 @@ class CuboidSpawner : public ParticleSpawner { /** * @brief Spawns particles in the given container - * @param particle_container Container to spawn particles in - * + * @param particles A vector of particles to spawn + * @return Number of particles spawned * Spawns particles in the given container. */ - void spawnParticles(std::unique_ptr& particle_container) const override; + int spawnParticles(std::vector& particles) const override; /** * @brief Estimate the number of particles to be spawned diff --git a/src/particles/spawners/sphere/SphereSpawner.cpp b/src/particles/spawners/sphere/SphereSpawner.cpp index a6c6966c3..55c2966bb 100644 --- a/src/particles/spawners/sphere/SphereSpawner.cpp +++ b/src/particles/spawners/sphere/SphereSpawner.cpp @@ -3,7 +3,6 @@ #include "particles/Particle.h" #include "physics/thermostats/Thermostat.h" #include "utils/ArrayUtils.h" -#include "utils/MaxwellBoltzmannDistribution.h" SphereSpawner::SphereSpawner(const std::array& center, const int sphere_radius, double grid_spacing, double mass, const std::array& initial_velocity, int type, bool third_dimension, double initial_temperature) @@ -16,7 +15,9 @@ SphereSpawner::SphereSpawner(const std::array& center, const int sphe initial_temperature(initial_temperature), third_dimension(third_dimension) {} -void SphereSpawner::spawnParticles(std::unique_ptr& particle_container) const { +int SphereSpawner::spawnParticles(std::vector& particles) const { + particles.reserve(particles.size() + getEstimatedNumberOfParticles()); + int num_particles_spawned = 0; for (int x = -sphere_radius; x <= sphere_radius; x++) { for (int y = -sphere_radius; y <= sphere_radius; y++) { for (int z = -sphere_radius; z <= sphere_radius; z++) { @@ -32,11 +33,13 @@ void SphereSpawner::spawnParticles(std::unique_ptr& particle_ Particle particle(position, initial_velocity, mass, type); Thermostat::setParticleTemperature(initial_temperature, particle, third_dimension ? 3 : 2); - particle_container->addParticle(std::move(particle)); + particles.push_back(std::move(particle)); + num_particles_spawned++; } } } } + return num_particles_spawned; } size_t SphereSpawner::getEstimatedNumberOfParticles() const { return static_cast(4.0 / 3.0 * M_PI * std::pow(sphere_radius, 3)); } \ No newline at end of file diff --git a/src/particles/spawners/sphere/SphereSpawner.h b/src/particles/spawners/sphere/SphereSpawner.h index 09d824515..bf9ad0399 100644 --- a/src/particles/spawners/sphere/SphereSpawner.h +++ b/src/particles/spawners/sphere/SphereSpawner.h @@ -1,7 +1,5 @@ #pragma once -#include - #include "particles/spawners/ParticleSpawner.h" /** @@ -46,11 +44,11 @@ class SphereSpawner : public ParticleSpawner { /** * @brief Spawns particles in the given container - * @param particle_container Container to spawn particles in - * + * @param particles A vector of particles to spawn + * @return Number of particles spawned * Spawns particles in the given container. */ - void spawnParticles(std::unique_ptr& particle_container) const override; + int spawnParticles(std::vector& particles) const override; /** * @brief Returns the number of particles to be spawned diff --git a/src/physics/forces/ForcePicker.cpp b/src/physics/forces/ForcePicker.cpp new file mode 100644 index 000000000..430b75c99 --- /dev/null +++ b/src/physics/forces/ForcePicker.cpp @@ -0,0 +1,19 @@ +#include "ForcePicker.h" + +#include + +#include "io/logger/Logger.h" +#include "physics/forces/GravitationalForce.h" +#include "physics/forces/LennardJonesForce.h" + +std::map> ForcePicker::get_supported_forces() { + std::map> force_names; + + auto lennardjones = std::make_shared(); + auto gravitational = std::make_shared(); + + force_names.insert({std::string(*lennardjones), lennardjones}); + force_names.insert({std::string(*gravitational), gravitational}); + + return force_names; +} diff --git a/src/physics/forces/ForcePicker.h b/src/physics/forces/ForcePicker.h new file mode 100644 index 000000000..4aee4fdc1 --- /dev/null +++ b/src/physics/forces/ForcePicker.h @@ -0,0 +1,12 @@ +#pragma once + +#include +#include +#include + +#include "physics/forces/ForceSource.h" + +class ForcePicker { + public: + static std::map> get_supported_forces(); +}; diff --git a/src/physics/forces/GravitationalForce.cpp b/src/physics/forces/GravitationalForce.cpp index 1506c8cec..6ad59c533 100644 --- a/src/physics/forces/GravitationalForce.cpp +++ b/src/physics/forces/GravitationalForce.cpp @@ -9,6 +9,6 @@ std::array GravitationalForce::calculateForce(Particle& p, Particle const auto f_gravity = (p.getM() * q.getM() / (std::pow(dist, 3))) * displacement; return f_gravity; -}; +} -GravitationalForce::operator std::string() const { return "Gravity"; }; \ No newline at end of file +GravitationalForce::operator std::string() const { return "Gravitational"; } \ No newline at end of file diff --git a/src/physics/forces/LennardJonesForce.cpp b/src/physics/forces/LennardJonesForce.cpp index bcc2c4665..48021cb84 100644 --- a/src/physics/forces/LennardJonesForce.cpp +++ b/src/physics/forces/LennardJonesForce.cpp @@ -12,4 +12,4 @@ std::array LennardJonesForce::calculateForce(Particle& p, Particle& return f_lennard_jones; }; -LennardJonesForce::operator std::string() const { return "Lennard-Jones"; }; \ No newline at end of file +LennardJonesForce::operator std::string() const { return "LennardJones"; }; \ No newline at end of file diff --git a/src/physics/forces/LennardJonesForce.h b/src/physics/forces/LennardJonesForce.h index c87626929..d3d5e0142 100644 --- a/src/physics/forces/LennardJonesForce.h +++ b/src/physics/forces/LennardJonesForce.h @@ -20,7 +20,7 @@ class LennardJonesForce : public ForceSource { const double sigma; public: - explicit LennardJonesForce(double epsilon = 5.0, double sigma = 1.0) : epsilon(epsilon), sigma(sigma) {} + explicit LennardJonesForce(double epsilon = 1.0, double sigma = 1.2) : epsilon(epsilon), sigma(sigma) {} /** * @brief Calculates the Lennard-Jones forces between two particles diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index ab07a9695..a0d5fc420 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -8,40 +8,68 @@ #include "integration/VerletFunctor.h" #include "io/logger/Logger.h" +#include "particles/containers/directsum/DirectSumContainer.h" +#include "particles/containers/linkedcells/LinkedCellsContainer.h" #include "utils/FormatTime.h" -Simulation::Simulation(std::unique_ptr& particles, const std::vector>& forces, - const SimulationParams& simulation_params, IntegrationMethod integration_method) - : particles(particles), - delta_t(simulation_params.delta_t), +void printProgress(const std::string& input_file_path, size_t percentage, size_t iteration, size_t expected_iterations, + int estimated_remaining_seconds, bool finished = false) { + auto file_name = std::filesystem::path(input_file_path).stem().string(); + + std::string progress = fmt::format("[{}{}] Iteration: {}/{}, {:>3}%, ETA: {} - [{}]", ansi_blue_bold + std::string(percentage, '#'), + std::string(100 - percentage, ' ') + ansi_end, iteration, expected_iterations, percentage, + format_seconds_eta(estimated_remaining_seconds), file_name); + + std::cout << progress << "\r" << (finished ? "\n" : "") << std::flush; +} + +Simulation::Simulation(const std::vector& initial_particles, const SimulationParams& simulation_params, + IntegrationMethod integration_method) + : delta_t(simulation_params.delta_t), simulation_end_time(simulation_params.end_time), - file_output_handler(FileOutputHandler(simulation_params.output_format, simulation_params.output_dir_path)), + file_output_handler(FileOutputHandler(simulation_params)), fps(simulation_params.fps), video_length(simulation_params.video_length), simulation_params(simulation_params), - forces(forces), - thermostat(std::move(simulation_params.thermostat)) { + forces(simulation_params.forces), + thermostat(simulation_params.thermostat) { + // Create particle container + if (std::holds_alternative(simulation_params.container_type)) { + auto linked_cells = std::get(simulation_params.container_type); + particles = + std::make_unique(linked_cells.domain_size, linked_cells.cutoff_radius, linked_cells.boundary_conditions); + } else if (std::holds_alternative(simulation_params.container_type)) { + particles = std::make_unique(); + } else { + throw std::runtime_error("Unknown container type"); + } + + // Add particles to container + particles->reserve(initial_particles.size()); + for (auto& particle : initial_particles) { + particles->addParticle(particle); + } + switch (integration_method) { case IntegrationMethod::VERLET: integration_functor = std::make_unique(); break; default: Logger::logger->error("Integration method not implemented."); - exit(1); + exit(-1); } } SimulationOverview Simulation::runSimulation() { - int iteration = 0; + size_t iteration = 0; double simulation_time = 0; - const size_t expected_iterations = simulation_end_time / delta_t; - const size_t fill_width = log10(expected_iterations) + 1; + const size_t expected_iterations = std::floor(simulation_end_time / delta_t); bool no_output = fps == 0 || video_length == 0; const size_t save_every_nth_iteration = - no_output ? std::numeric_limits::max() : std::max(expected_iterations / (fps * video_length), 1ul); + no_output ? expected_iterations / 100 : std::max(expected_iterations / (fps * video_length), 1ul); Logger::logger->info("Simulation started..."); @@ -50,27 +78,28 @@ SimulationOverview Simulation::runSimulation() { // keep track of time for progress high precision auto start_time = std::chrono::high_resolution_clock::now(); - auto t_now = start_time; + auto t_prev = start_time; while (simulation_time < simulation_end_time) { - if (!no_output && iteration % save_every_nth_iteration == 0) { + if (iteration % save_every_nth_iteration == 0) { // calculate time since last write - t_now = std::chrono::high_resolution_clock::now(); + auto t_now = std::chrono::high_resolution_clock::now(); const double seconds_since_last_write = std::chrono::duration(t_now - t_prev).count(); t_prev = t_now; // calculate estimated remaining time - const size_t estimated_remaining_seconds = - (expected_iterations - iteration) * seconds_since_last_write / save_every_nth_iteration; + const int estimated_remaining_seconds = + std::floor(seconds_since_last_write * static_cast(expected_iterations - iteration) / + static_cast(save_every_nth_iteration)); const size_t percentage = 100 * iteration / expected_iterations; - Logger::logger->info("Iteration {:>{}}/{} finished {:>3}% (ETA: {})", iteration, fill_width, expected_iterations, percentage, - format_seconds_eta(estimated_remaining_seconds)); + printProgress(simulation_params.input_file_path, percentage, iteration, expected_iterations, estimated_remaining_seconds); - // write output - file_output_handler.writeFile(iteration, particles); + if (!no_output) { + file_output_handler.writeFile(iteration, particles); + } } integration_functor->step(particles, forces, delta_t); @@ -83,13 +112,19 @@ SimulationOverview Simulation::runSimulation() { simulation_time += delta_t; } + printProgress(simulation_params.input_file_path, 100, expected_iterations, expected_iterations, 0, true); + Logger::logger->info("Simulation finished."); - auto total_simulation_time = + auto total_simulation_time_ms = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start_time).count(); - return SimulationOverview{total_simulation_time / 1000.0, total_simulation_time / static_cast(iteration - 1), - static_cast(iteration), expected_iterations / save_every_nth_iteration}; + return SimulationOverview{simulation_params, + static_cast(total_simulation_time_ms) / 1000.0, + static_cast(total_simulation_time_ms) / static_cast(iteration), + static_cast(iteration), + expected_iterations / save_every_nth_iteration + 1, + std::vector(particles->begin(), particles->end())}; } SimulationOverview Simulation::runSimulationPerfTest() { @@ -118,15 +153,19 @@ SimulationOverview Simulation::runSimulationPerfTest() { auto total_simulation_time = std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - start_time).count(); - SimulationOverview overview{total_simulation_time / 1000.0, total_simulation_time / static_cast(iteration), - static_cast(iteration), 0}; + SimulationOverview overview{simulation_params, + static_cast(total_simulation_time) / 1000.0, + static_cast(total_simulation_time) / static_cast(iteration), + static_cast(iteration), + 0, + std::vector(particles->begin(), particles->end())}; savePerformanceTest(overview, simulation_params, initial_particle_count); return overview; } -void Simulation::savePerformanceTest(const SimulationOverview& overview, const SimulationParams& params, size_t num_particles) const { +void Simulation::savePerformanceTest(const SimulationOverview& overview, const SimulationParams& params, size_t num_particles) { if (!std::filesystem::exists(params.output_dir_path)) { std::filesystem::create_directories(params.output_dir_path); } @@ -143,9 +182,9 @@ void Simulation::savePerformanceTest(const SimulationOverview& overview, const S std::string container_type_string; if (std::holds_alternative(params.container_type)) { - container_type_string = std::get(params.container_type); + container_type_string = std::string(std::get(params.container_type)); } else if (std::holds_alternative(params.container_type)) { - container_type_string = std::get(params.container_type); + container_type_string = std::string(std::get(params.container_type)); } else { Logger::logger->error("Invalid container type when saving performance test"); exit(-1); diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 439ce1802..d412feaa4 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -1,10 +1,10 @@ #pragma once -#include #include #include "integration/IntegrationFunctor.h" #include "io/output/FileOutputHandler.h" +#include "particles/Particle.h" #include "particles/containers/ParticleContainer.h" #include "simulation/SimulationOverview.h" #include "simulation/SimulationParams.h" @@ -15,11 +15,6 @@ * This class collects all the components needed to run a simulation, and provides a method to run it. */ class Simulation { - /** - * @brief Reference to the `ParticleContainer` on whose content the simulation is performed - */ - std::unique_ptr& particles; - /** * @brief Time step per iteration. This specifies the accuracy of the simulation */ @@ -51,12 +46,17 @@ class Simulation { const SimulationParams& simulation_params; /** - * @brief Vector of forces which are applied in the simulation + * @brief Vector of force sources which are used to calculate the new forces + */ + const std::vector> forces; + + /** + * @brief Reference to the `ParticleContainer` on whose content the simulation is performed */ - const std::vector>& forces; + std::unique_ptr particles; /** - * @brief Integration functor used to integrate the particles + * @brief Functor used to integrate the particles */ std::unique_ptr integration_functor; @@ -72,12 +72,11 @@ class Simulation { * @brief Construct a new Simulation object and initialize all the necessary components * * @param particles Reference to the `ParticleContainer` on whose content the simulation is performed - * @param forces Vector of forces which are applied in the simulation * @param simulation_params Parameters for the simulation. See the class `SimulationParams` for more information * @param integration_method The integration method to use for the simulation (Default: `IntegrationMethod::VERLET`) */ - Simulation(std::unique_ptr& particles, const std::vector>& forces, - const SimulationParams& simulation_params, IntegrationMethod integration_method = IntegrationMethod::VERLET); + Simulation(const std::vector& particles, const SimulationParams& simulation_params, + IntegrationMethod integration_method = IntegrationMethod::VERLET); /** * @brief Runs the simulation, using the parameters given at construction and returns a `SimulationOverview` object containing some data @@ -87,7 +86,7 @@ class Simulation { SimulationOverview runSimulation(); /** - * @brief Runs the simulation without any output for logging- or vtk/xyz-files, using the parameters given at construction and returns a + * @brief Runs the simulation without any output for logging- or vtu/xyz-files, using the parameters given at construction and returns a * `SimulationOverview` object containing some data * * @return SimulationOverview object containing some data about the simulation performed @@ -95,5 +94,5 @@ class Simulation { SimulationOverview runSimulationPerfTest(); private: - void savePerformanceTest(const SimulationOverview& overview, const SimulationParams& params, size_t num_particles) const; + static void savePerformanceTest(const SimulationOverview& overview, const SimulationParams& params, size_t num_particles); }; \ No newline at end of file diff --git a/src/simulation/SimulationOverview.cpp b/src/simulation/SimulationOverview.cpp new file mode 100644 index 000000000..3f5d36544 --- /dev/null +++ b/src/simulation/SimulationOverview.cpp @@ -0,0 +1,19 @@ +#include "SimulationOverview.h" + +#include "io/logger/Logger.h" +#include "utils/FormatTime.h" + +void SimulationOverview::logSummary(int depth) const { + std::string indent = std::string(depth * 2, ' '); + + Logger::logger->info("{}╔════════════════════════════════════════", indent); + Logger::logger->info("{}╟┤{}Simulation overview: {}", indent, ansi_yellow_bold, ansi_end); + Logger::logger->info("{}║ Input file: {}", indent, simulation_params.input_file_path); + Logger::logger->info("{}║ Output directory: {}", indent, simulation_params.output_dir_path); + Logger::logger->info("{}║ Simulation time: {}", indent, format_seconds_total(total_time_seconds)); + Logger::logger->info("{}║ Number of iterations: {}", indent, total_iterations); + Logger::logger->info("{}║ Average iteration time: {:.3f}ms", indent, average_time_per_iteration_millis); + Logger::logger->info("{}║ Number of files written: {}", indent, files_written); + Logger::logger->info("{}║ Number of particles left: {}", indent, resulting_particles.size()); + Logger::logger->info("{}╚════════════════════════════════════════", indent); +} diff --git a/src/simulation/SimulationOverview.h b/src/simulation/SimulationOverview.h index 338a3edf1..0101c7dd7 100644 --- a/src/simulation/SimulationOverview.h +++ b/src/simulation/SimulationOverview.h @@ -3,28 +3,47 @@ #include #include +#include "particles/containers/ParticleContainer.h" +#include "simulation/SimulationParams.h" + /** * @brief Class to store some overview data of an executed simulation */ class SimulationOverview { public: + /** + * @brief Original simulation parameters bevore the simulation + */ + SimulationParams simulation_params; + /** * @brief Total time the simulation took to execute in seconds (includes time for writing output files and logging) */ - const double total_time_seconds; + double total_time_seconds; /** * @brief Average time the simulation took to execute per iteration in milliseconds (includes time for writing output files and logging) */ - const double average_time_per_iteration_millis; + double average_time_per_iteration_millis; /** * @brief Total number of iterations the simulation ran for (includes an initial force calculation) */ - const size_t total_iterations; + size_t total_iterations; /** * @brief Number of output files written */ - const size_t files_written; + size_t files_written; + + /** + * @brief Resulting particles after the simulation + */ + std::vector resulting_particles; + + /** + * @brief Prints a summary of the simulation overview to the logger + * @param depth determines the indentation of the log message + */ + void logSummary(int depth = 0) const; }; \ No newline at end of file diff --git a/src/simulation/SimulationParams.cpp b/src/simulation/SimulationParams.cpp index c4685cfa0..46324b1b9 100644 --- a/src/simulation/SimulationParams.cpp +++ b/src/simulation/SimulationParams.cpp @@ -1,17 +1,64 @@ #include "SimulationParams.h" #include +#include +#include #include "io/logger/Logger.h" +#include "io/output/OutputFormats.h" +#include "physics/forces/ForcePicker.h" + +std::string construct_output_path(const std::string& base_path, const std::string& input_file_path) { + auto base = base_path; + + if (base.empty()) { + base = "./output"; + } -std::string construct_output_path(const std::string& input_file_path) { std::filesystem::path input_path{input_file_path}; - return "./output/" + std::string(input_path.stem()) + "/"; -}; + return base + "/" + input_path.stem().string(); +} + +auto convertToForces(const std::vector& force_strings) { + auto supported = ForcePicker::get_supported_forces(); + + std::vector> forces; + for (auto& force_s : force_strings) { + if (!supported.contains(force_s)) { + auto supported_forces = std::string(); + for (auto& [name, force] : supported) { + supported_forces += name + ", "; + } + + Logger::logger->error("Invalid force given: {}. Supported forces are: {}", force_s, supported_forces); + exit(-1); + } + forces.push_back(supported[force_s]); + } + return forces; +} + +auto convertToOutputFormat(const std::string& output_format) { + auto supported = get_supported_output_formats(); + + if (!supported.contains(output_format)) { + auto supported_formats = std::string(); + for (auto& [name, format] : supported) { + supported_formats += name + ", "; + } + + Logger::logger->error("Invalid output format given: {}. Supported output formats are: {}", output_format, supported_formats); + exit(-1); + } + + return supported[output_format]; +} SimulationParams::SimulationParams(const std::string& input_file_path, const std::string& output_dir_path, double delta_t, double end_time, int fps, int video_length, const std::variant& container_type, - const Thermostat& thermostat, const std::string& output_format, bool performance_test) + const Thermostat& thermostat, const std::string& output_format, + const std::vector& force_strings, bool performance_test, bool fresh, + const std::string& base_path) : input_file_path(input_file_path), delta_t(delta_t), end_time(end_time), @@ -19,7 +66,9 @@ SimulationParams::SimulationParams(const std::string& input_file_path, const std video_length(video_length), container_type(container_type), thermostat(thermostat), - performance_test(performance_test) { + forces(convertToForces(force_strings)), + performance_test(performance_test), + fresh(fresh) { if (fps < 0) { Logger::logger->error("FPS must be positive"); exit(-1); @@ -37,20 +86,85 @@ SimulationParams::SimulationParams(const std::string& input_file_path, const std exit(-1); } - if (output_format == "vtk") { - this->output_format = FileOutputHandler::OutputFormat::VTK; - } else if (output_format == "xyz") { - this->output_format = FileOutputHandler::OutputFormat::XYZ; - } else if (output_format == "none") { - this->output_format = FileOutputHandler::OutputFormat::NONE; - } else { - Logger::logger->error("Invalid output format given"); - exit(-1); - } + this->output_format = convertToOutputFormat(output_format); if (output_dir_path.empty()) { - this->output_dir_path = construct_output_path(input_file_path); + this->output_dir_path = construct_output_path(base_path, input_file_path); } else { this->output_dir_path = output_dir_path; } + + // calculate hash + if (input_file_path.empty()) { + this->input_file_hash = 0; + } else { + auto first_space = input_file_path.find(' '); + if (first_space == std::string::npos) { + first_space = input_file_path.size(); + } + + std::string real_input_file_path = input_file_path.substr(0, first_space); + std::ifstream input_file(real_input_file_path); + + auto buffer = std::stringstream(); + buffer << input_file.rdbuf(); + + std::hash hasher; + auto hash = hasher(buffer.str()); + this->input_file_hash = hash; + } + + this->num_particles = 0; +} + +void SimulationParams::logSummary(int depth) const { + std::string indent = std::string(depth * 2, ' '); + + std::string force_names = + std::accumulate(forces.begin(), forces.end(), std::string{}, + [](const std::string& acc, const std::shared_ptr& force) { return acc + std::string(*force) + ", "; }); + + Logger::logger->info("{}╔════════════════════════════════════════", indent); + Logger::logger->info("{}╟┤{}Simulation arguments: {}", indent, ansi_yellow_bold, ansi_end); + Logger::logger->info("{}║ Input file path: {}", indent, input_file_path); + Logger::logger->info("{}║ Output directory path: {}", indent, output_dir_path); + Logger::logger->info("{}║ Delta_t: {}", indent, delta_t); + Logger::logger->info("{}║ End_time: {}", indent, end_time); + Logger::logger->info("{}║ Reuse cached data: {}", indent, !fresh); + + Logger::logger->info("{}╟┤{}Rendering arguments: {}", indent, ansi_yellow_bold, ansi_end); + Logger::logger->info("{}║ Frames per second: {}", indent, fps); + Logger::logger->info("{}║ Video length: {}", indent, video_length); + + // Print Physical setup + Logger::logger->info("{}╟┤{}Physical setup: {}", indent, ansi_yellow_bold, ansi_end); + Logger::logger->info("{}║ Number of particles: {}", indent, num_particles); + Logger::logger->info("{}║ Number of forces: {}", indent, forces.size()); + Logger::logger->info("{}║ Forces: {}", indent, force_names); + + Logger::logger->info("{}╟┤{}Container: {}", indent, ansi_yellow_bold, ansi_end); + + if (std::holds_alternative(container_type)) { + auto lc_container = std::get(container_type); + + using LC = LinkedCellsContainer; + + auto domain_size = lc_container.domain_size; + Logger::logger->info("{}║ Linked Cells", indent); + Logger::logger->info("{}║ Domain size: {} x {} x {}", indent, domain_size[0], domain_size[1], domain_size[2]); + Logger::logger->info("{}║ Cutoff radius: {}", indent, lc_container.cutoff_radius); + Logger::logger->info("{}║ ┌Left: {}", indent, LC::boundaryConditionToString(lc_container.boundary_conditions[0])); + Logger::logger->info("{}║ ├Right: {}", indent, LC::boundaryConditionToString(lc_container.boundary_conditions[1])); + Logger::logger->info("{}║ ├Bottom: {}", indent, LC::boundaryConditionToString(lc_container.boundary_conditions[2])); + Logger::logger->info("{}║ ├Top: {}", indent, LC::boundaryConditionToString(lc_container.boundary_conditions[3])); + Logger::logger->info("{}║ ├Back: {}", indent, LC::boundaryConditionToString(lc_container.boundary_conditions[4])); + Logger::logger->info("{}║ └Front: {}", indent, LC::boundaryConditionToString(lc_container.boundary_conditions[5])); + } else if (std::holds_alternative(container_type)) { + Logger::logger->info("{}║ Direct Sum", indent); + } else { + Logger::logger->error("Invalid container type"); + exit(-1); + } + + Logger::logger->info("{}╚════════════════════════════════════════", indent); } \ No newline at end of file diff --git a/src/simulation/SimulationParams.h b/src/simulation/SimulationParams.h index 9f2989687..8e44294fe 100644 --- a/src/simulation/SimulationParams.h +++ b/src/simulation/SimulationParams.h @@ -1,11 +1,15 @@ #pragma once +#include #include #include #include +#include -#include "io/output/FileOutputHandler.h" +#include "io/input/InputFormats.h" +#include "io/output/OutputFormats.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" +#include "physics/forces/ForceSource.h" #include "physics/thermostats/Thermostat.h" /** @@ -19,7 +23,7 @@ class SimulationParams { * @brief Struct to specify the type of the particle container as DirectSumType */ struct DirectSumType { - operator std::string() const { return "DirectSum"; } + explicit operator std::string() const { return "DirectSum"; } }; /** @@ -35,7 +39,7 @@ class SimulationParams { const std::array& boundary_conditions) : domain_size(domain_size), cutoff_radius(cutoff_radius), boundary_conditions(boundary_conditions) {} - operator std::string() const { + explicit operator std::string() const { return "LinkedCells ([" + std::to_string(domain_size[0]) + "x" + std::to_string(domain_size[1]) + "x" + std::to_string(domain_size[2]) + "];" + std::to_string(cutoff_radius) + ";[" + LinkedCellsContainer::boundaryConditionToString(boundary_conditions[0]) + "|" + @@ -52,6 +56,11 @@ class SimulationParams { */ std::string input_file_path; + /** + * @brief Hash of the input file of the simulation + */ + std::size_t input_file_hash; + /** * @brief Path to the directory in which to save the simulation output */ @@ -88,15 +97,30 @@ class SimulationParams { Thermostat thermostat; /** - * @brief Output file format of the simulation + * @brief Forces to be applied to the particles */ - FileOutputHandler::OutputFormat output_format; + std::vector> forces; /** * @brief Whether to run the simulation in performance test mode */ bool performance_test; + /** + * @brief Output file format of the simulation + */ + OutputFormat output_format; + + /** + * @brief Number of particles in the simulation + */ + size_t num_particles; + + /** + * @brief Flag to indicate whether the simulation should be run from scratch, or whether cached data should be used + */ + bool fresh; + /** * @brief Construct a new SimulationParams object * @@ -110,15 +134,20 @@ class SimulationParams { * @param container_type Type of the particle container * @param thermostat Thermostat used in the simulation * @param output_format Output file format of the simulation - * @param performanceTest Whether to run the simulation in performance test mode - * + * @param force_strings Forces to be applied to the particles + * @param performance_test Whether to run the simulation in performance test mode + * @param fresh Flag to indicate whether the simulation should be run from scratch, or whether cached data should be used + * @param base_path Base path to the output directory. This is used to construct the output directory path if none is given + * explicitly. Defaults to "./output/" */ SimulationParams(const std::string& input_file_path, const std::string& output_dir_path, double delta_t, double end_time, int fps, int video_length, const std::variant& container_type, const Thermostat& thermostat, - const std::string& output_format, bool performanceTest = false); + const std::string& output_format, const std::vector& force_strings, bool performance_test, + bool fresh = false, const std::string& base_path = "./output"); /** - * @brief Dissallow default construction of a SimulationParams object (would have invalid values for a simulation) + * @brief Prints a summary of the simulation parameters to the console + * @param depth determines the indentation of the log message */ - SimulationParams() = delete; + void logSummary(int depth = 0) const; }; \ No newline at end of file diff --git a/tests/data/.gitignore b/tests/data/.gitignore index fd7a2db4e..fd5b093cd 100644 --- a/tests/data/.gitignore +++ b/tests/data/.gitignore @@ -1,2 +1,2 @@ -/temp/* -!/temp/.gitkeep +/output/* +!/output/.gitkeep diff --git a/tests/data/FileLoader.h b/tests/data/FileLoader.h index 5cba4d433..ca52eed53 100644 --- a/tests/data/FileLoader.h +++ b/tests/data/FileLoader.h @@ -20,10 +20,18 @@ class FileLoader { } /** - * @brief Gets the path to a file in the data directory + * @brief Gets the path to a file in the input directory * * @param file_name The name of the file * @return std::string The path to the file */ - static std::string get_test_file_path(const std::string& file_name) { return get_test_data_dir() + "/" + file_name; } + static std::string get_input_file_path(const std::string& file_name) { return get_test_data_dir() + "/input/" + file_name; } + + /** + * @brief Gets the path to a file in the output directory + * + * @param file_name The name of the file + * @return std::string The path to the file + */ + static std::string get_output_file_path(const std::string& file_name) { return get_test_data_dir() + "/output/" + file_name; } }; diff --git a/tests/data/input/CheckpointLoad.xml b/tests/data/input/CheckpointLoad.xml new file mode 100644 index 000000000..7dc3253a7 --- /dev/null +++ b/tests/data/input/CheckpointLoad.xml @@ -0,0 +1,30 @@ + + + + + 24 + 10 + 0.0014 + 100.0 + true + + + + LennardJones + + 1 + 1 + 10000 + + + + + + + ./ChktpExample.chkpt + + + + + \ No newline at end of file diff --git a/tests/data/input/ChktpExample.chkpt b/tests/data/input/ChktpExample.chkpt new file mode 100644 index 000000000..feffdcf73 --- /dev/null +++ b/tests/data/input/ChktpExample.chkpt @@ -0,0 +1,60 @@ + + + + input.xml + 1234567890 + 1.2345 + 0.0001 + + + + + + 1 + 2 + 3 + + + 4 + 5 + 6 + + + 7 + 8 + 9 + + + 10 + 11 + 12 + + 13 + 14 + + + + 15 + 16 + 17 + + + 18 + 19 + 20 + + + 21 + 22 + 23 + + + 24 + 25 + 26 + + 27 + 28 + + + \ No newline at end of file diff --git a/tests/data/CubExample.cub b/tests/data/input/CubExample.cub similarity index 81% rename from tests/data/CubExample.cub rename to tests/data/input/CubExample.cub index 6b6f9dc3d..73e088e2c 100644 --- a/tests/data/CubExample.cub +++ b/tests/data/input/CubExample.cub @@ -1,6 +1,6 @@ # Cube 1 1.0 2.0 3.0 # lower left -11 12 13 # grid dimensions +4 7 3 # grid dimensions 2.0 # grid spacing 3.14 # mass -1.0 -2.0 -3.0 # velocity @@ -9,7 +9,7 @@ # Cube 2 50.0 60.0 70.0 # lower left -8 4 1 # grid dimensions +2 2 1 # grid dimensions 1.345 # grid spacing 6.0 # mass -11.0 -10.0 6.0 # velocity diff --git a/tests/data/input/RecursiveExample.xml b/tests/data/input/RecursiveExample.xml new file mode 100644 index 000000000..0286981be --- /dev/null +++ b/tests/data/input/RecursiveExample.xml @@ -0,0 +1,88 @@ + + + + + 24 + 10 + 0.0014 + 16.0 + true + + + + LennardJones + + 1 + 1 + 10000 + + + + + + Demo 1 + + + 0 + 0 + 0.0014 + 5.0 + true + + + + LennardJones + + 1 + 1 + 10000 + + + + +
+ 0.0 + 0.0 + 0.0 + +
+ 2 + 1 + 5 + 1 + + 0.0 + 0.0 + 0.0 + + 1 +
+
+
+
+ + + + 100.0 + 20.0 + 20.0 + + + 2 + 2 + 2 + + 5 + 1 + 1.5 + + -10.0 + -10.0 + 0.0 + + 2 + +
+ +
\ No newline at end of file diff --git a/tests/data/input/RecursiveExample2.xml b/tests/data/input/RecursiveExample2.xml new file mode 100644 index 000000000..968fcbe29 --- /dev/null +++ b/tests/data/input/RecursiveExample2.xml @@ -0,0 +1,53 @@ + + + + + 24 + 10 + 0.0014 + 6.0 + true + + + + LennardJones + + 1 + 1 + 10000 + + + + + + Demo 13 + + ./RecursiveExample.xml + + + + + + 100.0 + 20.0 + 20.0 + + + 4 + 4 + 4 + + 5 + 1 + 1.5 + + -10.0 + -10.0 + 0.0 + + 2 + + + + \ No newline at end of file diff --git a/tests/data/test_collision.xml b/tests/data/input/test_collision.xml similarity index 87% rename from tests/data/test_collision.xml rename to tests/data/input/test_collision.xml index 1a8b723c0..5b12b4e0e 100644 --- a/tests/data/test_collision.xml +++ b/tests/data/input/test_collision.xml @@ -1,6 +1,6 @@ + xsi:noNamespaceSchemaLocation="../../../input/simulation_schema.xsd"> 24 @@ -11,14 +11,15 @@ + LennardJones - 0 - 0 - 10000000 + 1 + 1 + 10000 - + 0.0 @@ -86,6 +87,6 @@ 10 - + \ No newline at end of file diff --git a/tests/data/temp/.gitkeep b/tests/data/output/.gitkeep similarity index 100% rename from tests/data/temp/.gitkeep rename to tests/data/output/.gitkeep diff --git a/tests/io/filereaders/TestChkptReader.cpp b/tests/io/filereaders/TestChkptReader.cpp new file mode 100644 index 000000000..e672cb960 --- /dev/null +++ b/tests/io/filereaders/TestChkptReader.cpp @@ -0,0 +1,36 @@ +#include + +#include "data/FileLoader.h" +#include "io/input/chkpt/ChkptPointFileReader.h" + +#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ + EXPECT_TRUE(std::find_if((list).begin(), (list).end(), [&](auto& x) { return ArrayUtils::L2Norm(x - (point)) < (tol); }) != \ + (list).end()); + +/* + * Test if a CubFileReader reads the correct data out of the files. + */ +TEST(ChkptPointFileReader, CorrectReadingOfParticles) { + ChkptPointFileReader chkpt_reader; + + auto [particles, params] = chkpt_reader.readFile(FileLoader::get_input_file_path("ChktpExample.chkpt")); + + EXPECT_EQ(particles.size(), 2); + + auto expected_particle1 = Particle({1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}, 13, 14); + auto expected_particle2 = Particle({15, 16, 17}, {18, 19, 20}, {21, 22, 23}, {24, 25, 26}, 27, 28); + + std::vector expected_particles = {expected_particle1, expected_particle2}; + + for (size_t i = 0; i < particles.size(); i++) { + auto& particle = particles[i]; + auto& expected_particle = expected_particles[i]; + + EXPECT_EQ(particle.getX(), expected_particle.getX()); + EXPECT_EQ(particle.getV(), expected_particle.getV()); + EXPECT_EQ(particle.getF(), expected_particle.getF()); + EXPECT_EQ(particle.getOldF(), expected_particle.getOldF()); + EXPECT_EQ(particle.getM(), expected_particle.getM()); + EXPECT_EQ(particle.getType(), expected_particle.getType()); + } +} \ No newline at end of file diff --git a/tests/io/filereaders/TestCubFileReader.cpp b/tests/io/filereaders/TestCubFileReader.cpp index 1357e219d..ece0f34bc 100644 --- a/tests/io/filereaders/TestCubFileReader.cpp +++ b/tests/io/filereaders/TestCubFileReader.cpp @@ -2,26 +2,24 @@ #include "data/FileLoader.h" #include "io/input/custom_formats/cub/CubFileReader.h" -#include "particles/containers/ParticleContainer.h" -#include "particles/containers/directsum/DirectSumContainer.h" -#include "utils/ArrayUtils.h" -#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ - EXPECT_TRUE(std::find_if(list.begin(), list.end(), [&](auto& x) { return ArrayUtils::L2Norm(x - point) < tol; }) != list.end()); +#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ + EXPECT_TRUE(std::find_if((list).begin(), (list).end(), [&](auto& x) { return ArrayUtils::L2Norm(x - (point)) < (tol); }) != \ + (list).end()); /* * Test if a CubFileReader reads the correct data out of the files. */ TEST(CubFileReader, CorrectReadingOfParticles) { - std::unique_ptr particle_container = std::make_unique(); CubFileReader cub_file_reader; - cub_file_reader.readFile(FileLoader::get_test_file_path("CubExample.cub"), particle_container); - EXPECT_EQ(particle_container->size(), 11 * 12 * 13 + 8 * 4 * 1); + auto [particles, params] = cub_file_reader.readFile(FileLoader::get_input_file_path("CubExample.cub")); - EXPECT_NEAR((*particle_container)[0].getM(), 3.14, 1e-13); - EXPECT_EQ((*particle_container)[0].getType(), 42); + EXPECT_EQ(particles.size(), 4 * 7 * 3 + 2 * 2 * 1); - EXPECT_NEAR((*particle_container)[particle_container->size() - 1].getM(), 6.0, 1e-13); - EXPECT_EQ((*particle_container)[particle_container->size() - 1].getType(), 112); + EXPECT_NEAR((particles)[0].getM(), 3.14, 1e-13); + EXPECT_EQ((particles)[0].getType(), 42); + + EXPECT_NEAR((particles)[particles.size() - 1].getM(), 6.0, 1e-13); + EXPECT_EQ((particles)[particles.size() - 1].getType(), 112); } \ No newline at end of file diff --git a/tests/io/filereaders/TestXMLReader.cpp b/tests/io/filereaders/TestXMLReader.cpp index b58a993df..b23b685d9 100644 --- a/tests/io/filereaders/TestXMLReader.cpp +++ b/tests/io/filereaders/TestXMLReader.cpp @@ -1,17 +1,21 @@ #include #include "data/FileLoader.h" +#include "io/input/chkpt/ChkptPointFileReader.h" #include "io/input/xml/XMLFileReader.h" -#include "particles/containers/directsum/DirectSumContainer.h" +#include "particles/spawners/sphere/SphereSpawner.h" #include "utils/ArrayUtils.h" -#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ - EXPECT_TRUE(std::find_if(list.begin(), list.end(), [&](auto& x) { return ArrayUtils::L2Norm(x - point) < tol; }) != list.end()); +#define EXPECT_NOT_CONTAINS_POS_NEAR(list, point, tol) \ + EXPECT_FALSE(std::find_if((list).begin(), (list).end(), [&](auto& x) { return ArrayUtils::L2Norm(x.getX() - (point)) < (tol); }) != \ + (list).end()); TEST(XMLFileReader, CorrectParticleContainer) { - std::unique_ptr particle_container = std::make_unique(); - XMLFileReader file_reader; - SimulationParams conf = file_reader.readFile(FileLoader::get_test_file_path("test_collision.xml"), particle_container); + XMLFileReader file_reader(true); + + auto [particles, params] = file_reader.readFile(FileLoader::get_input_file_path("test_collision.xml")); + + auto conf = *params; double err = 1e-13; EXPECT_EQ(conf.video_length, 10); @@ -19,30 +23,84 @@ TEST(XMLFileReader, CorrectParticleContainer) { EXPECT_NEAR(conf.end_time, 100, err); EXPECT_NEAR(conf.delta_t, 0.0014, err); - EXPECT_EQ(particle_container->size(), 10 * 2 * 4 + 3 * 3 * 3 + 1); + EXPECT_EQ(particles.size(), 10 * 2 * 4 + 3 * 3 * 3 + 1); - EXPECT_EQ(conf.output_format, FileOutputHandler::OutputFormat::VTK); EXPECT_EQ(conf.container_type.index(), 0); for (int i = 0; i < 80; i++) { - EXPECT_NEAR((*particle_container)[i].getM(), 1, err); + EXPECT_NEAR((particles)[i].getM(), 1, err); } for (int i = 80; i < 107; i++) { - EXPECT_NEAR((*particle_container)[i].getM(), 1.5, err); - EXPECT_EQ(2, (*particle_container)[i].getType()); + EXPECT_NEAR((particles)[i].getM(), 1.5, err); + EXPECT_EQ(2, (particles)[i].getType()); + } + EXPECT_EQ(10, (particles)[107].getType()); + EXPECT_NEAR((particles)[107].getM(), 100, err); + + EXPECT_NEAR((particles)[0].getX()[0], 0, err); + EXPECT_NEAR((particles)[0].getX()[1], 0, err); + EXPECT_NEAR((particles)[0].getX()[2], 0, err); + + EXPECT_NEAR((particles)[80].getX()[0], 100, err); + EXPECT_NEAR((particles)[80].getX()[1], 20, err); + EXPECT_NEAR((particles)[80].getX()[2], 20, err); + + EXPECT_NEAR((particles)[107].getX()[0], 20, err); + EXPECT_NEAR((particles)[107].getX()[1], 100, err); + EXPECT_NEAR((particles)[107].getX()[2], 100, err); +} + +TEST(XMLFileReader, LoadCheckPoint) { + XMLFileReader file_reader(true); + ChkptPointFileReader chkpt_reader; + + auto [particles_xml, params_xml] = file_reader.readFile(FileLoader::get_input_file_path("CheckpointLoad.xml")); + auto [particles_chkpt, params_chkpt] = chkpt_reader.readFile(FileLoader::get_input_file_path("ChktpExample.chkpt")); + + EXPECT_EQ(particles_xml.size(), particles_chkpt.size()); + + for (size_t i = 0; i < particles_xml.size(); i++) { + auto& particle_xml = particles_xml[i]; + auto& particle_chkpt = particles_chkpt[i]; + + EXPECT_EQ(particle_xml, particle_chkpt); + } +} + +TEST(XMLFileReader, RecursiveSubSimulation) { + XMLFileReader file_reader(true); + + auto [particles_xml, params_xml] = file_reader.readFile(FileLoader::get_input_file_path("RecursiveExample.xml")); + + std::vector equilibrated_particles; + + SphereSpawner spawner{{0, 0, 0}, 2, 1, 5, {0, 0, 0}, 1, true}; + + spawner.spawnParticles(equilibrated_particles); + + EXPECT_EQ(particles_xml.size(), 33 + 8); + + for (const auto& particle : equilibrated_particles) { + EXPECT_NOT_CONTAINS_POS_NEAR(particles_xml, particle.getX(), 1) } - EXPECT_EQ(10, (*particle_container)[107].getType()); - EXPECT_NEAR((*particle_container)[107].getM(), 100, err); +} + +TEST(XMLFileReader, DoubleRecursiveSubSimulation) { + XMLFileReader file_reader(true); + + auto [particles_xml, params_xml] = file_reader.readFile(FileLoader::get_input_file_path("RecursiveExample2.xml")); + + std::vector equilibrated_particles; + + EXPECT_EQ(particles_xml.size(), 33 + 8 + 64); +} + +TEST(XMLFileReader, DoubleRecursiveLoadCachedResults) { + XMLFileReader file_reader(false); - EXPECT_NEAR((*particle_container)[0].getX()[0], 0, err); - EXPECT_NEAR((*particle_container)[0].getX()[1], 0, err); - EXPECT_NEAR((*particle_container)[0].getX()[2], 0, err); + auto [particles_xml, params_xml] = file_reader.readFile(FileLoader::get_input_file_path("RecursiveExample2.xml")); - EXPECT_NEAR((*particle_container)[80].getX()[0], 100, err); - EXPECT_NEAR((*particle_container)[80].getX()[1], 20, err); - EXPECT_NEAR((*particle_container)[80].getX()[2], 20, err); + std::vector equilibrated_particles; - EXPECT_NEAR((*particle_container)[107].getX()[0], 20, err); - EXPECT_NEAR((*particle_container)[107].getX()[1], 100, err); - EXPECT_NEAR((*particle_container)[107].getX()[2], 100, err); + EXPECT_EQ(particles_xml.size(), 33 + 8 + 64); } diff --git a/tests/io/filewriters/TestChkptWriter.cpp b/tests/io/filewriters/TestChkptWriter.cpp new file mode 100644 index 000000000..ed8675368 --- /dev/null +++ b/tests/io/filewriters/TestChkptWriter.cpp @@ -0,0 +1,40 @@ +#include + +#include "data/FileLoader.h" +#include "io/input/FileInputHandler.h" +#include "io/output/FileOutputHandler.h" +#include "particles/containers/directsum/DirectSumContainer.h" + +/* + * Test if the CheckPointWriter can write a file that can be read by the CheckPointReader without errors. + */ +TEST(CHKPTWriter, CorrectWritingAndReadingOfParticles) { + std::unique_ptr particle_container = std::make_unique(); + + for (double i = 1; i < 5; i++) { + auto pos = std::array{i, 2 * i, 3 * i}; + auto vel = std::array{4 * i, 5 * i, 6 * i}; + particle_container->addParticle(Particle(pos, vel, i, i)); + } + + auto output_folder = FileLoader::get_output_file_path("CHKPTWriterTest"); + + auto params = SimulationParams("", output_folder, 0, 0, 0, 0, SimulationParams::DirectSumType{}, Thermostat{0, 0, 100000}, "chkpt", + {"LennardJones"}, false); + + FileOutputHandler file_output_handler{params}; + + auto path = file_output_handler.writeFile(0, particle_container); + + // load the file + FileInputHandler file_input_handler; + + auto [loaded_particles, loaded_config] = file_input_handler.readFile(*path); + + // check if the file contains the correct data + EXPECT_EQ(loaded_particles.size(), particle_container->size()); + + for (size_t i = 0; i < loaded_particles.size(); i++) { + EXPECT_EQ(loaded_particles.at(i), particle_container->getParticles().at(i)); + } +} \ No newline at end of file diff --git a/tests/io/filewriters/TestVTKWriter.cpp b/tests/io/filewriters/TestVTKWriter.cpp index b3102fd23..bf3204ce4 100644 --- a/tests/io/filewriters/TestVTKWriter.cpp +++ b/tests/io/filewriters/TestVTKWriter.cpp @@ -9,9 +9,9 @@ #include "utils/ArrayUtils.h" /* - * Test if the VTKWriter writes the correct data into the file. + * Test if the VTUWriter writes the correct data into the file. */ -TEST(VTKWriter, CorrectWritingOfParticles) { +TEST(VTUWriter, CorrectWritingOfParticles) { std::unique_ptr particle_container = std::make_unique(); for (double i = 0; i < 5; i++) { @@ -20,13 +20,16 @@ TEST(VTKWriter, CorrectWritingOfParticles) { particle_container->addParticle(Particle(pos, vel, i, i)); } - auto output_folder = FileLoader::get_test_file_path("temp/VTKWriterTest"); - FileOutputHandler file_output_handler{FileOutputHandler::OutputFormat::VTK, output_folder}; + auto output_folder = FileLoader::get_output_file_path("VTUWriterTest"); - file_output_handler.writeFile(0, particle_container); + auto params = SimulationParams("", output_folder, 0, 0, 0, 0, SimulationParams::DirectSumType{}, Thermostat{0, 0, 100000}, "vtu", + {"LennardJones"}, false); + FileOutputHandler file_output_handler{params}; + + auto path = file_output_handler.writeFile(0, particle_container); // load the file - std::ifstream file(output_folder + "/MD_VTK_0000.vtu"); + std::ifstream file(*path); std::stringstream buffer; buffer << file.rdbuf(); diff --git a/tests/io/filewriters/TestXYZWriter.cpp b/tests/io/filewriters/TestXYZWriter.cpp index abd6f2843..11902134d 100644 --- a/tests/io/filewriters/TestXYZWriter.cpp +++ b/tests/io/filewriters/TestXYZWriter.cpp @@ -20,13 +20,16 @@ TEST(XYZWriter, CorrectWritingOfParticles) { particle_container->addParticle(Particle(pos, vel, i, i)); } - auto output_folder = FileLoader::get_test_file_path("temp/XYZWriterTest"); - FileOutputHandler file_output_handler{FileOutputHandler::OutputFormat::XYZ, output_folder}; + auto output_folder = FileLoader::get_output_file_path("XYZWriterTest"); - file_output_handler.writeFile(0, particle_container); + auto params = SimulationParams("", output_folder, 0, 0, 0, 0, SimulationParams::DirectSumType{}, Thermostat{0, 0, 100000}, "xyz", + {"LennardJones"}, false); + FileOutputHandler file_output_handler{params}; + + auto path = file_output_handler.writeFile(0, particle_container); // load the file - std::ifstream file(output_folder + "/MD_XYZ_0000.xyz"); + std::ifstream file(*path); std::stringstream buffer; buffer << file.rdbuf(); diff --git a/tests/particles/TestParticleContainer.cpp b/tests/particles/TestDirectSumContainer.cpp similarity index 100% rename from tests/particles/TestParticleContainer.cpp rename to tests/particles/TestDirectSumContainer.cpp diff --git a/tests/particles/TestLinkedCellsContainer.cpp b/tests/particles/TestLinkedCellsContainer.cpp index 126d7e2ef..9d2e5185f 100644 --- a/tests/particles/TestLinkedCellsContainer.cpp +++ b/tests/particles/TestLinkedCellsContainer.cpp @@ -6,9 +6,9 @@ #include "particles/containers/ParticleContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#define EXPECT_ARRAY_NEAR(a, b, tol) \ - for (int i = 0; i < 3; i++) { \ - EXPECT_NEAR(a[i], b[i], tol); \ +#define EXPECT_ARRAY_NEAR(a, b, tol) \ + for (int i = 0; i < 3; i++) { \ + EXPECT_NEAR((a)[i], (b)[i], tol); \ }; /** @@ -84,13 +84,13 @@ TEST(LinkedCellsContainer, ParticlePosToCell) { LinkedCellsContainer container(domain_size, cutoff_radius); EXPECT_EQ(container.getCells().size(), 27); - EXPECT_EQ(container.particlePosToCell(-1.1, 0, 0), nullptr); - EXPECT_EQ(container.particlePosToCell(0, -1.1, 0), nullptr); - EXPECT_EQ(container.particlePosToCell(0, 0, -1.1), nullptr); + EXPECT_THROW(container.particlePosToCell(-1.1, 0, 0), std::runtime_error); + EXPECT_THROW(container.particlePosToCell(0, -1.1, 0), std::runtime_error); + EXPECT_THROW(container.particlePosToCell(0, 0, -1.1), std::runtime_error); - EXPECT_EQ(container.particlePosToCell(2.1, 0, 0), nullptr); - EXPECT_EQ(container.particlePosToCell(0, 2.1, 0), nullptr); - EXPECT_EQ(container.particlePosToCell(0, 0, 2.1), nullptr); + EXPECT_THROW(container.particlePosToCell(2.1, 0, 0), std::runtime_error); + EXPECT_THROW(container.particlePosToCell(0, 2.1, 0), std::runtime_error); + EXPECT_THROW(container.particlePosToCell(0, 0, 2.1), std::runtime_error); EXPECT_EQ(container.particlePosToCell(-1.0, -1.0, -1.0), &container.getCells()[0]); EXPECT_EQ(container.particlePosToCell(1.0, 1.0, 1.0), &container.getCells()[26]); @@ -198,12 +198,10 @@ TEST(LinkedCellsContainer, AddParticle) { EXPECT_EQ(container.size(), 2); Particle h({-0.1, -0.1, -0.1}, {0, 0, 0}, 0.0, 0.0); - container.addParticle(h); - EXPECT_EQ(container.size(), 2); + EXPECT_THROW(container.addParticle(h), std::runtime_error); Particle out_of_bounds({5, 5, 5}, {0, 0, 0}, 0.0, 0.0); - container.addParticle(out_of_bounds); - EXPECT_EQ(container.size(), 2); + EXPECT_THROW(container.addParticle(out_of_bounds), std::runtime_error); } TEST(LinkedCellsContainer, BoundaryIterator) { @@ -219,8 +217,8 @@ TEST(LinkedCellsContainer, BoundaryIterator) { container.addParticle(p1); container.addParticle(p2); - container.addParticle(h); - container.addParticle(out_of_bounds); + EXPECT_THROW(container.addParticle(h), std::runtime_error); + EXPECT_THROW(container.addParticle(out_of_bounds), std::runtime_error); LinkedCellsContainer::BoundaryIterator it = container.boundaryBegin(); @@ -231,9 +229,9 @@ TEST(LinkedCellsContainer, BoundaryIterator) { Particle& it_p2 = *it; EXPECT_EQ(it_p2.getX(), p2.getX()); - for (auto it = container.boundaryBegin(); it != container.boundaryEnd(); ++it) { - EXPECT_TRUE(it->getX()[0] >= 0.0 && it->getX()[0] < 1.0); - EXPECT_TRUE(it->getX()[1] >= 0.0 && it->getX()[1] < 1.0); - EXPECT_TRUE(it->getX()[2] >= 0.0 && it->getX()[2] < 1.0); + for (auto bit = container.boundaryBegin(); bit != container.boundaryEnd(); ++bit) { + EXPECT_TRUE(bit->getX()[0] >= 0.0 && bit->getX()[0] < 1.0); + EXPECT_TRUE(bit->getX()[1] >= 0.0 && bit->getX()[1] < 1.0); + EXPECT_TRUE(bit->getX()[2] >= 0.0 && bit->getX()[2] < 1.0); } } \ No newline at end of file diff --git a/tests/particles/spawners/TestCuboidSpawner.cpp b/tests/particles/spawners/TestCuboidSpawner.cpp index 45a88eff0..be2315369 100644 --- a/tests/particles/spawners/TestCuboidSpawner.cpp +++ b/tests/particles/spawners/TestCuboidSpawner.cpp @@ -1,14 +1,14 @@ #include -#include "particles/containers/directsum/DirectSumContainer.h" #include "particles/spawners/cuboid/CuboidSpawner.h" #include "utils/ArrayUtils.h" /* * Macro to check if a point is in a list of points. */ -#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ - EXPECT_TRUE(std::find_if(list.begin(), list.end(), [&](auto& x) { return ArrayUtils::L2Norm(x - point) < tol; }) != list.end()); +#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ + EXPECT_TRUE(std::find_if((list).begin(), (list).end(), [&](auto& x) { return ArrayUtils::L2Norm(x - (point)) < (tol); }) != \ + (list).end()); /* * Test if a CuboidSpawner spawns the correct number of particles. @@ -22,10 +22,10 @@ TEST(CuboidParticleSpawner, SpawnCorrectNumberOfParticles) { int type = 0; CuboidSpawner spawner(lower_left_corner, grid_dimensions, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container = std::make_unique(); + std::vector particle_container; spawner.spawnParticles(particle_container); - ASSERT_EQ(particle_container->size(), 3 * 7 * 11); + ASSERT_EQ(particle_container.size(), 3 * 7 * 11); } /* @@ -40,7 +40,7 @@ TEST(CuboidParticleSpawner, SpawnParticlesAtCorrectPositions) { int type = 0; CuboidSpawner spawner(lower_left_corner, grid_dimensions, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container = std::make_unique(); + std::vector particle_container; spawner.spawnParticles(particle_container); auto expected_positions = @@ -48,9 +48,9 @@ TEST(CuboidParticleSpawner, SpawnParticlesAtCorrectPositions) { {0, 1, 1}, {1, 1, 1}, {0, 2, 1}, {1, 2, 1}, {0, 0, 2}, {1, 0, 2}, {0, 1, 2}, {1, 1, 2}, {0, 2, 2}, {1, 2, 2}, {0, 0, 3}, {1, 0, 3}, {0, 1, 3}, {1, 1, 3}, {0, 2, 3}, {1, 2, 3}}); - for (size_t i = 0; i < particle_container->size(); i++) { + for (const auto& i : particle_container) { // check if the position of the particle is inside the expected positions - EXPECT_CONTAINS_POS_NEAR(expected_positions, (*particle_container)[i].getX(), 1e-10); + EXPECT_CONTAINS_POS_NEAR(expected_positions, i.getX(), 1e-10) } } @@ -65,12 +65,12 @@ TEST(CuboidParticleSpawner, EstimateNumberOfParticles) { int type = 0; CuboidSpawner spawner2(lower_left, {2, 3, 4}, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container2 = std::make_unique(); + std::vector particle_container2; spawner2.spawnParticles(particle_container2); - EXPECT_EQ(spawner2.getEstimatedNumberOfParticles(), particle_container2->size()); + EXPECT_EQ(spawner2.getEstimatedNumberOfParticles(), particle_container2.size()); CuboidSpawner spawner16(lower_left, {4, 5, 6}, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container16 = std::make_unique(); + std::vector particle_container16; spawner16.spawnParticles(particle_container16); - EXPECT_EQ(spawner16.getEstimatedNumberOfParticles(), particle_container16->size()); + EXPECT_EQ(spawner16.getEstimatedNumberOfParticles(), particle_container16.size()); } \ No newline at end of file diff --git a/tests/particles/spawners/TestSphereSpawner.cpp b/tests/particles/spawners/TestSphereSpawner.cpp index 8ddc60a88..190b42534 100644 --- a/tests/particles/spawners/TestSphereSpawner.cpp +++ b/tests/particles/spawners/TestSphereSpawner.cpp @@ -1,14 +1,14 @@ #include -#include "particles/containers/directsum/DirectSumContainer.h" #include "particles/spawners/sphere/SphereSpawner.h" #include "utils/ArrayUtils.h" /* * Macro to check if a point is in a list of points. */ -#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ - EXPECT_TRUE(std::find_if(list.begin(), list.end(), [&](auto& x) { return ArrayUtils::L2Norm(x - point) < tol; }) != list.end()); +#define EXPECT_CONTAINS_POS_NEAR(list, point, tol) \ + EXPECT_TRUE(std::find_if((list).begin(), (list).end(), [&](auto& x) { return ArrayUtils::L2Norm(x - (point)) < (tol); }) != \ + (list).end()); /* * Test if a SphereSpawner spawns the correct number of particles. @@ -21,22 +21,22 @@ TEST(SphereParticleSpawner, SpawnCorrectNumberOfParticles) { int type = 0; // Radius 1 - std::unique_ptr particle_container1 = std::make_unique(); + std::vector particle_container1; SphereSpawner spawner(center, 1, grid_spacing, mass, initial_velocity, type); spawner.spawnParticles(particle_container1); - EXPECT_EQ(particle_container1->size(), 7); + EXPECT_EQ(particle_container1.size(), 7); // Radius 2 - std::unique_ptr particle_container2 = std::make_unique(); + std::vector particle_container2; SphereSpawner spawner2(center, 2, grid_spacing, mass, initial_velocity, type); spawner2.spawnParticles(particle_container2); - EXPECT_EQ(particle_container2->size(), 33); + EXPECT_EQ(particle_container2.size(), 33); // Radius 9 https://challenges.wolframcloud.com/challenge/lattice-points-in-a-sphere - std::unique_ptr particle_container9 = std::make_unique(); + std::vector particle_container9; SphereSpawner spawner3(center, 9, grid_spacing, mass, initial_velocity, type); spawner3.spawnParticles(particle_container9); - EXPECT_EQ(particle_container9->size(), 3071); + EXPECT_EQ(particle_container9.size(), 3071); } /* @@ -51,15 +51,15 @@ TEST(SphereParticleSpawner, SpawnParticlesAtCorrectPositions) { int type = 0; SphereSpawner spawner(center, radius, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container = std::make_unique(); + std::vector particle_container; spawner.spawnParticles(particle_container); auto expected_positions = std::vector>({{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}, {-1, 0, 0}, {0, -1, 0}, {0, 0, -1}}); - for (size_t i = 0; i < particle_container->size(); i++) { + for (const auto& i : particle_container) { // check if the position of the particle is inside the expected positions - EXPECT_CONTAINS_POS_NEAR(expected_positions, (*particle_container)[i].getX(), 1e-10); + EXPECT_CONTAINS_POS_NEAR(expected_positions, i.getX(), 1e-10) } } @@ -74,22 +74,22 @@ TEST(SphereParticleSpawner, EstimateNumberOfParticles) { int type = 0; SphereSpawner spawner2(center, 2, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container2 = std::make_unique(); + std::vector particle_container2; spawner2.spawnParticles(particle_container2); - EXPECT_NEAR(static_cast(spawner2.getEstimatedNumberOfParticles()) / particle_container2->size(), 1, 0.1); + EXPECT_NEAR(static_cast(spawner2.getEstimatedNumberOfParticles()) / particle_container2.size(), 1, 0.1); SphereSpawner spawner4(center, 4, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container4 = std::make_unique(); + std::vector particle_container4; spawner4.spawnParticles(particle_container4); - EXPECT_NEAR(static_cast(spawner4.getEstimatedNumberOfParticles()) / particle_container4->size(), 1, 0.1); + EXPECT_NEAR(static_cast(spawner4.getEstimatedNumberOfParticles()) / particle_container4.size(), 1, 0.1); SphereSpawner spawner8(center, 8, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container8 = std::make_unique(); + std::vector particle_container8; spawner8.spawnParticles(particle_container8); - EXPECT_NEAR(static_cast(spawner8.getEstimatedNumberOfParticles()) / particle_container8->size(), 1, 0.1); + EXPECT_NEAR(static_cast(spawner8.getEstimatedNumberOfParticles()) / particle_container8.size(), 1, 0.1); SphereSpawner spawner16(center, 16, grid_spacing, mass, initial_velocity, type); - std::unique_ptr particle_container16 = std::make_unique(); + std::vector particle_container16; spawner16.spawnParticles(particle_container16); - EXPECT_NEAR(static_cast(spawner16.getEstimatedNumberOfParticles()) / particle_container16->size(), 1, 0.1); + EXPECT_NEAR(static_cast(spawner16.getEstimatedNumberOfParticles()) / particle_container16.size(), 1, 0.1); } \ No newline at end of file diff --git a/tests/physics/forces/TestGravitationalForce.cpp b/tests/physics/forces/TestGravitationalForce.cpp index a9dc302d3..0c8384a0a 100644 --- a/tests/physics/forces/TestGravitationalForce.cpp +++ b/tests/physics/forces/TestGravitationalForce.cpp @@ -3,9 +3,9 @@ #include "physics/forces/GravitationalForce.h" #include "utils/ArrayUtils.h" -#define EXPECT_ARRAY_NEAR(a, b, tol) \ - for (int i = 0; i < 3; i++) { \ - EXPECT_NEAR(a[i], b[i], tol); \ +#define EXPECT_ARRAY_NEAR(a, b, tol) \ + for (int i = 0; i < 3; i++) { \ + EXPECT_NEAR((a)[i], (b)[i], tol); \ }; /* @@ -54,5 +54,5 @@ TEST(GravityFormula, DirectionCorrect) { auto normalized_f_gravity = (1 / ArrayUtils::L2Norm(f_gravity)) * f_gravity; - EXPECT_ARRAY_NEAR(normalized_f_gravity, expected_heading, 0.01); + EXPECT_ARRAY_NEAR(normalized_f_gravity, expected_heading, 0.01) } diff --git a/tests/physics/thermostats/TestThermostat.cpp b/tests/physics/thermostats/TestThermostat.cpp index 4ef1d02eb..59fd9e572 100644 --- a/tests/physics/thermostats/TestThermostat.cpp +++ b/tests/physics/thermostats/TestThermostat.cpp @@ -341,8 +341,8 @@ TEST(Thermostat, TemperatureKeeping) { // most 1.1025, ~10% which from the initial temperature is around 0.5 < 0.75). The maximum temperature change is 0.75 so the // temperature should stay about the same. double factor = dist(gen); - for (auto it = particle_container_ds->begin(); it != particle_container_ds->end(); ++it) { - it->setV(factor * it->getV()); + for (auto& it : *particle_container_ds) { + it.setV(factor * it.getV()); } EXPECT_GE(thermostat.getCurrentTemperature(particle_container_ds), initial_temperature_ds); @@ -366,8 +366,8 @@ TEST(Thermostat, TemperatureKeeping) { // most 1.1025, ~10% which from the initial temperature is around 0.5 < 0.75). The maximum temperature change is 0.75 so the // temperature should stay about the same. double factor = dist(gen); - for (auto it = particle_container_lc->begin(); it != particle_container_lc->end(); ++it) { - it->setV(factor * it->getV()); + for (auto& it : *particle_container_lc) { + it.setV(factor * it.getV()); } EXPECT_GE(thermostat.getCurrentTemperature(particle_container_lc), initial_temperature_lc); diff --git a/tests/simulation/SimulationUtils.h b/tests/simulation/SimulationUtils.h index 348cc88ba..b83edfb6f 100644 --- a/tests/simulation/SimulationUtils.h +++ b/tests/simulation/SimulationUtils.h @@ -1,5 +1,9 @@ #pragma once + #include "simulation/SimulationParams.h" -const SimulationParams TEST_DEFAULT_PARAMS = - SimulationParams("test_only", "", 0.002, 5, 24, 30, SimulationParams::DirectSumType{}, Thermostat{0, 0}, "none"); \ No newline at end of file +const SimulationParams TEST_DEFAULT_PARAMS_GRAVITY("test_only.xml", "", 0.002, 5, 24, 30, SimulationParams::DirectSumType{}, + Thermostat{0, 0}, "none", {"Gravitational"}, false, true); + +const SimulationParams TEST_DEFAULT_PARAMS_LENNARD_JONES("test_only.xml", "", 0.002, 5, 24, 30, SimulationParams::DirectSumType{}, + Thermostat{0, 0}, "none", {"LennardJones"}, false, true); diff --git a/tests/simulation/TestDirectSumLinkedCellsComparison.cpp b/tests/simulation/TestDirectSumLinkedCellsComparison.cpp index 6aa8b8158..cb1a5d92f 100644 --- a/tests/simulation/TestDirectSumLinkedCellsComparison.cpp +++ b/tests/simulation/TestDirectSumLinkedCellsComparison.cpp @@ -2,15 +2,13 @@ #include "io/logger/Logger.h" #include "io/output/FileOutputHandler.h" -#include "particles/containers/ParticleContainer.h" -#include "particles/containers/directsum/DirectSumContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/GravitationalForce.h" -#include "physics/forces/LennardJonesForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" #include "utils/ArrayUtils.h" +using BC = LinkedCellsContainer::BoundaryCondition; + #define EXPECT_ARRAY_NEAR(a, b, tol) \ for (int i = 0; i < 3; i++) { \ EXPECT_NEAR(a[i], b[i], tol); \ @@ -38,43 +36,35 @@ std::vector createParticles() { TEST(SimulationRunnerDirectSumLinkedCellsComparison, RandomSimulation1) { Logger::logger->set_level(spdlog::level::off); - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 8; - - std::unique_ptr particle_container_ds = std::make_unique(); - std::unique_ptr particle_container_lc = std::make_unique(domain_size, cutoff_radius); - double delta_t = 0.001; double end_t = 1; auto particles = createParticles(); - for (auto& particle : particles) { - particle_container_ds->addParticle(particle); - particle_container_lc->addParticle(particle); - } - - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params_ds = TEST_DEFAULT_PARAMS; + SimulationParams params_ds = TEST_DEFAULT_PARAMS_LENNARD_JONES; params_ds.end_time = end_t; params_ds.delta_t = delta_t; - params_ds.output_format = FileOutputHandler::OutputFormat::NONE; - SimulationParams params_lc = TEST_DEFAULT_PARAMS; + SimulationParams params_lc = TEST_DEFAULT_PARAMS_LENNARD_JONES; params_lc.end_time = end_t; params_lc.delta_t = delta_t; - params_lc.output_format = FileOutputHandler::OutputFormat::NONE; - Simulation simulation_ds(particle_container_ds, forces, params_ds); - Simulation simulation_lc(particle_container_lc, forces, params_lc); + std::array domain_size = {10, 10, 10}; + double cutoff_radius = 8; + + std::unique_ptr particle_container_lc = std::make_unique(domain_size, cutoff_radius); + + params_lc.container_type = + SimulationParams::LinkedCellsType({10, 10, 10}, 10, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); - simulation_ds.runSimulation(); - simulation_lc.runSimulation(); + Simulation simulation_ds(particles, params_ds); + Simulation simulation_lc(particles, params_lc); + + auto res_ds = simulation_ds.runSimulation(); + auto res_lc = simulation_lc.runSimulation(); for (int i = 0; i < 4; i++) { - EXPECT_ARRAY_NEAR((*particle_container_ds)[i].getX(), (*particle_container_lc)[i].getX(), 1e-7); + EXPECT_ARRAY_NEAR((res_ds.resulting_particles)[i].getX(), (res_lc.resulting_particles)[i].getX(), 1e-7) } } @@ -86,7 +76,7 @@ std::vector createCollidingCubesParticles(std::array offset for (double k = -5; k <= 5; k += 5) { std::array x = {i, j, k}; std::array v = {0, 0, 0}; - particles.push_back(Particle(x + offset_center, v, 1, 0)); + particles.emplace_back(x + offset_center, v, 1, 0); } } } @@ -99,43 +89,30 @@ std::vector createCollidingCubesParticles(std::array offset TEST(SimulationRunnerDirectSumLinkedCellsComparison, Collision) { Logger::logger->set_level(spdlog::level::off); - std::array domain_size = {30, 30, 30}; - double cutoff_radius = 7.5; - std::array offset_center = {15, 15, 15}; auto particles = createCollidingCubesParticles(offset_center); - std::unique_ptr particle_container_ds = std::make_unique(); - std::unique_ptr particle_container_lc = std::make_unique(domain_size, cutoff_radius); - double delta_t = 0.0005; double end_t = 1; - for (auto& particle : particles) { - particle_container_ds->addParticle(particle); - particle_container_lc->addParticle(particle); - } - - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params_ds = TEST_DEFAULT_PARAMS; + SimulationParams params_ds = TEST_DEFAULT_PARAMS_LENNARD_JONES; params_ds.end_time = end_t; params_ds.delta_t = delta_t; - params_ds.output_format = FileOutputHandler::OutputFormat::NONE; - SimulationParams params_lc = TEST_DEFAULT_PARAMS; + SimulationParams params_lc = TEST_DEFAULT_PARAMS_LENNARD_JONES; params_lc.end_time = end_t; params_lc.delta_t = delta_t; - params_lc.output_format = FileOutputHandler::OutputFormat::NONE; - Simulation simulation_ds(particle_container_ds, forces, params_ds); - Simulation simulation_lc(particle_container_lc, forces, params_lc); + params_lc.container_type = SimulationParams::LinkedCellsType( + {30, 30, 30}, 7.5, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation_ds(particles, params_ds); + Simulation simulation_lc(particles, params_lc); - simulation_ds.runSimulation(); - simulation_lc.runSimulation(); + auto res_ds = simulation_ds.runSimulation(); + auto res_lc = simulation_lc.runSimulation(); for (int i = 0; i < 4; i++) { - EXPECT_ARRAY_NEAR((*particle_container_ds)[i].getX(), (*particle_container_lc)[i].getX(), 1e-4); + EXPECT_ARRAY_NEAR((res_ds.resulting_particles)[i].getX(), (res_lc.resulting_particles)[i].getX(), 1e-4) } } \ No newline at end of file diff --git a/tests/simulation/TestRunInputFiles.cpp b/tests/simulation/TestRunInputFiles.cpp index 8ce5b0530..f2707cbb4 100644 --- a/tests/simulation/TestRunInputFiles.cpp +++ b/tests/simulation/TestRunInputFiles.cpp @@ -15,16 +15,39 @@ auto load_all_input_files() { std::vector input_files; - for (const auto& entry : std::filesystem::directory_iterator(FileLoader::get_test_data_dir() + "/../../input")) { + + std::set found_extensions = {}; + + for (const auto& entry : std::filesystem::recursive_directory_iterator(FileLoader::get_test_data_dir() + "/../../input")) { + // check for valid extension + auto supported_extensions = get_supported_input_file_extensions(); + + if (supported_extensions.find(entry.path().extension()) == supported_extensions.end()) { + continue; + } + + input_files.push_back(entry.path()); + found_extensions.insert(entry.path().extension()); + } + + for (const auto& entry : std::filesystem::recursive_directory_iterator(FileLoader::get_test_data_dir() + "/input")) { // check for valid extension - auto supported_extensions = FileInputHandler::get_supported_input_file_extensions(); + auto supported_extensions = get_supported_input_file_extensions(); if (supported_extensions.find(entry.path().extension()) == supported_extensions.end()) { continue; } input_files.push_back(entry.path()); + found_extensions.insert(entry.path().extension()); } + + for (const auto& extension : get_supported_input_file_extensions()) { + if (found_extensions.find(extension) == found_extensions.end()) { + throw std::runtime_error("No input file found for extension " + extension); + } + } + return input_files; } @@ -34,40 +57,26 @@ auto load_all_input_files() { TEST(SimulationRunner, EnsureBackwardsCompatibilityForAllInputFiles) { Logger::logger->set_level(spdlog::level::warn); - std::set tested_extensions = {}; + // Check that all supported extensions have actually been tested for (const auto& input_file : load_all_input_files()) { std::cout << "Testing input file: " << input_file << std::endl; - tested_extensions.insert(input_file.substr(input_file.find_last_of('.'))); - - // Create pointer for particle container - std::unique_ptr initial_particles; - // Parse input file - SimulationParams params_xml = FileInputHandler::readFile(input_file, initial_particles); - - EXPECT_GT(initial_particles->size(), 0); + auto [particles, file_config] = FileInputHandler::readFile(input_file, true, false); - // Create all force sources acting on the particles - std::vector> forces; - forces.push_back(std::make_unique()); + auto config = file_config.value_or(TEST_DEFAULT_PARAMS_LENNARD_JONES); - params_xml.end_time = 1; - params_xml.delta_t = 0.01; - params_xml.output_format = FileOutputHandler::OutputFormat::NONE; + config.end_time = 0.1; + config.delta_t = 0.001; + config.output_format = OutputFormat::NONE; // Initialize simulation - Simulation simulation{initial_particles, forces, params_xml}; + Simulation simulation{particles, config}; // Run simulation auto res = simulation.runSimulation(); EXPECT_GT(res.total_iterations, 0); } - - // Check that all supported extensions have actually been tested - for (const auto& extension : FileInputHandler::get_supported_input_file_extensions()) { - EXPECT_TRUE(tested_extensions.find(extension) != tested_extensions.end()); - } } \ No newline at end of file diff --git a/tests/simulation/directsum/Test3BodyPeriodicSolutionDS.cpp b/tests/simulation/directsum/Test3BodyPeriodicSolutionDS.cpp index 64958bc01..563d4df3d 100644 --- a/tests/simulation/directsum/Test3BodyPeriodicSolutionDS.cpp +++ b/tests/simulation/directsum/Test3BodyPeriodicSolutionDS.cpp @@ -2,8 +2,6 @@ #include "io/output/FileOutputHandler.h" #include "particles/containers/ParticleContainer.h" -#include "particles/containers/directsum/DirectSumContainer.h" -#include "physics/forces/GravitationalForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" @@ -17,7 +15,7 @@ * This test relies on the periodic solution presented in: http://three-body.ipb.ac.rs/sV_sol.php?id=0 */ TEST(SimulationRunnerDirectSum, ParticlesReturnToInitialPositionPeriodicSolution_Gravity) { - std::unique_ptr particle_container = std::make_unique(); + std::vector particles; auto p1 = 0.347113; auto p2 = 0.532727; @@ -36,23 +34,19 @@ TEST(SimulationRunnerDirectSum, ParticlesReturnToInitialPositionPeriodicSolution auto pa2 = Particle(x2, v2, 1, 0); auto pa3 = Particle(x3, v3, 1, 0); - particle_container->addParticle(pa1); - particle_container->addParticle(pa2); - particle_container->addParticle(pa3); + particles.push_back(pa1); + particles.push_back(pa2); + particles.push_back(pa3); - FileOutputHandler file_output_handler(FileOutputHandler::OutputFormat::NONE); - - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_GRAVITY; params.end_time = period; params.delta_t = 0.001; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + Simulation simulation(particles, params); + + auto result = simulation.runSimulation(); - EXPECT_ARRAY_NEAR((*particle_container)[0].getX(), x1, 0.01); - EXPECT_ARRAY_NEAR((*particle_container)[1].getX(), x2, 0.01); - EXPECT_ARRAY_NEAR((*particle_container)[2].getX(), x3, 0.01); + EXPECT_ARRAY_NEAR((result.resulting_particles)[0].getX(), x1, 0.01); + EXPECT_ARRAY_NEAR((result.resulting_particles)[1].getX(), x2, 0.01); + EXPECT_ARRAY_NEAR((result.resulting_particles)[2].getX(), x3, 0.01); } diff --git a/tests/simulation/directsum/TestGravitySimulationDS.cpp b/tests/simulation/directsum/TestGravitySimulationDS.cpp index c202734c3..13a5c9371 100644 --- a/tests/simulation/directsum/TestGravitySimulationDS.cpp +++ b/tests/simulation/directsum/TestGravitySimulationDS.cpp @@ -3,8 +3,6 @@ #include #include "io/output/FileOutputHandler.h" -#include "particles/containers/directsum/DirectSumContainer.h" -#include "physics/forces/GravitationalForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" #include "utils/ArrayUtils.h" @@ -13,7 +11,7 @@ * Test if the particles of a gravity simulation attract each other. */ TEST(SimulationRunnerDirectSum, ParticlesAttractEachother_Gravity) { - std::unique_ptr particle_container = std::make_unique(); + std::vector particles; std::array x1 = {0, 0, 0}; std::array v1 = {0, 0, 0}; @@ -28,22 +26,17 @@ TEST(SimulationRunnerDirectSum, ParticlesAttractEachother_Gravity) { auto p1 = Particle(x1, v1, mass, 0); auto p2 = Particle(x2, v2, mass, 0); - particle_container->addParticle(p1); - particle_container->addParticle(p2); + particles.push_back(p1); + particles.push_back(p2); - FileOutputHandler file_output_handler(FileOutputHandler::OutputFormat::NONE); - - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_GRAVITY; params.end_time = 0.1; params.delta_t = 0.001; - Simulation simulation(particle_container, forces, params); + Simulation simulation(particles, params); - simulation.runSimulation(); + auto res = simulation.runSimulation(); - auto new_dist = ArrayUtils::L2Norm((*particle_container)[0].getX() - (*particle_container)[1].getX()); + auto new_dist = ArrayUtils::L2Norm((res.resulting_particles)[0].getX() - (res.resulting_particles)[1].getX()); EXPECT_LT(new_dist, initial_distance); } diff --git a/tests/simulation/directsum/TestLennardJonesSimulationDS.cpp b/tests/simulation/directsum/TestLennardJonesSimulationDS.cpp index 7c1d0b108..e1e5b2f75 100644 --- a/tests/simulation/directsum/TestLennardJonesSimulationDS.cpp +++ b/tests/simulation/directsum/TestLennardJonesSimulationDS.cpp @@ -1,8 +1,6 @@ #include #include "particles/containers/ParticleContainer.h" -#include "particles/containers/directsum/DirectSumContainer.h" -#include "physics/forces/LennardJonesForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" #include "utils/ArrayUtils.h" @@ -11,7 +9,7 @@ * Test if the particles of a Lennard-Jones simulation attract each other. */ TEST(SimulationRunnerDirectSum, ParticlesAttractEachother_LennardJones) { - std::unique_ptr particle_container = std::make_unique(); + std::vector particles; std::array x1 = {0, 0, 0}; std::array v1 = {0, 0, 0}; @@ -26,22 +24,17 @@ TEST(SimulationRunnerDirectSum, ParticlesAttractEachother_LennardJones) { auto p1 = Particle(x1, v1, mass, 0); auto p2 = Particle(x2, v2, mass, 0); - particle_container->addParticle(p1); - particle_container->addParticle(p2); + particles.push_back(p1); + particles.push_back(p2); - FileOutputHandler file_output_handler(FileOutputHandler::OutputFormat::NONE); - - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.1; params.delta_t = 0.01; - Simulation simulation(particle_container, forces, params); + Simulation simulation(particles, params); - simulation.runSimulation(); + auto res = simulation.runSimulation(); - auto new_dist = ArrayUtils::L2Norm((*particle_container)[0].getX() - (*particle_container)[1].getX()); + auto new_dist = ArrayUtils::L2Norm((res.resulting_particles)[0].getX() - (res.resulting_particles)[1].getX()); EXPECT_LT(new_dist, initial_distance); } diff --git a/tests/simulation/directsum/TestNewtonOptimizationDS.cpp b/tests/simulation/directsum/TestNewtonOptimizationDS.cpp deleted file mode 100644 index 0ffdd02fc..000000000 --- a/tests/simulation/directsum/TestNewtonOptimizationDS.cpp +++ /dev/null @@ -1 +0,0 @@ -// TODO \ No newline at end of file diff --git a/tests/simulation/linkedcells/Test3BodyPeriodicSolutionLC.cpp b/tests/simulation/linkedcells/Test3BodyPeriodicSolutionLC.cpp index f6de97513..7a88775cf 100644 --- a/tests/simulation/linkedcells/Test3BodyPeriodicSolutionLC.cpp +++ b/tests/simulation/linkedcells/Test3BodyPeriodicSolutionLC.cpp @@ -1,17 +1,16 @@ #include #include "io/logger/Logger.h" -#include "io/output/FileOutputHandler.h" -#include "particles/containers/ParticleContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/GravitationalForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" #include "utils/ArrayUtils.h" -#define EXPECT_ARRAY_NEAR(a, b, tol) \ - for (int i = 0; i < 3; i++) { \ - EXPECT_NEAR(a[i], b[i], tol); \ +using BC = LinkedCellsContainer::BoundaryCondition; + +#define EXPECT_ARRAY_NEAR(a, b, tol) \ + for (int i = 0; i < 3; i++) { \ + EXPECT_NEAR((a)[i], (b)[i], tol); \ }; /* @@ -21,9 +20,7 @@ TEST(SimulationRunnerLinkedCells, ParticlesReturnToInitialPositionPeriodicSolution_Gravity) { Logger::logger->set_level(spdlog::level::off); - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 10; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius); + std::vector particles; auto p1 = 0.347113; auto p2 = 0.532727; @@ -44,23 +41,22 @@ TEST(SimulationRunnerLinkedCells, ParticlesReturnToInitialPositionPeriodicSoluti auto pa2 = Particle(x2 + center_offset, v2, 1, 0); auto pa3 = Particle(x3 + center_offset, v3, 1, 0); - particle_container->addParticle(pa1); - particle_container->addParticle(pa2); - particle_container->addParticle(pa3); - - FileOutputHandler file_output_handler(FileOutputHandler::OutputFormat::NONE); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(pa1); + particles.push_back(pa2); + particles.push_back(pa3); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_GRAVITY; params.end_time = period; params.delta_t = 0.001; - Simulation simulation = Simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = + SimulationParams::LinkedCellsType({10, 10, 10}, 10, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation = Simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_ARRAY_NEAR((*particle_container)[0].getX(), pa1.getX(), 0.01); - EXPECT_ARRAY_NEAR((*particle_container)[1].getX(), pa2.getX(), 0.01); - EXPECT_ARRAY_NEAR((*particle_container)[2].getX(), pa3.getX(), 0.01); + EXPECT_ARRAY_NEAR((res.resulting_particles)[0].getX(), pa1.getX(), 0.01) + EXPECT_ARRAY_NEAR((res.resulting_particles)[1].getX(), pa2.getX(), 0.01) + EXPECT_ARRAY_NEAR((res.resulting_particles)[2].getX(), pa3.getX(), 0.01) } diff --git a/tests/simulation/linkedcells/TestGravitySimulationLC.cpp b/tests/simulation/linkedcells/TestGravitySimulationLC.cpp index e93f3142a..648ef3704 100644 --- a/tests/simulation/linkedcells/TestGravitySimulationLC.cpp +++ b/tests/simulation/linkedcells/TestGravitySimulationLC.cpp @@ -2,21 +2,18 @@ #include -#include "io/output/FileOutputHandler.h" -#include "particles/containers/ParticleContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/GravitationalForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" #include "utils/ArrayUtils.h" +using BC = LinkedCellsContainer::BoundaryCondition; + /* * Test if the particles of a gravity simulation attract each other. */ TEST(SimulationRunnerLinkedCells, ParticlesAttractEachother_Gravity) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 10; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius); + std::vector particles; std::array center_offset = {5, 5, 5}; @@ -33,22 +30,21 @@ TEST(SimulationRunnerLinkedCells, ParticlesAttractEachother_Gravity) { auto p1 = Particle(x1 + center_offset, v1, mass, 0); auto p2 = Particle(x2 + center_offset, v2, mass, 0); - particle_container->addParticle(p1); - particle_container->addParticle(p2); - - FileOutputHandler file_output_handler(FileOutputHandler::OutputFormat::NONE); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(p1); + particles.push_back(p2); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_GRAVITY; params.end_time = 0.1; params.delta_t = 0.01; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = + SimulationParams::LinkedCellsType({10, 10, 10}, 10, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - auto new_dist = ArrayUtils::L2Norm((*particle_container)[0].getX() - (*particle_container)[1].getX()); + auto new_dist = ArrayUtils::L2Norm((res.resulting_particles)[0].getX() - (res.resulting_particles)[1].getX()); EXPECT_LT(new_dist, initial_distance); } diff --git a/tests/simulation/linkedcells/TestLennardJonesSimulationLC.cpp b/tests/simulation/linkedcells/TestLennardJonesSimulationLC.cpp index 7ea33d659..7ec7cfdc1 100644 --- a/tests/simulation/linkedcells/TestLennardJonesSimulationLC.cpp +++ b/tests/simulation/linkedcells/TestLennardJonesSimulationLC.cpp @@ -1,19 +1,17 @@ #include -#include "particles/containers/ParticleContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/LennardJonesForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" #include "utils/ArrayUtils.h" +using BC = LinkedCellsContainer::BoundaryCondition; + /* * Test if the particles of a Lennard-Jones simulation attract each other. */ TEST(SimulationRunnerLinkedCells, ParticlesAttractEachother_LennardJones) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 10; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius); + std::vector particles; std::array center_offset = {5, 5, 5}; @@ -30,22 +28,21 @@ TEST(SimulationRunnerLinkedCells, ParticlesAttractEachother_LennardJones) { auto p1 = Particle(x1 + center_offset, v1, mass, 0); auto p2 = Particle(x2 + center_offset, v2, mass, 0); - particle_container->addParticle(p1); - particle_container->addParticle(p2); - - FileOutputHandler file_output_handler(FileOutputHandler::OutputFormat::NONE); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(p1); + particles.push_back(p2); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.1; params.delta_t = 0.01; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = + SimulationParams::LinkedCellsType({10, 10, 10}, 10, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - auto new_dist = ArrayUtils::L2Norm((*particle_container)[0].getX() - (*particle_container)[1].getX()); + auto new_dist = ArrayUtils::L2Norm((res.resulting_particles)[0].getX() - (res.resulting_particles)[1].getX()); EXPECT_LT(new_dist, initial_distance); } diff --git a/tests/simulation/linkedcells/boundaries/TestOutflowBoundary.cpp b/tests/simulation/linkedcells/boundaries/TestOutflowBoundary.cpp index 0306a5db6..6618203d4 100644 --- a/tests/simulation/linkedcells/boundaries/TestOutflowBoundary.cpp +++ b/tests/simulation/linkedcells/boundaries/TestOutflowBoundary.cpp @@ -2,13 +2,10 @@ #include -#include "io/output/FileOutputHandler.h" #include "particles/containers/ParticleContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/LennardJonesForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" -#include "utils/ArrayUtils.h" using BC = LinkedCellsContainer::BoundaryCondition; @@ -16,172 +13,160 @@ using BC = LinkedCellsContainer::BoundaryCondition; * Test if the particle is deleted at the left boundary. */ TEST(OutflowBoundaryLC, DeletedAtLeftBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {2, 5, 5}; std::array v1 = {-4, 0, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 1; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_EQ(particle_container->size(), 0); + EXPECT_EQ(res.resulting_particles.size(), 0); } /* * Test if the particle is deleted at the right boundary. */ TEST(OutflowBoundaryLC, DeletedAtRightBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {8, 5, 5}; std::array v1 = {4, 0, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 1; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_EQ(particle_container->size(), 0); + EXPECT_EQ(res.resulting_particles.size(), 0); } /* * Test if the particle is deleted at the bottom boundary. */ TEST(OutflowBoundaryLC, DeletedAtBottomBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 2, 5}; std::array v1 = {0, -4, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 1; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_EQ(particle_container->size(), 0); + EXPECT_EQ(res.resulting_particles.size(), 0); } /* * Test if the particle is deleted at the top boundary. */ TEST(OutflowBoundaryLC, DeletedAtTopBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 8, 5}; std::array v1 = {0, 4, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 1; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE, BC::REFLECTIVE}); + + Simulation simulation(particles, params); - EXPECT_EQ(particle_container->size(), 0); + auto res = simulation.runSimulation(); + + EXPECT_EQ(res.resulting_particles.size(), 0); } /* - * Test if the particle is deleted at the back boundary. + * Test if the particle is deleted at the front boundary. */ TEST(OutflowBoundaryLC, DeletedAtFrontBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 5, 2}; std::array v1 = {0, 0, -4}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 1; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW, BC::REFLECTIVE}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_EQ(particle_container->size(), 0); + EXPECT_EQ(res.resulting_particles.size(), 0); } /* - * Test if the particle is deleted at the front boundary. + * Test if the particle is deleted at the back boundary. */ TEST(OutflowBoundaryLC, DeletedAtBackBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 5, 8}; std::array v1 = {0, 0, 4}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(particle); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 1; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::OUTFLOW}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_EQ(particle_container->size(), 0); + EXPECT_EQ(res.resulting_particles.size(), 0); } diff --git a/tests/simulation/linkedcells/boundaries/TestReflectiveBoundary.cpp b/tests/simulation/linkedcells/boundaries/TestReflectiveBoundary.cpp index 8b8aa41f7..87ceec279 100644 --- a/tests/simulation/linkedcells/boundaries/TestReflectiveBoundary.cpp +++ b/tests/simulation/linkedcells/boundaries/TestReflectiveBoundary.cpp @@ -2,227 +2,177 @@ #include -#include "io/output/FileOutputHandler.h" #include "particles/containers/ParticleContainer.h" #include "particles/containers/linkedcells/LinkedCellsContainer.h" -#include "physics/forces/LennardJonesForce.h" #include "simulation/Simulation.h" #include "simulation/SimulationUtils.h" -#include "utils/ArrayUtils.h" using BC = LinkedCellsContainer::BoundaryCondition; /* - * Test if the particle is reflected at the right boundary. + * Test if the particle is reflected at the left boundary. */ TEST(ReflectiveBoundaryLC, BouncesAtLeftBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {2, 5, 5}; std::array v1 = {-4, 0, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(particle); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.5; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_GE((*particle_container)[0].getV()[0], 0); - EXPECT_NEAR((*particle_container)[0].getV()[0], -v1[0], 1e-3); + EXPECT_GE((res.resulting_particles)[0].getV()[0], 0); + EXPECT_NEAR((res.resulting_particles)[0].getV()[0], -v1[0], 1e-3); } /* * Test if the particle is reflected at the right boundary. */ TEST(ReflectiveBoundaryLC, BouncesAtRightBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {8, 5, 5}; std::array v1 = {4, 0, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.5; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); - EXPECT_LE((*particle_container)[0].getV()[0], 0); - EXPECT_NEAR((*particle_container)[0].getV()[0], -v1[0], 1e-3); + EXPECT_LE((res.resulting_particles)[0].getV()[0], 0); + EXPECT_NEAR((res.resulting_particles)[0].getV()[0], -v1[0], 1e-3); } /* * Test if the particle is reflected at the bottom boundary. */ TEST(ReflectiveBoundaryLC, BouncesAtBottomBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 2, 5}; std::array v1 = {0, -4, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.5; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW}); + + Simulation simulation(particles, params); - EXPECT_GE((*particle_container)[0].getV()[1], 0); - EXPECT_NEAR((*particle_container)[0].getV()[1], -v1[1], 1e-3); + auto res = simulation.runSimulation(); + + EXPECT_GE((res.resulting_particles)[0].getV()[1], 0); + EXPECT_NEAR((res.resulting_particles)[0].getV()[1], -v1[1], 1e-3); } /* * Test if the particle is reflected at the top boundary. */ TEST(ReflectiveBoundaryLC, BouncesAtTopBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 8, 5}; std::array v1 = {0, 4, 0}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(particle); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.5; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW, BC::OUTFLOW}); - EXPECT_LE((*particle_container)[0].getV()[1], 0); - EXPECT_NEAR((*particle_container)[0].getV()[1], -v1[1], 1e-3); + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); + + EXPECT_LE((res.resulting_particles)[0].getV()[1], 0); + EXPECT_NEAR((res.resulting_particles)[0].getV()[1], -v1[1], 1e-3); } /* * Test if the particle is reflected at the back boundary. */ TEST(ReflectiveBoundaryLC, BouncesAtBackBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 5, 2}; std::array v1 = {0, 0, -4}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); - - std::vector> forces; - forces.push_back(std::make_unique()); + particles.push_back(particle); - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.5; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE, BC::OUTFLOW}); - EXPECT_GE((*particle_container)[0].getV()[2], 0); - EXPECT_NEAR((*particle_container)[0].getV()[2], -v1[2], 1e-3); + Simulation simulation(particles, params); + + auto res = simulation.runSimulation(); + + EXPECT_GE((res.resulting_particles)[0].getV()[2], 0); + EXPECT_NEAR((res.resulting_particles)[0].getV()[2], -v1[2], 1e-3); } /* * Test if the particle is reflected at the front boundary. */ TEST(ReflectiveBoundaryLC, BouncesAtFrontBoundary) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 5; - std::array bcs = {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + std::vector particles; std::array x1 = {5, 5, 8}; std::array v1 = {0, 0, 4}; auto particle = Particle(x1, v1, 1, 0); - particle_container->addParticle(particle); + particles.push_back(particle); - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; + SimulationParams params = TEST_DEFAULT_PARAMS_LENNARD_JONES; params.end_time = 0.5; params.delta_t = 0.005; - Simulation simulation(particle_container, forces, params); - simulation.runSimulation(); + params.container_type = SimulationParams::LinkedCellsType( + {10, 10, 10}, 5, {BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::OUTFLOW, BC::REFLECTIVE}); - EXPECT_LE((*particle_container)[0].getV()[2], 0); - EXPECT_NEAR((*particle_container)[0].getV()[2], -v1[2], 1e-3); -} - -/* - * Test if the particle stays inside the container if bounced along all boundaries. - */ -TEST(ReflectiveBoundaryLC, ParticleStaysInsideContainer) { - std::array domain_size = {10, 10, 10}; - double cutoff_radius = 10; - std::array bcs = {BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE, BC::REFLECTIVE}; - std::unique_ptr particle_container = std::make_unique(domain_size, cutoff_radius, bcs); + Simulation simulation(particles, params); - std::array x1 = {5, 7, 7.4}; - std::array v1 = {2.32, 3.12, 3.23}; + auto res = simulation.runSimulation(); - auto particle = Particle(x1, v1, 1, 0); - - particle_container->addParticle(particle); - - std::vector> forces; - forces.push_back(std::make_unique()); - - SimulationParams params = TEST_DEFAULT_PARAMS; - params.end_time = 10; - params.delta_t = 0.005; - params.fps = 5; - Simulation simulation(particle_container, forces, params); - - simulation.runSimulation(); - - EXPECT_GE((*particle_container)[0].getX()[0], 0); - EXPECT_LE((*particle_container)[0].getX()[0], domain_size[0]); - EXPECT_GE((*particle_container)[0].getX()[1], 0); - EXPECT_LE((*particle_container)[0].getX()[1], domain_size[1]); - EXPECT_GE((*particle_container)[0].getX()[2], 0); - EXPECT_LE((*particle_container)[0].getX()[2], domain_size[2]); -} \ No newline at end of file + EXPECT_LE((res.resulting_particles)[0].getV()[2], 0); + EXPECT_NEAR((res.resulting_particles)[0].getV()[2], -v1[2], 1e-3); +}