Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/developer/internal.input-file-parser.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- prepare celllist input file parser to remove engine dependency
- prepare constraints input file parser to remove engine dependency
- prepare files input file parser to remove engine dependency
30 changes: 14 additions & 16 deletions include/engine/engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ namespace engine
const std::shared_ptr<simulationBox::CellList> &getCellList() const;
[[nodiscard]]
const std::shared_ptr<constraints::Constraints> &getConstraints() const;
[[nodiscard]]
const std::shared_ptr<
intraNonBonded::IntraNonBonded> &getIntraNonBonded() const;

[[nodiscard]] simulationBox::SimulationBox &getSimulationBox();
[[nodiscard]] physicalData::PhysicalData &getPhysicalData();
[[nodiscard]] physicalData::PhysicalData &getAveragePhysicalData();
[[nodiscard]] forceField::ForceField &getForceField();
[[nodiscard]] intraNonBonded::IntraNonBonded &getIntraNonBonded();
[[nodiscard]] virial::Virial &getVirial();
[[nodiscard]] potential::Potential &getPotential();
[[nodiscard]] simulationBox::SimulationBox &getSimulationBox();
[[nodiscard]] physicalData::PhysicalData &getPhysicalData();
[[nodiscard]] physicalData::PhysicalData &getAveragePhysicalData();
[[nodiscard]] forceField::ForceField &getForceField();
[[nodiscard]] virial::Virial &getVirial();
[[nodiscard]] potential::Potential &getPotential();

/*************************
* output getter methods *
Expand All @@ -133,12 +135,11 @@ namespace engine
* get pointer methods *
***********************/

[[nodiscard]] forceField::ForceField *getForceFieldPtr();
[[nodiscard]] potential::Potential *getPotentialPtr();
[[nodiscard]] virial::Virial *getVirialPtr();
[[nodiscard]] simulationBox::SimulationBox *getSimulationBoxPtr();
[[nodiscard]] physicalData::PhysicalData *getPhysicalDataPtr();
[[nodiscard]] intraNonBonded::IntraNonBonded *getIntraNonBondedPtr();
[[nodiscard]] forceField::ForceField *getForceFieldPtr();
[[nodiscard]] potential::Potential *getPotentialPtr();
[[nodiscard]] virial::Virial *getVirialPtr();
[[nodiscard]] simulationBox::SimulationBox *getSimulationBoxPtr();
[[nodiscard]] physicalData::PhysicalData *getPhysicalDataPtr();

/******************************
* get shared pointer methods *
Expand All @@ -151,9 +152,6 @@ namespace engine
[[nodiscard]]
std::shared_ptr<physicalData::PhysicalData> getSharedPhysicalData(
) const;
[[nodiscard]]
std::shared_ptr<intraNonBonded::IntraNonBonded> getSharedIntraNonBonded(
) const;
[[nodiscard]] std::shared_ptr<virial::Virial> getSharedVirial() const;
[[nodiscard]] std::shared_ptr<potential::Potential> getSharedPotential(
) const;
Expand Down
3 changes: 3 additions & 0 deletions include/input/inputFileParser/filesInputParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ namespace input
class FilesInputParser : public InputFileParser
{
private:
std::shared_ptr<intraNonBonded::IntraNonBonded> _intraNonBonded;

bool _validateFilePaths;

public:
explicit FilesInputParser(
engine::Engine &,
std::shared_ptr<intraNonBonded::IntraNonBonded> intraNonBonded,
bool validateFilePaths = true
);

Expand Down
24 changes: 5 additions & 19 deletions src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,12 @@ ForceField &Engine::getForceField() { return *_forceField; }
/**
* @brief get the reference to the intra non bonded interactions
*
* @return IntraNonBonded&
* @return const std::shared_ptr<IntraNonBonded>&
*/
IntraNonBonded &Engine::getIntraNonBonded() { return *_intraNonBonded; }
const std::shared_ptr<IntraNonBonded> &Engine::getIntraNonBonded() const
{
return _intraNonBonded;
}

/**
* @brief get the reference to the virial
Expand Down Expand Up @@ -237,13 +240,6 @@ SimulationBox *Engine::getSimulationBoxPtr() { return _simulationBox.get(); }
*/
PhysicalData *Engine::getPhysicalDataPtr() { return _physicalData.get(); }

/**
* @brief get the pointer to the intra non bonded interactions
*
* @return IntraNonBonded*
*/
IntraNonBonded *Engine::getIntraNonBondedPtr() { return _intraNonBonded.get(); }

/**
* @brief set the inter-water interactions handler
*
Expand Down Expand Up @@ -391,16 +387,6 @@ const std::shared_ptr<Constraints> &Engine::getConstraints() const
return _constraints;
}

/**
* @brief get the shared pointer to the intra non bonded interactions
*
* @return std::shared_ptr<IntraNonBonded>
*/
std::shared_ptr<IntraNonBonded> Engine::getSharedIntraNonBonded() const
{
return _intraNonBonded;
}

/**
* @brief get the shared pointer to the virial
*
Expand Down
2 changes: 1 addition & 1 deletion src/engine/hessianEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ std::shared_ptr<Evaluator> HessianEngine::setupEvaluator()
evaluator->setPotential(getSharedPotential());
evaluator->setForceField(getSharedForceField());
evaluator->setConstraints(getConstraints());
evaluator->setIntraNonBonded(getSharedIntraNonBonded());
evaluator->setIntraNonBonded(getIntraNonBonded());
evaluator->setVirial(getSharedVirial());
evaluator->setPhysicalData(getSharedPhysicalData());
evaluator->setPhysicalDataOld(getSharedPhysicalDataOld());
Expand Down
12 changes: 9 additions & 3 deletions src/input/inputFileParser/filesInputParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ using namespace utilities;
*
* @param engine
*/
FilesInputParser::FilesInputParser(Engine &engine, const bool validateFilePaths)
: InputFileParser(engine), _validateFilePaths(validateFilePaths)
FilesInputParser::FilesInputParser(
Engine &engine,
std::shared_ptr<intraNonBonded::IntraNonBonded> intraNonBonded,
const bool validateFilePaths
)
: InputFileParser(engine),
_intraNonBonded(intraNonBonded),
_validateFilePaths(validateFilePaths)
{
addKeyword(
std::string("intra-nonBonded_file"),
Expand Down Expand Up @@ -144,7 +150,7 @@ void FilesInputParser::parseIntraNonBondedFile(
std::format("Intra non bonded file \"{}\" File not found", fileName)
);

_engine.getIntraNonBonded().activate();
_intraNonBonded->activate();

FileSettings::setIntraNonBondedFileName(fileName);
FileSettings::setIsIntraNonBondedFileNameSet();
Expand Down
6 changes: 5 additions & 1 deletion src/input/inputFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ InputFileReader::InputFileReader(
);
_parsers.push_back(make_unique<CoulombLongRangeInputParser>(_engine));
_parsers.push_back(
make_unique<FilesInputParser>(_engine, validateFilePaths)
make_unique<FilesInputParser>(
_engine,
_engine.getIntraNonBonded(),
validateFilePaths
)
);
_parsers.push_back(make_unique<MMInputParser>(_engine));
_parsers.push_back(make_unique<GeneralInputParser>(_engine));
Expand Down
13 changes: 7 additions & 6 deletions src/input/intraNonBondedReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "engine.hpp" // for Engine
#include "exceptions.hpp" // for IntraNonBondedException
#include "fileSettings.hpp" // for FileSettings
#include "intraNonBonded.hpp" // for IntraNonBonded
#include "intraNonBondedContainer.hpp" // for IntraNonBondedContainer
#include "mathUtilities.hpp" // for sign, utilities
#include "simulationBox.hpp" // for SimulationBox
Expand Down Expand Up @@ -92,7 +91,9 @@ IntraNonBondedReader::IntraNonBondedReader(
const std::string &fileName,
Engine &engine
)
: _fileName(fileName), _fp(fileName), _engine(engine){};
: _fileName(fileName), _fp(fileName), _engine(engine)
{
}

/**
* @brief reads the intra non bonded interactions from the intraNonBonded file
Expand Down Expand Up @@ -285,7 +286,7 @@ void IntraNonBondedReader::processMolecule(const size_t moleculeType)

const auto container = IntraNonBondedContainer(moleculeType, atomIndices);

_engine.getIntraNonBonded().addIntraNonBondedContainer(container);
_engine.getIntraNonBonded()->addIntraNonBondedContainer(container);
}

/**
Expand All @@ -297,8 +298,8 @@ void IntraNonBondedReader::processMolecule(const size_t moleculeType)
*/
void IntraNonBondedReader::checkDuplicates() const
{
auto &intraNonBonded = _engine.getIntraNonBonded();
const auto nonBondedCont = intraNonBonded.getIntraNonBondedContainers();
const auto &intraNonBonded = _engine.getIntraNonBonded();
const auto nonBondedCont = intraNonBonded->getIntraNonBondedContainers();

auto transform = [](const auto &container)
{ return container.getMolType(); };
Expand Down Expand Up @@ -333,4 +334,4 @@ void IntraNonBondedReader::setFileName(const std::string_view &fileName)
/**
* @brief reinitializes the file pointer
*/
void IntraNonBondedReader::reInitializeFp() { _fp = std::ifstream(_fileName); }
void IntraNonBondedReader::reInitializeFp() { _fp = std::ifstream(_fileName); }
15 changes: 7 additions & 8 deletions src/setup/intraNonBondedSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@

#include "intraNonBondedSetup.hpp"

#include "engine.hpp" // for Engine
#include "intraNonBonded.hpp" // for IntraNonBonded
#include "potential.hpp" // for Potential
#include "engine.hpp" // for Engine
#include "potential.hpp" // for Potential

using namespace setup;
using namespace engine;
Expand Down Expand Up @@ -52,7 +51,7 @@ void setup::setupIntraNonBonded(engine::Engine &engine)
*
* @param engine
*/
IntraNonBondedSetup::IntraNonBondedSetup(Engine &engine) : _engine(engine){};
IntraNonBondedSetup::IntraNonBondedSetup(Engine &engine) : _engine(engine) {}

/**
* @brief Setup intra non bonded interactions
Expand All @@ -71,8 +70,8 @@ void IntraNonBondedSetup::setup()
const auto &nonCoulombPot = potential.getNonCoulombPotSharedPtr();
const auto &coulombPot = potential.getCoulombPotSharedPtr();

intraNonBonded.setNonCoulombPotential(nonCoulombPot);
intraNonBonded.setCoulombPotential(coulombPot);
intraNonBonded->setNonCoulombPotential(nonCoulombPot);
intraNonBonded->setCoulombPotential(coulombPot);

intraNonBonded.fillIntraNonBondedMaps(_engine.getSimulationBox());
}
intraNonBonded->fillIntraNonBondedMaps(_engine.getSimulationBox());
}
2 changes: 1 addition & 1 deletion src/setup/optimizerSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ std::shared_ptr<Evaluator> OptimizerSetup::setupEvaluator()
evaluator->setPotential(_optEngine.getSharedPotential());
evaluator->setForceField(_optEngine.getSharedForceField());
evaluator->setConstraints(_optEngine.getConstraints());
evaluator->setIntraNonBonded(_optEngine.getSharedIntraNonBonded());
evaluator->setIntraNonBonded(_optEngine.getIntraNonBonded());
evaluator->setVirial(_optEngine.getSharedVirial());
evaluator->setSimulationBox(_optEngine.getSharedSimulationBox());
evaluator->setPhysicalData(_optEngine.getSharedPhysicalData());
Expand Down
4 changes: 2 additions & 2 deletions tests/include/input/testIntraNonBondedReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TestIntraNonBondedReader : public ::testing::Test
_engine = new engine::MMMDEngine();

_engine->getSimulationBox().addMoleculeType(molecule1);
_engine->getIntraNonBonded().activate();
_engine->getIntraNonBonded()->activate();

_intraNonBondedReader =
new input::intraNonBondedReader::IntraNonBondedReader(
Expand All @@ -75,4 +75,4 @@ class TestIntraNonBondedReader : public ::testing::Test
}
};

#endif // _TEST_INTRA_NON_BONDED_READER_HPP_
#endif // _TEST_INTRA_NON_BONDED_READER_HPP_
24 changes: 12 additions & 12 deletions tests/src/input/inputFileParsing/testFilesParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using namespace input;
*/
TEST_F(TestInputFileReader, testParseTopologyFilename)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());

std::vector<std::string> lineElements = {
"topology_file",
Expand Down Expand Up @@ -73,7 +73,7 @@ TEST_F(TestInputFileReader, testParseTopologyFilename)
*/
TEST_F(TestInputFileReader, testParseParameterFilename)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());

std::vector<std::string> lineElements = {
"parameter_file",
Expand Down Expand Up @@ -104,7 +104,7 @@ TEST_F(TestInputFileReader, testParseParameterFilename)
*/
TEST_F(TestInputFileReader, parseIntraNonBondedFile)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {
"intra-nonBonded_file",
"=",
Expand Down Expand Up @@ -134,7 +134,7 @@ TEST_F(TestInputFileReader, parseIntraNonBondedFile)
*/
TEST_F(TestInputFileReader, testStartFileName)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {
"startFile_name",
"=",
Expand All @@ -160,7 +160,7 @@ TEST_F(TestInputFileReader, testStartFileName)
*/
TEST_F(TestInputFileReader, testMoldescriptorFileName)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {
"moldescriptorFile_name",
"=",
Expand Down Expand Up @@ -191,7 +191,7 @@ TEST_F(TestInputFileReader, testMoldescriptorFileName)
*/
TEST_F(TestInputFileReader, testGuffPath)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
const std::vector<std::string> lineElements = {"guff_path", "=", "guff"};
EXPECT_THROW_MSG(
parser.parseGuffPath(lineElements, 0),
Expand All @@ -206,7 +206,7 @@ TEST_F(TestInputFileReader, testGuffPath)
*/
TEST_F(TestInputFileReader, guffDatFilename)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {"guffdat_file", "=", "guff.dat"};
EXPECT_THROW_MSG(
parser.parseGuffDatFilename(lineElements, 0),
Expand All @@ -227,7 +227,7 @@ TEST_F(TestInputFileReader, guffDatFilename)
*/
TEST_F(TestInputFileReader, testRpmdStartFileName)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {
"rpmd_start_file",
"=",
Expand Down Expand Up @@ -256,7 +256,7 @@ TEST_F(TestInputFileReader, testRpmdStartFileName)
*/
TEST_F(TestInputFileReader, testMShakeFileName)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {"mshake_file", "=", "mshake.dat"};

EXPECT_THROW_MSG(
Expand All @@ -278,7 +278,7 @@ TEST_F(TestInputFileReader, testMShakeFileName)
*/
TEST_F(TestInputFileReader, testDFTBFileName)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {
"dftb_file",
"=",
Expand All @@ -304,7 +304,7 @@ TEST_F(TestInputFileReader, testDFTBFileName)
*/
TEST_F(TestInputFileReader, testTMFileName)
{
FilesInputParser parser(*_engine);
FilesInputParser parser(*_engine, _engine->getIntraNonBonded());
std::vector<std::string> lineElements = {
"turbomole_file",
"=",
Expand All @@ -327,4 +327,4 @@ TEST_F(TestInputFileReader, testTMFileName)
settings::FileSettings::getTMFileName(),
"data/turbomoleReader/tm_define.template"
);
}
}
Loading
Loading