Skip to content

Commit

Permalink
Merge pull request #123 from OpenSEMBA/feature/sgbc
Browse files Browse the repository at this point in the history
Feature/sgbc
  • Loading branch information
Alberto-o authored Jan 28, 2025
2 parents ad33264 + c6b6e9b commit 014971d
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 105 deletions.
234 changes: 145 additions & 89 deletions src_main_pub/observation.F90

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src_main_pub/preprocess_geom.F90
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ SUBROUTINE read_geomData (sgg,sggMtag,tag_numbers, sggMiNo,sggMiEx,sggMiEy,sggMi
tag_numbers%edge%y(:,:,:) = 0
tag_numbers%edge%z(:,:,:) = 0
tag_numbers%face%x(:,:,:) = 0
tag_numbers%face%x(:,:,:) = 0
tag_numbers%face%x(:,:,:) = 0
tag_numbers%face%y(:,:,:) = 0
tag_numbers%face%z(:,:,:) = 0
!todo sustrato por defecto
sggmiNo (:, :, :) = 1
sggmiEx (:, :, :) = 1
Expand Down
11 changes: 6 additions & 5 deletions src_main_pub/timestepping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ subroutine launch_simulation(sgg,sggMtag,tag_numbers, sggMiNo,sggMiEx,sggMiEy,sg
endif

!!!!!!!sgg 121020 !rellena la matriz Mtag con los slots de una celda
call fillMtag(sgg, sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sggMtag, b)
call fillMtag(sgg, sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sggMtag, b, tag_numbers)
!!!!!!!fin

#ifdef CompileWithMPI
Expand Down Expand Up @@ -2806,7 +2806,7 @@ end subroutine XXXXfillMagnetic

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine fillMtag(sgg,sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sggMtag, b)
subroutine fillMtag(sgg,sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sggMtag, b, tag_numbers)

!------------------------>
type (SGGFDTDINFO), intent(IN) :: sgg
Expand All @@ -2818,6 +2818,7 @@ subroutine fillMtag(sgg,sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sgg
integer(kind = INTEGERSIZEOFMEDIAMATRICES), dimension ( 0 : b%sggMiEx%NX-1 , 0 : b%sggMiEx%NY-1 , 0 : b%sggMiEx%NZ-1 ) , intent( IN ) :: sggMiEx
integer(kind = INTEGERSIZEOFMEDIAMATRICES), dimension ( 0 : b%sggMiEy%NX-1 , 0 : b%sggMiEy%NY-1 , 0 : b%sggMiEy%NZ-1 ) , intent( IN ) :: sggMiEy
integer(kind = INTEGERSIZEOFMEDIAMATRICES), dimension ( 0 : b%sggMiEz%NX-1 , 0 : b%sggMiEz%NY-1 , 0 : b%sggMiEz%NZ-1 ) , intent( IN ) :: sggMiEz
type (taglist_t) :: tag_numbers
!------------------------> Variables locales
integer(kind = 4) :: i, j, k
integer(kind = INTEGERSIZEOFMEDIAMATRICES) :: medio1,medio2,medio3,medio4,medio5
Expand All @@ -2841,7 +2842,7 @@ subroutine fillMtag(sgg,sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sgg
mediois3= .true. !.not.((medio5==1).and.(((sggMiHx(i-1,j,k)/=1).or.(sggMiHx(i+1,j,k)/=1)))) !esta condicion en realidad no detecta alabeos de una celda que siendo slots son acoples de un agujerito solo en el peor de los casos
if ((mediois1.or.mediois2).and.(mediois3)) then
!solo lo hace con celdas de vacio porque en particular el mismo medio sgbc con diferentes orientaciones tiene distintos indices de medio y lo activaria erroneamente si lo hago para todos los medios
sggMtag(i,j,k)=-ibset(iabs(sggMtag(i,j,k)),3)
tag_numbers%face%x(i,j,k)=-ibset(iabs(tag_numbers%face%x(i,j,k)),3)
!ojo no cambiar: interacciona con observation tags 141020 !151020 a efectos de mapvtk el signo importa
endif
End do
Expand All @@ -2863,7 +2864,7 @@ subroutine fillMtag(sgg,sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sgg
mediois2= (medio5==1).and.(medio3/=1).and.(medio4/=1).and.(medio1==1).and.(medio2==1)
mediois3= .true. !.not.((medio5==1).and.(((sggMiHy(i,j-1,k)/=1).or.(sggMiHy(i,j+1,k)/=1))))
if ((mediois1.or.mediois2).and.(mediois3)) then
sggMtag(i,j,k)=-ibset(iabs(sggMtag(i,j,k)),4)
tag_numbers%face%y(i,j,k)=-ibset(iabs(tag_numbers%face%y(i,j,k)),4)
endif
End do
End do
Expand All @@ -2884,7 +2885,7 @@ subroutine fillMtag(sgg,sggMiEx, sggMiEy, sggMiEz, sggMiHx, sggMiHy, sggMiHz,sgg
mediois2= (medio5==1).and.(medio3/=1).and.(medio4/=1).and.(medio1==1).and.(medio2==1)
mediois3= .true. !.not.((medio5==1).and.(((sggMiHz(i,j,k-1)/=1).or.(sggMiHz(i,j,k+1)/=1))))
if ((mediois1.or.mediois2).and.(mediois3)) then
sggMtag(i,j,k)=-ibset(iabs(sggMtag(i,j,k)),5)
tag_numbers%face%z(i,j,k)=-ibset(iabs(tag_numbers%face%z(i,j,k)),5)
endif
End do
End do
Expand Down
23 changes: 21 additions & 2 deletions test/pyWrapper/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_tagnumbers_1_line(tmp_path):
line_media_dict = createPropertyDictionary(vtkmapfile, celltype = 3, property = 'mediatype')
assert line_media_dict[0.5] == 2 #PEC line

def test_tagnumbers_volume_and_surfacs(tmp_path):
def test_tagnumbers_volume_and_surfaces(tmp_path):
fn = CASES_FOLDER + 'tagNumber_mediaType/volume_and_surfaces.fdtd.json'
solver = FDTD(input_filename=fn, path_to_exe=SEMBA_EXE,
run_in_folder=tmp_path, flags=['-mapvtk'])
Expand Down Expand Up @@ -188,4 +188,23 @@ def test_tagnumbers_volume_and_surfacs(tmp_path):
line_media_dict = createPropertyDictionary(vtkmapfile, celltype = 3, property = 'mediatype')
assert line_media_dict[-0.5] == 4 #PMC line
assert line_media_dict[0.5] == 1 #PEC line
assert line_media_dict[3.5] == 3 #SGBC line
assert line_media_dict[3.5] == 3 #SGBC line

def test_tagnumbers_count_bug(tmp_path):
fn = CASES_FOLDER + 'tagNumber_mediaType/count_bug.fdtd.json'
solver = FDTD(input_filename=fn, path_to_exe=SEMBA_EXE,
run_in_folder=tmp_path, flags=['-mapvtk'])
solver['general']['numberOfSteps'] = 1
solver.run()

solver["materialAssociations"][0]["materialId"] = 3
solver["materialAssociations"][1]["materialId"] = 1
solver["materialAssociations"][2]["materialId"] = 3
solver.cleanUp()
solver.run()

solver["materialAssociations"][0]["materialId"] = 3
solver["materialAssociations"][1]["materialId"] = 3
solver["materialAssociations"][2]["materialId"] = 1
solver.cleanUp()
solver.run()
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
],

"materialAssociations": [
{"type": "surface", "materialId": 1, "elementIds": [4]}
{"materialId": 1, "elementIds": [4]}
],

"sources": [
Expand Down
66 changes: 66 additions & 0 deletions testData/cases/tagNumber_mediaType/count_bug.fdtd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"format": "FDTD Input file",
"__comments": "Example input with sgbc material",

"general": {
"timeStep": 10e-12,
"numberOfSteps": 2000
},

"boundary": {
"all": {"type": "mur"}
},

"mesh": {
"grid": {
"numberOfCells": [10, 10, 10],
"steps": { "x": [0.1], "y": [0.1], "z": [0.1] }
},
"elements": [
{"id": 1, "type": "cell", "intervals": [ [ [3, 3, 3], [4, 4, 3] ] ]},
{"id": 2, "type": "cell", "intervals": [ [ [3, 3, 4], [4, 4, 4] ] ]},
{"id": 3, "type": "cell", "intervals": [ [ [3, 3, 3], [3, 4, 4] ] ]}
]
},

"materials": [
{
"type": "pec",
"id": 1
},
{
"name": "2-layers-composite",
"type": "multilayeredSurface",
"id": 2,
"layers": [
{"thickness": 1e-3, "relativePermittivity": 1.3, "electricConductivity": 2e-4},
{"thickness": 5e-3, "relativePermittivity": 1.3}
]
},
{
"name": "3-layers-composite",
"type": "multilayeredSurface",
"id": 3,
"layers": [
{"thickness": 1e-3, "electricConductivity": 2e-4},
{"thickness": 5e-3, "relativePermeability": 1.3},
{"thickness": 1e-3, "magneticConductivity": 1e-4}
]
}
],

"materialAssociations": [
{
"materialId": 1,
"elementIds": [ 3 ]
},
{
"materialId": 3,
"elementIds": [ 1 ]
},
{
"materialId": 3,
"elementIds": [ 2 ]
}
]
}
2 changes: 0 additions & 2 deletions testData/cases/tagNumber_mediaType/three_surfaces.fdtd.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@
"elementIds": [ 1 ]
},
{
"type": "surface",
"materialId": 2,
"elementIds": [ 2 ]
},
{
"type": "surface",
"materialId": 3,
"elementIds": [ 3 ]
}
Expand Down
1 change: 0 additions & 1 deletion testData/input_examples/airplane.fdtd.json
Original file line number Diff line number Diff line change
Expand Up @@ -10719,7 +10719,6 @@
],
"materialAssociations": [
{
"type": "surface",
"materialId": 1,
"elementIds": [
7
Expand Down
1 change: 0 additions & 1 deletion testData/input_examples/large_airplane_mtln.fdtd.json
Original file line number Diff line number Diff line change
Expand Up @@ -46856,7 +46856,6 @@
],
"materialAssociations": [
{
"type": "surface",
"materialId": 1,
"elementIds": [
7,
Expand Down
2 changes: 0 additions & 2 deletions testData/input_examples/sgbc.fdtd.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@
"elementIds": [ 1 ]
},
{
"type": "surface",
"materialId": 2,
"elementIds": [ 2 ]
},
{
"type": "surface",
"materialId": 3,
"elementIds": [ 3 ]
}
Expand Down

0 comments on commit 014971d

Please sign in to comment.