CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[Other] Contribution a new utility: refine wall layer mesh based on yPlus field

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree36Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 28, 2012, 19:21
Default Contribution a new utility: refine wall layer mesh based on yPlus field
  #1
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Dear all,


As discussed in this thread, there is a need to refine the wall layer mesh based on the yPlus or yStar information on the patch fields.

So I modified the original refineWallLayer utility and make a "smart"-refine-wall-layer-mesh utility.

Here it is: refineWallLayerSmart.tar.gz

Most of the options are similar to the original refineWallLayer utility, only
"esgeWeight" is replaced by "stretchingRatio", which I think will make more sense. It should be larger than 1, best to be around 1~1.5, in order not to have too big stretching ratios.

The key feature here is to refine the mesh not just once, but many times based on the current yPlus file or yStar file information, so to reach a desired estimated yPlus value.

The default yPlus target value is to reach y+=1;
Of cause you can set any other y+ target;

To use this utility, please turn on the "basedOnYPlus" option.

If "basedOnYPlus" option is off, the utility behaves like original refineWallLayer utily.

I do not see a need to use "cellSet" mechanism, so by default, when the "basedOnYPlus" option is turned on, the whole wall layer is refined.

Of cause however, this method is just a rough estimation, the real flow field and the yPlus values need to you to rerun the simulation!

Code:
$ refineWallLayerSmart -help

Usage: refineWallLayerSmart [OPTIONS] <patchName> <stretchingRatio>
options:
  -basedOnYPlus     Based on y+/y* field, run these utilities first. Target
                    yPlus is unity
  -case <dir>       specify alternate case directory, default is the cwd
  -noFunctionObjects
                    do not execute functionObjects
  -overwrite        overwrite existing mesh/results files
  -refineLevel <value>
                    Manually set the refineLevel, e.g. 3
  -targetYPlus <value>
                    Manually set the target yPlus, e.g. 5 or 30
  -useSet <name>    (obsoleted) restrict cells to refine based on specified
                    cellSet name
  -srcDoc           display source code in browser
  -doc              display application documentation in browser
  -help             print the usage

A smart way to refine wall layer cells based on the y+/y* value.
Please turn on the option "basedOnYPlus"to see its effect
Examples:

Code:
refineWallLayerSmart -basedOnYPlus cyl 1.15
Refine the wall patch cells named "cyl" based on the latestTime yPlus information, the refine level is automatically calculated, in order to reach y+=1.

Code:
refineWallLayerSmart -basedOnYPlus -targetYPlus 30 cyl 1.15
refine the wall layer mesh to have a target yPlus 30 (mean yPlus value is compared in the utility.)
If "-targetYPlus 50" is larger than the mean yPlus value on that patch, error will show. That is no need to refine.

Code:
refineWallLayerSmart -basedOnYPlus -targetYPlus 30 -refineLevel 3 cyl 1.15
Same as above, but refineLevel is forced to be three, so here "-targetYPlus 50" is useless.


The following is a sample output:
Code:
$ refineWallLayerSmart -basedOnYPlus -targetYPlus 2 cyl 1.12
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.0                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 2.1.0-5141eb679a6c
Exec   : refineWallLayerSmart -basedOnYPlus -targetYPlus 2 cyl 1.12
Date   : Nov 28 2012
Time   : 18:29:59
Host   : "ubuntuWorkStation"
PID    : 13010
Case   : .../run/test/rectangular
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0.01

Note: this utility default is using yPlus, if you have yStar file also in the folder, 
      please double check which one you want to use, and delete the other. Thanks!

Using refineWallLayer utility in a smart way!

Mean yPlus is 19.8019, targetYPlusValue is 2, refineLevel is 4

        Originally, patch 0 named cyl
         d  : min: 0.00069375 max: 0.0008625 average: 0.000735

Selected 284 cells connected to patch cyl

Cutting:
    cells:284
    edges:568

Morphing ...
Selected 284 cells connected to patch cyl

Cutting:
    cells:284
    edges:568

Morphing ...
Selected 284 cells connected to patch cyl

Cutting:
    cells:284
    edges:568

Morphing ...
Selected 284 cells connected to patch cyl

Cutting:
    cells:284
    edges:568

Morphing ...
Writing refined morphMesh to time 0.01001

        After refining, Patch 0 named cyl
         d  : min: 5.405e-05 max: 6.7e-05 average: 5.72429e-05

End



Comments and suggestions are very welcome!
Cheers,
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   November 29, 2012, 04:11
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
Wow, you received your kudos quite fast

It is a nice, simple tool, especially with the loop on the refinement-levels makes life easy hopefully.

I still have some doubts on the stretchingRatio, as it will result in a thicker cell in the first layer than in the second layer, which is probably unwanted. I will see if I can think of anything slightly nicer here (except for using a value of 1 here).


I used the cellSet route, because high have patches with very high and low y+ values, but I think I will agree with you that I don't need it this way, as an additional layer will in general not add to many cells anyhow.

Maybe this utility is worth starting a Wiki-entry?
Bernhard is offline   Reply With Quote

Old   November 29, 2012, 05:03
Default
  #3
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
I added a flad -adjacent to the utility which interprets the stretchRatio as the stretchRatio between consecutive cells. I think it is more intuitive, and it nicely scales all the cells in the wall-layer.
Attached Files
File Type: c refineWallLayerSmart.C (12.6 KB, 151 views)
Alhasan, hua1015, Dimanov and 1 others like this.
Bernhard is offline   Reply With Quote

Old   December 3, 2012, 03:19
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
Just some more thoughts. It would be really awesome if the utility was also able to move some of the nodes of second/third/fourth cell, to reduce the stretch-ratio between the first largest cell inside the layer and the smallest one outside. Does anyone have an idea or suggestion?
Bernhard is offline   Reply With Quote

Old   December 3, 2012, 11:40
Default
  #5
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
If I were you, I would go with some smoothing schemes, but for now, I won't integrate it into this utility. Just some thoughts.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   December 10, 2012, 04:57
Default
  #6
Member
 
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 15
vishalsacharya is on a distinguished road
Hi,

When you use this utility, can it be done before any computations?
I have a case where i plan to generate a steady state RAS solution and then use that as an initial state to do a transient LES.
Can I do this utility before i do my steady state solution?
When a solution exists, how does it work? Obviously it uses the solution to get a more accurate yPlus and then refines wall layers and then writes a new mesh (and new solution interpolated?) to a new directory?
In the basedOnYplus option, which version does it use? yPlusRAS or yPlusLES?

Btw, much appreciation for writing this utility. I am yet to use the in-built refineWallLayer but when i came across your utility, I would like to directly give that a try. Mine is a axisymmetric swirl combustor with a cylindrical dump region preceded by a cylindrical annuls in which 8 swirler guide vanes are present.

Thanks !
vishalsacharya is offline   Reply With Quote

Old   December 10, 2012, 05:00
Default
  #7
Member
 
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 15
vishalsacharya is on a distinguished road
Bernhard:
The new C file and the reason for it makes sense.
If for example, the first cell is say about y+ = 1.5 and we target y+ =1, then a first step would be make a y+ =1 but the next cell then becomes smaller than this new wall cell, am i right? And i guess this is your concern?
In this case, is it not better to just move the y+ = 1.5 point to y+ =1 rather than add a new one? A check can then be made to see the cell expansion ratio near wall.
I hope im not missing something in what you mentioned or implemented, when i say the above?

Thanks
vishalsacharya is offline   Reply With Quote

Old   December 10, 2012, 06:55
Default
  #8
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
The utility will first try to read either yPlus or yStar from the time-file. If it is not present, it will fall back to the normal refineWallLayer. I changed the code I posted in above slightly, such that I can also use refineLevel without yPlus present.

It depends on the utility that you use how -basedOnYPlus works. If you use yPlusRAS, you will not get yPlus, but yStar (see thread linked in first post). You can also use the utility in this other thread, it does not really matter for this utility.

If you use low-Re RANS models, I think the wall layer refinement is not a bad strategy, of course you can also move some nodes, but than your second cell becomes larger than the third one (probably). A combination of both approaches would be ideal (see above post), but for now I don't know how to implement this

This utility will by the way operate based on patch-average y+ values, which in most cases will not bring all y+ down to <1 if the average is. But as long as you keep sure that y+<3 for all cells, I don't think you will get into trouble.
Bernhard is offline   Reply With Quote

Old   December 12, 2012, 16:24
Default
  #9
Member
 
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 15
vishalsacharya is on a distinguished road
That makes sense.

A general question - If I have a simulation yet to run, but i want to decide if my yPlusLES is good, then can i just set the internalField for U in 0/U to be the inlet velocity everywhere? and then it calculates the yPlus based on that?
How does yPlus calculation work for the intial condition?
vishalsacharya is offline   Reply With Quote

Old   December 12, 2012, 16:30
Default
  #10
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
Not sure what you are trying to do. But y+ is simply calculated from velocity gradient, where there is velocity field, there is the y+ field. However, note that some turb models have convergence problem with a ill posed initial field.
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   December 12, 2012, 16:44
Default
  #11
Member
 
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 15
vishalsacharya is on a distinguished road
My thoughts exactly daniel. Imposing a uniform field like that would not be right, and i dont do it. But how do you get yPlus before you do a simulation when there is no velocity field?
vishalsacharya is offline   Reply With Quote

Old   December 12, 2012, 16:46
Default
  #12
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
So your internal field is vacuum? No fluid at all?
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   December 12, 2012, 16:56
Default
  #13
Member
 
Vishal Achasrya
Join Date: Nov 2011
Posts: 38
Rep Power: 15
vishalsacharya is on a distinguished road
When i have a mesh and i have just the 0/ folder, its stagnant field inside... not really vacuum
Before i run my LES, if i want to check my mesh to see if it has a good yPLus, then how do i do it is my question? How do i use yPlusLES before i begin my LES? so that i can refine my wall or not depending on the values?
vishalsacharya is offline   Reply With Quote

Old   December 12, 2012, 17:03
Default
  #14
Senior Member
 
lakeat's Avatar
 
Daniel WEI (老魏)
Join Date: Mar 2009
Location: Beijing, China
Posts: 689
Blog Entries: 9
Rep Power: 21
lakeat is on a distinguished road
Send a message via Skype™ to lakeat
First, I will not use this utility for doing this.

There are numerous ways to estimate first cell height needed when building initial mesh, to list a few:
1. http://www.cfd-online.com/Tools/yplus.php
2. Run on a reduced-dimensional case
3. Experience from similar flow
__________________
~
Daniel WEI
-------------
Boeing Research & Technology - China
Beijing, China
Email
lakeat is offline   Reply With Quote

Old   June 6, 2013, 13:29
Default
  #15
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
Hi daniel
how can set all yPlus values below a specified value(like 1)
mean the maximum value be 1 not the average.
I have a shock tube like case that the flow has not reached all the channel and because the tool assumes average values it doesn't decrease yPlus due to including stationary cells that the flow has not reached them,but the maximum yPlus is 16 and I want it be smaller than 1.
thanks.
-------------------
and also it gives an error on double numbers:
Code:
Create time

Create mesh for time = 1.8e-05

Note: this utility default is using yPlus, if you have yStar file also in the folder, 
      please double check which one you want to use, and delete the other. Thanks!



--> FOAM FATAL IO ERROR: 
wrong token type - expected int, found on line 0 the doubleScalar 0.2

file: IStringStream.sourceFile at line 0.

    From function operator>>(Istream&, int&)
    in file primitives/ints/int/intIO.C at line 68.

FOAM exiting
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 9, 2013, 07:36
Default
  #16
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

Attached is a modification as requested by Ehsan. It's based on Daniel's original modifications and I changed the following:
  1. Changed this:
    Code:
    args.optionLookupOrDefault("targetYPlus",1);
    to this:
    Code:
    args.optionLookupOrDefault("targetYPlus",1.0);
  2. Changed this:
    Code:
    scalar YpAvg = average(Yp);
    to this:
    Code:
    scalar YpAvg = max(Yp);
  3. After that, it's just cosmetic changes... namely changing "YpAvg" to "YpMax" and text references from "Mean" to "Maximum".
Best regards,
Bruno
Attached Files
File Type: gz refineWallLayerSmart_MaxY.tar.gz (3.9 KB, 127 views)
__________________
wyldckat is offline   Reply With Quote

Old   June 9, 2013, 12:43
Default
  #17
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
thanks Bruno
but why y+ doesn't display in terminal?
Code:
Hiii ...
refineLevelValue = 6
Using refineWallLayer utility in a smart way!

Maximum yPlus is 36.32381771, targetYPlusValue is 1, refineLevel is 6

	Originally, patch 2 named walls
	 d  : min: 3.1116565e-06 max: 3.111656539e-06 average: 3.11165652e-06

Selected 1400 cells connected to patch walls

Cutting:
    cells:1400
    edges:2804

Morphing ...
Selected 1400 cells connected to patch walls

Cutting:
    cells:1400
    edges:2804

Morphing ...
Selected 1400 cells connected to patch walls

Cutting:
    cells:1400
    edges:2804

Morphing ...
Selected 1400 cells connected to patch walls

Cutting:
    cells:1400
    edges:2804

Morphing ...
Selected 1400 cells connected to patch walls

Cutting:
    cells:1400
    edges:2804

Morphing ...
Selected 1400 cells connected to patch walls

Cutting:
    cells:1400
    edges:2804

Morphing ...
Writing refined morphMesh to time 1.60063e-05

	After refining, Patch 2 named walls
	 d  : min: 7.286986025e-08 max: 7.287e-08 average: 7.286993012e-08

End
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 9, 2013, 12:52
Default
  #18
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

It shows the maximum "yPlus" value, the target yPlus and the refine level needed for reaching said target:
Quote:
Code:
Maximum yPlus is 36.32381771, targetYPlusValue is 1, refineLevel is 6
I forgot to mention that in my tests I used the following:
Code:
refineWallLayerSmart -basedOnYPlus -targetYPlus 0.5 defaultFaces 1.5
Note: add the option "-overwrite" is you want it to override the existing mesh.
I used it on the tutorial case "incompressible/pimpleFoam/TJunction" and used yPlusRAS to calculate the field "yPlus". I have no idea if these are good values, it was just for testing if the worked.

If you want to confirm the resulting "yPlus", I guess it's just a matter of running the "yPlus" application again... in my case, yPlusRAS.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 9, 2013, 13:42
Default
  #19
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
thanks dear Bruno.
it seems it concentrate the mesh on near the wall not like ordinary blockMesh.its fine because avoids of increasing mesh numbers a lot.
but I can't grasp well how it works.for example when we set 1.15 its the ratio between nearest cell to wall and what?and what does -refineLevel exactly?
and it seems it keeps original mesh numbers(except of some more cells near wall)
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 9, 2013, 14:48
Default
  #20
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

The "-refineLevel" sets the level manually, instead of allowing the utility to calculate the refine level for itself. This will mean that by imposing the level other than the automatically calculated, you will probably reach a y+ higher or lower than you had planned.

As for the "stretchingRatio", it is used for calculating the "weight":
Code:
const scalar weight = args.argRead<scalar>(2)
        /(args.argRead<scalar>(2)+1);
This means that if the "stretchingRatio" is 1.15, then the "weight" is ~0.5348, which means that the first split will be the distance from the patch face to the opposing cell face, times this size.

Attached is the example I'm looking at, which uses a stretch ratio of 1.5, which leads to "1.5/(1+1.5) = 0.6". Since the edge length is 0.004, then the first division will be at "0.6*0.004 = 0.0024".
Then the second division will refer to the new closest cell to the wall, therefore using "0.6*0.0024" and so on.

Best regards,
Bruno
Attached Images
File Type: jpg example_refinewalllayersmart.jpg (25.3 KB, 281 views)
__________________
wyldckat is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 06:38
[snappyHexMesh] Creating multiple multiple cell zones with snappyHexMesh - a newbie in deep water! divergence OpenFOAM Meshing & Mesh Conversion 0 January 23, 2019 05:17
[mesh manipulation] Wall mesh refinement based on y+ Hrushi OpenFOAM Meshing & Mesh Conversion 1 July 9, 2017 07:06
[snappyHexMesh] snappyHexMesh - geometry does not appear in Mesh czhongrong OpenFOAM Meshing & Mesh Conversion 1 January 20, 2016 06:26
Water subcooled boiling Attesz CFX 7 January 5, 2013 04:32


All times are GMT -4. The time now is 23:00.