From 312dbd05293fc854ea3a89291bc1f8272648f5fb Mon Sep 17 00:00:00 2001 From: chn Date: Tue, 26 Sep 2023 13:43:11 +0800 Subject: [PATCH] fix some code --- CMakeLists.txt | 6 ++++++ flake.nix | 7 ++++++- include/ufo/ufo.hpp | 4 +++- include/ufo/ufo.impl.hpp | 7 +++---- plot.cpp => src/plot.cpp | 11 +---------- 5 files changed, 19 insertions(+), 16 deletions(-) rename plot.cpp => src/plot.cpp (91%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dea36f..d023a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,12 @@ set_property(GLOBAL PROPERTY CXX_STANDARD 23) set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED ON) set_property(GLOBAL PROPERTY CXX_EXTENSIONS OFF) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message("Setting build type to 'RelWithDebInfo' as none was specified.") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + find_package(yaml-cpp REQUIRED) find_package(Eigen3 REQUIRED) find_package(fmt REQUIRED) diff --git a/flake.nix b/flake.nix index 2b1932a..46d76b3 100644 --- a/flake.nix +++ b/flake.nix @@ -5,6 +5,11 @@ outputs = inputs: let pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux; + # pkgs = import inputs.nixpkgs + # { + # localSystem = { system = "x86_64-linux"; gcc = { arch = "alderlake"; tune = "alderlake"; }; }; + # config.allowUnfree = true; + # }; localPackages = import "${inputs.nixos}/local/pkgs" { inherit pkgs; inherit (inputs.nixpkgs) lib; }; in { @@ -17,7 +22,7 @@ localPackages.zpp-bits ]; hardeningDisable = [ "all" ]; - NIX_DEBUG = "1"; + # NIX_DEBUG = "1"; }; }; } diff --git a/include/ufo/ufo.hpp b/include/ufo/ufo.hpp index 21e3463..ec66464 100644 --- a/include/ufo/ufo.hpp +++ b/include/ufo/ufo.hpp @@ -13,7 +13,7 @@ # include # include # include -# include +# include # include # include # include @@ -136,6 +136,8 @@ struct Output std::vector QPointData; void write(std::string filename, std::string format, unsigned percision = 10); + Output() = default; + Output(std::string filename); }; concurrencpp::generator, unsigned>> diff --git a/include/ufo/ufo.impl.hpp b/include/ufo/ufo.impl.hpp index 43bc9d4..e37b40f 100644 --- a/include/ufo/ufo.impl.hpp +++ b/include/ufo/ufo.impl.hpp @@ -3,7 +3,6 @@ inline HighFive::CompoundType create_compound_complex() { return {{"r", HighFive::AtomicType{}}, {"i", HighFive::AtomicType{}}}; } - inline Input::Input(std::string filename) { // read main input file @@ -21,7 +20,7 @@ inline Input::Input(std::string filename) SuperCellDeformation.emplace(); for (unsigned i = 0; i < 3; i++) for (unsigned j = 0; j < 3; j++) - (*SuperCellDeformation)(i, j) = node["SuperCellDeformation"][i][j].as(); + (*SuperCellDeformation)(i, j) = value[i][j].as(); } for (unsigned i = 0; i < 3; i++) @@ -45,9 +44,9 @@ inline Input::Input(std::string filename) auto& _ = QPointDataOutputFile.emplace_back(); _.FileName = value[i]["FileName"].as(); _.Format = value[i]["Format"].as(); - if (!std::set{"yaml", "hdf5"}.contains(_.Format)) + if (!std::set{"yaml", "yaml-human-readable", "zpp"}.contains(_.Format)) throw std::runtime_error(fmt::format - ("Unknown format: {}, should be \"yaml\" or \"hdf5\".", _.Format)); + ("Unknown format: {}, should be \"yaml\", \"yaml-human-readable\" or \"zpp\".", _.Format)); } } diff --git a/plot.cpp b/src/plot.cpp similarity index 91% rename from plot.cpp rename to src/plot.cpp index c667ed9..be36d6d 100644 --- a/plot.cpp +++ b/src/plot.cpp @@ -1,13 +1,4 @@ -# include -# include -# include -# include -# include -# include -# include -# include - -using namespace std::literals; +# include // 一个临时的程序, 用于将数据导出画图