-
Notifications
You must be signed in to change notification settings - Fork 25
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
New method to handle and convert user inputs to FEniCS objects #940
Merged
+666
−241
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fenicsx #940 +/- ##
===========================================
- Coverage 96.04% 96.02% -0.03%
===========================================
Files 45 45
Lines 2455 2490 +35
===========================================
+ Hits 2358 2391 +33
- Misses 97 99 +2 ☔ View full report in Codecov by Sentry. |
jorgensd
reviewed
Feb 21, 2025
jorgensd
reviewed
Feb 21, 2025
jorgensd
reviewed
Feb 21, 2025
jorgensd
reviewed
Feb 21, 2025
jorgensd
reviewed
Feb 21, 2025
Co-authored-by: Jørgen Schartum Dokken <[email protected]>
I'll release an alpha version before merging this if you don't mind |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Statement of need
Many classes within festim have a function called either
create_value_fenics
orcreate_value
which is there to convert a user given input and converts it to a relevant fenics object depending on what has been provided. However, many of these functions have a lot of code duplication. Furthermore, in an effort to allow users to access given inputs, these same classes typically have thevalue
attribute, then thevalue_fenics
, and in some cases, an associated fem.Expression to update time dependent values within the function at each iteration.Proposed changes
This change introduces a new class within helpers called
Value
which will have one argument, input_value, given by the users and remains unformatted should the user wish to retrieve it. Then 3 further attributes: ufl_expression, fenics_interpolation_expression and fenics_object.For the implementation, classes which have value as an argument, automatically convert the user given value to a Value class object with the given value as the
input_value
argument. The Value class itself then has two additional properties:time_dependent
andtemperature_dependent
depending on the value given by the user.The class has two functions: convert_input_value which creates one of 3 acceptable FEniCS objects: fem.Constant, ufl.core.expr.Expr or fem.Function, depending on the input given by the user. In some cases such as with sources and fluxes, callable inputs given need only be passed the temperature or time or space as needed to create a ufl expression, and so an additional optional argument: up_to_ufl_expr is provided for this case. All the functions used in this conversion function are also provided in helpers if there are cases where just the function may be needed.
For the moment I have just updated the tests for
test_h_transport_problem.py
andtest_heat_transfer_problem.py
to show that this could work for both types of problems, however I haven't delved into the multi-material classes yet to see how compatible this may be.@RemDelaporteMathurin I know you didn't want to automatically convert user given inputs, but this way they are still retrievable, what do you think?
Also very open to changing any of the naming of functions/attributes etc.
Types of changes
What types of changes does your code introduce to FESTIM?
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...