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

Do not require get_form in user code #228

Merged
merged 13 commits into from
Nov 17, 2024
Merged

Do not require get_form in user code #228

merged 13 commits into from
Nov 17, 2024

Conversation

ddundo
Copy link
Member

@ddundo ddundo commented Nov 12, 2024

Closes #223.

We only need the form when we do GoalOrientedMeshSeq.indicate_errors, so everything form-related was removed from MeshSeq and AdjointMeshSeq. Communicating the form from user code to GoalOrientedMeshSeq is now done with the read_forms method.

@ddundo ddundo added the refactor A suggested reworking of the code label Nov 12, 2024
@ddundo ddundo self-assigned this Nov 12, 2024
@ddundo ddundo marked this pull request as draft November 12, 2024 18:33
@acse-ej321
Copy link
Collaborator

@ddundo would it be worth adding a check in forms or _read_forms to check that the form has been passed by the user? I wonder if there is a good place in the class method templates or elsewhere to indicate this is needed for indicate_errors?

@ddundo
Copy link
Member Author

ddundo commented Nov 12, 2024

@ddundo would it be worth adding a check in forms or _read_forms to check that the form has been passed by the user? I wonder if there is a good place in the class method templates or elsewhere to indicate this is needed for indicate_errors?

Thanks! I'll add this :) but the PR is still in draft phase so don't waste time looking into it now, as it might change :) I'll request a review soonish

@ddundo ddundo marked this pull request as ready for review November 12, 2024 23:54
@ddundo
Copy link
Member Author

ddundo commented Nov 12, 2024

Ready now! Could you please review when you get the time? No rush at all.

Most changes are in demos, where stuff in get_form was just moved to get_solver. So it's a much smaller PR than it looks :)

Comment on lines 235 to 239
transfer(self.solutions[f][FWD][i][j], u[f])
transfer(self.solutions[f][FWD_OLD][i][j], u_[f])
if self.field_types[f] == "unsteady":
transfer(self.solutions[f][FWD_OLD][i][j], u_[f])
transfer(self.solutions[f][ADJ][i][j], u_star[f])
transfer(self.solutions[f][ADJ_NEXT][i][j], u_star_next[f])
Copy link
Member Author

@ddundo ddundo Nov 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating forward and forward_old here only serves to update the coefficients in the form. Since there is no lagged solution in the variational form for "steady" fields, I do not update it here.

But the notion of a lagged solution still makes sense for "steady" fields in time-dependent problems. I kept this update for adjoint_next since in the next few lines we compute the average of it and adjoint. I'm not familiar with the theory here so I don't know if it makes sense or not, so I just left it as it is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Unrelated to this issue :) )

Copy link
Member

@jwallwork23 jwallwork23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great @ddundo, thanks! Tidies things up very nicely.

@ddundo ddundo merged commit b458ccd into main Nov 17, 2024
1 check passed
@ddundo ddundo deleted the 223_get_form branch November 17, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor A suggested reworking of the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't use get_form
3 participants