From 7770010cf1375d39c04baa839cea153f4b3c405d Mon Sep 17 00:00:00 2001 From: Dan Short Date: Fri, 31 Jul 2020 16:55:00 +0100 Subject: [PATCH] Formatting updates Use American English consistently. A small tweak to a brace in the SerializedSource. --- examples/serialized_custom_source/README.md | 6 +++--- examples/serialized_custom_source/build_xml.py | 2 +- .../serialized_source_ring.cpp | 15 +++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/serialized_custom_source/README.md b/examples/serialized_custom_source/README.md index 2ebc1ecc26..d7c1e0542d 100644 --- a/examples/serialized_custom_source/README.md +++ b/examples/serialized_custom_source/README.md @@ -1,4 +1,4 @@ -# Building a Serialised Custom Source +# Building a Serialized Custom Source To run this example, you first need to compile the custom source library, which requires headers from OpenMC. A CMakeLists.txt file has been set up for you that @@ -10,7 +10,7 @@ library, you can run: make After this, you can build the model by running `python build_xml.py`. In the XML -files that are created, you should see a reference to build/libserialised_source.so, +files that are created, you should see a reference to build/libserialized_source.so, the custom source library that was built by CMake, and the path to the serialized representation of the source in serialized_source.xml. The model is also set up with a mesh tally of the flux, so once you run `openmc`, you will get a statepoint file @@ -19,5 +19,5 @@ results from the statepoint file and display them. If all worked well, you should see a ring "imprint" as well as a higher flux to the right side (since the custom source has all particles moving in the positive x direction). -Once built, you can edit the serialised_source.xml file to change the radius of the +Once built, you can edit the serialized_source.xml file to change the radius of the sampled ring or the energy of the sampled particles. diff --git a/examples/serialized_custom_source/build_xml.py b/examples/serialized_custom_source/build_xml.py index fba5459598..7c6d5f61da 100644 --- a/examples/serialized_custom_source/build_xml.py +++ b/examples/serialized_custom_source/build_xml.py @@ -1,6 +1,6 @@ import openmc -# Define the serialised source +# Define the serialized source serialized_source = """ 1.5 1e3 diff --git a/examples/serialized_custom_source/serialized_source_ring.cpp b/examples/serialized_custom_source/serialized_source_ring.cpp index 7e19bc579c..bf398ce834 100644 --- a/examples/serialized_custom_source/serialized_source_ring.cpp +++ b/examples/serialized_custom_source/serialized_source_ring.cpp @@ -5,13 +5,13 @@ #include "openmc/particle.h" #include "pugixml.hpp" -class SerialisedSource { +class SerializedSource { protected: double radius_; double energy_; // Protect the constructor so that the class can only be created by serialisation. - SerialisedSource(double radius, double energy) { + SerializedSource(double radius, double energy) { radius_ = radius; energy_ = energy; } @@ -25,21 +25,20 @@ class SerialisedSource { // in the input XML document. // Note that the source will have already been read from file, so what will be passed // in here is a string-like serialized value (not the path to the serialized value). - static SerialisedSource from_xml(char* serialised_source) { + static SerializedSource from_xml(char* serialized_source) { pugi::xml_document doc; - doc.load_string(serialised_source); + doc.load_string(serialized_source); pugi::xml_node root_node = doc.root().child("Source"); double radius = root_node.child("Radius").text().as_double(); double energy = root_node.child("Energy").text().as_double(); - return SerialisedSource(radius, energy); + return SerializedSource(radius, energy); } }; // you must have external C linkage here otherwise // dlopen will not find the file -extern "C" openmc::Particle::Bank sample_source(uint64_t* seed, char* serialised_source) -{ - SerialisedSource source = SerialisedSource::from_xml(serialised_source); +extern "C" openmc::Particle::Bank sample_source(uint64_t* seed, char* serialized_source) { + SerializedSource source = SerializedSource::from_xml(serialized_source); openmc::Particle::Bank particle; // wgt