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

OpenFOAM CalculiX XY (issue#34) #92

Closed
wants to merge 14 commits into from

Conversation

prasadadhav
Copy link

A flap tutorial case for OpenFOAM-CalculiX, in the XY direction as needed in #34.
The meshes are created using Salome.

If some files are deleted during ./Allclean, Readme.md contains instructions to recreate those files.
preCICE version 2.0.2
OpenFOAM v7
CalculiX v2.15

Fixes #34.

@MakisH
Copy link
Member

MakisH commented Jul 8, 2020

Thank you very very much, @alphaoo!

I think it would be a good idea to actually change the files of the current tutorial, since this is a better default. For people that have already built their cases based on the current orientation, this PR would be a clear indication of what they could change. Moreover, it would make reviewing easier, as we could see the changes only. If anybody still wants to use the previous case, it is always available on GitHub.

@uekerman I vote for replacing the current case instead of adding a new one. What do you think?

@Eder-K this will also then need an update in the reference results of the system tests.

@uekerman
Copy link
Member

uekerman commented Jul 8, 2020

@uekerman I vote for replacing the current case instead of adding a new one. What do you think?

Yes, replacing is better than a new one. Is this only for flap_perp/OpenFOAM-CalculiX? What about the other cases 3D-3D and 3D-2D cases? Isn't this a larger problem?

@MakisH
Copy link
Member

MakisH commented Jul 8, 2020

Yes, this affects also the other cases and we should gradually port them as well. For deal.II it will be easy, for SU2 we would need help (maybe a nice first contribution for anyone interested in precice/su2-adapter#16).

@prasadadhav
Copy link
Author

I have added the OpenFOAM+CalculiX CHT case, which have some issues from CalculiX side.
I took the general setup of the flap case from the FSI.

I have adapted the CHT part similar to the heat-exchanger case.

I am currently working on making a flow over the heat plate case similar to OF+Nutils. I will push as soon as I am done, working towards Issue #103 .

@precice-bot
Copy link
Collaborator

This pull request has been mentioned on preCICE Forum on Discourse. There might be relevant details there:

https://precice.discourse.group/t/precice-mesh-id-1-error-openfoam-calculix-cht/313/9

@MakisH
Copy link
Member

MakisH commented Sep 7, 2020

I have added the OpenFOAM+CalculiX CHT case, which have some issues from CalculiX side.
I took the general setup of the flap case from the FSI.

I have adapted the CHT part similar to the heat-exchanger case.

I am currently working on making a flow over the heat plate case similar to OF+Nutils. I will push as soon as I am done, working towards Issue #103 .

Thank you very much for contributing, @Alphaoo1! Could you please split this PR to a different one for each tutorial? This would make the review much easier. Otherwise, this may stay an open PR for too long.

@prasadadhav
Copy link
Author

Could you please split this PR to a different one for each tutorial? This would make the review much easier. Otherwise, this may stay an open PR for too long.

@MakisH Yes. No Problem.

@MakisH
Copy link
Member

MakisH commented Sep 24, 2020

@Alphaoo1 could you please also remove all the result files? You can keep a screenshot in the README to help users understand what this is about, but currently this PR has way too many files to start reviewing it. You can have a look at the files changed tab, where I would like to be able to browse the code and add comments.

Thank you for keeping this up to date all this time! 😃

@prasadadhav
Copy link
Author

@MakisH I have tried to clean up all the things I could think of.

You might find that there are copies of PolyMesh, it is because when we do clean case OpenFOAM clears everything, along with the PolyMesh directory.

Let me know if I need to do something else. 😄

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.

Congratulations of your first preCICE PR review! 🥳

Thank you very much for all the work, please look through my comments and try to apply all the suggestions, if possible, to make this case consistent with the rest of the preCICE tutorials.

See also a separate detailed comment in the discussion, but in this review my main points are:

  • Change the approach from Salome-based mesh generation to OpenFOAM/CalculiX-native rotation at preprocessing time.
  • Remove some non-relevant changes.
  • Move the interFoam-based tutorial to a different PR, preferably after applying the results from our discussion here.

@@ -0,0 +1,86 @@
solid
Copy link
Member

Choose a reason for hiding this comment

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

I guess we can remove all the new files in CHT/flow-over-plate/buoyantPimpleFoam-nutils/.

@@ -68,7 +68,7 @@ Solver2="ccx_preCICE"
cd ${Participant2}
# We use CalculiX CGX to setup the structural simulation
echo " Executing cgx (provided by CalculiX, make sure this exists)..."
cgx -bg pre_flap.fbd > prepare_flap.log 2>&1
# cgx -bg pre_flap.fbd > prepare_flap.log 2>&1
Copy link
Member

Choose a reason for hiding this comment

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

This has now been removed in #95. Please merge.

Comment on lines 15 to 17
cd constant
cp -rfv polyMesh_backup polyMesh
cd ..
Copy link
Member

Choose a reason for hiding this comment

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

See detailed comment in the conversation: let's not copy an already created mesh, but add the steps to rotate the created mesh into the run scripts.

Comment on lines +35 to +36
# rm -fv *.nam
# rm -fv *.msh
Copy link
Member

Choose a reason for hiding this comment

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

Why keeping these files? Similarly to the OpenFOAM files, let's add the rotation commands to the run scripts.

Copy link
Author

@prasadadhav prasadadhav Sep 25, 2020

Choose a reason for hiding this comment

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

Why keeping these files?

As we have pre_flap.fbd in the original tutorial case, it has commands to export the .nam and .msh files. But in this case, I had to do it manually. The commands are the same but I haven't yet figured out how to write a script to export all these files.

Similarly to the OpenFOAM files, let's add the rotation commands to the run scripts.

CalculiX does not rotate around the same point as OpenFOAM, and ultimately we have a bit mismatching meshes.
(one does rotation around the origin and the other does rotation around a corner, but I don't remember now which is which).
It was easier for me to just create new geometry and new mesh in Salome. 😅

But yes, Salome workflow might not be fitting to everyone.

Copy link
Member

Choose a reason for hiding this comment

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

Probably the Salome workflow would be a quite pragmatic approach: many users use it anyway. However, we try to keep the dependencies of the tutorials to a minimum (preCICE already has too many dependencies and components). In any case, this is a tutorial to learn how to use preCICE and its adapters, not how to make a perfect FSI simulation.

What if we just rotate the CalculiX case by hand, e.g. using the Salome output as an example?

@@ -32,7 +32,7 @@ Participant1="Fluid"
cd ..

echo " Preparing the mesh..."
blockMesh -case ${Participant1} > ${Participant1}_blockMesh.log 2>&1
# blockMesh -case ${Participant1} > ${Participant1}_blockMesh.log 2>&1
Copy link
Member

Choose a reason for hiding this comment

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

We want to keep the mesh generation with blockMesh. After this line, we also need to rotate the mesh.

@@ -0,0 +1,62 @@
#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

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

Please move the FSI/flap_perp/OpenFOAM-CalculiX_interFoam/ into a separate PR.

@@ -0,0 +1,54 @@
/*--------------------------------*- C++ -*----------------------------------*\
Copy link
Member

Choose a reason for hiding this comment

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

Is this a temporary backup file?

@@ -0,0 +1,97 @@
/*--------------------------------*- C++ -*----------------------------------*\
Copy link
Member

Choose a reason for hiding this comment

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

Similarly: temporary backup file?

@@ -0,0 +1,19 @@
# Tutorial for an FSI simulation of an elastic flap perpendicular to a channel flow
Copy link
Member

Choose a reason for hiding this comment

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

This README probably needs to be updated to correspond to the interFoam case.

Copy link
Author

Choose a reason for hiding this comment

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

I will work on this.

Comment on lines +52 to +82
<!--<coupling-scheme:serial-explicit>
<time-window-size value="1e-4"/>
<max-time value="1.0"/>
<participants first="Fluid" second="Calculix"/>
<exchange data="Forces0" mesh="Solid" from="Fluid" to="Calculix"/>
<exchange data="Displacements0" mesh="Solid" from="Calculix" to="Fluid"/>
</coupling-scheme:serial-explicit>-->


<!--<coupling-scheme:serial-implicit>
<time-window-size value="1.e-3" />
<max-time value="0.5"/>
<participants first="Fluid" second="Calculix"/>
<exchange data="Forces0" mesh="Solid" from="Fluid" to="Calculix"/>
<exchange data="Displacements0" mesh="Solid" from="Calculix" to="Fluid" />

<max-iterations value="100"/>
<absolute-convergence-measure limit="1e-6" data="Displacements0" mesh="Solid"/>
<relative-convergence-measure limit="1e-2" data="Forces0" mesh="Solid"/>
<extrapolation-order value="2"/>

<acceleration:IQN-ILS>
<data name="Displacements0" mesh="Solid"/>
<preconditioner type="residual-sum"/>
<filter type="QR1" limit="1e-6"/>
<initial-relaxation value="0.01"/>
<max-used-iterations value="15"/>
<time-windows-reused value="0"/>
</acceleration:IQN-ILS>

</coupling-scheme:serial-implicit>-->
Copy link
Member

Choose a reason for hiding this comment

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

This file needs some clean-up. We should choose a config that is robust but also uses default values wherever possible.

@MakisH
Copy link
Member

MakisH commented Sep 24, 2020

Thank you, @Alphaoo1! I additionally removed all the OpenFOAM-CalculiX_interFoam/Solid/*.vtu files and we are now down to 88 files: that's more manageable. 😄

You might find that there are copies of PolyMesh, it is because when we do clean case OpenFOAM clears everything, along with the PolyMesh directory.

I see that you are essentially taking the already produced mesh and rotating it. This is not an ideal solution, however, because:

  1. we need to distribute the mesh, which adds several new files and significantly increases the size of the repository.
  2. the user cannot easily modify the (already produced) mesh.

I understand also that this is the easy solution and manually converting the blockMeshDict would be painful. I would then propose the following: let's keep the original blockMeshDict files and add the rotation commands in the run scripts. Then the user should be happy, even though a bit puzzled for the additional step. But this is then future problem.

Before we start looking into details, let's also break this PR to smaller ones, one for each tutorial. With a quick look, I see changes/additions in the following directories:

  • CHT/flow-over-plate/buoyantPimpleFoam-nutils/: I assume these are probably residues from a previous run, so we can remove all the new files. We anyway don't need to rotate this case.
  • FSI/flap_perp/OpenFOAM-CalculiX: These changes stay in this PR.
    • I see also a binary file FSI/flap_perp/OpenFOAM-CalculiX/Fluid/Fluid_XY.hdf. What is this? We probably don't need it here. Similarly for FSI/flap_perp/OpenFOAM-CalculiX/Fluid/Fluid_xy_original.unv .
    • I see that you renamed the blockMeshDict to blockMeshDict_original. Let's rename it back to blockMeshDict and use it.
  • FSI/flap_perp/OpenFOAM-CalculiX_interFoam: This is a different case, let's move it to a separate PR. Many points of the review will also apply there, so let's first get this one merged.

In any case, please make your new PRs to target the develop branch of the tutorials. You can also change the target branch of this one, by clicking edit next to the title. Preferably merge the latest updates from develop into your branch first (git merge develop). Everything will hopefully be merged automatically, without any conflicts.

@prasadadhav
Copy link
Author

Thank you, @Alphaoo1! I additionally removed all the OpenFOAM-CalculiX_interFoam/Solid/*.vtu files and we are now down to 88 files: that's more manageable.

Thank you for your patience @MakisH, I am a bit new to git workflow so not yet up to the standards.

You might find that there are copies of PolyMesh, it is because when we do clean case OpenFOAM clears everything, along with the PolyMesh directory.

I see that you are essentially taking the already produced mesh and rotating it. This is now an ideal solution, however, because:

  1. we need to distribute the mesh, which adds several new files and significantly increases the size of the repository.
  2. the user cannot easily modify the (already produced) mesh.

No I am not rotating the already produced mesh.
I use ideasUnvToFoam Fluid_xy_original.unv to create the polyMesh directory.
I tried rotating the mesh using the commands available in OpenFOAM, it works fine, but the rotation of CalculiX is a bit tricky and it does not exactly match with Fluid mesh. This is why I chose to make a new mesh all together.

I understand also that this is the easy solution and manually converting the blockMeshDict would be painful. I would then propose the following: let's keep the original blockMeshDict files and add the rotation commands in the run scripts. Then the user should be happy, even though a bit puzzled for the additional step. But this is then future problem.

As I said earlier, it's a bit more complicated to directly rotate mesh and have it aligned with Solid mesh.
I went through the files again, and we only need to keep the boundary file from polyMesh_backup.
When we do ideasUnvToFoam Fluid_xy_original.unv, it creates a boundary file with all the boundaries with type patch. We have type wall for some boundaries, so I chose to copy the polyMesh folder.
I have added this command to runFluid if we want to go in this direction.

Before we start looking into details, let's also break this PR to smaller ones, one for each tutorial. With a quick look, I see changes/additions in the following directories:

  • CHT/flow-over-plate/buoyantPimpleFoam-nutils/: I assume these are probably residues from a previous run, so we can remove all the new files. We anyway don't need to rotate this case.

Yes. Will do

  • FSI/flap_perp/OpenFOAM-CalculiX: These changes stay in this PR.

    • I see also a binary file FSI/flap_perp/OpenFOAM-CalculiX/Fluid/Fluid_XY.hdf. What is this? We probably don't need it here. Similarly for FSI/flap_perp/OpenFOAM-CalculiX/Fluid/Fluid_xy_original.unv .
    • I see that you renamed the blockMeshDict to blockMeshDict_original. Let's rename it back to blockMeshDict and use it.

The .hdf file is the file for original geometry and mesh created in Salome. .unv file is exported from Salome and converted into polyMesh using the command I mentioned earlier.

  • FSI/flap_perp/OpenFOAM-CalculiX_interFoam: This is a different case, let's move it to a separate PR. Many points of the review will also apply there, so let's first get this one merged.

Yes, I will create a new PR for the interFoam.

In any case, please make your new PRs to target the develop branch of the tutorials. You can also change the target branch of this one, by clicking edit next to the title. Preferably merge the latest updates from develop into your branch first (git merge develop). Everything will hopefully be merged automatically, without any conflicts.

Ok. I will do the changes.
Let me know what do you think about my comments. and I will make changes accordingly.

@MakisH
Copy link
Member

MakisH commented Sep 25, 2020

Thank you for your patience @MakisH, I am a bit new to git workflow so not yet up to the standards.

Welcome to the git workflow! 🤗 I am always very happy to help anybody trying to learn, especially if it results in a contribution here.

Pro tip: you are currently requesting to merge from your master branch. But now with all these changes I proposed you will mess up your current production work. So, better keep different "features" in different branches. For now, better make a branch for your work and keep this PR from master.

No I am not rotating the already produced mesh.
I use ideasUnvToFoam Fluid_xy_original.unv to create the polyMesh directory.

I had not heard about this tool before. Interesting but maybe not really needed. I will check again in a second round.

I tried rotating the mesh using the commands available in OpenFOAM, it works fine, but the rotation of CalculiX is a bit tricky and it does not exactly match with Fluid mesh. This is why I chose to make a new mesh all together.

What do you mean "does not exactly match with Fluid mesh"? Unless there is an offset/rotation, this should not be an issue for preCICE.

Ideally, we would like a rotated blockMeshDict and a rotated CalculiX configuration. This should be the cleanest solution and maybe not so difficult in this case, since the geometries are rather simple. I guess we should at least try to remove the Salome dependency and see what we can do afterwards.

@MakisH
Copy link
Member

MakisH commented Apr 12, 2021

We forgot about this for a while, but it is also fine, as #146 now rotated the case as part of a larger restructuring project.

@MakisH MakisH closed this Apr 12, 2021
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.

Rotate FSI flap_perp case
4 participants