From fa0a16082778c6180168b2235177b18bf16a47f4 Mon Sep 17 00:00:00 2001 From: William F Godoy Date: Tue, 23 Aug 2022 10:08:27 -0400 Subject: [PATCH] Add isComplex and refactor ProjectData getters Add isComplex public function and private member variable Move inline functions to a single translation unit Add test --- src/Utilities/ProjectData.cpp | 24 +++++++++++++++++- src/Utilities/ProjectData.h | 31 +++++++++++++++-------- src/Utilities/tests/test_project_data.cpp | 9 +++++++ 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/src/Utilities/ProjectData.cpp b/src/Utilities/ProjectData.cpp index 3bd8f00b2..ad002f34a 100644 --- a/src/Utilities/ProjectData.cpp +++ b/src/Utilities/ProjectData.cpp @@ -24,6 +24,8 @@ namespace qmcplusplus { + +// PUBLIC //---------------------------------------------------------------------------- // ProjectData //---------------------------------------------------------------------------- @@ -35,7 +37,12 @@ ProjectData::ProjectData(const std::string& atitle, ProjectData::DriverVersion d series_(0), cur_(NULL), max_cpu_secs_(360000), - driver_version_(driver_version) + driver_version_(driver_version), +#ifdef QMC_COMPLEX + is_complex_(true) +#else + is_complex_(false) +#endif { my_comm_ = OHMMS::Controller; if (title_.empty()) @@ -234,6 +241,21 @@ bool ProjectData::put(xmlNodePtr cur) return true; } +const std::string& ProjectData::getTitle() const noexcept { return title_; } + +const std::string& ProjectData::currentMainRoot() const noexcept { return project_main_; } + +const std::string& ProjectData::nextRoot() const noexcept { return next_root_; } + +int ProjectData::getSeriesIndex() const noexcept { return series_; } + +int ProjectData::getMaxCPUSeconds() const noexcept { return max_cpu_secs_; } + +ProjectData::DriverVersion ProjectData::getDriverVersion() const noexcept { return driver_version_; } + +bool ProjectData::isComplex() const noexcept { return is_complex_; } + +// PRIVATE ProjectData::DriverVersion ProjectData::lookupDriverVersion(const std::string& enum_value) { std::string enum_value_str(lowerCase(enum_value)); diff --git a/src/Utilities/ProjectData.h b/src/Utilities/ProjectData.h index b2973160d..c3e9ed32b 100644 --- a/src/Utilities/ProjectData.h +++ b/src/Utilities/ProjectData.h @@ -72,32 +72,40 @@ public: void setCommunicator(Communicate* c); - /** returns the title of the project + /** + * @brief returns the title of the project * * translate to title_ = "det_qmc_short_sdbatch_vmcbatch_mwalkers" */ - inline const std::string& getTitle() const { return title_; } + const std::string& getTitle() const noexcept; - /** returns the projectmain of the project, the series id is incremented at every QMC section + /** + * @brief returns the projectmain of the project, the series id is incremented at every QMC section * * translate to project_main_ = "det_qmc_short_sdbatch_vmcbatch_mwalkers.s000" */ - inline const std::string& currentMainRoot() const { return project_main_; } + const std::string& currentMainRoot() const noexcept; - /** returns the nextroot of the project, the series id is incremented at every QMC section + /** + * @brief returns the nextroot of the project, the series id is incremented at every QMC section * * translate to project_main_ = "det_qmc_short_sdbatch_vmcbatch_mwalkers.s001" */ - inline const std::string& nextRoot() const { return next_root_; } + const std::string& nextRoot() const noexcept; - /** return the root of the previous sequence + /** + * @brief return the root of the previous sequence * @param oldroot is composed by the title_ and series_ */ bool previousRoot(std::string& oldroot) const; - int getSeriesIndex() const { return series_; } - int getMaxCPUSeconds() const { return max_cpu_secs_; } - DriverVersion getDriverVersion() const { return driver_version_; } + int getSeriesIndex() const noexcept; + + int getMaxCPUSeconds() const noexcept; + + DriverVersion getDriverVersion() const noexcept; + + bool isComplex() const noexcept; private: static DriverVersion lookupDriverVersion(const std::string& enum_value); @@ -134,6 +142,9 @@ private: // The driver version of the project DriverVersion driver_version_; + + // tracks if complex wavefunction is used, true: complex, false: real + bool is_complex_; }; } // namespace qmcplusplus diff --git a/src/Utilities/tests/test_project_data.cpp b/src/Utilities/tests/test_project_data.cpp index 4e93531c4..b79403cc9 100644 --- a/src/Utilities/tests/test_project_data.cpp +++ b/src/Utilities/tests/test_project_data.cpp @@ -136,5 +136,14 @@ TEST_CASE("ProjectData::TestDriverVersion", "[ohmmsapp]") // host and date nodes get added for output to the .cont.xml file } +TEST_CASE("ProjectData::TestIsComplex", "[ohmmsapp]") +{ + ProjectData proj; +#ifdef QMC_COMPLEX + REQUIRE(proj.isComplex()); +#else + REQUIRE(!proj.isComplex()); +#endif +} } // namespace qmcplusplus