-
Notifications
You must be signed in to change notification settings - Fork 0
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
Consolidating and simplifying command-line options #195
Conversation
@bishtgautam , can you add other people who you believe would have an opinion on this stuff? The FE folks will eventually care, I think, but this is still just a work in progress at the moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks simpler and more understandable to me.
I like the logic also. One question that wasn't clear to me from a quick look over the changes: if TDySetDM is called, and then an option is passed in for a mesh (violating rulle 1), will Options throw an error? |
Yes, in the name of specificity. If this is too irritating and we'd rather use the option to override the DM supplied with TDySetDM, that's fine, but this is where I started. If you look at the changes in |
What is PETSc's option to read a mesh? |
If we want to read a mesh, we can use our own |
So, instead of options in https://github.com/TDycores-Project/TDycore/blob/master/src/tdydm.c#L19-L53, use the following?
|
Yes, that's what I'm advocating. The benefit is that recent changes to PETSc (which we now have via the latest update) now make all these options available, and we could grab any new ones that appear without adding our own. |
@jeff-cohere I agree with your proposal. Let's use PETSc options. |
Cool. I'll get rid of the TDycore-specific mesh generation options and retrofit the demos to use the PETSc ones, and I'll let everyone know if I hit any snags. |
@bishtgautam For reading in a mesh, you can use |
The only demo using this function was mpfao, which has been modified not to need it. Note the PETSc -dm_plex_* functions used as demo arguments.
PETSC_INTERN PetscErrorCode TDyConstantSoilDensityFunction(TDy,PetscReal*,PetscReal*,void*); | ||
PETSC_INTERN PetscErrorCode TDyConstantSoilSpecificHeatFunction(TDy,PetscReal*,PetscReal*,void*); | ||
PETSC_INTERN PetscErrorCode TDyConstantPermeabilityFunction(TDy,PetscReal *,PetscReal *,void*); | ||
PETSC_INTERN PetscErrorCode TDyConstantThermalConductivityFunction(TDy,PetscReal *,PetscReal *,void*); | ||
PETSC_INTERN PetscErrorCode TDyConstantPorosityFunction(TDy,PetscReal *,PetscReal *,void*); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not pertinent to the name change, but we may want to make these vectorizable, taking arguments (TDy, PetscInt, const PetscReal *, PetscReal *, void *)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea and one we should adopt.
@@ -201,7 +201,7 @@ PetscErrorCode TDyRegressionOutput(TDy tdy, Vec U) { | |||
ierr = VecRestoreArray(U,&u_p); CHKERRQ(ierr); | |||
ierr = VecRestoreArray(U_pres,&pres_p); CHKERRQ(ierr); | |||
|
|||
if (tdy->mode == TH) { | |||
if (tdy->options.mode == TH) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also not pertinent to this step, but it would be nice to use callbacks instead of if statements, which will become switch
statements if there are ever more than two modes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give an example of what you mean by this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, the mode could have a tdy->diagnostics(tdy, ...)
that computes/reports any diagnostics specific to that mode. This saves having a sequence of switch statements with possibly fragile carried dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay. A "virtual table". Yes, that makes sense.
Codecov Report
@@ Coverage Diff @@
## master #195 +/- ##
==========================================
+ Coverage 67.73% 67.81% +0.07%
==========================================
Files 7 7
Lines 1221 1224 +3
==========================================
+ Hits 827 830 +3
Misses 394 394
Continue to review full report at Codecov.
|
I don't think this covers all the ground mentioned in #188, but things are working, and I kinda don't want to make this PR much bigger. @bishtgautam , let me know if you'd like me to address anything else. @jedbrown , I made an issue for "vectorizing" our functions. |
This PR gathers our command line options, elaborating on
TDyOptions
and adding features for specifying boundary condition functions and the like. I hope it's easier to understand.Also, I'm forcing us to be more specific about how we specify a mesh, because our rules to date have been confusing. Here are the new rules:
TDySetDM
is called beforeTDySetFromOptions
in a demo/driver, the DM passed to the dycore in that function is the mesh, period. It can't be overridden. We should only use this function in programs that use a fixed geometry, or that generate their own geometry without leaning onTDySetFromOptions
.TDySetDM
is not called beforeTDySetFromOptions
, the user must specify exactly one of-tdy_read_mesh <filename>
or-tdy_generate_mesh
. If-tdy_generate_mesh
is given, the properties of the mesh are extracted from our existing mesh-related command line options (though, as I mention in a comment on this PR, I believe we should eliminate our own options and rely on the options that PETSc provides for generating DMPlexes, for simplicity and to leverage the work of the PETSc team).TDySetFromOptions
returns successfully, TDycore has a distributed mesh with the right overlapping cells and all that--there's no need for anything else to be done.With these rules, it's always clear what the geometry is. This is good, because the word "obvious" is meaningless in every context in which anything matters. :-)
There's still work to be done. PR #188 proposes a lot of new options.