Skip to content

Commit

Permalink
Merge pull request #58 from OpenSEMBA/dev
Browse files Browse the repository at this point in the history
Bugfix for reading large cellRegions happening in windows intelLLVM
  • Loading branch information
lmdiazangulo authored Oct 22, 2024
2 parents ebf6d23 + 8b7d8f3 commit cec0e25
Show file tree
Hide file tree
Showing 65 changed files with 6,569 additions and 649 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ubuntu-gnu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:

- name: Install required packages
run: |
sudo apt update
sudo apt install libhdf5-dev libopenmpi-dev
- name: Build application
Expand Down
67 changes: 63 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Prebuilt binares are available at [releases](https://github.com/OpenSEMBA/fdtd/r

In windows, you need to install [intel oneapi runtime libraries](https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html).

## Compilation
## GNU/Linux Compilation

It is important to point out the repository has dependencies which are available as submodules. It is necessary to run `git submodule init` and `git submodule update` from the root folder before running any `cmake` or `build` commands.

Expand Down Expand Up @@ -104,7 +104,6 @@ libngspice_la_CFLAGS = -static
libngspice_la_LDFLAGS = -static -version-info @LIB_VERSION@
```


#### MPI

If you use intel oneapi, make sure to load the mpi environment variables:
Expand All @@ -113,9 +112,65 @@ If you use intel oneapi, make sure to load the mpi environment variables:
source /opt/intel/oneapi/mpi/latest/env/vars.sh
```

## Testing
## Windows (intelLLVM) Compilation

Tests must be run from the root folder. `python` wrapper test assumes that `semba-fdtd` has been compiled successfully and is located in folder `build/bin/`. For intel compilation it also assumes that the intel runtime libraries are accessible.
Clone this repository:

```shell
git clone https://github.com/OpenSEMBA/fdtd.git
```

or, if using SSH keys:

```shell
git clone git@github.com:OpenSEMBA/fdtd.git
```

navigate to the `/fdtd/` folder that has been created, this folder will be referred to as `root` for any future purposes.

### Prerequisites

This compilation process will use the already available precompiled libraries included with the project, thus it's not required to build them manually.
This repository has dependencies that are available as submodules. It is necessary to run `git submodule init` and `git submodule update` from the root folder before running any `cmake` or `build` commands.
In the .gitmodules file, the submodules use the SSH remote URL by default. If not using a SSH-key in the computer where the following process will be performed, the remote addresses for each submodule must be individually changed to their HTTPS alternative.

This software requires [Windows BaseKit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit.html) and [Windows HPCKit](https://www.intel.com/content/www/us/en/developer/tools/oneapi/hpc-toolkit-download.html). Install these packages with all their features selected.

Additionally, if not done already, install [CMake](https://cmake.org/download/) and [Ninja](https://github.com/ninja-build/ninja), follow their respective installation steps.

### Compilation process

Open a command prompt with OneAPI variables initialised, to do this open a new command prompt and type:

```shell
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64
```

This will load the OneAPI environment for x64.

Navigate to the fdtd root folder, choose between "Debug"/"Release" for `-DCMAKE_BUILD_TYPE`, and "Yes"/"No" for `-DSEMBA_FDTD_ENABLE_MPI`, for example, a Release version with MPI Support would be:

```shell
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release -DSEMBA_FDTD_ENABLE_MPI=Yes
```

Then,

```shell
cmake --build build -j
```

We should now find the compiled executables in `\build\bin\`.

### Usage

In order to use semba-fdtd, the executable must have access to the dynamic libraries it has dependencies on. Either move the libraries to the same folder as the executable, or run the executable through a console with the OneAPI environment loaded:

```shell
"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" intel64
```

Once the environment is loaded, follow the steps in the next section.

## Running cases

Expand All @@ -126,6 +181,10 @@ These can be run with
semba-fdtd -i CASE_NAME.fdtd.json
```

## Testing

Tests must be run from the root folder. `python` wrapper test assumes that `semba-fdtd` has been compiled successfully and is located in folder `build/bin/`. For intel compilation it also assumes that the intel runtime libraries are accessible.

# License

This code is licensed under the terms of the [MIT License](LICENSE). All rights reserved by the University of Granada (Spain)
Expand Down
4 changes: 3 additions & 1 deletion src_json_parser/idchildtable.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module idchildtable_mod

#ifdef CompileWithSMBJSON
use json_module
use fhash, only: fhash_tbl_t, key=>fhash_key
use labels_mod
Expand Down Expand Up @@ -61,5 +63,5 @@ function getId(this, id) result(res)
res = d
end select
end function

#endif
end module
4 changes: 3 additions & 1 deletion src_json_parser/labels_mod.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module labels_mod

#ifdef CompileWithSMBJSON
! LABELS
! -- common labels
character (len=*), parameter :: J_NAME = "name"
Expand Down Expand Up @@ -181,5 +183,5 @@ module labels_mod
character (len=*), parameter :: J_PR_DOMAIN_FREQ_SPACING = "frequencySpacing"
character (len=*), parameter :: J_PR_DOMAIN_FREQ_SPACING_LINEAR = "linear"
character (len=*), parameter :: J_PR_DOMAIN_FREQ_SPACING_LOGARITHMIC = "logarithmic"

#endif
end module
5 changes: 3 additions & 2 deletions src_json_parser/mesh.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module mesh_mod


#ifdef CompileWithSMBJSON
use, intrinsic :: iso_fortran_env , only: error_unit

use fhash, only: fhash_tbl_t, key=>fhash_key
Expand Down Expand Up @@ -316,5 +317,5 @@ logical function coordinate_eq(a, b)
class(coordinate_t), intent(in) :: a, b
coordinate_eq = all(a%position == b%position)
end function

#endif
end module
5 changes: 3 additions & 2 deletions src_json_parser/nfdetypes_extension.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module NFDETypes_extension
module NFDETypes_extension
#ifdef CompileWithSMBJSON
use NFDETypes

implicit none
Expand Down Expand Up @@ -951,5 +952,5 @@ elemental logical function volprobes_eq(a, b)
all(a%collection == b%collection)
end function volprobes_eq


#endif
end module
31 changes: 25 additions & 6 deletions src_json_parser/parser_tools.F90
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module parser_tools_mod

#ifdef CompileWithSMBJSON
use labels_mod
use mesh_mod
use cells_mod
Expand Down Expand Up @@ -32,18 +34,35 @@ subroutine addCellRegionsAsCoords(res, cellRegions, cellType)
type(coords), dimension(:), pointer :: res
type(cell_region_t), dimension(:), intent(in) :: cellRegions
integer, intent(in), optional :: cellType
type(cell_interval_t), dimension(:), allocatable :: intervals
type(cell_interval_t), dimension(:), allocatable :: intervals, intervalsInRegion
type(coords), dimension(:), allocatable :: cs
integer :: i
integer :: i, j
integer :: numberOfIntervals, copiedIntervals

allocate(intervals(0))

numberOfIntervals = 0
do i = 1, size(cellRegions)
if (present(cellType)) then
intervals = [intervals, cellRegions(i)%getIntervalsOfType(cellType)]
numberOfIntervals = numberOfIntervals + count(cellRegions(i)%intervals%getType() == cellType)
else
numberOfIntervals = numberOfIntervals + size(cellRegions(i)%intervals)
end if
end do

allocate(intervals(numberOfIntervals))
copiedIntervals = 0
do i = 1, size(cellRegions)
if (present(cellType)) then
intervalsInRegion = cellRegions(i)%getIntervalsOfType(cellType)
else
intervals = [intervals, cellRegions(i)%intervals]
intervalsInRegion = cellRegions(i)%intervals
end if
do j = 1, size(intervalsInRegion)
copiedIntervals = copiedIntervals + 1
intervals(copiedIntervals) = intervalsInRegion(j)
end do
end do

cs = cellIntervalsToCoords(intervals)
allocate(res(size(cs)))
res = cs
Expand Down Expand Up @@ -175,5 +194,5 @@ function scalarToMatrix(scalar) result(res)
allocate(res(1,1), source = 0.0)
res(1,1) = scalar
end function

#endif
end module
3 changes: 3 additions & 0 deletions src_json_parser/smbjson.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module smbjson

#ifdef CompileWithSMBJSON
use NFDETypes

use NFDETypes_extension
Expand Down Expand Up @@ -2879,4 +2880,6 @@ function getSingleVolumeInElementsIds(this, pw) result (res)
if (size(res) /= 1) &
write(error_unit, *) "Entity must contain a single cell region defining a volume."
end function

#endif
end module
2 changes: 1 addition & 1 deletion src_main_pub/anisotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ subroutine InitAnisotropic(sgg,sggmiex,sggmiey,sggmiez,sggMiHx ,sggMiHy ,sggMiHz
AniMed%info(jmed)%Ex_Shared(i1)%times = sgg%Eshared%elem(j1)%Times
if (sgg%Eshared%elem(j1)%Times > 1 ) then
allocate (AniMed%info(jmed)%Ex_Shared(i1)%SharedMed(1:sgg%Eshared%elem(j1)%Times)) !OJO, EN EL ORIGINAL LO ALLOCATEABA HASTA -1
!LO CAMBIO EL 26/10 POR ERROR EN LA NACELLE DEL SS5, PERO NO ESTOY SEGURO QUE HAYA UN BUG CON ESTO DE LOS SHARED !Ç
!LO CAMBIO EL 26/10 POR ERROR EN LA NACELLE DEL SS5, PERO NO ESTOY SEGURO QUE HAYA UN BUG CON ESTO DE LOS SHARED !!?
endif
!PRINT *,'---> eX',sgg%Eshared%elem(j1)%i,sgg%Eshared%elem(j1)%J,sgg%Eshared%elem(j1)%k,sgg%Eshared%elem(j1)%times
exit buscaEx
Expand Down
6 changes: 3 additions & 3 deletions src_main_pub/bordersmur.F90
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,9 @@ subroutine AdvanceMagneticMUR(b, sgg,sggMiHx, sggMiHy, sggMiHz, Hx, Hy, Hz,mur_s


call stoponerror(0,0,'ERROR: MUR SECOND not correctly implemented')
!!!!!ÇÇÇÇÇ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!ÇÇÇÇÇ!!!!!!!!!!!!!!!!!!!Edges!!!!!!!!!!!!!!!!!!!!!Mur primer orden
!!!!!ÇÇÇÇÇ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!?!?!?!?!?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!?!?!?!?!?!!!!!!!!!!!!!!!!!!!Edges!!!!!!!!!!!!!!!!!!!!!Mur primer orden
!!!!!!?!?!?!?!?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

IF (sgg%Border%IsLeftMUR) then
REGION = left
Expand Down
4 changes: 2 additions & 2 deletions src_main_pub/farfield.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,7 @@ subroutine FlushFarfield(layoutnumber,size, b, dxe, dye, dze, dxh, dyh, dzh,face
endif
!
If( FF%farfieldTr_ClonePEC_LEFT.or.FF%farfieldFr_ClonePEC_LEFT) then
!!!!!!!!ÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇ
!!!!!!!!!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?
new_My = - My
new_Mz = + Mz
new_Jy = + Jy
Expand Down Expand Up @@ -3136,7 +3136,7 @@ subroutine FlushFarfield(layoutnumber,size, b, dxe, dye, dze, dxh, dyh, dzh,face
call cloneAbAr(comun,new_co,sintheta_cosphi,sintheta_sinphi,costheta,costheta_cosphi,costheta_sinphi,sintheta,sinphi,cosphi,new_Mx,new_My,new_Mz,new_Jx,new_Jy,new_Jz,L_theta,L_phi,N_theta,N_phi,NORMAL)
!
If( FF%farfieldAb_ClonePEC_LEFT.or.FF%farfieldAr_ClonePEC_LEFT) then
!ÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇÇ
!!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?!?
new_Mx = + Mx
new_My = - My
new_Jx = - Jx
Expand Down
Loading

0 comments on commit cec0e25

Please sign in to comment.