-
Notifications
You must be signed in to change notification settings - Fork 0
Introduce Solver
class
#239
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
base: develop
Are you sure you want to change the base?
Conversation
@acse-ej321 we very briefly discussed this on the meeting and @jwallwork23 is in principle in favour of this. If you are as well, maybe you could try this approach for your enriched mesh seq issue and see if that solves it? I think it should since the two are now separated :) |
Please change branch target to develop. |
@jwallwork23 @acse-ej321 could you please take a look at the small commit 73f3610 where I added the Do you agree with this? I find it a bit messy, but I don't have a different suggestion. |
@dundo just a few quick observations:
Your unstated question is a good one: whether the benefit of making the user input mostly independent is outweighed by added complexity to the API? |
Thanks @acse-ej321!
I agree but I don't want to make changes related to #181 in this PR since this will require more discussion I think.
So you would prefer not to pass a
I would prefer to keep arguments the same in all methods and to pass everything
|
demos/burgers_time_integrated.py
Outdated
class BurgersModel(Model): | ||
def get_initial_condition(self, time_partition, meshes, fields, function_spaces): | ||
fs = function_spaces["u"][0] | ||
x, y = SpatialCoordinate(meshes[0]) | ||
return {"u": Function(fs).interpolate(as_vector([sin(pi * x), 0]))} | ||
|
||
def get_solver( | ||
self, index, time_partition, meshes, field_functions, function_spaces | ||
): |
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.
We have a Model
class which is separate from the Solver
class, so we need to pass time_partition
, meshes
, field_functions
, and function_spaces
from the Solver
to Model
's get_*
methods.
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.
I'd prefer not to keep passing all these arguments repeatedly. Could we not pass the time_partition
to the __init__
method of the Model
? Also, we should be able to determine the fields and function spaces using that information, no? Then we'd only need to pass meshes and indices to these methods.
qoi = mesh_seq.get_qoi(index) | ||
qoi = self.get_qoi( | ||
index, time_partition, meshes, field_functions, function_spaces | ||
) | ||
while t < t_end - 1.0e-05: | ||
solve(F == 0, u, ad_block_tag="u") | ||
mesh_seq.J += qoi(t) | ||
yield | ||
self.J += qoi(t) |
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.
Time-integrated qoi requires us to communicate J
from the Model
to the Solver
.
Similarly for goal-oriented error estimation, where we currently use GoalOrientedMeshSeq.read_forms({"field": Form})
. We need to modify it so that {"field": Form}
gets passed from Model
to Solver
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.
Simplest solution would be to pass J
as an argument to get_*
functions as well. I think this is fine since we plan to add QoIs for Hessian-based adaptations too (#280)
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.
I think the way we handle the J
attribute needs some rethinking anyway. How about you draft something and then we can comment further on that?
Closes #238. Closes #22.
Summary (so far):
goalie.solver.Solver
that all user-defined problems should inherit fromMeshSeq
now only has these methods left:count_elements
,count_vertices
,plot
,set_meshes
get_solver
no longer requires a nestedsolver
function (Clean up wrapping of getter functions #22)AdjointMeshSeq
andGoalOrientedMeshSeq
toAdjointSolver
andGoalOritentedSolver
, respectivelyExample workflow
Won't do in this PR:
RenameCan introduce aSolver
and its methods? MaybeModel
would be better and then renameget_initial_condition
toinitial_condition
, etc.?Model
class in another PR. This would require Passing information to user-definedget_*
functions as kwargs #279 or a similar solutionPassfield_names
andfield_types
toSolver
so that it's self-contained