Skip to content

Commit a57ae37

Browse files
authored
Merge pull request #75 from OpenSEMBA/dev
Foxes bug with intel parsing files with many elements
2 parents 40156a2 + c293304 commit a57ae37

36 files changed

+48283
-583
lines changed

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ if (SEMBA_FDTD_MAIN_LIB)
116116
"src_main_pub/timestepping.F90"
117117
"src_main_pub/observation.F90"
118118
"src_main_pub/vtk.F90"
119+
"src_main_pub/xdmf.F90"
120+
"src_main_pub/xdmf_h5.F90"
119121
"src_wires_pub/wires.F90"
120122
"src_wires_pub/wires_mtln.F90"
121123
)
@@ -140,13 +142,6 @@ add_definitions(
140142
-DCompileWithInt2
141143
-DCompileWithReal4
142144
-DCompileWithOpenMP
143-
-DCompileWithAnisotropic
144-
-DCompileWithEDispersives
145-
-DCompileWithNF2FF
146-
-DCompileWithNodalSources
147-
-DCompileWithDMMA
148-
-DCompileWithSGBC
149-
-DCompileWithWires
150145
)
151146

152147

doc/smbjson.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,15 +634,15 @@ If not `magnitudeFile` is specified and only one `source` is defined, the `magni
634634

635635
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`.
636636
`currentDensity` will store only the surface density currents on `pec` or lossy surfaces.
637-
The stored values can be selected using `[components]`, which stores an array of the following labels `x`, `y`, `z`, or `magnitude`; if no components are specified, defaults to `magnitude`.
637+
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`.
638638

639639
An example follows:
640640
```json
641641
{
642642
"name": "electric_field_movie",
643643
"type": "movie",
644644
"field": "electric",
645-
"components": ["x"],
645+
"component": "x",
646646
"elementIds": [4]
647647
}
648648
```

src_json_parser/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ add_library (jsonfortran
1313
)
1414

1515
add_library(smbjson
16-
"labels_mod.F90"
16+
"smbjson_labels.F90"
1717
"cells.F90"
1818
"smbjson.F90"
1919
"idchildtable.F90"

src_json_parser/idchildtable.F90

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module idchildtable_mod
22

33
#ifdef CompileWithSMBJSON
44
use json_module
5+
use smbjson_labels_mod, only: J_ID
56
use fhash, only: fhash_tbl_t, key=>fhash_key
6-
use labels_mod
77
use parser_tools_mod, only: json_value_ptr
88

99
type :: IdChildTable_t
@@ -29,10 +29,13 @@ function ctor(core, root, path) result(res)
2929
integer :: id
3030
integer :: i
3131
logical :: found
32+
integer :: numberOfEntries
3233

3334
call core%get(root, path, jentries, found)
3435
if (.not. found) return
35-
do i = 1, core%count(jentries)
36+
numberOfEntries = core%count(jentries)
37+
call res%idToChilds%allocate(10*numberOfEntries)
38+
do i = 1, numberOfEntries
3639
call core%get_child(jentries, i, jentry)
3740
call core%get(jentry, J_ID, id)
3841
call res%idToChilds%set(key(id), json_value_ptr(jentry))

src_json_parser/mesh.F90

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ module mesh_mod
4040
procedure :: checkId => mesh_checkId
4141

4242
procedure :: addElement => mesh_addElement
43+
procedure :: addCellRegion => mesh_addCellRegion
44+
4345
procedure :: getNode => mesh_getNode
4446
procedure :: getPolyline => mesh_getPolyline
45-
46-
procedure :: addCellRegion => mesh_addCellRegion
4747
procedure :: getCellRegion => mesh_getCellRegion
4848
procedure :: getCellRegions => mesh_getCellRegions
4949

@@ -54,6 +54,7 @@ module mesh_mod
5454

5555
procedure :: printCoordHashInfo => mesh_printCoordHashInfo
5656
procedure :: allocateCoordinates => mesh_allocateCoordinates
57+
procedure :: allocateElements => mesh_allocateElements
5758
end type
5859

5960

@@ -65,6 +66,13 @@ subroutine mesh_allocateCoordinates(this, buck)
6566
integer :: buck
6667
call this%coordinates%allocate(buck)
6768
end subroutine
69+
70+
subroutine mesh_allocateElements(this, buck)
71+
class(mesh_t) :: this
72+
integer :: buck
73+
call this%elements%allocate(buck)
74+
end subroutine
75+
6876

6977
subroutine mesh_printCoordHashInfo(this)
7078
class(mesh_t) :: this
@@ -193,12 +201,26 @@ function mesh_getCellRegions(this, ids) result (res)
193201
integer, dimension(:), intent(in) :: ids
194202
type(cell_region_t) :: cR
195203
logical :: found
196-
integer :: i
204+
integer :: i, j
205+
integer :: numberOfCellRegions
197206

198-
allocate(res(0))
207+
! Precounts
208+
numberOfCellRegions = 0
199209
do i = 1, size(ids)
200210
cR = this%getCellRegion(ids(i), found)
201-
if (found) res = [res, cR]
211+
if (found) then
212+
numberOfCellRegions = numberOfCellRegions + 1
213+
end if
214+
end do
215+
216+
allocate(res(numberOfCellRegions))
217+
j = 1
218+
do i = 1, size(ids)
219+
cR = this%getCellRegion(ids(i), found)
220+
if (found) then
221+
res(j) = cR
222+
j = j + 1
223+
end if
202224
end do
203225

204226
end function

src_json_parser/parser_tools.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
module parser_tools_mod
22

33
#ifdef CompileWithSMBJSON
4-
use labels_mod
54
use mesh_mod
65
use cells_mod
76
use json_module

src_json_parser/smbjson.F90

Lines changed: 58 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module smbjson
44
use NFDETypes
55

66
use NFDETypes_extension
7-
use labels_mod
7+
use smbjson_labels_mod
88
use mesh_mod
99
use parser_tools_mod
1010
use idchildtable_mod
@@ -30,7 +30,6 @@ module smbjson
3030

3131
contains
3232
procedure :: readProblemDescription
33-
procedure :: initializeJson
3433

3534
! private
3635
procedure :: readGeneral
@@ -93,112 +92,96 @@ function parser_ctor(filename) result(res)
9392
type(parser_t) :: res
9493
character(len=*), intent(in) :: filename
9594
res%filename = filename
96-
end function
97-
98-
subroutine initializeJson(this)
99-
class(parser_t) :: this
100-
integer :: stat
101-
102-
allocate(this%jsonfile)
103-
call this%jsonfile%initialize()
104-
if (this%jsonfile%failed()) then
105-
call this%jsonfile%print_error_message(error_unit)
95+
96+
allocate(res%jsonfile)
97+
call res%jsonfile%initialize()
98+
if (res%jsonfile%failed()) then
99+
call res%jsonfile%print_error_message(error_unit)
106100
return
107101
end if
108102

109-
call this%jsonfile%load(filename = this%filename)
110-
if (this%jsonfile%failed()) then
111-
call this%jsonfile%print_error_message(error_unit)
103+
call res%jsonfile%load(filename = res%filename)
104+
if (res%jsonfile%failed()) then
105+
call res%jsonfile%print_error_message(error_unit)
112106
return
113107
end if
114108

115-
allocate(this%core)
116-
call this%jsonfile%get_core(this%core)
117-
call this%jsonfile%get('.', this%root)
118-
end subroutine
109+
allocate(res%core)
110+
call res%jsonfile%get_core(res%core)
111+
call res%jsonfile%get('.', res%root)
112+
end function
119113

120114
function readProblemDescription(this) result (res)
121115
class(parser_t) :: this
122116
type(Parseador) :: res
123117
integer :: stat
124118

125-
allocate(this%jsonfile)
126-
call this%jsonfile%initialize()
127-
if (this%jsonfile%failed()) then
128-
call this%jsonfile%print_error_message(error_unit)
129-
return
130-
end if
131-
132-
call this%jsonfile%load(filename = this%filename)
133-
if (this%jsonfile%failed()) then
134-
call this%jsonfile%print_error_message(error_unit)
135-
return
136-
end if
137-
138-
allocate(this%core)
139-
call this%jsonfile%get_core(this%core)
140-
call this%jsonfile%get('.', this%root)
141-
142119
this%mesh = this%readMesh()
143120
this%matTable = IdChildTable_t(this%core, this%root, J_MATERIALS)
144-
121+
145122
call initializeProblemDescription(res)
146-
123+
147124
! Basics
148125
res%general = this%readGeneral()
149126
res%matriz = this%readMediaMatrix()
150127
res%despl = this%readGrid()
151128
res%front = this%readBoundary()
152-
129+
153130
! Materials
154131
res%pecRegs = this%readPECRegions()
155132
res%pmcRegs = this%readPMCRegions()
156-
133+
157134
! Sources
158135
res%plnSrc = this%readPlanewaves()
159136
res%nodSrc = this%readNodalSources()
160-
137+
161138
! Probes
162139
res%oldSonda = this%readProbes()
163140
res%sonda = this%readMoreProbes()
164141
res%BloquePrb = this%readBlockProbes()
165142
res%VolPrb = this%readVolumicProbes()
166-
143+
167144
! Thin elements
168145
res%tWires = this%readThinWires()
169146
res%mtln = this%readMTLN(res%despl)
170147

171-
! Cleanup
172-
call this%core%destroy()
173-
call this%jsonfile%destroy()
174-
nullify(this%root)
148+
!! Cleanup
149+
!call this%core%destroy()
150+
!call this%jsonfile%destroy()
151+
!nullify(this%root)
175152

176153
end function
177154

178155
function readMesh(this) result(res)
179156
class(parser_t) :: this
180157
type(Mesh_t) :: res
181-
type(json_value), pointer :: jcs, jc
182-
integer :: id, i
183-
real, dimension(:), allocatable :: pos
184-
type(coordinate_t) :: c
185-
integer :: stat
186-
logical :: found
187-
188-
call this%core%get(this%root, J_MESH//'.'//J_COORDINATES, jcs, found=found)
189-
if (found) then
190-
call res%allocateCoordinates(10*this%core%count(jcs))
191-
do i = 1, this%core%count(jcs)
192-
call this%core%get_child(jcs, i, jc)
193-
call this%core%get(jc, J_ID, id)
194-
call this%core%get(jc, J_COORDINATE_POS, pos)
195-
c%position = pos
196-
call res%addCoordinate(id, c)
197-
end do
198-
end if
158+
call addCoordinates(res)
199159
call addElements(res)
200160

201161
contains
162+
subroutine addCoordinates(mesh)
163+
type(mesh_t), intent(inout) :: mesh
164+
type(json_value), pointer :: jcs, jc
165+
integer :: id, i
166+
real, dimension(:), allocatable :: pos
167+
type(coordinate_t) :: c
168+
integer :: numberOfCoordinates
169+
logical :: found
170+
171+
call this%core%get(this%root, J_MESH//'.'//J_COORDINATES, jcs, found=found)
172+
if (found) then
173+
numberOfCoordinates = this%core%count(jcs)
174+
call res%allocateCoordinates(10*numberOfCoordinates)
175+
do i = 1, numberOfCoordinates
176+
call this%core%get_child(jcs, i, jc)
177+
call this%core%get(jc, J_ID, id)
178+
call this%core%get(jc, J_COORDINATE_POS, pos)
179+
c%position = pos
180+
call mesh%addCoordinate(id, c)
181+
end do
182+
end if
183+
end subroutine
184+
202185
subroutine addElements(mesh)
203186
type(mesh_t), intent(inout) :: mesh
204187
character (len=:), allocatable :: elementType
@@ -207,10 +190,15 @@ subroutine addElements(mesh)
207190
type(node_t) :: node
208191
type(polyline_t) :: polyline
209192
integer, dimension(:), allocatable :: coordIds
193+
integer :: numberOfElements
210194
logical :: found
195+
211196
call this%core%get(this%root, J_MESH//'.'//J_ELEMENTS, jes, found=found)
197+
numberOfElements = this%core%count(jes)
198+
call res%allocateElements(10*numberOfElements)
199+
212200
if (found) then
213-
do i = 1, this%core%count(jes)
201+
do i = 1, numberOfElements
214202
call this%core%get_child(jes, i, je)
215203
call this%core%get(je, J_ID, id)
216204
call this%core%get(je, J_TYPE, elementType)
@@ -985,19 +973,13 @@ function readVolProbe(p) result(res)
985973
cs = cellIntervalsToCoords(cRs(1)%intervals)
986974

987975
fieldType = this%getStrAt(p, J_FIELD, default=J_FIELD_ELECTRIC)
988-
call this%core%get(p, J_PR_MOVIE_COMPONENTS, compsPtr, found=componentsFound)
976+
call this%core%get(p, J_PR_MOVIE_COMPONENT, compsPtr, found=componentsFound)
977+
allocate(res%cordinates(1))
989978
if (componentsFound) then
990-
numberOfComponents = this%core%count(compsPtr)
991-
allocate(res%cordinates(numberOfComponents))
992-
do i = 1, numberOfComponents
993-
call this%core%get_child(compsPtr, i, compPtr)
994-
call this%core%get(compPtr, component)
995-
res%cordinates(i) = cs(1)
996-
res%cordinates(i)%Or = buildVolProbeType(fieldType, component)
997-
end do
998-
else
999-
allocate(res%cordinates(1))
979+
call this%core%get(compsPtr, component)
1000980
res%cordinates(1) = cs(1)
981+
res%cordinates(1)%Or = buildVolProbeType(fieldType, component)
982+
else
1001983
component = J_DIR_M
1002984
res%cordinates(1)%Or = buildVolProbeType(fieldType, component)
1003985
endif
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module labels_mod
1+
module smbjson_labels_mod
22

33
#ifdef CompileWithSMBJSON
44
! LABELS
@@ -155,7 +155,7 @@ module labels_mod
155155

156156
character (len=*), parameter :: J_PR_POINT_DIRECTIONS = "directions"
157157

158-
character (len=*), parameter :: J_PR_MOVIE_COMPONENTS = "components"
158+
character (len=*), parameter :: J_PR_MOVIE_COMPONENT = "component"
159159

160160
character (len=*), parameter :: J_PR_FAR_FIELD_THETA = "theta"
161161
character (len=*), parameter :: J_PR_FAR_FIELD_PHI = "phi"

src_main_pub/anisotropic.F90

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3333

3434
module Anisotropic
35-
36-
#ifdef CompileWithAnisotropic
37-
3835
use fdetypes
3936
implicit none
4037
private
@@ -1581,6 +1578,4 @@ Subroutine CalculateCoeff(epr,mur,sigma,sigmam,dt,coeff)
15811578

15821579
end subroutine
15831580

1584-
#endif
1585-
15861581
end module Anisotropic

0 commit comments

Comments
 (0)