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
3 changes: 2 additions & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class DissolveRecipe(ConanFile):
name = "Dissolve"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"

def configure(self):
self.options["puxixml"].header_only = False
self.options["antlr4-cppruntime"].shared = True
Expand All @@ -22,7 +23,7 @@ def requirements(self):
self.requires("pugixml/1.15")
self.requires("onetbb/2021.10.0")
self.requires("onedpl/2022.3.0")
self.requires("toml11/3.7.0")
self.requires("toml11/4.4.0")
self.requires("antlr4-cppruntime/4.13.1")
self.requires("gsl/2.7.1")
self.requires("gtest/1.17.0")
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
inputs = {
self.submodules = true;
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
outdated.url = "github:NixOS/nixpkgs/nixos-24.05";
bundlers.url = "github:nix-community/nix-bundle";
bundlers.inputs.nixpkgs.follows = "outdated";
Expand All @@ -22,18 +22,17 @@
let

toml = pkgs: ((import ./nix/toml11.nix) { inherit pkgs; });
onedpl =
pkgs:
((import ./nix/onedpl.nix) {
inherit (pkgs)
lib
stdenv
fetchFromGitHub
fetchpatch
cmake
;
tbb = pkgs.tbb_2021_11;
});
onedpl = pkgs: old: pkgs.onedpl;
# ((import ./nix/onedpl.nix) {
# inherit (pkgs)
# lib
# stdenv
# fetchFromGitHub
# fetchpatch
# cmake
# ;
# tbb = old.tbb_2021_11;
# });
exe-name = gui: if gui then "dissolve-gui" else "dissolve";
cmake-bool = x: if x then "ON" else "OFF";
version = "1.9.0";
Expand All @@ -46,6 +45,7 @@
cmake
cli11
freetype
gcc14
gsl
inetutils # for rsh
ninja
Expand Down Expand Up @@ -90,7 +90,7 @@
checks ? true,
benchmarks ? false,
}:
pkgs.stdenv.mkDerivation ({
pkgs.gcc14Stdenv.mkDerivation ({
inherit version;
pname = exe-name gui;
src = pkgs.lib.fileset.toSource {
Expand All @@ -112,11 +112,10 @@
++ pkgs.lib.optionals gui (gui_libs system pkgs qt)
++ pkgs.lib.optionals checks (check_libs pkgs)
++ pkgs.lib.optionals threading [
pkgs.tbb_2021_11
(onedpl pkgs)
(onedpl pkgs).dev
old.tbb_2021_11
(onedpl pkgs old)
];
nativeBuildInputs = pkgs.lib.optionals gui [ pkgs.wrapGAppsHook ];
nativeBuildInputs = pkgs.lib.optionals gui [ pkgs.wrapGAppsHook3 ];

CTEST_OUTPUT_ON_FAILURE = "ON";

Expand Down Expand Up @@ -178,7 +177,7 @@

defaultPackage = self.packages.${system}.dissolve;

devShells.default = pkgs.mkShell {
devShells.default = pkgs.mkShellNoCC {
name = "dissolve-shell";
buildInputs =
base_libs pkgs
Expand All @@ -187,7 +186,7 @@
++ (with pkgs; [
llvmPackages_20.clang-tools

(onedpl pkgs)
(onedpl pkgs old)

ccache
ccls
Expand All @@ -197,11 +196,12 @@
conan
cppcheck
direnv
gcc14
gdb
gtk3
nixGL.nixGLIntel
qt.qttools
tbb_2021_11
old.tbb_2021_11
valgrind
weggli
]);
Expand Down
8 changes: 4 additions & 4 deletions nix/toml11.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{ pkgs }:

pkgs.gcc9Stdenv.mkDerivation rec {
pkgs.stdenv.mkDerivation rec {
name = "toml11";
version = "v3.7.1";
version = "v4.4.0";
cmake = true;
buildInputs = [pkgs.cmake];
buildInputs = [ pkgs.cmake ];
src = pkgs.fetchFromGitHub {
owner = "ToruNiina";
repo = "toml11";
rev = version;
sha256 = "HnhXBvIjo1JXhp+hUQvjs83t5IBVbNN6o3ZGhB4WESQ=";
sha256 = "sha256-sgWKYxNT22nw376ttGsTdg0AMzOwp8QH3E8mx0BZJTQ=";
fetchSubmodules = true;
};
cmakeFlags = [
Expand Down
5 changes: 4 additions & 1 deletion src/base/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ double Geometry::value() const { return value_; }
// Return index value
int Geometry::indices(int i) const { return indices_[i]; }

bool Geometry::operator==(const Geometry &rhs) const { return value_ == rhs.value_ && indices_ == rhs.indices_; }
bool Geometry::operator==(const Geometry &rhs) const
{
return value_ == rhs.value_ && std::equal(std::begin(indices_), std::end(indices_), std::begin(rhs.indices_));
}
Comment on lines +35 to +38

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. Been meaning to fix this particular warning for a while!

bool Geometry::operator!=(const Geometry &rhs) const { return !(rhs == *this); }

namespace Serialisable
Expand Down
34 changes: 33 additions & 1 deletion src/base/serialiser.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,46 @@

#include "templates/orderedMap.h"
#include <toml11/toml.hpp>
#include <toml11/toml11/error_info.hpp>
#include <toml11/toml11/parser.hpp>
#include <toml11/toml11/result.hpp>
#include <toml11/toml11/source_location.hpp>
#include <vector>

struct wo_comment_config
{
using comment_type = toml::discard_comments;

using boolean_type = bool;
using integer_type = std::int64_t;
using floating_type = double;
using string_type = std::string;

template <typename T> using array_type = std::vector<T>;
template <typename K, typename T> using table_type = dissolve::OrderedMap<K, T>;

static toml::result<integer_type, toml::error_info> parse_int(const std::string &str, const toml::source_location src,
const std::uint8_t base)
{
return toml::read_int<integer_type>(str, src, base);
}

static toml::result<floating_type, toml::error_info> parse_float(const std::string &str, const toml::source_location src,
const bool is_hex)
{
return toml::read_float<floating_type>(str, src, is_hex);
}
};

// The type we use for the nodes of our serialisation tree
using SerialisedValue = toml::basic_value<toml::discard_comments, dissolve::OrderedMap, std::vector>;
using SerialisedValue = toml::basic_value<wo_comment_config>;

namespace Serialisable
{

using array = toml::array;
using table = toml::table;

void serialiseOnto(const int a, std::string tag, SerialisedValue &target);
void serialiseOnto(const double a, std::string tag, SerialisedValue &target);
void serialiseOnto(const std::string a, std::string tag, SerialisedValue &target);
Expand Down
10 changes: 2 additions & 8 deletions src/base/serialiserLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,7 @@ template <typename T> void vector(const std::vector<std::shared_ptr<T>> &vec, st
// A helper function to add the elements of a vector to a node under a name
template <typename T> void vector(const std::vector<T> &vec, std::string name, SerialisedValue &node)
{
vector(vec, name, node,
[](const auto &item)
{
SerialisedValue outer;
item.serialise("inner", outer);
return outer["inner"];
});
vector(vec, name, node, [](const auto &item) { return ser(item); });
}
// A helper function to add the elements of a vector to a node under a name
template <typename T, typename Lambda>
Expand Down Expand Up @@ -213,7 +207,7 @@ template <typename Lambda> bool optionalOn(const SerialisedValue &node, std::str
if (node.contains(name))
{
auto child = toml::find(node, name);
if (!node.is_uninitialized())
if (!child.is_empty())
action(child);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/classes/atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ bool AtomBase::isGeometry(AtomGeometry geom) const { return geometry() == geom;
// Express as a serialisable value
void AtomBase::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"index", index_}, {"z", Serialisable::ser(Z_)}, {"r", Serialisable::ser(r_)}, {"q", q_}};
target[tag] = Serialisable::table{{"index", index_}, {"z", Serialisable::ser(Z_)}, {"r", Serialisable::ser(r_)}, {"q", q_}};
}
// Read values from a serialisable value
void AtomBase::deserialise(const SerialisedValue &node)
Expand Down
2 changes: 1 addition & 1 deletion src/classes/atomType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void AtomType::serialise(std::string tag, SerialisedValue &target) const
{
auto &atomType = target[tag];

atomType["z"] = Z_;
atomType["z"] = Serialisable::ser(Z_);
atomType["charge"] = charge_;
atomType["form"] = ShortRangeFunctions::forms().keyword(interactionPotential_.form());
atomType["exchangeable"] = exchangeable_;
Expand Down
5 changes: 4 additions & 1 deletion src/classes/bond.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ template <class AtomClass> class Bond
*/
public:
// Express as a serialisable value
void serialise(std::string tag, SerialisedValue &target) const { target[tag] = {{"i", i_->index()}, {"j", j_->index()}}; }
void serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = Serialisable::table{{"i", i_->index()}, {"j", j_->index()}};
}
};
4 changes: 2 additions & 2 deletions src/classes/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,6 @@ double Box::minimumDistanceSquared(const Vector3 &r1, const Vector3 &r2) const {
void Box::serialise(std::string tag, SerialisedValue &target) const
{
auto &box = target[tag];
box["lengths"] = {a_, b_, c_};
box["angles"] = {alpha_, beta_, gamma_};
box["lengths"] = SerialisedValue::array_type{a_, b_, c_};
box["angles"] = SerialisedValue::array_type{alpha_, beta_, gamma_};
}
2 changes: 1 addition & 1 deletion src/classes/speciesAtom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ SpeciesAtom::ScaledInteractionDefinition SpeciesAtom::scaling(const SpeciesAtom
// Express as a serialisable value
void SpeciesAtom::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"index", index_}, {"z", Serialisable::ser(Z_)}, {"r", Serialisable::ser(r_)}, {"q", q_}};
target[tag] = Serialisable::table{{"index", index_}, {"z", Serialisable::ser(Z_)}, {"r", Serialisable::ser(r_)}, {"q", q_}};
if (atomType_)
target[tag]["type"] = atomType_->name().data();
}
Expand Down
2 changes: 1 addition & 1 deletion src/classes/speciesSite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void SpeciesSite::serialise(std::string tag, SerialisedValue &target) const
switch (type_)
{
case SiteType::Dynamic:
site["element"] = dynamicElements_;
Serialisable::vector(dynamicElements_, "element", site);
break;
case SiteType::Fragment:
site["description"] = fragment_.definitionString();
Expand Down
2 changes: 1 addition & 1 deletion src/expression/variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ExpressionValue *ExpressionVariable::valuePointer() { return &value_; }
// Express as a serialisable value
void ExpressionVariable::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"name", Serialisable::ser(baseName_)}, {"value", Serialisable::ser(value_)}};
target[tag] = Serialisable::table{{"name", Serialisable::ser(baseName_)}, {"value", Serialisable::ser(value_)}};
}

// Read values from a serialisable value
Expand Down
1 change: 0 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <format>
#include <fstream>
#include <iostream>
#include <toml11/toml/exception.hpp>

int main(int args, char **argv)
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// Serialise pair potential
SerialisedValue Dissolve::serialisePairPotentials() const
{
SerialisedValue pairPotentials = {
SerialisedValue pairPotentials = Serialisable::table{
{"range", PairPotential::range()},
{"delta", PairPotential::delta()},
{"chargeSource", PairPotential::chargeSources().serialise(PairPotential::chargeSource())},
Expand Down
2 changes: 1 addition & 1 deletion src/math/data1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void Data1D::operator/=(const double factor)
// Express as a serialisable value
void Data1D::serialise(std::string tag, SerialisedValue &target) const
{
SerialisedValue result = {{"tag", tag_}, {"x", x_}, {"y", values_}};
SerialisedValue result = Serialisable::table{{"tag", tag_}, {"x", x_}, {"y", values_}};
if (hasError_)
result["errors"] = errors_;
target[tag] = result;
Expand Down
2 changes: 1 addition & 1 deletion src/math/data2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void Data2D::operator/=(const double factor)
// Express as a serialisable value
void Data2D::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"tag", tag_}, {"x", x_}, {"y", y_}, {"values", values_.linearArray()}};
target[tag] = Serialisable::table{{"tag", tag_}, {"x", x_}, {"y", y_}, {"values", values_.linearArray()}};
if (hasError_)
target[tag]["errors"] = errors_.linearArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/math/data3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void Data3D::operator/=(const double factor)
// Express as a serialisable value
void Data3D::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"tag", tag_}, {"x", x_}, {"y", y_}, {"z", z_}, {"values", values_.linearArray()}};
target[tag] = Serialisable::table{{"tag", tag_}, {"x", x_}, {"y", y_}, {"z", z_}, {"values", values_.linearArray()}};
if (hasError_)
target[tag]["errors"] = errors_.linearArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/math/histogram1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Histogram1D Histogram1D::operator+(const Histogram1D &other) const
// Express as a serialisable value
void Histogram1D::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {
target[tag] = Serialisable::table{
{"minimum", minimum_}, {"maximum", maximum_}, {"binWidth", binWidth_}, {"nBinned", nBinned_}, {"nMissed", nMissed_}};
Serialisable::vector(averages_, "averages", target[tag]);
}
Expand Down
5 changes: 3 additions & 2 deletions src/math/histogram2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ void Histogram2D::operator=(const Histogram2D &source)
// Express as a serialisable value
void Histogram2D::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"xMinimum", xMinimum_}, {"xMaximum", xMaximum_}, {"xBinWidth", xBinWidth_}, {"yMinimum", yMinimum_},
{"yMaximum", yMaximum_}, {"yBinWidth", yBinWidth_}, {"nBinned", nBinned_}, {"nMissed", nMissed_}};
target[tag] = Serialisable::table{{"xMinimum", xMinimum_}, {"xMaximum", xMaximum_}, {"xBinWidth", xBinWidth_},
{"yMinimum", yMinimum_}, {"yMaximum", yMaximum_}, {"yBinWidth", yBinWidth_},
{"nBinned", nBinned_}, {"nMissed", nMissed_}};
Serialisable::vector(averages_.linearArray(), "averages", target[tag]);
}

Expand Down
7 changes: 4 additions & 3 deletions src/math/histogram3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ void Histogram3D::operator=(const Histogram3D &source)
// Express as a serialisable value
void Histogram3D::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"xMinimum", xMinimum_}, {"xMaximum", xMaximum_}, {"xBinWidth", xBinWidth_}, {"yMinimum", yMinimum_},
{"yMaximum", yMaximum_}, {"yBinWidth", yBinWidth_}, {"zMinimum", zMinimum_}, {"zMaximum", zMaximum_},
{"zBinWidth", zBinWidth_}, {"nBinned", nBinned_}, {"nMissed", nMissed_}};
target[tag] = Serialisable::table{{"xMinimum", xMinimum_}, {"xMaximum", xMaximum_}, {"xBinWidth", xBinWidth_},
{"yMinimum", yMinimum_}, {"yMaximum", yMaximum_}, {"yBinWidth", yBinWidth_},
{"zMinimum", zMinimum_}, {"zMaximum", zMaximum_}, {"zBinWidth", zBinWidth_},
{"nBinned", nBinned_}, {"nMissed", nMissed_}};
Serialisable::vector(averages_.linearArray(), "averages", target[tag]);
}

Expand Down
3 changes: 2 additions & 1 deletion src/math/integerHistogram1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ const Data1D &IntegerHistogram1D::accumulatedData() const { return accumulatedDa
// Express as a serialisable value
void IntegerHistogram1D::serialise(std::string tag, SerialisedValue &target) const
{
target[tag] = {{"zeroCounter", Serialisable::ser(zeroCounter_)}, {"nBinned", nBinned_}, {"nMissed", nMissed_}};
target[tag] =
Serialisable::table{{"zeroCounter", Serialisable::ser(zeroCounter_)}, {"nBinned", nBinned_}, {"nMissed", nMissed_}};

if (minimum_)
target[tag]["minimum"] = *minimum_;
Expand Down
Loading
Loading