Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rfct(solution): encapsulate convergence params #1353

Merged
merged 31 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
257b980
Add diagnostics for PETSc solver: dvmax and residual change. (wip)
mjr-deltares Sep 16, 2023
b80b3d0
refactor solution convergence variables into convergence summary stru…
mjr-deltares Sep 18, 2023
fc141be
fprettify
mjr-deltares Sep 18, 2023
f88eb33
add to msvs
mjr-deltares Sep 19, 2023
bb5732b
change makefile
mjr-deltares Sep 19, 2023
5d944a0
Merge branch 'rfct-numsol' of https://github.com/mjr-deltares/modflow…
mjr-deltares Sep 19, 2023
ba61757
modified petscrc
mjr-deltares Sep 19, 2023
117b1ad
conditional storage of convergence info
mjr-deltares Sep 19, 2023
e70617a
introducing linear settings, petsc solver now configured from IMS
mjr-deltares Sep 21, 2023
4da8924
small clean and fix symmetry requirement
mjr-deltares Sep 22, 2023
b880244
Add file to msvs
mjr-deltares Sep 22, 2023
ae173fa
- add custom precondition
mjr-deltares Sep 22, 2023
fe0826b
fprettify
mjr-deltares Sep 22, 2023
be1c2d8
add new PETSc file to exclude file list
mjr-deltares Sep 22, 2023
d269064
- add example jacobi pc
mjr-deltares Sep 22, 2023
29d835f
fix: imslinear was settings defaults after init
mjr-deltares Sep 25, 2023
9c34525
Merge branch 'develop' into rfct-numsol
mjr-deltares Sep 25, 2023
50be835
regenerate makefile
mjr-deltares Sep 25, 2023
dee504d
add petsc file to msvs but exclude from build
mjr-deltares Sep 25, 2023
c877097
adding debug symbols, temporarily
mjr-deltares Sep 25, 2023
875d75c
set defaults on ims params
mjr-deltares Sep 25, 2023
765c080
revert debug flag
mjr-deltares Sep 25, 2023
4e0a8dc
fix deallocation of PC context
mjr-deltares Sep 26, 2023
42def28
fixed bug/typo in initialization of convergence arrays
mjr-deltares Sep 26, 2023
853b64a
Merge branch 'develop' into rfct-numsol
mjr-deltares Sep 27, 2023
11ccfe3
updated makefiles after merging develop
mjr-deltares Sep 27, 2023
a650a1c
small clean up
mjr-deltares Sep 27, 2023
d3bf121
clean up: add explicit interface to PETSc convergence module
mjr-deltares Sep 27, 2023
581d1f8
add comment
mjr-deltares Sep 27, 2023
1a8a859
- by default, parallel should run without .petscrc database file now
mjr-deltares Sep 27, 2023
4b9165b
use .petscrc for newtonur test for now
mjr-deltares Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions autotest/test_par_gwf01.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,8 @@ def get_model(idx, dir):
return sim


def build_petsc_db(exdir):
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, "w") as petsc_file:
petsc_file.write("-ksp_type cg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-dvclose 10e-7\n")
petsc_file.write("-options_left no\n")


def build_model(idx, exdir):
sim = get_model(idx, exdir)
build_petsc_db(exdir)
return sim, None


Expand Down
10 changes: 0 additions & 10 deletions autotest/test_par_gwf02.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,8 @@ def add_exchange_south_north(sim, name_south, name_north):
filename=exg_filename
)

def build_petsc_db(exdir):
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, 'w') as petsc_file:
petsc_file.write("-ksp_type cg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write(f"-dvclose {Decimal(hclose):.2E}\n")
petsc_file.write("-options_left no\n")

def build_model(idx, exdir):
sim = get_simulation(idx, exdir)
build_petsc_db(exdir)
return sim, None

def eval_model(sim):
Expand Down
13 changes: 0 additions & 13 deletions autotest/test_par_gwf03.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,8 @@ def add_exchange_south_north(sim, name_south, name_north, nlay, nrow, ncol):
filename=exg_filename
)

def build_petsc_db(idx, exdir):
np = ncpus[idx]
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, 'w') as petsc_file:
petsc_file.write("-ksp_type cg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {Decimal(hclose):.2E}\n")
petsc_file.write(f"-nitermax {500}\n")
petsc_file.write("-options_left no\n")

def build_model(idx, exdir):
sim = get_simulation(idx, exdir)
build_petsc_db(idx, exdir)
return sim, None

def eval_model(sim):
Expand Down
13 changes: 0 additions & 13 deletions autotest/test_par_gwf_idomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,8 @@

ex = ["par_idomain"]

def build_petsc_db(idx, exdir):
from test_gwf_ifmod_idomain import hclose_check, max_inner_it
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, 'w') as petsc_file:
petsc_file.write("-ksp_type bicg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {Decimal(hclose_check):.2E}\n")
petsc_file.write(f"-nitermax {max_inner_it}\n")
petsc_file.write("-options_left no\n")

def build_model(idx, exdir):
from test_gwf_ifmod_idomain import build_model as build_model_ext
build_petsc_db(idx, exdir)
sim, dummy = build_model_ext(idx, exdir)
return sim, dummy

Expand Down
16 changes: 0 additions & 16 deletions autotest/test_par_gwf_ims_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,12 @@ def update_ims(idx, ims):
return


def build_petsc_db(exdir):
from test_par_gwf01 import hclose, ninner

petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, "w") as petsc_file:
petsc_file.write("-ksp_type cg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {hclose}\n")
petsc_file.write(f"-nitermax {ninner}\n")
petsc_file.write("-options_left no\n")
# petsc_file.write("-log_view\n")


def build_model(idx, exdir):
from test_par_gwf01 import get_model as get_model_ext
from test_par_gwf01 import ex as ex_ext

sim = get_model_ext(idx, exdir)
update_ims(idx, sim.get_solution_package(f"{ex_ext[idx]}.ims"))
build_petsc_db(exdir)
return sim, None


Expand Down
13 changes: 0 additions & 13 deletions autotest/test_par_gwf_newton.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,8 @@

ex = ["par_newton"]

def build_petsc_db(idx, exdir):
from test_gwf_ifmod_newton import hclose_check, max_inner_it
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, 'w') as petsc_file:
petsc_file.write("-ksp_type bicg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {Decimal(hclose_check):.2E}\n")
petsc_file.write(f"-nitermax {max_inner_it}\n")
petsc_file.write("-options_left no\n")

def build_model(idx, exdir):
from test_gwf_ifmod_newton import build_model as build_model_ext
build_petsc_db(idx, exdir)
sim, dummy = build_model_ext(idx, exdir)
return sim, dummy

Expand Down
15 changes: 0 additions & 15 deletions autotest/test_par_gwf_pakcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,9 @@
ex = ["par_uzf_3lay_1p", "par_uzf_3lay_2p"]


def build_petsc_db(idx, exdir):
from test_gwf_uzf_gwet import hclose, ninner

petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, "w") as petsc_file:
petsc_file.write("-ksp_type bicg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {Decimal(hclose):.2E}\n")
petsc_file.write(f"-nitermax {ninner}\n")
petsc_file.write("-options_left no\n")


def build_model(idx, exdir):
from test_gwf_uzf_gwet import build_model as build_model_ext

build_petsc_db(idx, exdir)
sim, dummy = build_model_ext(idx, exdir)
if idx == 1:
sim.set_sim_path(exdir / "working")
Expand Down
12 changes: 0 additions & 12 deletions autotest/test_par_gwf_rewet.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,9 @@
# with a serial 'refmodel'
ex = ["par_rewet"]

def build_petsc_db(idx, exdir):
from test_gwf_ifmod_rewet import hclose_check, max_inner_it
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, 'w') as petsc_file:
petsc_file.write("-ksp_type bicg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {Decimal(hclose_check):.2E}\n")
petsc_file.write(f"-nitermax {max_inner_it}\n")
petsc_file.write("-options_left no\n")

def build_model(idx, exdir):
from test_gwf_ifmod_rewet import build_model as build_model_ext
build_petsc_db(idx, exdir)
sim, dummy = build_model_ext(idx, exdir)
return sim, dummy

Expand Down
13 changes: 0 additions & 13 deletions autotest/test_par_gwf_xt3d02.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,8 @@
# with a serial 'refmodel' in case of XT3D
ex = ["par_xt3d02"]

def build_petsc_db(idx, exdir):
from test_gwf_ifmod_xt3d02 import hclose_check, max_inner_it
petsc_db_file = os.path.join(exdir, ".petscrc")
with open(petsc_db_file, 'w') as petsc_file:
petsc_file.write("-ksp_type bicg\n")
petsc_file.write("-pc_type bjacobi\n")
petsc_file.write("-sub_pc_type ilu\n")
petsc_file.write("-sub_pc_factor_levels 2\n")
petsc_file.write(f"-dvclose {Decimal(hclose_check):.2E}\n")
petsc_file.write(f"-nitermax {max_inner_it}\n")
petsc_file.write("-options_left no\n")

def build_model(idx, exdir):
from test_gwf_ifmod_xt3d02 import build_model as build_model_ext
build_petsc_db(idx, exdir)
sim, dummy = build_model_ext(idx, exdir)
return sim, dummy

Expand Down
60 changes: 31 additions & 29 deletions make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@ include ./makedefaults

# Define the source file directories
SOURCEDIR1=../src
SOURCEDIR2=../src/Exchange
SOURCEDIR3=../src/Model
SOURCEDIR4=../src/Model/Geometry
SOURCEDIR5=../src/Model/TransportModel
SOURCEDIR2=../src/Model
SOURCEDIR3=../src/Model/TransportModel
SOURCEDIR4=../src/Model/GroundWaterFlow
SOURCEDIR5=../src/Model/Geometry
SOURCEDIR6=../src/Model/ModelUtilities
SOURCEDIR7=../src/Model/Connection
SOURCEDIR8=../src/Model/GroundWaterTransport
SOURCEDIR9=../src/Model/GroundWaterFlow
SOURCEDIR10=../src/Distributed
SOURCEDIR11=../src/Solution
SOURCEDIR12=../src/Solution/PETSc
SOURCEDIR13=../src/Solution/LinearMethods
SOURCEDIR14=../src/Timing
SOURCEDIR15=../src/Utilities
SOURCEDIR16=../src/Utilities/TimeSeries
SOURCEDIR17=../src/Utilities/Libraries
SOURCEDIR18=../src/Utilities/Libraries/rcm
SOURCEDIR19=../src/Utilities/Libraries/sparsekit
SOURCEDIR20=../src/Utilities/Libraries/sparskit2
SOURCEDIR21=../src/Utilities/Libraries/blas
SOURCEDIR22=../src/Utilities/Libraries/daglib
SOURCEDIR23=../src/Utilities/Idm
SOURCEDIR24=../src/Utilities/Idm/selector
SOURCEDIR25=../src/Utilities/Idm/mf6blockfile
SOURCEDIR26=../src/Utilities/Matrix
SOURCEDIR27=../src/Utilities/Vector
SOURCEDIR28=../src/Utilities/Observation
SOURCEDIR29=../src/Utilities/OutputControl
SOURCEDIR30=../src/Utilities/Memory
SOURCEDIR31=../src/Utilities/ArrayRead
SOURCEDIR7=../src/Model/GroundWaterTransport
SOURCEDIR8=../src/Model/Connection
SOURCEDIR9=../src/Distributed
SOURCEDIR10=../src/Utilities
SOURCEDIR11=../src/Utilities/Idm
SOURCEDIR12=../src/Utilities/Idm/mf6blockfile
SOURCEDIR13=../src/Utilities/Idm/selector
SOURCEDIR14=../src/Utilities/Vector
SOURCEDIR15=../src/Utilities/Matrix
SOURCEDIR16=../src/Utilities/Observation
SOURCEDIR17=../src/Utilities/ArrayRead
SOURCEDIR18=../src/Utilities/OutputControl
SOURCEDIR19=../src/Utilities/Libraries
SOURCEDIR20=../src/Utilities/Libraries/blas
SOURCEDIR21=../src/Utilities/Libraries/rcm
SOURCEDIR22=../src/Utilities/Libraries/sparsekit
SOURCEDIR23=../src/Utilities/Libraries/sparskit2
SOURCEDIR24=../src/Utilities/Libraries/daglib
SOURCEDIR25=../src/Utilities/Memory
SOURCEDIR26=../src/Utilities/TimeSeries
SOURCEDIR27=../src/Timing
SOURCEDIR28=../src/Solution
SOURCEDIR29=../src/Solution/PETSc
SOURCEDIR30=../src/Solution/LinearMethods
SOURCEDIR31=../src/Exchange

VPATH = \
${SOURCEDIR1} \
Expand Down Expand Up @@ -206,6 +206,8 @@ $(OBJDIR)/gwf3vsc8.o \
$(OBJDIR)/GwfNpfOptions.o \
$(OBJDIR)/InterfaceMap.o \
$(OBJDIR)/SeqVector.o \
$(OBJDIR)/ImsLinearSettings.o \
$(OBJDIR)/ConvergenceSummary.o \
$(OBJDIR)/CellWithNbrs.o \
$(OBJDIR)/NumericalExchange.o \
$(OBJDIR)/gwf3uzf8.o \
Expand Down
7 changes: 7 additions & 0 deletions msvs/mf6core.vfproj
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,26 @@
<File RelativePath="..\src\Solution\LinearMethods\ims8linear.f90"/>
<File RelativePath="..\src\Solution\LinearMethods\ims8misc.f90"/>
<File RelativePath="..\src\Solution\LinearMethods\ims8reordering.f90"/>
<File RelativePath="..\src\Solution\LinearMethods\ImsLinearSettings.f90"/>
<File RelativePath="..\src\Solution\LinearMethods\ImsLinearSolver.f90"/></Filter>
<Filter Name="PETSc">
<File RelativePath="..\src\Solution\PETSc\PetscConvergence.F90">
<FileConfiguration Name="Debug|Win32" ExcludedFromBuild="true"/>
<FileConfiguration Name="Release|x64" ExcludedFromBuild="true"/>
<FileConfiguration Name="Debug|x64" ExcludedFromBuild="true"/>
<FileConfiguration Name="Release|Win32" ExcludedFromBuild="true"/></File>
<File RelativePath="..\src\Solution\PETSc\PetscImsPreconditioner.F90">
<FileConfiguration Name="Debug|Win32" ExcludedFromBuild="true"/>
<FileConfiguration Name="Release|x64" ExcludedFromBuild="true"/>
<FileConfiguration Name="Debug|x64" ExcludedFromBuild="true"/>
<FileConfiguration Name="Release|Win32" ExcludedFromBuild="true"/></File>
<File RelativePath="..\src\Solution\PETSc\PetscSolver.F90">
<FileConfiguration Name="Debug|Win32" ExcludedFromBuild="true"/>
<FileConfiguration Name="Release|x64" ExcludedFromBuild="true"/>
<FileConfiguration Name="Debug|x64" ExcludedFromBuild="true"/>
<FileConfiguration Name="Release|Win32" ExcludedFromBuild="true"/></File></Filter>
<File RelativePath="..\src\Solution\BaseSolution.f90"/>
<File RelativePath="..\src\Solution\ConvergenceSummary.f90"/>
<File RelativePath="..\src\Solution\ExplicitSolution.f90"/>
<File RelativePath="..\src\Solution\LinearSolverBase.f90"/>
<File RelativePath="..\src\Solution\LinearSolverFactory.F90">
Expand Down
3 changes: 2 additions & 1 deletion pymake/excludefiles.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
../src/Solution/PETSc/PetscSolver.F90
../src/Solution/PETSc/PetscConvergence.F90
../src/Solution/PETSc/PetscImsPreconditioner.F90
../src/Solution/PETSc/PetscSolver.F90
../src/Solution/ParallelSolution.f90
../src/Utilities/Matrix/PetscMatrix.F90
../src/Utilities/Vector/PetscVector.F90
Expand Down
1 change: 0 additions & 1 deletion src/Distributed/MpiRunControl.F90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ subroutine mpi_ctrl_start(this)

inquire (file=petsc_db_file, exist=petsc_db_exists)
if (.not. petsc_db_exists) then
write (*, *) 'WARNING. PETSc database file not found: '//petsc_db_file
call PetscInitialize(PETSC_NULL_CHARACTER, ierr)
CHKERRQ(ierr)
else
Expand Down
Loading