Skip to content

Commit

Permalink
refactor: Procedures are now just Generators (#1946)
Browse files Browse the repository at this point in the history
  • Loading branch information
trisyoungs authored Jul 29, 2024
1 parent 5a4e709 commit b9bcdfd
Show file tree
Hide file tree
Showing 138 changed files with 1,531 additions and 1,808 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ set(BASIC_LINK_LIBS
import
neta
analyser
procedure
procedureNodes
generator
keywords
expression
items
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ add_subdirectory(classes)
add_subdirectory(data)
add_subdirectory(expression)
add_subdirectory(items)
add_subdirectory(generator)
add_subdirectory(kernels)
add_subdirectory(keywords)
add_subdirectory(io)
add_subdirectory(main)
add_subdirectory(math)
add_subdirectory(module)
add_subdirectory(procedure)
add_subdirectory(neta)

if(GUI)
Expand Down
20 changes: 10 additions & 10 deletions src/classes/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ std::string_view Configuration::name() const { return name_; }
std::string_view Configuration::niceName() const { return niceName_; }

// Return the current generator
Procedure &Configuration::generator() { return generator_; }
Generator &Configuration::generator() { return generator_; }

// Create the Configuration according to its generator Procedure
bool Configuration::generate(const ProcedureContext &procedureContext)
// Create the Configuration according to its generator
bool Configuration::generate(const GeneratorContext &generatorContext)
{
// Empty the current contents
empty();

// Generate the contents
Messenger::print("\nExecuting generator procedure for Configuration '{}'...\n\n", niceName());
auto result = generator_.execute({procedureContext, this});
auto result = generator_.execute({generatorContext, this});
if (!result)
return Messenger::error("Failed to generate Configuration '{}'.\n", niceName());
Messenger::print("\n");

// Set-up Cells for the Box
cells_.generate(box_.get(), requestedCellDivisionLength_, procedureContext.potentialMap().range());
cells_.generate(box_.get(), requestedCellDivisionLength_, generatorContext.potentialMap().range());

// Make sure all objects know about each other
updateObjectRelationships();
Expand All @@ -92,15 +92,15 @@ bool Configuration::generate(const ProcedureContext &procedureContext)
}

// Initialise (generate or load) the basic contents of the Configuration
bool Configuration::initialiseContent(const ProcedureContext &procedureContext)
bool Configuration::initialiseContent(const GeneratorContext &generatorContext)
{
// Clear existing content
empty();

appliedSizeFactor_ = std::nullopt;

// Run the generator Procedure
if (!generate(procedureContext))
// Run the generator Generator
if (!generate(generatorContext))
return false;

updateAtomLocations(true);
Expand All @@ -110,10 +110,10 @@ bool Configuration::initialiseContent(const ProcedureContext &procedureContext)
return false;

// Create cell array
updateCells(procedureContext.potentialMap().range());
updateCells(generatorContext.potentialMap().range());

// Apply size factor scaling if required
applySizeFactor(procedureContext.processPool(), procedureContext.potentialMap());
applySizeFactor(generatorContext.processPool(), generatorContext.potentialMap());

return true;
}
Expand Down
18 changes: 9 additions & 9 deletions src/classes/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
#include "classes/cellArray.h"
#include "classes/molecule.h"
#include "classes/siteStack.h"
#include "generator/generator.h"
#include "io/import/coordinates.h"
#include "items/list.h"
#include "kernels/potentials/base.h"
#include "math/data1D.h"
#include "math/histogram1D.h"
#include "math/interpolator.h"
#include "module/layer.h"
#include "procedure/procedure.h"
#include "templates/vector3.h"
#include <deque>
#include <map>
Expand Down Expand Up @@ -51,10 +51,10 @@ class Configuration : public Serialisable<const CoreData &>
std::string name_;
// Nice name (generated from name_) used for output files
std::string niceName_;
// Procedure to generate the Configuration
Procedure generator_;
static constexpr double defaultTemperature_ = 300.0;
// Generator for the Configuration
Generator generator_;
// Temperature of this configuration (K)
static constexpr double defaultTemperature_ = 300.0;
double temperature_{defaultTemperature_};

public:
Expand All @@ -64,12 +64,12 @@ class Configuration : public Serialisable<const CoreData &>
std::string_view name() const;
// Return nice name of the Configuration
std::string_view niceName() const;
// Return the current generator
Procedure &generator();
// Create the Configuration according to its generator Procedure
bool generate(const ProcedureContext &procedureContext);
// Return the generator for the Configuration
Generator &generator();
// Create the Configuration according to its generator
bool generate(const GeneratorContext &generatorContext);
// Initialise (generate or load) the basic contents of the Configuration
bool initialiseContent(const ProcedureContext &procedureContext);
bool initialiseContent(const GeneratorContext &generatorContext);
// Set configuration temperature
void setTemperature(double t);
// Return configuration temperature
Expand Down
77 changes: 40 additions & 37 deletions src/procedure/nodes/CMakeLists.txt → src/generator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,68 +1,71 @@
add_library(
procedureNodes
generator
add.cpp
addPair.cpp
box.cpp
context.cpp
coordinateSets.cpp
copy.cpp
customRegion.cpp
cylindricalGlobalPotential.cpp
cylindricalRegion.cpp
generalRegion.cpp
importCoordinates.cpp
iterateSelection.cpp
node.cpp
parameters.cpp
pick.cpp
pickBase.cpp
pickProximity.cpp
pickRegion.cpp
regionBase.cpp
regionalGlobalPotential.cpp
registry.cpp
remove.cpp
restraintPotential.cpp
rotateFragment.cpp
runLayer.cpp
select.cpp
sequence.cpp
sphericalGlobalPotential.cpp
sizeFactor.cpp
temperature.cpp
transmute.cpp
add.h
addPair.cpp
addPair.h
box.cpp
box.h
context.cpp
context.h
coordinateSets.cpp
coordinateSets.h
copy.cpp
copy.h
customRegion.cpp
customRegion.h
cylindricalGlobalPotential.cpp
cylindricalGlobalPotential.h
cylindricalRegion.cpp
cylindricalRegion.h
generalRegion.cpp
generalRegion.h
generator.cpp
generator.h
importCoordinates.cpp
importCoordinates.h
iterateSelection.cpp
iterateSelection.h
node.cpp
node.h
nodeValue.cpp
nodeValue.h
parameters.cpp
parameters.h
pick.h
pickBase.cpp
pickBase.h
pick.cpp
pick.h
pickProximity.cpp
pickProximity.h
pickRegion.cpp
pickRegion.h
regionBase.h
regionalGlobalPotential.cpp
regionalGlobalPotential.h
regionBase.cpp
regionBase.h
registry.cpp
registry.h
remove.cpp
remove.h
restraintPotential.cpp
restraintPotential.h
rotateFragment.cpp
rotateFragment.h
runLayer.h
select.cpp
select.h
sequence.cpp
sequence.h
sphericalGlobalPotential.h
sizeFactor.cpp
sizeFactor.h
sphericalGlobalPotential.cpp
sphericalGlobalPotential.h
temperature.cpp
temperature.h
transmute.cpp
transmute.h
)

target_include_directories(procedureNodes PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(procedureNodes PRIVATE base)
target_include_directories(generator PRIVATE ${PROJECT_SOURCE_DIR}/src)

target_link_libraries(generator PRIVATE base)
Loading

0 comments on commit b9bcdfd

Please sign in to comment.