Skip to content

Commit 8b27c5e

Browse files
committed
refactor: reorganize exchange type hierarchy
1 parent ca7ee26 commit 8b27c5e

22 files changed

Lines changed: 560 additions & 403 deletions

make/makefile

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -341,20 +341,11 @@ $(OBJDIR)/DroppedEvent.o \
341341
$(OBJDIR)/Cell.o \
342342
$(OBJDIR)/Method.o \
343343
$(OBJDIR)/CellExitEvent.o \
344-
$(OBJDIR)/SubcellExitEvent.o \
345-
$(OBJDIR)/MethodCell.o \
346-
$(OBJDIR)/TernarySolveUtils.o \
347-
$(OBJDIR)/SubcellTri.o \
348-
$(OBJDIR)/MethodSubcell.o \
349-
$(OBJDIR)/SubcellRect.o \
350-
$(OBJDIR)/MethodSubcellTernary.o \
351-
$(OBJDIR)/MethodSubcellPollock.o \
352344
$(OBJDIR)/TimeStepSelect.o \
353345
$(OBJDIR)/LinearAlgebraUtils.o \
354346
$(OBJDIR)/SfrCrossSectionUtils.o \
355-
$(OBJDIR)/CellPoly.o \
356-
$(OBJDIR)/CellRectQuad.o \
357-
$(OBJDIR)/CellRect.o \
347+
$(OBJDIR)/SubcellExitEvent.o \
348+
$(OBJDIR)/MethodCell.o \
358349
$(OBJDIR)/SwfCxsUtils.o \
359350
$(OBJDIR)/PrintSaveManager.o \
360351
$(OBJDIR)/tsp-fmi.o \
@@ -363,10 +354,10 @@ $(OBJDIR)/IsothermInterface.o \
363354
$(OBJDIR)/SfrCrossSectionManager.o \
364355
$(OBJDIR)/dag_module.o \
365356
$(OBJDIR)/BoundaryPackageExt.o \
366-
$(OBJDIR)/MethodCellTernary.o \
367-
$(OBJDIR)/MethodCellPollockQuad.o \
368-
$(OBJDIR)/MethodCellPollock.o \
369-
$(OBJDIR)/MethodCellPassToBot.o \
357+
$(OBJDIR)/TernarySolveUtils.o \
358+
$(OBJDIR)/SubcellTri.o \
359+
$(OBJDIR)/MethodSubcell.o \
360+
$(OBJDIR)/SubcellRect.o \
370361
$(OBJDIR)/VectorInterpolation.o \
371362
$(OBJDIR)/swf-cxs.o \
372363
$(OBJDIR)/OutputControlData.o \
@@ -391,8 +382,11 @@ $(OBJDIR)/gwf-lak.o \
391382
$(OBJDIR)/GwfVscInputData.o \
392383
$(OBJDIR)/gwf-ghb.o \
393384
$(OBJDIR)/gwf-drn.o \
394-
$(OBJDIR)/MethodModel.o \
395-
$(OBJDIR)/CellUtil.o \
385+
$(OBJDIR)/MethodSubcellTernary.o \
386+
$(OBJDIR)/CellPoly.o \
387+
$(OBJDIR)/MethodSubcellPollock.o \
388+
$(OBJDIR)/CellRectQuad.o \
389+
$(OBJDIR)/CellRect.o \
396390
$(OBJDIR)/swf-dfw.o \
397391
$(OBJDIR)/OutputControl.o \
398392
$(OBJDIR)/swf-ic.o \
@@ -419,8 +413,12 @@ $(OBJDIR)/GwfNpfOptions.o \
419413
$(OBJDIR)/GwfConductanceUtils.o \
420414
$(OBJDIR)/ParticleTracks.o \
421415
$(OBJDIR)/ParticleReleaseSchedule.o \
422-
$(OBJDIR)/MethodDisv.o \
423-
$(OBJDIR)/MethodDis.o \
416+
$(OBJDIR)/MethodModel.o \
417+
$(OBJDIR)/MethodCellTernary.o \
418+
$(OBJDIR)/MethodCellPollockQuad.o \
419+
$(OBJDIR)/MethodCellPollock.o \
420+
$(OBJDIR)/MethodCellPassToBot.o \
421+
$(OBJDIR)/CellUtil.o \
424422
$(OBJDIR)/swf-zdg.o \
425423
$(OBJDIR)/swf-sto.o \
426424
$(OBJDIR)/swf-pcp.o \
@@ -451,6 +449,8 @@ $(OBJDIR)/GweCndOptions.o \
451449
$(OBJDIR)/prt-prp.o \
452450
$(OBJDIR)/prt-oc.o \
453451
$(OBJDIR)/prt-mip.o \
452+
$(OBJDIR)/MethodDisv.o \
453+
$(OBJDIR)/MethodDis.o \
454454
$(OBJDIR)/ExplicitModel.o \
455455
$(OBJDIR)/gwf-api.o \
456456
$(OBJDIR)/swf.o \
@@ -493,11 +493,12 @@ $(OBJDIR)/chf.o \
493493
$(OBJDIR)/VirtualDataLists.o \
494494
$(OBJDIR)/VirtualDataContainer.o \
495495
$(OBJDIR)/SimStages.o \
496+
$(OBJDIR)/BaseExchange.o \
496497
$(OBJDIR)/IndexMap.o \
497498
$(OBJDIR)/ArrayReaderBase.o \
498499
$(OBJDIR)/ModelPackageInput.o \
499500
$(OBJDIR)/VirtualModel.o \
500-
$(OBJDIR)/BaseExchange.o \
501+
$(OBJDIR)/CellConnectionExchange.o \
501502
$(OBJDIR)/InterfaceMap.o \
502503
$(OBJDIR)/SeqVector.o \
503504
$(OBJDIR)/ImsLinearSettings.o \
@@ -521,7 +522,7 @@ $(OBJDIR)/Double1dReader.o \
521522
$(OBJDIR)/LoadContext.o \
522523
$(OBJDIR)/VirtualExchange.o \
523524
$(OBJDIR)/GridSorting.o \
524-
$(OBJDIR)/DisConnExchange.o \
525+
$(OBJDIR)/GeometricConnectionExchange.o \
525526
$(OBJDIR)/CsrUtils.o \
526527
$(OBJDIR)/RouterBase.o \
527528
$(OBJDIR)/STLStackInt.o \
@@ -543,7 +544,7 @@ $(OBJDIR)/ImsLinear.o \
543544
$(OBJDIR)/BaseSolution.o \
544545
$(OBJDIR)/LoadMf6File.o \
545546
$(OBJDIR)/AsciiInputLoadType.o \
546-
$(OBJDIR)/SpatialModelConnection.o \
547+
$(OBJDIR)/InterfaceModelExchange.o \
547548
$(OBJDIR)/GwtInterfaceModel.o \
548549
$(OBJDIR)/exg-gwtgwt.o \
549550
$(OBJDIR)/GwfInterfaceModel.o \

msvs/mf6core.vfproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@
112112
<File RelativePath="..\src\Distributed\VirtualSolution.f90"/></Filter>
113113
<Filter Name="Exchange">
114114
<File RelativePath="..\src\Exchange\BaseExchange.f90"/>
115-
<File RelativePath="..\src\Exchange\DisConnExchange.f90"/>
115+
<File RelativePath="..\src\Exchange\CellConnectionExchange.f90"/>
116+
<File RelativePath="..\src\Exchange\NumericalExchange.f90"/>
117+
<File RelativePath="..\src\Exchange\GeometricConnectionExchange.f90"/>
116118
<File RelativePath="..\src\Exchange\exg-chfgwf.f90"/>
117119
<File RelativePath="..\src\Exchange\exg-gwegwe.f90"/>
118120
<File RelativePath="..\src\Exchange\exg-gwfgwe.f90"/>
@@ -123,8 +125,7 @@
123125
<File RelativePath="..\src\Exchange\exg-olfgwf.f90"/>
124126
<File RelativePath="..\src\Exchange\exg-swfgwf.f90"/>
125127
<File RelativePath="..\src\Exchange\GhostNode.f90"/>
126-
<File RelativePath="..\src\Exchange\GwfExchangeMover.f90"/>
127-
<File RelativePath="..\src\Exchange\NumericalExchange.f90"/></Filter>
128+
<File RelativePath="..\src\Exchange\GwfExchangeMover.f90"/></Filter>
128129
<Filter Name="Idm">
129130
<Filter Name="selector">
130131
<File RelativePath="..\src\Idm\selector\IdmChfDfnSelector.f90"/>
@@ -270,7 +271,7 @@
270271
<File RelativePath="..\src\Model\Connection\GwtGwtConnection.f90"/>
271272
<File RelativePath="..\src\Model\Connection\GwtInterfaceModel.f90"/>
272273
<File RelativePath="..\src\Model\Connection\qsort_inline.inc"/>
273-
<File RelativePath="..\src\Model\Connection\SpatialModelConnection.f90"/></Filter>
274+
<File RelativePath="..\src\Model\Connection\InterfaceModelExchange.f90"/></Filter>
274275
<Filter Name="Discretization">
275276
<File RelativePath="..\src\Model\Discretization\Dis.f90"/>
276277
<File RelativePath="..\src\Model\Discretization\Dis2d.f90"/>

src/Distributed/Mapper.f90

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ end subroutine init
4343
subroutine add_exchange_vars(this)
4444
use SimStagesModule
4545
use ListsModule, only: baseconnectionlist
46-
use SpatialModelConnectionModule, only: SpatialModelConnectionType, &
47-
get_smc_from_list
46+
use InterfaceModelExchangeModule, only: InterfaceModelExchangeType, &
47+
GetInterfaceModelExchangeFromList
4848
use VirtualExchangeModule, only: VirtualExchangeType, get_virtual_exchange
4949
class(MapperType) :: this
5050
! local
5151
integer(I4B) :: iconn
52-
class(SpatialModelConnectionType), pointer :: conn
52+
class(InterfaceModelExchangeType), pointer :: conn
5353
class(VirtualExchangeType), pointer :: virt_exg
5454
character(len=LENMEMPATH) :: virt_mem_path, local_mem_path
5555

5656
do iconn = 1, baseconnectionlist%Count()
57-
conn => get_smc_from_list(baseconnectionlist, iconn)
57+
conn => GetInterfaceModelExchangeFromList(baseconnectionlist, iconn)
5858
virt_exg => get_virtual_exchange(conn%prim_exchange%id)
5959
if (.not. virt_exg%v_model1%is_local) then
6060
virt_mem_path = virt_exg%get_vrt_mem_path('NODEM1', '')
@@ -108,15 +108,15 @@ end subroutine add_exchange_vars
108108
!<
109109
subroutine add_interface_vars(this)
110110
use ListsModule, only: baseconnectionlist
111-
use SpatialModelConnectionModule, only: SpatialModelConnectionType, &
112-
get_smc_from_list
111+
use InterfaceModelExchangeModule, only: InterfaceModelExchangeType, &
112+
GetInterfaceModelExchangeFromList
113113
class(MapperType) :: this
114114
! local
115115
integer(I4B) :: iconn
116-
class(SpatialModelConnectionType), pointer :: conn
116+
class(InterfaceModelExchangeType), pointer :: conn
117117

118118
do iconn = 1, baseconnectionlist%Count()
119-
conn => get_smc_from_list(baseconnectionlist, iconn)
119+
conn => GetInterfaceModelExchangeFromList(baseconnectionlist, iconn)
120120
! add the variables for this interface model to our mapper
121121
call this%add_dist_vars(conn%owner%idsoln, &
122122
conn%iface_dist_vars, &

src/Distributed/VirtualDataManager.f90

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ module VirtualDataManagerModule
1717
use NumericalModelModule, only: NumericalModelType, GetNumericalModelFromList
1818
use NumericalExchangeModule, only: NumericalExchangeType, &
1919
GetNumericalExchangeFromList
20-
use DisConnExchangeModule, only: DisConnExchangeType, &
21-
GetDisConnExchangeFromList
22-
use SpatialModelConnectionModule, only: SpatialModelConnectionType, &
23-
get_smc_from_list
20+
use GeometricConnectionExchangeModule, only: &
21+
GeometricConnectionExchangeType, &
22+
GetGeometricConnectionExchangeFromList
23+
use InterfaceModelExchangeModule, only: &
24+
InterfaceModelExchangeType, &
25+
GetInterfaceModelExchangeFromList
2426
implicit none
2527
private
2628

@@ -89,8 +91,8 @@ subroutine vds_add_solution(this, num_sol)
8991
integer(I4B) :: i, im, ix, ihm, ihx
9092
type(VirtualSolutionType), pointer :: virt_sol
9193
class(NumericalModelType), pointer :: num_mod
92-
class(DisConnExchangeType), pointer :: exg
93-
class(SpatialModelConnectionType), pointer :: conn
94+
class(GeometricConnectionExchangeType), pointer :: exg
95+
class(InterfaceModelExchangeType), pointer :: conn
9496
integer(I4B) :: model_id, exg_id
9597
type(STLVecInt) :: model_ids, exchange_ids
9698
class(VirtualDataContainerType), pointer :: vdc
@@ -125,7 +127,7 @@ subroutine vds_add_solution(this, num_sol)
125127

126128
! 2) adding all local exchanges with a virtual exchange counterpart
127129
do ix = 1, num_sol%exchangelist%Count()
128-
exg => GetDisConnExchangeFromList(num_sol%exchangelist, ix)
130+
exg => GetGeometricConnectionExchangeFromList(num_sol%exchangelist, ix)
129131
if (.not. associated(exg)) cycle ! interface model is handled separately
130132
found = .false.
131133
do i = 1, virtual_exchange_list%Count()
@@ -140,7 +142,7 @@ subroutine vds_add_solution(this, num_sol)
140142

141143
! 3) add halo models and exchanges from interface models
142144
do ix = 1, num_sol%exchangelist%Count()
143-
conn => get_smc_from_list(num_sol%exchangelist, ix)
145+
conn => GetInterfaceModelExchangeFromList(num_sol%exchangelist, ix)
144146
if (.not. associated(conn)) cycle
145147

146148
! it's an interface model based exchanged, get
@@ -185,13 +187,13 @@ subroutine vds_activate_halo(this)
185187
type(STLVecInt) :: halo_model_ids
186188
class(VirtualModelType), pointer :: vm
187189
class(VirtualExchangeType), pointer :: ve
188-
class(SpatialModelConnectionType), pointer :: conn
190+
class(InterfaceModelExchangeType), pointer :: conn
189191

190192
call halo_model_ids%init()
191193

192194
! add halo models to list with ids (unique)
193195
do ic = 1, baseconnectionlist%Count()
194-
conn => get_smc_from_list(baseconnectionlist, ic)
196+
conn => GetInterfaceModelExchangeFromList(baseconnectionlist, ic)
195197
do im = 1, conn%halo_models%size
196198
call halo_model_ids%push_back_unique(conn%halo_models%at(im))
197199
end do
@@ -240,7 +242,7 @@ subroutine vds_compress_halo(this)
240242
character(len=128) :: monitor_file
241243
type(VirtualSolutionType), pointer :: virt_sol
242244
class(NumericalSolutionType), pointer :: num_sol
243-
class(SpatialModelConnectionType), pointer :: conn
245+
class(InterfaceModelExchangeType), pointer :: conn
244246
class(VirtualDataContainerType), pointer :: vdc
245247
type(IndexMapType), pointer :: nmap, cmap
246248

@@ -249,7 +251,7 @@ subroutine vds_compress_halo(this)
249251
virt_sol => this%virtual_solutions(isol)
250252
num_sol => CastAsNumericalSolutionClass(virt_sol%numerical_solution)
251253
do iexg = 1, num_sol%exchangelist%Count()
252-
conn => get_smc_from_list(num_sol%exchangelist, iexg)
254+
conn => GetInterfaceModelExchangeFromList(num_sol%exchangelist, iexg)
253255
if (.not. associated(conn)) cycle
254256
! these are interface models, now merge their
255257
! interface maps

src/Exchange/BaseExchange.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module BaseExchangeModule
1313

1414
type, abstract :: BaseExchangeType
1515
character(len=LENEXCHANGENAME) :: name !< the name of this exchange
16+
character(len=7) :: typename !< the type of exchange (e.g., 'GWF-GWF', 'PRT-PRT')
1617
character(len=LENMEMPATH) :: memoryPath !< the location in the memory manager where the variables are stored
1718
character(len=LENMEMPATH) :: input_mempath
1819
integer(I4B) :: id
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
module CellConnectionExchangeModule
2+
3+
use KindModule, only: DP, I4B, LGP
4+
use ConstantsModule, only: LENEXCHANGENAME, LENMEMPATH
5+
use ListModule, only: ListType
6+
use BaseExchangeModule, only: BaseExchangeType, AddBaseExchangeToList
7+
use BaseModelModule, only: BaseModelType
8+
9+
implicit none
10+
11+
private
12+
public :: CellConnectionExchangeType, AddCellConnectionExchangeToList, &
13+
GetCellConnectionExchangeFromList
14+
15+
!> @brief CellConnectionExchangeType
16+
!!
17+
!! Base exchange type that stores the topological cell-to-cell connections
18+
!! between models. This type represents pure connectivity information without
19+
!! geometric data (connection lengths, areas, etc.). It stores:
20+
!! - nexg: number of connected cell pairs
21+
!! - nodem1, nodem2: node numbers in each model (reduced, 0-based)
22+
!! - ihc: horizontal connection indicator (0=vertical, 1=horizontal)
23+
!!
24+
!! This is the foundation for more specialized exchange types that add
25+
!! geometric information (GeometricConnectionExchangeType) or numerical
26+
!! coupling methods (NumericalExchangeType).
27+
!<
28+
type, extends(BaseExchangeType) :: CellConnectionExchangeType
29+
integer(I4B), pointer :: nexg => null() !< number of connected cell pairs
30+
integer(I4B), dimension(:), pointer, contiguous :: nodem1 => null() !< node numbers in model 1 (reduced, 0-based)
31+
integer(I4B), dimension(:), pointer, contiguous :: nodem2 => null() !< node numbers in model 2 (reduced, 0-based)
32+
integer(I4B), dimension(:), pointer, contiguous :: ihc => null() !< horizontal connection indicator (0=vertical, 1=horizontal)
33+
contains
34+
procedure :: exg_df
35+
procedure :: exg_ar
36+
procedure :: exg_da
37+
procedure :: allocate_scalars
38+
procedure :: allocate_arrays
39+
end type CellConnectionExchangeType
40+
41+
contains
42+
43+
subroutine exg_df(this)
44+
class(CellConnectionExchangeType) :: this !< instance of cell connection exchange object
45+
! override in child types
46+
end subroutine exg_df
47+
48+
subroutine exg_ar(this)
49+
class(CellConnectionExchangeType) :: this !< instance of cell connection exchange object
50+
! override in child types
51+
end subroutine exg_ar
52+
53+
!> @brief Allocate scalar variables for this cell connection exchange
54+
!<
55+
subroutine allocate_scalars(this)
56+
! -- modules
57+
use MemoryManagerModule, only: mem_allocate
58+
! -- dummy
59+
class(CellConnectionExchangeType) :: this !< instance of cell connection exchange object
60+
!
61+
call mem_allocate(this%nexg, 'NEXG', this%memoryPath)
62+
this%nexg = 0
63+
end subroutine allocate_scalars
64+
65+
!> @brief Allocate array data for this cell connection exchange,
66+
!! using the number of connected nodes nexg
67+
!<
68+
subroutine allocate_arrays(this)
69+
! -- modules
70+
use MemoryManagerModule, only: mem_allocate
71+
! -- dummy
72+
class(CellConnectionExchangeType) :: this !< instance of cell connection exchange object
73+
!
74+
call mem_allocate(this%nodem1, this%nexg, 'NODEM1', this%memoryPath)
75+
call mem_allocate(this%nodem2, this%nexg, 'NODEM2', this%memoryPath)
76+
call mem_allocate(this%ihc, this%nexg, 'IHC', this%memoryPath)
77+
end subroutine allocate_arrays
78+
79+
!> @brief Deallocate memory associated with this cell connection exchange
80+
!<
81+
subroutine exg_da(this)
82+
! -- modules
83+
use MemoryManagerModule, only: mem_deallocate
84+
! -- dummy
85+
class(CellConnectionExchangeType) :: this !< instance of cell connection exchange object
86+
!
87+
call mem_deallocate(this%nodem1)
88+
call mem_deallocate(this%nodem2)
89+
call mem_deallocate(this%ihc)
90+
call mem_deallocate(this%nexg)
91+
end subroutine exg_da
92+
93+
function CastAsCellConnectionExchangeClass(obj) result(res)
94+
implicit none
95+
class(*), pointer, intent(inout) :: obj
96+
class(CellConnectionExchangeType), pointer :: res
97+
98+
res => null()
99+
if (.not. associated(obj)) return
100+
101+
select type (obj)
102+
class is (CellConnectionExchangeType)
103+
res => obj
104+
end select
105+
end function CastAsCellConnectionExchangeClass
106+
107+
subroutine AddCellConnectionExchangeToList(list, exchange)
108+
implicit none
109+
type(ListType), intent(inout) :: list
110+
class(CellConnectionExchangeType), pointer, intent(in) :: exchange
111+
class(*), pointer :: obj
112+
113+
obj => exchange
114+
call list%Add(obj)
115+
end subroutine AddCellConnectionExchangeToList
116+
117+
function GetCellConnectionExchangeFromList(list, idx) result(res)
118+
implicit none
119+
type(ListType), intent(inout) :: list
120+
integer(I4B), intent(in) :: idx
121+
class(CellConnectionExchangeType), pointer :: res
122+
class(*), pointer :: obj
123+
124+
obj => list%GetItem(idx)
125+
res => CastAsCellConnectionExchangeClass(obj)
126+
end function GetCellConnectionExchangeFromList
127+
128+
end module CellConnectionExchangeModule

0 commit comments

Comments
 (0)