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

Various adjustments #209

Merged
merged 7 commits into from
Dec 13, 2021
Merged

Various adjustments #209

merged 7 commits into from
Dec 13, 2021

Conversation

olesenm
Copy link
Contributor

@olesenm olesenm commented Dec 11, 2021

Hi @MakisH - just gave a test compilation with the current OpenFOAM develop branch (mostly wanted to see if we made any changes that broke compilation for you). Needed a few changes for clang (ambiguity with tmp -> Field etc).

While I was looking at the code, noticed a few places with copy instead of reference (copying the pressure field is the nastiest one).

Cleaned up some of the handling of adding in checkpoint fields to remove large chunks of near-duplication code. The bit with getObjectPtr may or may not be what you want (depending on which versions of OpenFOAM you are targeting). Can replace with the equivalent:

mesh_.db().getObjectPtr<volScalarField>(...) ->
&(const_cast<volScalarField>(mesh_.db().lookupObject<volScalarField(...))

A bit more typing, but it's wrapped in a macro anyhow.
Either way, for this type of code I think it is better to be passing through the pointer and let the called method determine its validity. This makes it easier to wrap up a find/add logic together.

Copy link
Member

@davidscn davidscn left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for this great contribution! My personal understanding of tmp in the OpeFOAM context was never good enough in order to apply it appropriately and I thought auto might allow me to get away with it, which seems to be wrong.

We had a few bug fixes within the last weeks and are now waiting for the upcoming OpenFOAM release in order to release the adapter alongside.

Now that you already touch the checkpointing allow me to ask a question: we have oftentimes the case that we reload the checkpoint after a single time step was computed. Does OpenFOAM store fields of the previous time step automatically? If it does, we could access these 'old' fields in order to reload the checkpointing instead of storing them explicitly and reloading them later on (would need to reload the old fields, though). This could save us a considerable amount of memory (namely all global fields at least once). I never really figured this out.

preciceAdapterFunctionObject.H Outdated Show resolved Hide resolved
Adapter.C Show resolved Hide resolved
@olesenm
Copy link
Contributor Author

olesenm commented Dec 12, 2021

(namely all global fields at least once). I never really figured this out.

Can't answer immediately, need a closer look at how/where it is being used. I suspect will also need a closer look at the registry flags to see what the adapter has done.

Copy link
Member

@MakisH MakisH left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the contributions and for the amazing care of checking for breaking changes! I have again a very good feeling about this OpenFOAM release.

Nothing of these changes should not work for past versions of OpenFOAM, right? Everything looks familiar.

By the way, a large part of this PR closes #55.

Adapter.C Show resolved Hide resolved
Adapter.C Show resolved Hide resolved
Adapter.C Show resolved Hide resolved
@davidscn
Copy link
Member

davidscn commented Dec 13, 2021

I also resolved the merge conflict as it was more or less my change leading to the conflict.

@davidscn davidscn merged commit 17d1776 into precice:develop Dec 13, 2021
@davidscn
Copy link
Member

Can't answer immediately, need a closer look at how/where it is being used. I suspect will also need a closer look at the registry flags to see what the adapter has done.

Merging here, but want still want to mention that I'm interest in this.

@olesenm
Copy link
Contributor Author

olesenm commented Dec 13, 2021

Merging here, but want still want to mention that I'm interest in this.

Sure, but deserves a separate issue.

@davidscn
Copy link
Member

Absolutely.

@davidscn
Copy link
Member

Opened in #210

@MakisH
Copy link
Member

MakisH commented Feb 2, 2022

An update on the compatibility with other versions:

  • All recent .com version (v1912-v2112) built and ran successfully in our new GitHub Actions workflow to build with any version.
  • All .org versions (4-8) complained at the exact point that @olesenm mentioned above

In the OpenFOAM4 branch (on which every other .org branch is based upon), I applied the following patch to make it work:

-    for (const word& obj : mesh_.sortedNames<GeomField>())               \
-    {                                                                    \
-        addCheckpointField(mesh_.thisDb().getObjectPtr<GeomField>(obj)); \
+    for (const word& obj : mesh_.lookupClass<GeomField>().toc())                                    \
+    {                                                                                               \
+        addCheckpointField(&(const_cast<GeomField&>(mesh_.thisDb().lookupObject<GeomField>(obj)))); \

Note that I reverted the sortedNames back to the toc, as I could not find a templated version of sortedNames in OpenFOAM4.

I hope I did not overlook/misuse anything here. I sometimes get confused in these long chains of lookups and type conversions (loving auto and C++17 automatic type deduction in templates).

@olesenm
Copy link
Contributor Author

olesenm commented Feb 3, 2022

@MakisH Should at least use sortedToc() instead of toc() for overall consistency

@MakisH
Copy link
Member

MakisH commented Feb 3, 2022

@MakisH Should at least use sortedToc() instead of toc() for overall consistency

Good point, thank you. I applied this patch and rebased again.

@MakisH MakisH added this to the v1.1.0 milestone Feb 8, 2022
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