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

Add a vector_calculus class #120

Merged
merged 9 commits into from
Sep 6, 2024
Merged

Conversation

semi-h
Copy link
Member

@semi-h semi-h commented Aug 27, 2024

This PR moves the vector calculus operations currently implemented inside solver class out to a dedicated new class. This new structure should allow accessing vector calculus operations outside the solver class. Examples include the laplacian operation iterative Poisson solver needs and curl/divergence for postprocessing/monitoring.

@semi-h semi-h marked this pull request as ready for review August 30, 2024 11:51
!! derivatives are decided at runtime. Backend implementations
!! are responsible from directing calls to transeq_ders into
!! the correct algorithm.
subroutine tds_solve(self, du, u, tdsops)
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed dirps argument here, it had become redundant when we introduced mesh class a while ago.

Copy link
Collaborator

@Nanoseb Nanoseb left a comment

Choose a reason for hiding this comment

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

looks good to me, I just think it would be good to properly define what is expected from the input variables in terms of direction and dataloc.

src/vector_calculus.f90 Outdated Show resolved Hide resolved
src/vector_calculus.f90 Outdated Show resolved Hide resolved
src/vector_calculus.f90 Outdated Show resolved Hide resolved
src/vector_calculus.f90 Show resolved Hide resolved
@semi-h
Copy link
Member Author

semi-h commented Sep 2, 2024

looks good to me, I just think it would be good to properly define what is expected from the input variables in terms of direction and dataloc.

Thanks! Changed the namings from velocity/pressure grid to data_loc based VERT/CELL. Also added a bit more explanation in subroutine headers to explain expected DIRs and data_locs for input and output arrays.

src/backend.f90 Outdated Show resolved Hide resolved

type :: vector_calculus_t
!! Defines vector calculus operators
class(base_backend_t), pointer :: backend
Copy link
Member

Choose a reason for hiding this comment

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

This is the kind of circular pointer that I think we should try and avoid (i.e. a pointer to the backend object in the parent class of vector_calculus). Could we pass backend as an argument to vector_calculus methods? e.g.

call vector_calculus%curl(..., backend)

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't really have a circular pointer or dependency here. backend, solver and vector_calculus are all independent classes and there is no inheritance relationship among them. There are other classes too that use backend, like time_integrator and new wind turbine stuff. In a class diagram backend would be under all of them so I don't see a problem having a pointer to backend in these classes. Why do you think we should avoid?

@pbartholomew08
Copy link
Member

Nanoseb: is it worth checking that u is in DIR_X before doing that? or at least add a comment in the header to explain that it is expected
semi-h: tds_solve is doing a check based on directions so added a comment in the laplacian subroutine header to explain

I think it might be worth checking the conditions at the start of the curl/div/grad/xxx subroutines. A "invalid field locations passed to curl" will be easier to debug than "invalid fields in tdsops" (which you then need to figure out where it came from). Having the tdsops perform this last level check is good to ensure we catch everything, but a higher-level check might ultimately be beneficial in my opinion.

@semi-h semi-h merged commit d0e58b4 into xcompact3d:main Sep 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants