-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Adapter precice 3.1 with 3D support and "point load" #26
base: develop
Are you sure you want to change the base?
Conversation
This pull request has been mentioned on preCICE Forum on Discourse. There might be relevant details there: https://precice.discourse.group/t/fsi-with-fenicsx-and-precice-3/1966/3 |
I finally made it work, at least the perpendicular flap tutorial, To do it I added a I added two more examples the turek-heron, and a turbine-tower, right now I'm running them to see what happens. I'm having problems by running the turbine-tower in parallel from the OpenFOAM side, but I don't know how to diagnose what happen |
This pull request has been mentioned on preCICE Forum on Discourse. There might be relevant details there: |
Add untested mockup of Nonlinear solver.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution and apologies for the delay in reviewing. Even if the total number of new files is large, as a first step I looked at the adapter files, so the folder fenicsxprecice
. I see that you have broadly stuck to the existing adapter class structure, by having a Config
class, an Adapter
class, and a class to manage the state for checkpointing. To me it seems like this could have potentially been accommodated in the existing adapter structure. What was the reason to completely discard the existing adapter and write a new one?
Contents of the file fenicsxprecice/solvers.py
is related to the numerical solvers. Such code typically goes in the application files, as it is not directly related to coupling.
Apart from the adapter files, there are a lot of files related to different simulation setups. Ideally such simulation setups are added to the precice/tutorials repository, rather than the adapter repository. Once we start to converge on the adapter contribution, we can move the case files to the tutorials repository.
@IshaanDesai thanks for your quick review. Yes, I use the original adapter structure, because first I tried to use the original on my FSI by doing the small modifications. As I'm new on preCICE and DOLFINx, I began to modify the code in place to do some reverse engineering, until I reached good results, and I removed a lot of code that I didn't understand to keep my version as clean as possible with the minimum needs to perform an FSI, as you can see the API on this version is a lot simpler than the original. I know that I put a lot of tutorials that do not belong here, as de solver.py, but I think it is easier to have all things together in one place to test/review before moving/merge and put all in the right place. But OK I did some cleaning The main part of the Adapter are the methods:
the first return the DOFs and coordinates of the interface. and then is easy to use the |
This pull request has been mentioned on preCICE Forum on Discourse. There might be relevant details there: https://precice.discourse.group/t/how-mesh-coupling-works-for-parallel-participants/2059/1 |
I understand how your reached the state you have, and that it serves the purpose of doing FSI simulations. But the original structure is intended to be for generic use and was also designed rigorously for legacy FEniCS. I am tending towards keeping the old structure and accommodating your improvements in it. Did you encounter any fundamental design problems while trying to incorporate your implementation in the current adapter? If yes, we can improve the design.
This is perfectly fine for now, but just something to do at the end, just before merging.
This would be very interesting to know. If this can be done, we could potentially just move to the new design.
This is a known problem. I would suggest the following next steps:
What do you think? I will, of course, assist to a large degree here. |
I can try to adapt my implementation into the current adapter, but for this, I would need your help, I don't remember the problems in the main implementation. I think that the main cut-off is on the And the same for the Right now this version has a problem working in parallel, and I'm working on it right now, the I could try to start mergin with the current implementation. Notice that the current implementation also is for preCICE < 3, and this implementation not, so here some method changes its names and parameters. |
I can and will definitely help here. I see that you extract the data from the function directly at the time of reading and writing. I will check how this would work with the original implementation. Handling FEniCS Expressions was part of the original design because many times Expressions were used on the user-side. We can rethink this now.
I saw the Discourse post about the issue with parallel runs. Let me try to answer there, so as to not clutter this pull request too much. Thanks for agreeing to merging with the current implementation 😄 I know it feels like taking a step backwards, but in the long run we would benefit from the original design decisions.
Thanks for pointing this out 👍 |
I'm cleaning the branch here to provide only de adapter aligned with the current version class architecture. Notice that the API have some changes due to the preCICE version, here I'm supporting only the preCICEv3. Tutorials and other things where moved to main branch.
as example on how to use this version of the adapter
I accidentally overwrote my last commit, but I believe it's not a significant issue. I modified the adapter using the current class reference to simplify the merging process. In the current implementation, the read and write methods are much simpler because preCICE v3 does not differentiate between vectors and scalars, using the same function for both. I also removed some checks that I didn't fully understand, and I'm not certain if they were necessary.
As I mention in my last post, I'm porting the adapter to preCICEv3 so some methods change, now we have:
I also added some new properties:
So the API change a little bit due to this new properties, and the change of the preCICE version. Also in the FinallyI include the flap tutorial again with this modification, jus to show how we can use it. |
Also I manage to add a working heat transfer tutorial, in this commit of my main branch (which is not aligned right now with this last version). The tutorial runs until the end and change data between participants, but as I'm not an expert in heat transfer I'm sure that there are things wrong there on the FEniCSx side implementation, but it's a starting point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for refactoring your adapter design into the old design. I see now that most things in the old design are rendered unnecessary. The write function in the initialization can be removed as it no longer serves a purpose. I have some last suggestions, which I have written as comments. Once these are incorporated, we can finalize this pull request. Before merging, we should move the simulation setups to the tutorials repository. I can quickly port these once testing is done.
LICENSE
Outdated
Library. | ||
Library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets not change the license file. Can you please keep the original file?
.gitattributes
Outdated
@@ -1 +1 @@ | |||
fenicsxprecice/_version.py export-subst |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the license file.
.github/workflows/build-and-test.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the build and test CI, hence we need this file, and the Action to pass.
.github/workflows/build-docker.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to keep this CI.
.github/workflows/check-links.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as other CI related files. Let us keep this file to keep the check.
|
||
def initialize(self, coupling_subdomain, read_function_space=None, write_object=None): | ||
""" | ||
Initializes the coupling and sets up the mesh where coupling happens in preCICE. | ||
"""Initializes the coupling and sets up the mesh where coupling happens in preCICE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Initializes the coupling and sets up the mesh where coupling happens in preCICE. | |
""" | |
Initializes the coupling and sets up the mesh where coupling happens in preCICE. |
coupling_subdomain : Object of class dolfinx.cpp.mesh.SubDomain | ||
SubDomain of mesh which is the physical coupling boundary. | ||
read_function_space : Object of class dolfinx.functions.functionspace.FunctionSpace | ||
coupling_subdomain : List |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coupling_subdomain : List | |
coupling_subdomain : list |
return self.dt | ||
|
||
def store_checkpoint(self, states: List): | ||
"""Defines an object of class SolverState which stores the current states of the variable and the time stamp.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Defines an object of class SolverState which stores the current states of the variable and the time stamp.""" | |
""" | |
Defines an object of class SolverState which stores the current states of the variable and the time stamp. | |
""" |
fenicsxprecice/fenicsxprecice.py
Outdated
|
||
def retrieve_checkpoint(self): | ||
""" | ||
Resets the FEniCSx participant state to the state of the stored checkpoint. | ||
"""Resets the FEniCSx participant state to the state of the stored checkpoint. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Resets the FEniCSx participant state to the state of the stored checkpoint. | |
""" | |
Resets the FEniCSx participant state to the state of the stored checkpoint. |
tests/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets try to preserve the testing infrastructure as much as possible. I understand that tests related to old functionality are no longer relevant, but modifying existing tests to test the new functionality would be really helpful in catching potential bugs.
There was a problem hiding this 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 all the work and the updates! I don't want to interfere too much here. Just two small comments on versioneer-related files. I would try to not mix these changes into the PR because it's not really related.
For some background: We are using versioneer in this repository to synchronize git-tags and the version numbers used in the setup.py
respectively returned by fenicsxadapter.__version__
.
versioneer.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the changes in this file? I think no changes should be necessary here.
fenicsxprecice/_version.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated by versioneer. Please revert the changes.
Revert changes on code style and formatting to make precice#26 easier to review.
To make this PR a bit easier to review and manage I reverted some changes in fc02757. This should reduce the diff to some degree. @efirvida: If this interferes with your work, feel free to simply revert that commit ( I think we should generally try to factor some things out from this PR. Otherwise it is just too big. Some points that are part of this PR which we could factor out are minor changes like adding braces around |
https://github.com/efirvida/fenicsx-adapter/blob/develop/fenicsxprecice/fenicsxprecice.py#L84 This version of the adapter only supports surface coupling now, right? It think it should be possible to make it more general with an additional argument in the initialization of the adapter. |
Sorry If I dont follow the source style here, my point was to quick develop a solution when it works, we can do it well. This also can keep the code more clean, to discuss over it. Also I have to say that I'm learing preCICE and FenicsX at the same time, so maybe the solution here will be simple and I can't notice it.
I post a first version of the adapter on the preCICE Disource because at that point I have where I call a scaling problem in the flap tutorial, having similar results but with 1 to100 diference in the result.
Then I create a simple static beam problem comparing the results of CaluliX and FenicsX and here I notice the problem, I was integrating the load over the surface, instead of on a DoF as Calculix does, which was confirmed by BenjaminRodenberg in the discourse. This is the example that I put on the test folder. So I update my the flap tutorial based on the lessons learned here.
This also guided by this other thread on FeniscX forum, about mapping the loads over DoFs. But I still having problems validting the flap tutorial. Considering that the FenicsX dos'nt have a PointSource as the legacy version, I use another approach of modifiying directly the vector value as:
Which works for a single point, but I'm missing somthing here, and I dont know if is on the preCICE side or in the implementation of the flap tutorial. Rigth now I can confirm that the adapter can handle 2D and 3D problems, but without good results.