diff --git a/.github/workflows/automatic-release-ubuntu-gnu.yml b/.github/workflows/automatic-release-ubuntu-gnu.yml index bae773c6..935ff9ee 100644 --- a/.github/workflows/automatic-release-ubuntu-gnu.yml +++ b/.github/workflows/automatic-release-ubuntu-gnu.yml @@ -3,7 +3,7 @@ name: automatic-release-ubuntu-gnu on: push: branches: - - main + - main jobs: diff --git a/.github/workflows/windows-intelLLVM.yml b/.github/workflows/windows.yml similarity index 93% rename from .github/workflows/windows-intelLLVM.yml rename to .github/workflows/windows.yml index b174a60d..ccc9fb06 100644 --- a/.github/workflows/windows-intelLLVM.yml +++ b/.github/workflows/windows.yml @@ -1,4 +1,4 @@ -name: windows-intelLLVM +name: windows on: @@ -32,7 +32,7 @@ jobs: fail-fast: false - name: ${{matrix.build-type}}-mpi(${{matrix.mpi}})-mtln(${{matrix.mtln}})-hdf(${{matrix.hdf}}) + name: ${{matrix.compiler.name}}-${{matrix.build-type}}-mpi(${{matrix.mpi}})-mtln(${{matrix.mtln}})-hdf(${{matrix.hdf}}) steps: diff --git a/.gitignore b/.gitignore index 5ac8506a..98cbd108 100755 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,4 @@ src_pyWrapper/__pycache__/* tmp/ tmp_cases/ testData/outputs/paul/paul_8.6_square.txt +testing_hdf5_writing_and_reading.h5 diff --git a/doc/development.md b/doc/development.md index c24ef6bd..58587dcb 100644 --- a/doc/development.md +++ b/doc/development.md @@ -29,9 +29,9 @@ You can compile HDF5 for your specific platform downloading the latest sources f Extract to a folder and build and install with the following commands ```shell - cmake -S . -B build-ifx --fresh -DHDF5_BUILD_FORTRAN=YES - cmake --build build-ifx -j - cmake --install build-ifx --prefix ~/hdf5-installed + cmake -S . -B build -DHDF5_BUILD_FORTRAN=YES -DHDF5_ENABLE_Z_LIB_SUPPORT=NO --fresh + cmake --build build -j + cmake --install build --prefix ~/hdf5-installed ``` A specific HDF5 library can be set with the option `-DHDF5_ROOT=`, e.g. @@ -143,6 +143,7 @@ Once the environment is loaded, follow the steps in the next section. 2. **Generate the Project with CMake GUI**: - In **CMake GUI**, select the option to create a project for **Visual Studio 2019** from the CMake files. + - Set `-T fortran=ifx` to use intelLLVM compiler. - Specify the output folder where the `.sln` file for the project will be generated. 3. **Open the Project in Visual Studio**: diff --git a/doc/smbjson.md b/doc/smbjson.md index c5d874e1..0c5ae423 100644 --- a/doc/smbjson.md +++ b/doc/smbjson.md @@ -629,6 +629,7 @@ If not `magnitudeFile` is specified and only one `source` is defined, the `magni Probes of type `movie` record a vector field in a volume region indicated by `elementIds`. `[field]` can be `electric`, `magnetic`, or `currentDensity`; defaults to `electric`. `currentDensity` will store only the surface density currents on `pec` or lossy surfaces. +For movies in time domain, the `initialTime`, `finalTime`, and `samplingPeriod` must be specified by the user; there is no default value. The stored values can be selected using the `[component]` entry, which stores one of the following labels `x`, `y`, `z`, or `magnitude`; if no component is specified, defaults to `magnitude`. An example follows: diff --git a/requirements.txt b/requirements.txt index 3ae511fe..a6b0d698 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ numpy matplotlib pandas pyvista +h5py scikit-rf \ No newline at end of file diff --git a/set_precompiled_libraries.cmake b/set_precompiled_libraries.cmake index d946230d..e5949a82 100644 --- a/set_precompiled_libraries.cmake +++ b/set_precompiled_libraries.cmake @@ -36,36 +36,6 @@ if (SEMBA_FDTD_ENABLE_MTLN) MESSAGE(STATUS "Using lapack libraries at: " ${LAPACK_DIR}) endif() -# if (SEMBA_FDTD_ENABLE_MTLN) -# if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") -# if (${CMAKE_Fortran_COMPILER_ID} STREQUAL "GNU") -# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-gcc/ngspice/") -# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a) -# elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "NVHPC") -# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-gcc/ngspice/") -# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a) -# elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") -# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-intel/ngspice/") -# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a) -# elseif (${CMAKE_Fortran_COMPILER_ID} STREQUAL "IntelLLVM") -# set(NGSPICE_DIR "${PRECOMPILED_DIR}/linux-intelLLVM/ngspice/") -# set(NGSPICE_LIB ${NGSPICE_DIR}libngspice.a) -# endif() -# elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") -# set(NGSPICE_DIR "${PRECOMPILED_DIR}/windows-intel/ngspice/") -# set(NGSPICE_LIB ${NGSPICE_DIR}ngspice.lib) -# add_library(ngspice SHARED IMPORTED) -# set_target_properties(ngspice PROPERTIES -# IMPORTED_LOCATION "${NGSPICE_DIR}ngspice.dll" -# IMPORTED_IMPLIB "${NGSPICE_DIR}ngspice.lib" -# ) -# endif() -# if (NOT NGSPICE_DIR) -# message(FATAL_ERROR "ngspice libraries for this platform and/or compiler have not been found.") -# endif() -# MESSAGE(STATUS "Using ngspice libraries at: " ${NGSPICE_DIR}) -# endif() - if (SEMBA_FDTD_ENABLE_HDF AND NOT HDF5_FOUND) if (NOT HDF5_ROOT) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") diff --git a/src_json_parser/smbjson.F90 b/src_json_parser/smbjson.F90 index 6421815e..6666f436 100644 --- a/src_json_parser/smbjson.F90 +++ b/src_json_parser/smbjson.F90 @@ -58,7 +58,6 @@ module smbjson procedure, private :: readThinSlots ! ! - ! procedure, private :: getLogicalAt procedure, private :: getIntAt procedure, private :: getIntsAt diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 94e97d9b..d79a4217 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,5 +25,6 @@ target_link_libraries(fdtd_tests ${MTLN_TESTS_LIBRARY} ${SMBJSON_TESTS_LIBRARY} ${SYSTEM_TESTS_LIBRARY} + ${HDF_TESTS_LIBRARY} GTest::gtest_main ) \ No newline at end of file diff --git a/test/pyWrapper/test_full_system.py b/test/pyWrapper/test_full_system.py index b3e9c2cf..14f70ba1 100644 --- a/test/pyWrapper/test_full_system.py +++ b/test/pyWrapper/test_full_system.py @@ -129,7 +129,24 @@ def test_sphere(tmp_path): assert len(electric_field_movie_files) == 3 p = Probe(electric_field_movie_files[0]) assert p.type == 'movie' + +@no_hdf_skip +@pytest.mark.hdf +def test_movie_in_planewave_in_box(tmp_path): + fn = CASE_FOLDER + 'planewave/pw-in-box-with-movie.fdtd.json' + solver = FDTD(fn, path_to_exe=SEMBA_EXE, run_in_folder=tmp_path) + solver.run() + assert solver.hasFinishedSuccessfully() + h5file = solver.getSolvedProbeFilenames("electric_field_movie")[2] + with h5py.File(h5file, "r") as f: + time_key = list(f.keys())[0] + field_key = list(f.keys())[1] + time_ds = f[time_key][()] + field_ds = f[field_key][()] + + assert np.isclose(np.max(field_ds), 1.0, rtol=1e-2) + assert np.min(field_ds) == 0.0 def test_planewave_in_box(tmp_path): fn = CASE_FOLDER + 'planewave/pw-in-box.fdtd.json' diff --git a/test/pyWrapper/utils.py b/test/pyWrapper/utils.py index f6947982..4df3244c 100644 --- a/test/pyWrapper/utils.py +++ b/test/pyWrapper/utils.py @@ -6,6 +6,7 @@ import pyvista as pv from numpy.fft import * import pytest +import h5py from os import environ as env from sys import platform diff --git a/test/smbjson/smbjson_tests.h b/test/smbjson/smbjson_tests.h index ef6dba3b..f7a00720 100644 --- a/test/smbjson/smbjson_tests.h +++ b/test/smbjson/smbjson_tests.h @@ -18,12 +18,13 @@ extern "C" int test_read_dielectricslab(); extern "C" int test_read_thinslot(); extern "C" int test_read_holland1981(); extern "C" int test_read_towelhanger(); -extern "C" int test_read_connectedwires(); extern "C" int test_read_currentinjection(); -extern "C" int test_read_shieldedpair(); -extern "C" int test_read_mtln(); extern "C" int test_read_sphere(); extern "C" int test_read_airplane(); +extern "C" int test_read_mtln(); +extern "C" int test_read_holland1981(); +extern "C" int test_read_connectedwires(); +extern "C" int test_read_shieldedpair(); extern "C" int test_read_large_airplane_mtln(); TEST(smbjson, idchildtable_fhash) {EXPECT_EQ(0, test_idchildtable_fhash()); } diff --git a/test/smbjson/test_read_holland1981.F90 b/test/smbjson/test_read_holland1981.F90 index 8b990404..4c55ea99 100644 --- a/test/smbjson/test_read_holland1981.F90 +++ b/test/smbjson/test_read_holland1981.F90 @@ -123,8 +123,7 @@ function expectedProblemDescription() result (expected) expected%tWires%n_tw = 1 expected%tWires%n_tw_max = 1 - - ! expected mtln bundles + expected%mtln%time_step = 30e-12 expected%mtln%number_of_steps = 1000 diff --git a/testData/cases/.gitignore b/testData/cases/.gitignore index feb0286a..00e50537 100644 --- a/testData/cases/.gitignore +++ b/testData/cases/.gitignore @@ -3,4 +3,7 @@ *.txt *.vtk *.bin -*.log \ No newline at end of file +*.log +*.h5 +*.xdmf +*.bin \ No newline at end of file diff --git a/testData/cases/planewave/pw-in-box-with-movie.fdtd.json b/testData/cases/planewave/pw-in-box-with-movie.fdtd.json new file mode 100644 index 00000000..1b4b0617 --- /dev/null +++ b/testData/cases/planewave/pw-in-box-with-movie.fdtd.json @@ -0,0 +1,56 @@ +{ + "format": "FDTD Input file", + "__comments": "Planewave passing through an empty box.", + + "general": { + "timeStep": 0.05e-9, + "numberOfSteps": 400 + }, + + "boundary": { + "all": {"type": "mur"} + }, + + "mesh": { + "grid": { + "numberOfCells": [6, 6, 6], + "steps": { "x": [0.01], "y": [0.01], "z": [0.01] } + }, + "elements": [ + {"id": 1, "type": "cell", "name": "pw-box", "intervals": [ [ [2, 2, 2], [4, 4, 4] ] ]}, + {"id": 2, "type": "cell", "name": "movie-box", "intervals": [ [ [0, 0, 0], [6, 6, 6] ] ]} + ] + }, + + "sources": [ + { + "type": "planewave", + "magnitudeFile": "gauss_1GHz.exc", + "elementIds": [1], + "direction": { + "theta": 0.0, + "phi": 0.0 + }, + "polarization": { + "theta": 1.5708, + "phi": 0.0 + } + } + ], + + "probes": [ + { + "name": "electric_field_movie", + "type": "movie", + "field": "electric", + "component": "magnitude", + "elementIds": [2], + "domain": { + "type": "time", + "initialTime": 0.0, + "finalTime": 5e-9, + "samplingPeriod": 1.5e-12 + } + } + ] +} \ No newline at end of file diff --git a/testData/cases/planewave/pw_prepost.py b/testData/cases/planewave/pw_prepost.py index a5a275ed..08f9ee06 100644 --- a/testData/cases/planewave/pw_prepost.py +++ b/testData/cases/planewave/pw_prepost.py @@ -12,11 +12,8 @@ # %% Prepare solver -# solver = FDTD(input_filename = 'pw-in-box.fdtd.json', path_to_exe=SEMBA_EXE) -solver = FDTD(input_filename = 'pw-with-periodic.fdtd.json', path_to_exe=SEMBA_EXE) +solver = FDTD(input_filename = 'pw-in-box.fdtd.json', path_to_exe=SEMBA_EXE) solver.cleanUp() - -# %% Run solver solver.run() assert solver.hasFinishedSuccessfully() @@ -33,4 +30,20 @@ plt.xlim(0,4e-9) + +# %% +# %% Prepare solver +solver = FDTD(input_filename = 'pw-in-box-with-movie.fdtd.json', path_to_exe=SEMBA_EXE) +solver.cleanUp() +solver.run() +assert solver.hasFinishedSuccessfully() + +# %% Postprocess +import h5py +fn = solver.getSolvedProbeFilenames("electric_field_movie")[2] +with h5py.File(fn, "r") as f: + time_key = list(f.keys())[0] + field_key = list(f.keys())[1] + time_ds = f[time_key][()] + field_ds = f[field_key][()] # %%