diff --git a/CMakeLists.txt b/CMakeLists.txt index 047b0f97cba73a12d3091877931f771f2385a3c8..80681c5e74e6e790604bd271e4285099dcac5bab 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 98818d1b4baae4100d15ff3dea9f8ae72324f698..e1e14d18109c14012b8c6bf1a5cd999075afba6a 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 89d56185d62ebe63c6a09da1fd938873a4f45de8..9682c88f4140d921e433b1a0b9e4ea9b8b1b62ef 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 d5f7626fe4a4dfef5ab8288ed7f2e00204c354b5..f5485d59b49ea33f544f9933f25d2be531b9dab1 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 0000000000000000000000000000000000000000..9fd46c5cb2c3301f13cdf5a84d5953f30b4b94de --- /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 0000000000000000000000000000000000000000..f7abfbaf6ce246f4494f8b90ef456222bbfe0ee9 --- /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 0000000000000000000000000000000000000000..bfba7ec06d02a3b2a45a53d167983274389032e1 --- /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 c9ffea23e4b7275505fffb47083f092ea039f8b4..6bceafae5fc85841fab1e1cc331a1014e5cff2ee 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;