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 partitioned-heat OpenFOAM participant with solver #223

Merged
merged 24 commits into from
Jul 29, 2021

Conversation

davidscn
Copy link
Member

@davidscn davidscn commented Jun 25, 2021

Since #214 is a far away from its purpose and includes various changes I don't understand let me add a clean PR. The tutorial requires groovyBC in order to handle the time dependent inhomogenous Dirichlet boundary condition.
Open to discuss: this PR comprises the solver as well.

@davidscn davidscn linked an issue Jun 25, 2021 that may be closed by this pull request
@MakisH
Copy link
Member

MakisH commented Jun 25, 2021

Are the solver files part of OpenFOAM? If yes, why include them here? (guessing from the copyright notices)

@davidscn
Copy link
Member Author

davidscn commented Jun 25, 2021

No they are not, just started from OpenFOAM own files,

@uekerman
Copy link
Member

uekerman commented Jun 28, 2021

@davidscn Could you also please quickly comment here which results you get? (I did not run the case yet). Do you get the correct results when e.g. coupling to FEniCS?

Edit: Just saw that you already added the results in precice/openfoam-adapter#93

@uekerman
Copy link
Member

Open to discuss: this PR comprises the solver as well.

We do the same for FEniCS and Nutils. If they are not part of OpenFOAM, the right way to got is indeed to add them here in my opinion.

@MakisH
Copy link
Member

MakisH commented Jun 28, 2021

We do the same for FEniCS and Nutils. If they are not part of OpenFOAM, the right way to got is indeed to add them here in my opinion.

Definitely, but currently the copyright notices look as if these solvers are part of OpenFOAM v2012, that's why I got confused.

@uekerman
Copy link
Member

Definitely, but currently the copyright notices look as if these solvers are part of OpenFOAM v2012, that's why I got confused.

I see. How should / could we change the copyright notice? Just remove?

@MakisH
Copy link
Member

MakisH commented Jun 28, 2021

Definitely, but currently the copyright notices look as if these solvers are part of OpenFOAM v2012, that's why I got confused.

I see. How should / could we change the copyright notice? Just remove?

@davidscn knows best here. If the code is mostly from OpenFOAM with some small changes, then keep the headers as they are and write some "extended by" (David, preCICE, whatever policy we want to have). If the code is mostly new, then I don't see any need for detailed copyright notices, maybe only an attribution such as "based on previous work on X by Y".

@davidscn
Copy link
Member Author

I wrote some custom text in order to highlight from where we started..

@davidscn davidscn self-assigned this Jul 13, 2021
@davidscn
Copy link
Member Author

This PR is now ready to go. As documented in the issue, it works as expected. I only need to update the documentation if we want to merge it. Any volunteer how wants to try out the actual tutorial (groovyBC required)?

@uekerman
Copy link
Member

I only need to update the documentation if we want to merge it.

To which documentation are you referring?

Let's wait for the changelog PR from @IshaanDesai such that we can also document this change.

@davidscn
Copy link
Member Author

To which documentation are you referring?

https://precice.org/tutorials-partitioned-heat-conduction.html

@uekerman
Copy link
Member

I need some documentation to build the OpenFOAM solvers 😁
Could you please update the documentation already?
Also run scripts are missing.

A new inconsistency issue is now the folder structure 😕

  • fenics
  • nutils
  • openfoam-dirichlet
  • openfoam-neumann

@davidscn
Copy link
Member Author

davidscn commented Jul 14, 2021

A new inconsistency issue is now the folder structure confused

fenics
nutils
openfoam-dirichlet
openfoam-neumann

Hm, not sure which part is inconsistent. Merging the OpenFOAM cases is, however, not possible as long as we explicitly want to run the OpenFOAM-OpenFOAM coupling.

EDIT: We also have the problem where to put the solver files. Duplicating them into both OF cases is certainly a bad idea.

@MakisH
Copy link
Member

MakisH commented Jul 14, 2021

I think that fenics and nutils are the special case here because they needed to store the solver together with the case.

We have a kind-of-similar situation in the elastic-tube-1d. Previously, the Python solvers were sharing some files, which we merged into the solvers to not have this issue (e.g. hard-code parameters, instead of using configuration files, move the tools to the root directory). If we have the duplication there, we could also have it here, if it helps the structure.

An alternative we already use in the repository to avoid duplications is symbolic links.

Another alternative would be to have the solvers in a tools/ directory in the case and then the run.sh script of each case would e.g. build and copy the solver binary before executing it. There are many alternatives in this direction, but this is one option.

@uekerman
Copy link
Member

Yes, we could duplicate fenics and nutils into fenics-dirichlet, ...

... @BenjaminRodenberg might not like this idea? (I think we had this discussion already)

Symbolic links or tools/ feel a bit over-engineered to me here.

The other alternative is to keep it as it is and just be careful to properly document the "how to run" in the README.

@MakisH
Copy link
Member

MakisH commented Jul 15, 2021

Yes, we could duplicate fenics and nutils into fenics-dirichlet, ...

... @BenjaminRodenberg might not like this idea? (I think we had this discussion already)

Yes, we had such a discussion already and I understand that this duplication avoidance was the original motivation.

My main counterargument was (and remains here) that special cases can lead again to a difficult to maintain situation and can make automation harder. But I completely understand that this is not a trivial case that fits nicely into our current structure.

Symbolic links or tools/ feel a bit over-engineered to me here.

For me too. However, I think the structure breaks because normally we assume that the solver already exists and the tutorial is only a set of config files. So, if we want to stick to the structure, we should try to separate the solver from the configs. One way is to have the solvers in a directory of a standardized name inside each tutorial case.

The other alternative is to keep it as it is and just be careful to properly document the "how to run" in the README.

I am afraid this will set a precedent for more special cases in the future, so I would prefer to adjust the system now.

@BenjaminRodenberg
Copy link
Member

I quickly skimmed over this PR. I would suggest to merge the structure as it is fenics, nutils, openfoam (if possible) or fenics, nutils, openfoam-dirichlet, openfoam-neumann (if necessary). The discussion about whether we should restructure the nutils and fenics case does not really belong into this PR and should be moved to an issue in my opinion. If we do the restructuring in this PR, if will become gigantic. Therefore, let's try to move it into an issue / another PR as soon as possible.

Yes, we could duplicate fenics and nutils into fenics-dirichlet, ...
... @BenjaminRodenberg might not like this idea? (I think we had this discussion already)

Yes, we had such a discussion already and I understand that this duplication avoidance was the original motivation.

My main counterargument was (and remains here) that special cases can lead again to a difficult to maintain situation and can make automation harder. But I completely understand that this is not a trivial case that fits nicely into our current structure.

And yes. I don't like this idea 😅 We could stick to our structure by introducing some links (e.g. heat-dirichlet.py and heat-neumann.py are just links pointing to heat.py). But I think this is now an idea that @MakisH does not like (and probably @uekerman also?).

@BenjaminRodenberg
Copy link
Member

And yes. I don't like this idea 😅

We could still draft the "duplication" idea. I can imagine that it also has some possible benefits. Right now heat.py has no duplication, but it is sometimes also a bit hard to read and convoluted due to the many if-statements. We can also create modules, where we put code that is common to both solvers and which would require a lot of duplication (e.g. https://github.com/precice/tutorials/blob/master/partitioned-heat-conduction/fenics/problem_setup.py).

@davidscn
Copy link
Member Author

Ok, then I would continue with the following structure:

.
├── clean-tutorial.sh -> ../tools/clean-tutorial-base.sh
├── fenics
├── images
├── nutils
├── openfoam-dirichlet
├── openfoam-neumann
├── openfoam-solver
├── precice-config.xml
└── README.md

@uekerman
Copy link
Member

Therefore, let's try to move it [the discussion] into an issue / another PR as soon as possible.

Please don't forget

@BenjaminRodenberg
Copy link
Member

Therefore, let's try to move it [the discussion] into an issue / another PR as soon as possible.

Please don't forget

Done #228

@davidscn
Copy link
Member Author

Ok, ready for review. I guess every potential reviewer is now already notified.

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.

A quick first review. Please trigger me again afterwards to try it.

partitioned-heat-conduction/openfoam-solver/Make/files Outdated Show resolved Hide resolved

CHT
{
k [ 1 1 -3 -1 0 0 0 ] -1;
Copy link
Member

Choose a reason for hiding this comment

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

Why the -1 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Compatibility. fenics and nutils have different sign conventions here.

Copy link
Member

Choose a reason for hiding this comment

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

Are we then restricted to which solver combinations we can run? Can the user still select between openfoam-openfoam, openfoam-nutils, fenics-openfoam? I understand that now only the openfoam-<other> and <other>-openfoam are valid cases now. Maybe we could find a more fundamental solution to this.

If I am looking at the right places, this is not documented.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah GitHub duplicated your comment, see the answer below.

Copy link
Member

Choose a reason for hiding this comment

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

Ah GitHub duplicated your comment, see the answer below.

I am not sure if we found a GitHub bug or if I commented in the wrong places, but something confusing is going on here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think you did not comment here but rather sent it with a new review. Too much confusion for GitHub. Anyway, let's consider the discussion.

Copy link
Member

Choose a reason for hiding this comment

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

Compatibility. fenics and nutils have different sign conventions here.

Sounds like sth we need to resolve. All combinations should be possible without changing any of the participants.

Copy link
Member Author

Choose a reason for hiding this comment

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

As documented below, all combinations work with the current setup.

partitioned-heat-conduction/openfoam-neumann/0/T Outdated Show resolved Hide resolved
partitioned-heat-conduction/openfoam-dirichlet/0/T Outdated Show resolved Hide resolved
partitioned-heat-conduction/README.md Outdated Show resolved Hide resolved
@davidscn
Copy link
Member Author

A quick first review. Please trigger me again afterwards to try it.

Done and ready to try.


CHT
{
k [ 1 1 -3 -1 0 0 0 ] -1;
Copy link
Member

Choose a reason for hiding this comment

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

Are we then restricted to which solver combinations we can run? Can the user still select between openfoam-openfoam, openfoam-nutils, fenics-openfoam? I understand that now only the openfoam-<other> and <other>-openfoam are valid cases now. Maybe we could find a more fundamental solution to this.

If I am looking at the right places, this is not documented.

@davidscn
Copy link
Member Author

davidscn commented Jul 20, 2021

Are we then restricted to which solver combinations we can run? Can the user still select between openfoam-openfoam, openfoam-nutils, fenics-openfoam? I understand that now only the openfoam- and -openfoam are valid cases now. Maybe we could find a more fundamental solution to this.

If I am looking at the right places, this is not documented.

All combinations are valid as the sign cancels out for openfoam-openfoam

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.

I also ran it now and it works as expected. If you want, consider these two additional points and feel free to merge.

@davidscn davidscn merged commit 4085a8e into precice:develop Jul 29, 2021
@davidscn
Copy link
Member Author

Done, thanks @MakisH

@BenjaminRodenberg BenjaminRodenberg added this to the v202104.2.0 milestone Aug 4, 2021
@davidscn davidscn deleted the partitioned-heat-OF branch September 23, 2021 14:34
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.

Missing partitioned heat conduction tutorial with OpenFOAM
4 participants