CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   dynamicRefineFvMesh + Vorticity ? (https://www.cfd-online.com/Forums/openfoam-programming-development/191455-dynamicrefinefvmesh-vorticity.html)

badoumba August 10, 2017 11:44

dynamicRefineFvMesh + Vorticity ?
 
Hi experts,

I try to make adaptive mesh refinement reacting to vorticity - no success so far.

- Can I have vorticity declared as function object in ControlDict? What yould it look like?
- Will it be registered in openFoam db() as required by dynamicRefineFvMesh?

Could also be Q-criterion or Lambda2 instead of vorticity (as suggested here: https://www.vutbr.cz/www_base/zav_pr...file_id=148921)

Thx

floquation August 11, 2017 03:49

Or you use a user extension that can do what you want:
https://github.com/tgvoskuilen/meshBalancing
(It can refine based on the curl of volVectorFields, which is the vorticity when you apply it to U.)

badoumba August 11, 2017 06:07

Hi Floquation,

What does this balancing brings on top of the std DynamicRefineFvMesh class?
I think I can do the same with it. I just need to figure out where to set and link the vorticity/curl/Q... variable.

Thx

floquation August 11, 2017 07:24

As you can see in their examples:
https://github.com/tgvoskuilen/meshB...ynamicMeshDict
They provide more options to dynamicRefineFvMesh, amongst which:
  • lowerRefineLevel/upperRefineLevel
    • enables you to refine between values of a field, rather than above a certain threshold. Useful if you, for example, want to capture the interface (0.1<alpha<0.9) in interFoam.
  • internalRefinementField
    • allows you to calculate a new field to base the refinement on, amongst which the vorticity if you set it to curl of U.
    • also allow you to use multiple fields to base the refinement on, for example both vorticity and velocity magnitude
  • enableBalancing
    • dynamically redistributes the cells over the processors as to ensure that each cell has (roughly) the same workload. This is particularly important if you have a case in which most refinement occurs within a single processor, causing that processor to do (e.g.) 90% of the work.
Options you do not want to use, you can simply turn off. For example, "enableBalancing = false" turns off the dynamic load balancing.

badoumba August 11, 2017 18:38

Hi Floquation,

Thanks for sharing. This refinementControls is definitely a great plus. I will give it a try this week-end.

Thanks!

badoumba August 13, 2017 17:51

Hi Floquation,

I think I made all the necessary changes in my project including the refinement range. I suspect an error in the refinementControls.

Is there any description somwhere for how to fill in params in RefinementControls section? I don't know exactly what the number means in U (0.5 1).

Is Curls ( U(0.5 1)); the only thing I need for vorticity? Is there a need for SetFieldsDict? I don't think vorticity is available without running a specific function.
What about if I want to try with Q criterion instead, is there any doc I can refer to for this?

Many thx

floquation August 14, 2017 04:29

Quote:

Originally Posted by badoumba (Post 660566)
Hi Floquation,

I think I made all the necessary changes in my project including the refinement range. I suspect an error in the refinementControls.

Is there any description somwhere for how to fill in params in RefinementControls section? I don't know exactly what the number means in U (0.5 1).

Not that I know of. Note: I never actually used this code myself. I had written a vorticity-based refinement myself in OF40, but I later found this code which could do what my code could do, but then much more. Hence I linked you that one.

Either way, to find out the answer to your question, we open the source code.
cntrl+F for "curl".
Then I spot the following two lines:
Code:

scalar wgt = curlFields_[fldName].first();
label maxLevel = static_cast<label>(curlFields_[fldName].second()+0.5);

In other words, the first number is the weight.
Code:

refFld = wgt * mag(fvc::curl(fld)) * cubeRtV;
refinementField = wgt \cdot |\nabla\times fld| \cdot \Delta x
This is specifically important if you want to combine multiple criteria, as those criteria are combined to a single field. If you do not weigh fields properly, one field might be negligible w.r.t. the others.
A proper weight would be proportional to the inverse characteristic velocity, as then your refFld will be O(1).

Then, the latter (maxLevel), allows you to (code slightly adapted to illustrate the principle):
Code:

// Limit the value of refFld based on its max level
if( cellLevel[cellI] >= maxLevel )
refFld[cellI] = 0.5*(refinePoints.first() + refinePoints.second())

So if your field (so vorticity in your case) is greater than "maxLevel", the refinementField is set equal to the average of the lower and higher limit of refinement.
That is, that specific cell is forced inside the please-do-refine range.
So if your field is larger than maxLevel, those cells will guaranteedly be refined.

Quote:

Originally Posted by badoumba (Post 660566)
Is Curls ( U(0.5 1)); the only thing I need for vorticity? Is there a need for SetFieldsDict? I don't think vorticity is available without running a specific function.

The curl of U is by definition vorticity, so that is indeed all that you need.
You do not need setFieldsDict. It is in their example, because it is also possible to use a CellSet to base the refinement on - but you don't need that.

Quote:

Originally Posted by badoumba (Post 660566)
What about if I want to try with Q criterion instead, is there any doc I can refer to for this?

Many thx

The code supports "gradient", "curl" and "cellSet".
If you wish to use any other kind of math, you'll have to adapt the code for your purposes.
(Perhaps my simpler code would be more useful for you in that case. What version do you use?)

badoumba August 14, 2017 04:37

Hi Floquation!

version is 17.06.


All times are GMT -4. The time now is 21:43.