Allow BC_Sym_Plane to be used as Slip wall for viscous flow - #740
Conversation
… flow. Removed viscous terms from Euler wall.
viscous flow anymore.
…iny bit on symmetry marker, thus the change.
|
Hi @TobiKattmann Eduardo |
|
Hey @EduardoMolina , |
|
Maybe instead of adding a new one, we can modify an existing one to check that feature. Or we add a new one and remove an existing one. We have to somehow reduce the number of tests ... |
|
For clarification: you mean removing a Testcase from the active regression tests to get faster turnaround from travis, the Testcase-files can stay probably. Just as an additional idea: I removed README.md from the gitignore list of the Testcases in a branch and my plan is to shortly explain what the cases are intended to test specifically Link (Note: The Readme there is not done at all, but it shows the idea kinda) |
pcarruscag
left a comment
There was a problem hiding this comment.
It should be possible to accomplish this while keeping the initial assumptions for true symmetry planes, and not requiring the users to use different names for the same boundary condition depending on flow type.
| /*--- The "Normal" in SU2 is an Area-Normal and is most likely not constant ---*/ | ||
| /*--- on the symmetry-plane. ---*/ | ||
| /*--- Edit July 2019: In order to use this BC_Sym_Plane method for slip walls in viscous ---*/ | ||
| /*--- flow the unit-normal & tangent computation is moved into the loop over---*/ |
There was a problem hiding this comment.
I would just edit your initial comment, mention the issue number if you want, but the historical context should not be required to understand what any code currently does.
There was a problem hiding this comment.
Yep, Going to change that, once the implementation itself is approved
|
@TobiKattmann is the incompressible solver the only one that needs the special implementation? |
|
Hi @pcarruscag , Towards input boolean: I thought about that as well, but with that preprocessing step it is impossible to get it wrong imo. I personally agree with BC_Sym always being flat and Euler allowing to be curvy, but as seen in issue #735 this opinion is not undisputed. By paying the price of checking straightness once, one eliminates the use of Marker_Sym (assumes const normal after your proposal) on curvy slip walls (happened in #735 ), or the possibly correct use of Marker_Euler on flat boundaries which would be a lot more expensive than checking once, right. |
|
I see... well every commercial code I have used to date complained about curvy symmetries, we would need to ask Euclid but I think symmetries are flat too. ? |
pcarruscag
left a comment
There was a problem hiding this comment.
Question: What happens in moving mesh cases if the surface starts out flat and then gets deformed?
| CVertex*** vertex; /*!< \brief Boundary Vertex vector (dual grid information). */ | ||
| CTurboVertex**** turbovertex; /*!< \brief Boundary Vertex vector ordered for turbomachinery calculation(dual grid information). */ | ||
| unsigned long *nVertex; /*!< \brief Number of vertex for each marker. */ | ||
| bool *bound_is_straight; /*!< \brief Bool if boundary-marker is straight(2D)/plane(3D) for each marker. */ |
There was a problem hiding this comment.
Can I interest you in std::vector<bool>? It is optimum w.r.t. size and you no longer need to worry about memory management.
| if(RefUnitNormal_defined) { | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| if( abs(RefUnitNormal[iDim] - UnitNormal[iDim]) > epsilon ) | ||
| bound_is_straight[iMarker] = false; break; |
There was a problem hiding this comment.
Are you missing curly brackets here?
| } //while iVertex | ||
|
|
||
| /*--- Print results on screen. ---*/ | ||
| if(rank == MASTER_NODE && print_on_screen) { |
There was a problem hiding this comment.
Is this routine only run by the master node? If not, I think you need a reduction over all partitions that may have gotten a piece of the marker.
There was a problem hiding this comment.
Yeah this one was a bit more involved because of the good'ol local vs global marker stuff.
In this previous version each process had its own bound_is_straight array and accessed that in the BC_sym routine -> therefore the computation was correct i think. It would have happened that on the Master-process the value is true and on another false for the same global marker (e.g. picture the 2D wedge cases split in the middle), but as only the master-process prints its value to screen ...the info on screen would be wrong.
I changed it now: there is an Allreduce in the end such that each process has the same globally correct info. I acknowledge that it is prob not the most elegant implementation, so if there is a hint on how to do it better...
There was a problem hiding this comment.
MPI wise looks ok, idk if there is a better way in SU2 to get a iMarker to iMarkerGlobal correspondence than comparing strings though.
Maybe let each rank decide if its patch should be straight or not and communicate only the messages you want to print to master and don't do the reduction.
At least convert back from global to local in the preprocessing to avoid comparing strings inside the actual boundary condition.
There was a problem hiding this comment.
Reverted implementation back to local vector<bool> bound_is_straight . But I kept a global version in the geometry->ComputeSurf_Straightness to print the result on screen.
| } | ||
| case 3: { | ||
| /*--- Find the largest entry index of the UnitNormal, and create Tangential vector based on that. ---*/ | ||
| unsigned short Largest, Arbitrary, Zero; |
There was a problem hiding this comment.
I think the method in the top voted answer should allow you to do this with less logic.
https://math.stackexchange.com/questions/137362/how-to-find-perpendicular-vector-to-another-vector
There was a problem hiding this comment.
Well, 1. It has to be a unit normal, therefore the division by sqrt(...) and 2. this Largest, Arbitratry, Zero stuff (which I understand bothers you) is there to avoid having the unit vector build upon numerical zeros which I found to give wrong results. Example: normal is n=( 1e-13, 1e-13, 1) then I could just take t=(n2, -n1, 0) (which is in fact the way v_1 from that top voted answer is build). Then t is no unit vector so I divide each entry by the norm of t which ends up with inaccurate tangentials. That problem occurred in my tests for #657 . I hope that makes it clearer why it is like that. Search the largest entry of the vector and do that switch (like here first and second value t=(n2, -n1, 0) with that largest value
Or did I misinterpret your suggestion
There was a problem hiding this comment.
Yeah I got the purpose, but he does a linear combination of two trivially perpendicular vectors.
Which, if the coefficients of the combination are arbitrary, can still give you a small vector.
So one has to choose the coefficients that maximize the magnitude of the potentially zero element (that's one "if").
Worst case scenario this keeps the largest and smallest element in the tangent vector, but if one adds a third trivially perpendicular vector to the result that is avoided:
n = ai + bj +ck
if |b| > |c|
t = bi + (c-a)j - bk
else
t = ci - cj + (b-a)k
Which can actually be written without the conditional. But anyway maybe this is not even expensive at all, I just puzzles.
There was a problem hiding this comment.
Ok, got it. And I agree that it is the more elegant solution so I took it.
|
|
||
| void CTurbSolver::BC_Sym_Plane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { | ||
| void CTurbSolver::BC_Sym_Plane(CGeometry *geometry, | ||
| CSolver **solver_container, |
There was a problem hiding this comment.
@talbring should we start using the short container names everywhere now?
@pcarruscag I now explicitly stated that: |
pcarruscag
left a comment
There was a problem hiding this comment.
Thanks @TobiKattmann , I won't nag anymore about implementation details.
| */ | ||
| void BC_Euler_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, | ||
| unsigned short val_marker); | ||
| void BC_Euler_Wall(CGeometry *geometry, |
There was a problem hiding this comment.
more indentation here and there
There was a problem hiding this comment.
Went over (hopefully) everything and set correct indentation. Good'ol tabs vs spaces problems in IDE 😐
| } | ||
| case 3: { | ||
| /*--- Find the largest entry index of the UnitNormal, and create Tangential vector based on that. ---*/ | ||
| unsigned short Largest, Arbitrary, Zero; |
There was a problem hiding this comment.
Yeah I got the purpose, but he does a linear combination of two trivially perpendicular vectors.
Which, if the coefficients of the combination are arbitrary, can still give you a small vector.
So one has to choose the coefficients that maximize the magnitude of the potentially zero element (that's one "if").
Worst case scenario this keeps the largest and smallest element in the tangent vector, but if one adds a third trivially perpendicular vector to the result that is avoided:
n = ai + bj +ck
if |b| > |c|
t = bi + (c-a)j - bk
else
t = ci - cj + (b-a)k
Which can actually be written without the conditional. But anyway maybe this is not even expensive at all, I just puzzles.
|
|
||
| if (iVertex == 0 || | ||
| geometry->bound_is_straight[val_marker_Global] != true || | ||
| config->GetKind_GridMovement() != RIGID_MOTION) { |
There was a problem hiding this comment.
Is the default grid movement RIGID_MOTION or NONE? I would bake this check into bound_is_straight during the straightness preprocessing, which lets you return early from that function without doing any computation / MPI and reduces the number of places you need to maintain should (when) the grid motions changes.
There was a problem hiding this comment.
Good catch again. As suggested i moved the check into the preprocessing routine.
economon
left a comment
There was a problem hiding this comment.
Thanks, @TobiKattmann, looking good so far. Some comments below
| /*--- The "Normal" in SU2 is an Area-Normal and is most likely not constant ---*/ | ||
| /*--- on the symmetry-plane. ---*/ | ||
| /*--- Edit July 2019: In order to use this BC_Sym_Plane method for slip walls in viscous ---*/ | ||
| /*--- flow the unit-normal & tangent computation is moved into the loop over---*/ |
There was a problem hiding this comment.
Can you please remove the old comment in favor of the new? No need to keep the history, since git takes care of this for us.. might confuse folks more than it helps
| CConfig *config, | ||
| unsigned short val_marker) { | ||
|
|
||
| BC_Sym_Plane(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); |
| } | ||
| delete [] Jacobian_b; | ||
| delete [] DubDu; | ||
| BC_Sym_Plane(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); |
There was a problem hiding this comment.
So, I understand that this is the only change needing some additional attention to make sure that the non-ideal cases are handled for inviscid flows or slip walls in viscous problems, correct? @AlbertoGuardone: if you or anyone in your group has a moment, can you please take a look?
There was a problem hiding this comment.
Ciao @economon, ciao @TobiKattmann, we looked into it and it sounds good.
Implementation is correct: it uses a ghost node with an inverted velocity which does not changes the thermodynamic state. The Jacobian is OK as well. Green light from a NICFD perspective.
Thanks!
There was a problem hiding this comment.
Thanks Alberto for checking
|
Alright everyone, this PR is now ready to get merged from my point of view. If there are further concerns regarding particular Testcases please let me know. @pcarruscag did you check airfoil_fsi_rbf and discadj_fsi_airfoil? If yes, your (dis-)approval for this PR would be appreciated (of course from everyone else as well). I would like to get this integrated before #790 and I would recommend @economon not to start changing reg-test values before this is merged. The code still fixes the initial Issue #735 |
|
LGTM. Thanks for the fix and updating all regressions, @TobiKattmann Final question: in the end, the Euler and symmetry BCs are identical implementations, so do we have a practical guideline for when to use one or the other (or some error check), or will we just carry both and allow them to be used interchangeably? |
|
@economon Right now, Euler & Sym can be used interchangeably in both (incomp. & comp.) solvers. One could safely remove one but keeping both is reasonable I guess as both BC are expected by users and maybe the implementation deviates in the future. Bonus info: Comp & Incomp implementations are identical, so if a higher-level FlowSolver is implemented, EulerWall and SymBC could move up there. |
|
Thanks @TobiKattmann for that fix and going through the hassle of changing all the reg. test values. |
|
@TobiKattmann, |
|
Hi @pcarruscag , Boundary marker leading_edge is NOT a single straight. The diff of my local branch with (origin/)develop is empty, so can you double check for me if you are using the latest develop or fix_SlipWall branch? For the 0.0 markers: In the configFlow.cfg you have Does that help or am I on the wrong track? |
|
Maybe also an explanation why I specifically state |
|
I mean the case in disc_adj_fsi/airfoil_2d for which you updated a filediff regression. You are probably right on the 0's, those were RANS cases... |
|
For the fluid zone0 the boundaries are detected as NOT straight (captial letters because it is written on screen like that ;) ) and for the solid zone1 the fluid markers are still in the Global marker list but not in the local list... thats why they are written as straight on screen (explanation in next paragraph) In parallel cases this case (process knows the global marker but does not own any nodes of it i.e. it is also not in the local marker list) the process has to assume that the boundary is straight for the mpi communication otherwise we would never have straight boundary-straightness predictions in high process-count simulations. Here the situation is the same... except for it is a serial case I have to admit I am not really sure how to best tackle that. Can you split the cfg files like in the Airfoil_RBF case (not sure if this is an old vs new driver thing)? I could exclude that structral solver from the surf_straightness check in CDriver::Geometrical_Preprocessing but I am not sure if that possible and if, what boolean to use. |
|
Is the solver doing the right thing then? That is all I care about. That case cannot be split for now, but since that driver will be retired in the near future I would say you don't need to worry (so long as the solver is doing the right thing). |
|
As each zone has its own geometry_container in which the bound_is_straight data is stored, the false data for the solid zone should not interfere with the fluid zone. And as the fluid zone contains the correct straightness info everything should be fine (except for the screen output of course). |
BC_Sym_Plane was written with only straight lines or planes as symmetry boundaries in mind. Therefore a constant unit normal was used. If symmetry as a slip wall in viscous flows is used the boundary in MARKER_SYM can have some curvature which results in a non-constant unit normal. This is fixed in this PR. + MARKER_SYM now allows non-straight walls with local symmetry enforced + For viscous flows, MARKER_EULER now accounts for viscosity + MARKER_EULER and MARKER_SYM (symmetry planes and Euler walls) now share their implementation Right now, Euler & Sym can be used interchangeably in both (incomp. & comp.) solvers. One could safely remove one but keeping both is reasonable as both BC are expected by users and maybe the implementation deviates in the future. Both will give the same results, independent of the 'curvyness' of the boundary (as that is checked in a preprocessing step). See the following issues/PRs for more details: su2code#735 su2code#740
Hi all,
Proposed Changes
BC_Sym_Plane was written with only straight lines or planes as symmetry boundaries in mind. Therefore a constant unit normal was used. If symmetry as a slip wall in viscous flows is used the boundary in MARKER_SYM can have some curvature which results in a non-constant unit normal. This is fixed in this PR. Additionally viscous terms are removed from Euler wall and MARKER_EULER can not be used in viscous flows.
Affected Regression tests:
a lot ... see a list in the Conversation below
Related Work
This PR is meant to resolve issue #735 opened by @EduardoMolina which was introduced by PR #657 . More details are in the issue
PR Checklist