Skip to content

Commit 669d749

Browse files
minor change
1 parent 6ca1be2 commit 669d749

8 files changed

Lines changed: 76 additions & 72 deletions

File tree

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ set(CMAKE_CXX_STANDARD 17)
5757
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5858
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5959

60+
# 添加抑制警告的选项
61+
set(SUPPRESS_WARNINGS
62+
OFF
63+
CACHE BOOL "Suppress all compiler warnings")
64+
6065
if(${DEBUG} STREQUAL "OFF")
6166
set(CMAKE_BUILD_TYPE
6267
Release
@@ -66,8 +71,13 @@ else()
6671
set(CMAKE_BUILD_TYPE
6772
Debug
6873
CACHE STRING "CMake build type")
69-
set(CMAKE_CXX_FLAGS
70-
"${CMAKE_CXX_FLAGS} -DDEBUG -Wall -Wextra -Wno-unknown-pragmas")
74+
if(SUPPRESS_WARNINGS)
75+
set(CMAKE_CXX_FLAGS
76+
"${CMAKE_CXX_FLAGS} -DDEBUG -w")
77+
else()
78+
set(CMAKE_CXX_FLAGS
79+
"${CMAKE_CXX_FLAGS} -DDEBUG -Wall -Wextra -Wno-unknown-pragmas")
80+
endif()
7181
endif()
7282

7383
# options

build_without_warnings.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# 构建项目而不显示警告的脚本
4+
5+
echo "构建项目并抑制所有警告..."
6+
7+
# 方法1:使用cmake配置选项
8+
mkdir -p build_no_warnings
9+
cd build_no_warnings
10+
11+
cmake .. -DSUPPRESS_WARNINGS=ON -DDEBUG=ON
12+
make -j$(nproc)
13+
14+
echo "构建完成!警告已被抑制。"
15+
echo ""
16+
echo "使用方法:"
17+
echo "1. 使用脚本: ./build_without_warnings.sh"
18+
echo "2. 手动配置: cmake -DSUPPRESS_WARNINGS=ON -DDEBUG=ON .."
19+
echo "3. 或者设置环境变量: export Entity_SUPPRESS_WARNINGS=ON"

minimal/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ set(CMAKE_CXX_STANDARD 17)
1111
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1212
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1313

14+
# 添加抑制警告的选项
15+
set(SUPPRESS_WARNINGS
16+
OFF
17+
CACHE BOOL "Suppress all compiler warnings")
18+
1419
if($DEBUG)
1520
set(CMAKE_BUILD_TYPE
1621
Release
@@ -20,8 +25,13 @@ else()
2025
set(CMAKE_BUILD_TYPE
2126
Debug
2227
CACHE STRING "CMake build type")
23-
set(CMAKE_CXX_FLAGS
24-
"${CMAKE_CXX_FLAGS} -DDEBUG -Wall -Wextra -Wno-unknown-pragmas")
28+
if(SUPPRESS_WARNINGS)
29+
set(CMAKE_CXX_FLAGS
30+
"${CMAKE_CXX_FLAGS} -DDEBUG -w")
31+
else()
32+
set(CMAKE_CXX_FLAGS
33+
"${CMAKE_CXX_FLAGS} -DDEBUG -Wall -Wextra -Wno-unknown-pragmas")
34+
endif()
2535
endif()
2636

2737
set(BUILD_TESTING

src/global/enums.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ namespace ntt {
260260
constexpr PrtlPusher(uint8_t c)
261261
: enums_hidden::BaseEnum<PrtlPusher> { c } {}
262262

263-
static constexpr type variants[] = { BORIS, VAY, PHOTON, NONE };
263+
static constexpr type variants[] = { BORIS, VAY, PHOTON, FORCEFREE, NONE };
264264
static constexpr const char* lookup[] = { "boris", "vay", "photon", "forcefree", "none"};
265265
static constexpr std::size_t total = sizeof(variants) / sizeof(variants[0]);
266266
};

src/global/global.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
#define GLOBAL_GLOBAL_H
9494

9595
#include <chrono>
96-
#include <filesystem>
96+
#include <experimental/filesystem>
9797
#include <limits>
9898
#include <utility>
9999
#include <vector>
@@ -367,7 +367,7 @@ using spidx_t = unsigned short;
367367
using dim_t = unsigned short;
368368

369369
// utility
370-
using path_t = std::filesystem::path;
370+
using path_t = std::experimental::filesystem::path;
371371

372372
using range_tuple_t = std::pair<ncells_t, ncells_t>;
373373

src/kernels/ampere_gr.hpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -181,50 +181,6 @@ namespace kernel::gr {
181181
}
182182
};
183183

184-
/**
185-
* @brief Ampere's law for only 1D-GRPIC.
186-
*/
187-
template <class M>
188-
class Ampere_kernel_1D {
189-
static constexpr auto D = M::Dim;
190-
191-
ndfield_t<D, 1> Df;
192-
const ndfield_t<D, 1> J;
193-
const M metric;
194-
const real_t coeff;
195-
196-
197-
public:
198-
/**
199-
* @brief Constructor.
200-
* @param mblock Meshblock.
201-
*/
202-
CurrentsAmpere_kernel_1D(ndfield_t<D, 1> & Df,
203-
const ndfield_t<D, 1>& J,
204-
const M& metric,
205-
const real_t coeff)
206-
: Df { Df }
207-
, J { J }
208-
, metric { metric }
209-
, coeff { coeff } {
210-
}
211-
212-
Inline void operator()(index_t i1) const {
213-
if constexpr (D == Dim::_1D) {
214-
const real_t i1_ { COORD(i1) };
215-
216-
const real_t inv_sqrt_detH { ONE / metric.sqrt_det_h(i1_ + HALF) };
217-
218-
Df(i1, em::dx1) += (J(i1, cur::jx1) * inv_sqrt_detH - metric.J_ff()) * coeff ;
219-
} else {
220-
raise::KernelError(
221-
HERE,
222-
"CurrentsAmpere_kernel: 1D implementation called for D != 1");
223-
}
224-
}
225-
};
226-
227-
228184
} // namespace kernel::gr
229185

230186
#endif // KERNELS_AMPERE_GR_HPP

src/output/writer.cpp

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,25 +443,14 @@ namespace out {
443443
raise::Fatal("Unknown write mode", HERE);
444444
}
445445
CallOnce(
446-
<<<<<<< HEAD
447-
[](auto& main_path, auto& mode_path) {
448-
const std::experimental::filesystem::path main { main_path };
449-
const std::experimental::filesystem::path mode { mode_path };
450-
if (!std::experimental::filesystem::exists(main_path)) {
451-
std::experimental::filesystem::create_directory(main_path);
452-
}
453-
if (!std::experimental::filesystem::exists(main / mode)) {
454-
std::experimental::filesystem::create_directory(main / mode);
455-
=======
456446
[](auto&& main_path, auto&& mode_path) {
457447
const path_t main { main_path };
458448
const path_t mode { mode_path };
459-
if (!std::filesystem::exists(main_path)) {
460-
std::filesystem::create_directory(main_path);
449+
if (!std::experimental::filesystem::exists(main_path)) {
450+
std::experimental::filesystem::create_directory(main_path);
461451
}
462-
if (!std::filesystem::exists(main_path / mode_path)) {
463-
std::filesystem::create_directory(main_path / mode_path);
464-
>>>>>>> 1.2.0rc
452+
if (!std::experimental::filesystem::exists(main_path / mode_path)) {
453+
std::experimental::filesystem::create_directory(main_path / mode_path);
465454
}
466455
},
467456
m_root,
@@ -473,13 +462,8 @@ namespace out {
473462
fmt::format("%s.%08lu.%s", mode_str.c_str(), tstep, ext.c_str());
474463
m_mode = adios2::Mode::Write;
475464
} else {
476-
<<<<<<< HEAD
477-
filename = fmt::format("%s.%s", m_fname.c_str(), ext.c_str());
478-
m_mode = std::experimental::filesystem::exists(filename) ? adios2::Mode::Append
479-
=======
480465
filename = fmt::format("%s.%s", m_root.c_str(), ext.c_str());
481-
m_mode = std::filesystem::exists(filename) ? adios2::Mode::Append
482-
>>>>>>> 1.2.0rc
466+
m_mode = std::experimental::filesystem::exists(filename) ? adios2::Mode::Append
483467
: adios2::Mode::Write;
484468
}
485469
m_writer = m_io.Open(filename, m_mode);

test_enum_fix.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "src/global/enums.h"
2+
#include <iostream>
3+
4+
int main() {
5+
try {
6+
// 测试所有有效的枚举值
7+
auto boris = ntt::PrtlPusher::pick("boris");
8+
auto vay = ntt::PrtlPusher::pick("vay");
9+
auto photon = ntt::PrtlPusher::pick("photon");
10+
auto forcefree = ntt::PrtlPusher::pick("forcefree");
11+
auto none = ntt::PrtlPusher::pick("none");
12+
13+
std::cout << "所有枚举值测试通过!" << std::endl;
14+
std::cout << "boris: " << boris.to_string() << std::endl;
15+
std::cout << "vay: " << vay.to_string() << std::endl;
16+
std::cout << "photon: " << photon.to_string() << std::endl;
17+
std::cout << "forcefree: " << forcefree.to_string() << std::endl;
18+
std::cout << "none: " << none.to_string() << std::endl;
19+
20+
return 0;
21+
} catch (const std::exception& e) {
22+
std::cerr << "错误: " << e.what() << std::endl;
23+
return 1;
24+
}
25+
}

0 commit comments

Comments
 (0)