Closed jeff-cohere closed 3 years ago
Merging #192 (130a002) into master (b74fafd) will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #192 +/- ##
=======================================
Coverage 67.73% 67.73%
=======================================
Files 7 7
Lines 1221 1221
=======================================
Hits 827 827
Misses 394 394
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update b74fafd...130a002. Read the comment docs.
I've added support for selecting porosity and forcing functions using the same method. The transient_snes_mpfaof90
demo now uses the registry to select its porosity. If we wanted to, we could add command line parameters to this function to tell it which pressure and porosity functions to use.
For permeability (which we're not yet doing in this Fortran demo), we might have to have a "tensor function" Fortran type (as opposed to the "scalar function" type we're currently assuming), to accommodate the different rank of the function's range. If we wanted to shoehorn all functions into the same type, we'd have to stipulate that the function's values are stored in an array instead of a scalar. I expect we'll discuss this stuff when it becomes more interesting.
This PR adds a registry for named functions. This lets a demo/driver program register functions (in C or Fortran) that can be selected for boundary conditions. We can also use these functions for forcing functions and other volumetric quantities. All functions live in the same namespace.
The basic functionality is demonstrated in the
transient_snes_mpfaof90
demo. Instead of callingTDySetBoundaryPressureFn
, we registerPressureFunction
under the name "p0" with a call toTDyRegisterFunction
, and then we select the boundary pressure function usingTDySelectBoundaryPressureFn
and referring to "p0". The original mechanism (TDySetBoundaryPressure
) is still supported, and is in fact used by the new registry selection thingy.This allows us to do all sorts of things that were previously difficult, including using names of functions in command line arguments, and embedding function names in mesh files. We can now register these functions in our demos/drivers and e.g. create mesh files specifically for those drivers that can associate different domain boundary surfaces with different named functions. For now, we only allow a single boundary function, but we can expand that when we're interested in doing so.
(I'm excited by this PR, because I've figured out a way to make the Fortran 2003 interoperability standard cooperate with PETSc's bespoke Fortran bindings!)
Also included: I added a
TDyOnFinalize
function to allow us to register shutdown functions that are called whenTDyFinalize
is called. This allows us to write subsystems without the basic foundation having to know about them.(In service of #188)