From c76ce4262f00445957a3efa56d99450473586a25 Mon Sep 17 00:00:00 2001 From: Matteo Cicuttin <datafl4sh@toxicnet.eu> Date: Fri, 4 Jun 2021 12:17:41 +0200 Subject: [PATCH] Fixed stuff to compile on CECI clusters. --- CMakeLists.txt | 11 +++-- cmake/FindSILO.cmake | 4 +- include/eigen.h | 2 - include/maxwell_interface.h | 5 +-- share/capacitor/capacitor.geo | 15 +++++++ share/capacitor/capacitor.m | 16 +++++++ share/capacitor/params_capacitor.lua | 66 ++++++++++++++++++++++++++++ src/silo_io.cpp | 4 ++ 8 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 share/capacitor/capacitor.geo create mode 100644 share/capacitor/capacitor.m create mode 100644 share/capacitor/params_capacitor.lua diff --git a/CMakeLists.txt b/CMakeLists.txt index 047b0f9..80681c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ include(CheckLanguage) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CUDA_ARCHITECTURES 35) +set(CMAKE_CUDA_ARCHITECTURES 35 70) # Additional modules path for cmake set (CMAKE_MODULE_PATH @@ -53,11 +53,15 @@ else() endif() endif() -find_package(SILO) +find_package(SILO REQUIRED) if (SILO_FOUND) add_definitions(-DHAVE_SILO) include_directories("${SILO_INCLUDE_DIRS}") set(LINK_LIBS ${LINK_LIBS} ${SILO_LIBRARIES}) + option(OPT_SILO_USE_HDF5 "Use HDF5 driver for silo files" ON) + if (OPT_SILO_USE_HDF5) + add_definitions(-DSILO_USE_HDF5) + endif() endif() find_package(Lua REQUIRED) @@ -96,7 +100,8 @@ if (OPT_ENABLE_GPU_SOLVER) add_definitions(-DHAVE_CUDA) endif() - if (TARGET CUDA::nvml) + option(OPT_USE_CUDA_NVML "Enable NVML" ON) + if (OPT_USE_CUDA_NVML AND TARGET CUDA::nvml) set(HAVE_CUDA_NVML TRUE) set(LINK_LIBS ${LINK_LIBS} CUDA::nvml) add_definitions(-DHAVE_CUDA_NVML) diff --git a/cmake/FindSILO.cmake b/cmake/FindSILO.cmake index 98818d1..e1e14d1 100644 --- a/cmake/FindSILO.cmake +++ b/cmake/FindSILO.cmake @@ -3,10 +3,10 @@ include(FindPackageHandleStandardArgs) find_path(SILO_INCLUDE_DIRS NAMES silo.h - PATHS /usr/include /usr/local/include) + PATHS /usr/include /usr/local/include ${SILO_DIR}/include) find_library(SILO_LIBRARIES NAMES silo siloh5 - PATHS /usr/lib /usr/local/include) + PATHS /usr/lib /usr/local/include ${SILO_DIR}/lib) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SILO DEFAULT_MSG SILO_LIBRARIES SILO_INCLUDE_DIRS) diff --git a/include/eigen.h b/include/eigen.h index 89d5618..9682c88 100644 --- a/include/eigen.h +++ b/include/eigen.h @@ -1,7 +1,5 @@ #pragma once -#define EIGEN_MAX_ALIGN_BYTES 32 - #include <Eigen/Dense> #include <Eigen/Sparse> #include <Eigen/StdVector> diff --git a/include/maxwell_interface.h b/include/maxwell_interface.h index d5f7626..f5485d5 100644 --- a/include/maxwell_interface.h +++ b/include/maxwell_interface.h @@ -385,9 +385,6 @@ init_H_field(const model& mod, solver_state_gpu& state, const Function& H) state.emf_curr.Hz.copyin(Hz.data(), Hz.size()); } - -#endif /* ENABLE_GPU_SOLVER */ - void gpu_compute_jumps(const entity_data_gpu&, const field_gpu&, field_gpu&, double *, gpuStream_t stream = 0); @@ -409,4 +406,6 @@ void gpu_compute_fluxes_H(const entity_data_gpu&, const field_gpu&, field_gpu&, void decompress_bndsrc(const solver_state_gpu& state, const field_gpu& csrcs, field_gpu& srcs); +#endif /* ENABLE_GPU_SOLVER */ + } // namespace maxwell diff --git a/share/capacitor/capacitor.geo b/share/capacitor/capacitor.geo new file mode 100644 index 0000000..9fd46c5 --- /dev/null +++ b/share/capacitor/capacitor.geo @@ -0,0 +1,15 @@ +l = 0.02; +d = 0.001; +t = 0.0003; +sh = 2*t+d; + +SetFactory("OpenCASCADE"); +Mesh.Algorithm3D = 10; + +Box(1) = {-l/2, -l/2, -sh/2, l, l, t}; +Box(2) = {-l/2, -l/2, -sh/2 + t, l, l, d}; +Box(3) = {-l/2, -l/2, -sh/2 + t+d, l, l, t}; +Sphere(4) = {0, 0, 0, l, -Pi/2, Pi/2, 2*Pi}; +Coherence; + +MeshSize{ PointsOf{ Volume{1,2,3}; } } = 0.0008; diff --git a/share/capacitor/capacitor.m b/share/capacitor/capacitor.m new file mode 100644 index 0000000..f7abfba --- /dev/null +++ b/share/capacitor/capacitor.m @@ -0,0 +1,16 @@ +l = 0.02; +d = 0.001; +epsilon = 10 * 8.85e-12; +t = 1e-13; +J = 1; + +A = l*l; +I = J*A; + +C = epsilon*A/d; +Q = I*t; + +V = Q/C +E = V/d + +Q*d/(epsilon*l*A) diff --git a/share/capacitor/params_capacitor.lua b/share/capacitor/params_capacitor.lua new file mode 100644 index 0000000..bfba7ec --- /dev/null +++ b/share/capacitor/params_capacitor.lua @@ -0,0 +1,66 @@ +sim.name = "capacitor" -- simulation name +sim.dt = 1e-13 -- timestep size +sim.timesteps = 100000 -- num of iterations +sim.gmsh_model = "capacitor.geo" -- gmsh model filename +sim.use_gpu = 0 -- 0: cpu, 1: gpu +sim.approx_order = 1 -- approximation order +sim.time_integrator = "leapfrog" +postpro.silo_output_rate = 10 -- rate at which to write silo files +postpro.cycle_print_rate = 10 -- console print rate + +local alu = {1, 3} +for i,v in ipairs(alu) do + materials[v] = {} + materials[v].epsilon = 1 + materials[v].mu = 1 + materials[v].sigma = 3.69e7 +end + +local diel = { 2 } +for i,v in ipairs(diel) do + materials[v] = {} + materials[v].epsilon = 10 + materials[v].mu = 1 + materials[v].sigma = 0 +end + +local air = { 4 } +for i,v in ipairs(air) do + materials[v] = {} + materials[v].epsilon = 1 + materials[v].mu = 1 + materials[v].sigma = 0 +end + +-- ** Boundary conditions ** +local absorbing_bcs = {1} +for i,v in ipairs(absorbing_bcs) do + bndconds[v] = {} + bndconds[v].kind = "impedance" +end + +function interp(t, t0, t1, y0, y1) + return (t-t0)*(y1-y0)/(t1-t0) + y0 +end + +local current_shape = { {0, 1}, {10*sim.dt, 1} } + + +function discharge_source(tag, x, y, z, t) + for ii = 1,(#current_shape-1) do + local t0 = current_shape[ii][1] + local c0 = current_shape[ii][2] + local t1 = current_shape[ii+1][1] + local c1 = current_shape[ii+1][2] + if (t >= t0 and t < t1) then + Ez = interp(t, t0, t1, c0, c1) + return 0, 0, Ez + end + end + return 0, 0, 0 +end + +sources[2] = discharge_source + + + diff --git a/src/silo_io.cpp b/src/silo_io.cpp index c9ffea2..6bceafa 100644 --- a/src/silo_io.cpp +++ b/src/silo_io.cpp @@ -110,7 +110,11 @@ silo::import_mesh_from_gmsh() bool silo::create_db(const std::string& dbname) { +#ifdef SILO_USE_HDF5 m_siloDb = DBCreate(dbname.c_str(), DB_CLOBBER, DB_LOCAL, NULL, DB_HDF5); +#else + m_siloDb = DBCreate(dbname.c_str(), DB_CLOBBER, DB_LOCAL, NULL, DB_PDB); +#endif if (m_siloDb) return true; -- GitLab