Skip to content

Commit

Permalink
Core: add Spirit namespace
Browse files Browse the repository at this point in the history
Note, now using C++17 nested namespace declarations.

Also updated usage of `using` declarations in some places.
  • Loading branch information
GPMueller committed Jun 8, 2023
1 parent cffe9f8 commit 997f262
Show file tree
Hide file tree
Showing 113 changed files with 1,640 additions and 1,682 deletions.
16 changes: 8 additions & 8 deletions core/CMake/Spirit_Version.hpp.in
Expand Up @@ -4,16 +4,16 @@

#include <string>

namespace Utility
namespace Spirit::Utility::Version
{

const int version_major = ${META_VERSION_MAJOR};
const int version_minor = ${META_VERSION_MINOR};
const int version_patch = ${META_VERSION_PATCH};
const int major = ${META_VERSION_MAJOR};
const int minor = ${META_VERSION_MINOR};
const int patch = ${META_VERSION_PATCH};

const std::string version = "${META_VERSION}";
const std::string version_revision = "${META_VERSION_REVISION}";
const std::string version_full = "${META_VERSION} (${META_VERSION_REVISION})";
const std::string version = "${META_VERSION}";
const std::string revision = "${META_VERSION_REVISION}";
const std::string full = "${META_VERSION} (${META_VERSION_REVISION})";

const std::string compiler = "${META_COMPILER}";
const std::string compiler_version = "${META_COMPILER_VERSION}";
Expand All @@ -30,6 +30,6 @@ const std::string threads = "${SPIRIT_USE_THREADS}";

const std::string fftw = "${SPIRIT_USE_FFTW}";

} // namespace Utility
} // namespace Spirit::Utility

#endif
4 changes: 2 additions & 2 deletions core/include/Spirit/Log.h
Expand Up @@ -60,11 +60,11 @@ PREFIX void Log_Send(

// Get the entries from the Log and write new number of entries into given int
// TODO: can this be written in a C-style way?
namespace Utility
namespace Spirit::Utility
{
struct LogEntry;
}
std::vector<Utility::LogEntry> Log_Get_Entries( State * state ) SUFFIX;
std::vector<Spirit::Utility::LogEntry> Log_Get_Entries( State * state ) SUFFIX;

// Append the Log to it's file
PREFIX void Log_Append( State * state ) SUFFIX;
Expand Down
4 changes: 2 additions & 2 deletions core/include/data/Geometry.hpp
Expand Up @@ -8,7 +8,7 @@

#include <vector>

namespace Data
namespace Spirit::Data
{

// TODO: replace that type with Eigen!
Expand Down Expand Up @@ -174,6 +174,6 @@ class Geometry
// TODO: find better place (?)
std::vector<triangle_t> compute_delaunay_triangulation_2D( const std::vector<vector2_t> & points );

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method.hpp
Expand Up @@ -6,7 +6,7 @@

#include <string>

namespace Data
namespace Spirit::Data
{

// Solver Parameters Base Class
Expand Down Expand Up @@ -42,6 +42,6 @@ struct Parameters_Method
IO::VF_FileFormat output_vf_filetype = IO::VF_FileFormat::OVF_TEXT;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method_EMA.hpp
Expand Up @@ -4,7 +4,7 @@

#include <data/Parameters_Method.hpp>

namespace Data
namespace Spirit::Data
{

// EMA_Parameters contains all EMA information about the spin system
Expand All @@ -29,6 +29,6 @@ struct Parameters_Method_EMA : Parameters_Method
bool output_configuration_archive = false;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method_GNEB.hpp
Expand Up @@ -7,7 +7,7 @@
#include <random>
#include <vector>

namespace Data
namespace Spirit::Data
{

// LLG_Parameters contains all LLG information about the spin system
Expand Down Expand Up @@ -49,6 +49,6 @@ struct Parameters_Method_GNEB : Parameters_Method_Solver
bool output_chain_step = false;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method_LLG.hpp
Expand Up @@ -8,7 +8,7 @@
#include <random>
#include <vector>

namespace Data
namespace Spirit::Data
{

// LLG_Parameters contains all LLG information about the spin system
Expand Down Expand Up @@ -52,6 +52,6 @@ struct Parameters_Method_LLG : Parameters_Method_Solver
bool output_configuration_archive = false;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method_MC.hpp
Expand Up @@ -7,7 +7,7 @@
#include <random>
#include <vector>

namespace Data
namespace Spirit::Data
{

// LLG_Parameters contains all LLG information about the spin system
Expand Down Expand Up @@ -45,6 +45,6 @@ struct Parameters_Method_MC : public Parameters_Method
bool output_configuration_archive = false;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method_MMF.hpp
Expand Up @@ -7,7 +7,7 @@
#include <random>
#include <vector>

namespace Data
namespace Spirit::Data
{

// LLG_Parameters contains all LLG information about the spin system
Expand All @@ -30,6 +30,6 @@ struct Parameters_Method_MMF : public Parameters_Method_Solver
bool output_configuration_archive = false;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Parameters_Method_Solver.hpp
Expand Up @@ -4,7 +4,7 @@

#include <data/Parameters_Method.hpp>

namespace Data
namespace Spirit::Data
{

// Solver Parameters Base Class
Expand All @@ -14,6 +14,6 @@ struct Parameters_Method_Solver : Parameters_Method
double dt = 1e-3;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Spin_System.hpp
Expand Up @@ -16,7 +16,7 @@
#include <memory>
#include <random>

namespace Data
namespace Spirit::Data
{

/*
Expand Down Expand Up @@ -82,6 +82,6 @@ class Spin_System
Utility::OrderedLock ordered_lock;
};

} // namespace Data
} // namespace Spirit::Data

#endif
4 changes: 2 additions & 2 deletions core/include/data/Spin_System_Chain.hpp
Expand Up @@ -7,7 +7,7 @@
#include <data/Parameters_Method_GNEB.hpp>
#include <data/Spin_System.hpp>

namespace Data
namespace Spirit::Data
{

enum class GNEB_Image_Type
Expand Down Expand Up @@ -91,6 +91,6 @@ class Spin_System_Chain
Utility::OrderedLock ordered_lock;
};

} // namespace Data
} // namespace Spirit::Data

#endif
22 changes: 11 additions & 11 deletions core/include/data/State.hpp
Expand Up @@ -22,11 +22,11 @@
struct State
{
// Currently "active" chain
std::shared_ptr<Data::Spin_System_Chain> chain;
std::shared_ptr<Spirit::Data::Spin_System_Chain> chain;
// Currently "active" image
std::shared_ptr<Data::Spin_System> active_image;
std::shared_ptr<Spirit::Data::Spin_System> active_image;
// Spin System instance in clipboard
std::shared_ptr<Data::Spin_System> clipboard_image;
std::shared_ptr<Spirit::Data::Spin_System> clipboard_image;

// Spin configuration in clipboard
std::shared_ptr<vectorfield> clipboard_spins;
Expand All @@ -40,9 +40,9 @@ struct State

// The Methods
// max. noi*noc methods on images [noc][noi]
std::vector<std::shared_ptr<Engine::Method>> method_image{};
std::vector<std::shared_ptr<Spirit::Engine::Method>> method_image{};
// max. noc methods on the entire chain [noc]
std::shared_ptr<Engine::Method> method_chain{};
std::shared_ptr<Spirit::Engine::Method> method_chain{};

// Timepoint of creation
std::chrono::system_clock::time_point datetime_creation = std::chrono::system_clock::now();
Expand All @@ -61,13 +61,13 @@ inline void check_state( const State * state )
if( state == nullptr )
{
spirit_throw(
Utility::Exception_Classifier::System_not_Initialized, Utility::Log_Level::Error,
Spirit::Utility::Exception_Classifier::System_not_Initialized, Spirit::Utility::Log_Level::Error,
"The State pointer is invalid" );
}
if( state->chain == nullptr )
{
spirit_throw(
Utility::Exception_Classifier::System_not_Initialized, Utility::Log_Level::Error,
Spirit::Utility::Exception_Classifier::System_not_Initialized, Spirit::Utility::Log_Level::Error,
"The State seems to not be initialised correctly" );
}
}
Expand All @@ -78,7 +78,7 @@ inline void throw_if_nullptr( const void * ptr, const std::string & name )
if( ptr == nullptr )
{
spirit_throw(
Utility::Exception_Classifier::API_GOT_NULLPTR, Utility::Log_Level::Error,
Spirit::Utility::Exception_Classifier::API_GOT_NULLPTR, Spirit::Utility::Log_Level::Error,
fmt::format( "Got passed a null pointer for '{}'", name ) );
}
}
Expand All @@ -95,8 +95,8 @@ inline void throw_if_nullptr( const void * ptr, const std::string & name )
* any change to the corresponding variable (eg. )
*/
inline void from_indices(
const State * state, int & idx_image, int & idx_chain, std::shared_ptr<Data::Spin_System> & image,
std::shared_ptr<Data::Spin_System_Chain> & chain )
const State * state, int & idx_image, int & idx_chain, std::shared_ptr<Spirit::Data::Spin_System> & image,
std::shared_ptr<Spirit::Data::Spin_System_Chain> & chain )
{
check_state( state );

Expand All @@ -108,7 +108,7 @@ inline void from_indices(
if( idx_image >= state->chain->noi )
{
spirit_throw(
Utility::Exception_Classifier::Non_existing_Image, Utility::Log_Level::Warning,
Spirit::Utility::Exception_Classifier::Non_existing_Image, Spirit::Utility::Log_Level::Warning,
fmt::format(
"Index {} points to non-existent image (NOI={}). No action taken.", idx_image, state->chain->noi ) );
}
Expand Down
12 changes: 4 additions & 8 deletions core/include/engine/Backend_par.hpp
Expand Up @@ -14,11 +14,7 @@
#endif
// clang-format on

namespace Engine
{
namespace Backend
{
namespace par
namespace Spirit::Engine::Backend::par
{

#ifdef SPIRIT_USE_CUDA
Expand Down Expand Up @@ -210,7 +206,7 @@ void apply( int N, const F & f )
}

#endif
} // namespace par
} // namespace Backend
} // namespace Engine

} // namespace Engine::Backend::par

#endif
11 changes: 3 additions & 8 deletions core/include/engine/Backend_seq.hpp
Expand Up @@ -4,12 +4,9 @@

#include <engine/Vectormath_Defines.hpp>

namespace Engine
{
namespace Backend
{
namespace seq
namespace Spirit::Engine::Backend::seq
{

template<typename A, typename F>
scalar reduce( const field<A> & vf1, const F f )
{
Expand Down Expand Up @@ -64,8 +61,6 @@ void apply( int N, const F & f )
}
}

} // namespace seq
} // namespace Backend
} // namespace Engine
} // namespace Spirit::Engine::Backend::seq

#endif
7 changes: 2 additions & 5 deletions core/include/engine/Eigenmodes.hpp
Expand Up @@ -10,9 +10,7 @@
#include <memory>
#include <vector>

namespace Engine
{
namespace Eigenmodes
namespace Spirit::Engine::Eigenmodes
{

// Check whether system members and EMA parameters are consistent with eachother
Expand Down Expand Up @@ -42,7 +40,6 @@ bool Sparse_Hessian_Partial_Spectrum(
const SpMatrixX & hessian, int n_modes, SpMatrixX & tangent_basis, SpMatrixX & hessian_constrained,
VectorX & eigenvalues, MatrixX & eigenvectors );

} // end namespace Eigenmodes
} // end namespace Engine
} // namespace Spirit::Engine::Eigenmodes

#endif
7 changes: 2 additions & 5 deletions core/include/engine/FFT.hpp
Expand Up @@ -28,9 +28,7 @@
#include <cufft.h>
#endif

namespace Engine
{
namespace FFT
namespace Spirit::Engine::FFT
{

#ifdef SPIRIT_USE_KISSFFT
Expand Down Expand Up @@ -264,7 +262,6 @@ void iFour_3D( const FFT_Plan & plan, field<FFT_cpx_type> & in, field<FFT_real_t
void batch_Four_3D( FFT_Plan & plan );
void batch_iFour_3D( FFT_Plan & plan );

} // namespace FFT
} // namespace Engine
} // namespace Spirit::Engine::FFT

#endif

0 comments on commit 997f262

Please sign in to comment.