Skip to content

Commit

Permalink
Merge a1b5224 into 6ef195c
Browse files Browse the repository at this point in the history
  • Loading branch information
GPMueller committed Mar 23, 2023
2 parents 6ef195c + a1b5224 commit 7b4f74a
Show file tree
Hide file tree
Showing 282 changed files with 45,929 additions and 27,700 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -262,8 +262,8 @@ jobs:
matrix:
config:
- os: ubuntu-22.04
- os: ubuntu-20.04
- os: ubuntu-18.04
# - os: ubuntu-20.04 # does not seem to support C++17
# - os: ubuntu-18.04 # does not seem to support C++17
env:
BUILD_TYPE: Release
CMAKE_FLAGS: -DSPIRIT_UI_USE_IMGUI=OFF -DSPIRIT_UI_CXX_USE_QT=OFF -DSPIRIT_USE_CUDA=ON -DSPIRIT_CUDA_ARCH=sm_70
Expand Down
10 changes: 8 additions & 2 deletions CMakeLists.txt
Expand Up @@ -223,6 +223,13 @@ endif()



######### Add include folder for libfmt ############################
set( libfmt_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}/thirdparty/fmt/include )
####################################################################



######### Add subdirectory projects ################################
add_subdirectory( thirdparty/qhull )
set( qhull_INCLUDE_DIRS
Expand Down Expand Up @@ -273,14 +280,13 @@ endif()
install( FILES ${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt DESTINATION ./ COMPONENT spirit_licenses )

install( FILES ${CMAKE_CURRENT_LIST_DIR}/thirdparty/qhull/COPYING.txt DESTINATION licenses RENAME qhull.txt COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/thirdparty/fmt/LICENSE.rst DESTINATION licenses RENAME fmt.rst COMPONENT spirit_licenses )

install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/cub/LICENSE.TXT DESTINATION licenses RENAME cub.txt COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/Eigen/COPYING.BSD DESTINATION licenses RENAME eigen.txt COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/fmt/LICENSE.rst DESTINATION licenses RENAME fmt.rst COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/kiss_fft/COPYING DESTINATION licenses RENAME kiss_fft.txt COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/ovf/README.md DESTINATION licenses RENAME ovf.md COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/spectra/LICENSE DESTINATION licenses RENAME spectra.txt COMPONENT spirit_licenses )
install( FILES ${CMAKE_CURRENT_LIST_DIR}/core/thirdparty/termcolor/LICENSE DESTINATION licenses RENAME termcolor.txt COMPONENT spirit_licenses )

install( FILES ${CMAKE_CURRENT_LIST_DIR}/ui-cpp/thirdparty/Lyra/LICENSE.txt DESTINATION licenses RENAME lyra.txt COMPONENT spirit_licenses )

Expand Down
3 changes: 3 additions & 0 deletions core/CMakeLists.txt
Expand Up @@ -279,6 +279,7 @@ configure_file( ${CMAKE_CURRENT_LIST_DIR}/CMake/Spirit_Version.hpp.in ${CMAKE_CU
######### Dependencies that need to be built #######################
include( GetQHull )
add_subdirectory( ${PROJECT_SOURCE_DIR}/thirdparty/ovf )
target_include_directories( ovf PRIVATE ${libfmt_INCLUDE_DIRS} )
####################################################################


Expand Down Expand Up @@ -328,6 +329,7 @@ target_include_directories( ${META_PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/thirdparty
${CMAKE_CURRENT_LIST_DIR}/thirdparty/ovf/include
${CMAKE_CURRENT_LIST_DIR}/thirdparty/spectra/include
${libfmt_INCLUDE_DIRS}
${qhull_INCLUDE_DIRS}
${FFT_INCLUDE_DIRS} )

Expand Down Expand Up @@ -470,6 +472,7 @@ if( SPIRIT_BUILD_FOR_CXX OR SPIRIT_BUILD_FOR_JS )
target_include_directories( ${testName} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/test
${CMAKE_CURRENT_LIST_DIR}/thirdparty
${libfmt_INCLUDE_DIRS}
${FFT_INCLUDE_DIRS} )
# Apply public includes from the object library
target_include_directories( ${testName} PUBLIC
Expand Down
11 changes: 9 additions & 2 deletions core/include/data/State.hpp
Expand Up @@ -4,7 +4,14 @@

#include <engine/Method.hpp>
#include <utility/Exception.hpp>
#include <utility/Timing.hpp>

#include <fmt/chrono.h>
#include <fmt/format.h>

#include <chrono>
#include <memory>
#include <string>
#include <vector>

/*
* The State struct is passed around in an application to make the
Expand Down Expand Up @@ -39,7 +46,7 @@ struct State

// Timepoint of creation
std::chrono::system_clock::time_point datetime_creation{ std::chrono::system_clock::now() };
std::string datetime_creation_string{ Utility::Timing::TimePointToString( datetime_creation ) };
std::string datetime_creation_string{ fmt::format( "{:%Y-%m-%d_%H-%M-%S}", datetime_creation ) };

// Config file at creation
std::string config_file{ "" };
Expand Down
60 changes: 30 additions & 30 deletions core/include/engine/Method_Solver.hpp
Expand Up @@ -257,23 +257,23 @@ void Method_Solver<solver>::Message_Start()

//---- Log messages
std::vector<std::string> block;
block.push_back( fmt::format( "------------ Started {} Calculation ------------", this->Name() ) );
block.push_back( fmt::format( " Going to iterate {} step(s)", this->n_log ) );
block.push_back( fmt::format( " with {} iterations per step", this->n_iterations_log ) );
block.push_back( fmt::format(
block.emplace_back( fmt::format( "------------ Started {} Calculation ------------", this->Name() ) );
block.emplace_back( fmt::format( " Going to iterate {} step(s)", this->n_log ) );
block.emplace_back( fmt::format( " with {} iterations per step", this->n_iterations_log ) );
block.emplace_back( fmt::format(
" Force convergence parameter: {:." + fmt::format( "{}", this->print_precision ) + "f}",
this->parameters->force_convergence ) );
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Maximum torque: {:." + fmt::format( "{}", this->print_precision ) + "f}",
this->max_torque ) );
block.push_back( fmt::format( " Solver: {}", this->SolverFullName() ) );
block.emplace_back( fmt::format( " Solver: {}", this->SolverFullName() ) );
if( this->Name() == "GNEB" )
{
scalar length = Manifoldmath::dist_geodesic( *this->configurations[0], *this->configurations[this->noi - 1] );
block.push_back( fmt::format( " Total path length: {}", length ) );
block.emplace_back( fmt::format( " Total path length: {}", length ) );
}
block.push_back( "-----------------------------------------------------" );
Log.SendBlock( Log_Level::All, this->SenderName, block, this->idx_image, this->idx_chain );
block.emplace_back( "-----------------------------------------------------" );
Log( Log_Level::All, this->SenderName, block, this->idx_image, this->idx_chain );
}

template<Solver solver>
Expand All @@ -293,30 +293,30 @@ void Method_Solver<solver>::Message_Step()

// Send log message
std::vector<std::string> block;
block.push_back( fmt::format(
block.emplace_back( fmt::format(
"----- {} Calculation ({} Solver): {}", this->Name(), this->SolverName(),
Timing::DateTimePassed( t_current - this->t_start ) ) );
block.push_back(
block.emplace_back(
fmt::format( " Time since last step: {}", Timing::DateTimePassed( t_current - this->t_last ) ) );
block.push_back(
block.emplace_back(
fmt::format( " Completed {:>8} {} / {} iterations", percentage, this->iteration, this->n_iterations ) );
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Iterations / sec: {:.2f}",
this->n_iterations_log / Timing::SecondsPassed( t_current - this->t_last ) ) );
if( llg_dynamics )
block.push_back( fmt::format( " Simulated time: {} ps", this->get_simulated_time() ) );
block.emplace_back( fmt::format( " Simulated time: {} ps", this->get_simulated_time() ) );
if( this->Name() == "GNEB" )
{
scalar length = Manifoldmath::dist_geodesic( *this->configurations[0], *this->configurations[this->noi - 1] );
block.push_back( fmt::format( " Total path length: {}", length ) );
block.emplace_back( fmt::format( " Total path length: {}", length ) );
}
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Force convergence parameter: {:." + fmt::format( "{}", this->print_precision ) + "f}",
this->parameters->force_convergence ) );
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Maximum torque: {:." + fmt::format( "{}", this->print_precision ) + "f}",
this->max_torque ) );
Log.SendBlock( Log_Level::All, this->SenderName, block, this->idx_image, this->idx_chain );
Log( Log_Level::All, this->SenderName, block, this->idx_image, this->idx_chain );

// Update time of last step
this->t_last = t_current;
Expand Down Expand Up @@ -348,30 +348,30 @@ void Method_Solver<solver>::Message_End()

//---- Log messages
std::vector<std::string> block;
block.push_back( fmt::format( "------------ Terminated {} Calculation ------------", this->Name() ) );
block.emplace_back( fmt::format( "------------ Terminated {} Calculation ------------", this->Name() ) );
if( reason.length() > 0 )
block.push_back( fmt::format( "------- Reason: {}", reason ) );
block.push_back( fmt::format( " Total duration: {}", Timing::DateTimePassed( t_end - this->t_start ) ) );
block.push_back(
block.emplace_back( fmt::format( "------- Reason: {}", reason ) );
block.emplace_back( fmt::format( " Total duration: {}", Timing::DateTimePassed( t_end - this->t_start ) ) );
block.emplace_back(
fmt::format( " Completed {:>8} {} / {} iterations", percentage, this->iteration, this->n_iterations ) );
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Iterations / sec: {:.2f}", this->iteration / Timing::SecondsPassed( t_end - this->t_start ) ) );
if( llg_dynamics )
block.push_back( fmt::format( " Simulated time: {} ps", this->get_simulated_time() ) );
block.emplace_back( fmt::format( " Simulated time: {} ps", this->get_simulated_time() ) );
if( this->Name() == "GNEB" )
{
scalar length = Manifoldmath::dist_geodesic( *this->configurations[0], *this->configurations[this->noi - 1] );
block.push_back( fmt::format( " Total path length: {}", length ) );
block.emplace_back( fmt::format( " Total path length: {}", length ) );
}
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Force convergence parameter: {:." + fmt::format( "{}", this->print_precision ) + "f}",
this->parameters->force_convergence ) );
block.push_back( fmt::format(
block.emplace_back( fmt::format(
" Maximum torque: {:." + fmt::format( "{}", this->print_precision ) + "f}",
this->max_torque ) );
block.push_back( fmt::format( " Solver: {}", this->SolverFullName() ) );
block.push_back( "-----------------------------------------------------" );
Log.SendBlock( Log_Level::All, this->SenderName, block, this->idx_image, this->idx_chain );
block.emplace_back( fmt::format( " Solver: {}", this->SolverFullName() ) );
block.emplace_back( "-----------------------------------------------------" );
Log( Log_Level::All, this->SenderName, block, this->idx_image, this->idx_chain );
}

template<>
Expand Down
2 changes: 1 addition & 1 deletion core/include/io/Filter_File_Handle.hpp
Expand Up @@ -4,11 +4,11 @@

#include <engine/Vectormath_Defines.hpp>
#include <io/Fileformat.hpp>
#include <io/Formatters.hpp>
#include <utility/Exception.hpp>
#include <utility/Logging.hpp>

#include <fmt/format.h>
#include <fmt/ostream.h>

#include <fstream>
#include <sstream>
Expand Down
131 changes: 131 additions & 0 deletions core/include/io/Formatters.hpp
@@ -0,0 +1,131 @@
#pragma once
#include <type_traits>
#ifndef SPIRIT_CORE_IO_TYPE_FORMATTERS_HPP
#define SPIRIT_CORE_IO_TYPE_FORMATTERS_HPP

#include <utility/Exception.hpp>
#include <utility/Logging.hpp>

#include <Eigen/Core>

#include <fmt/color.h>
#include <fmt/ostream.h>

#include <iostream>

template<typename T>
struct fmt::formatter<T, std::enable_if_t<std::is_base_of_v<Eigen::DenseBase<T>, T>, char>> : ostream_formatter
{
};

template<>
struct fmt::formatter<Utility::Log_Sender> : formatter<string_view>
{
template<typename FmtContext>
auto format( Utility::Log_Sender sender, FmtContext & ctx )
{
using namespace Utility;
string_view name = "???";

if( sender == Log_Sender::All )
name = "ALL";
else if( sender == Log_Sender::IO )
name = "IO";
else if( sender == Log_Sender::API )
name = "API";
else if( sender == Log_Sender::GNEB )
name = "GNEB";
else if( sender == Log_Sender::HTST )
name = "HTST";
else if( sender == Log_Sender::LLG )
name = "LLG";
else if( sender == Log_Sender::MC )
name = "MC";
else if( sender == Log_Sender::MMF )
name = "MMF";
else if( sender == Log_Sender::UI )
name = "UI";
else if( sender == Log_Sender::EMA )
name = "EMA";
else
{
spirit_throw(
Exception_Classifier::Not_Implemented, Log_Level::Severe,
"Tried converting unknown Log_Sender to string" );
}

return formatter<string_view>::format( name, ctx );
}
};

template<>
struct fmt::formatter<Utility::Log_Level> : formatter<string_view>
{
template<typename FmtContext>
auto format( Utility::Log_Level level, FmtContext & ctx )
{
using namespace Utility;

string_view name = "unknown";
if( level == Log_Level::All )
name = "ALL";
else if( level == Log_Level::Severe )
name = "SEVERE";
else if( level == Log_Level::Error )
name = "ERROR";
else if( level == Log_Level::Warning )
name = "WARNING";
else if( level == Log_Level::Parameter )
name = "PARAM";
else if( level == Log_Level::Info )
name = "INFO";
else if( level == Log_Level::Debug )
name = "DEBUG";
else
{
spirit_throw(
Exception_Classifier::Not_Implemented, Log_Level::Severe,
"Tried converting unknown Log_Level to string" );
}

return formatter<string_view>::format( name, ctx );
}
};

template<>
struct fmt::formatter<Utility::LogEntry> : formatter<string_view>
{
template<typename FmtContext>
auto format( Utility::LogEntry entry, FmtContext & ctx )
{
using namespace Utility;

auto index_to_string = []( int idx ) -> std::string
{
if( idx >= 0 )
return fmt::format( "{:0>2}", idx + 1 );
else
return "--";
};

// First line includes the datetime tag etc.
std::string format_str;
if( Log.bracket_separators )
format_str = "{} [{:^7}] [{:^4}] [{}] {}";
else
format_str = "{} {:^7} {:^4} {} {}";
// Note, ctx.out() is an output iterator to write to.
// Currently not using entry.idx_chain, as it is not actively used in the codebase
auto out = fmt::format_to(
ctx.out(), format_str, entry.time, entry.level, entry.sender, index_to_string( entry.idx_image ),
entry.message_lines[0] );

// Rest of the block
for( std::size_t i = 1; i < entry.message_lines.size(); ++i )
out = fmt::format_to( ctx.out(), "\n{}{}", Log.tags_space, entry.message_lines[i] );

return out;
}
};

#endif

0 comments on commit 7b4f74a

Please sign in to comment.