|
[Sponsors] |
July 3, 2019, 11:24 |
Need help for interpolation
|
#1 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Good afternoon everyone and thank you for your time!
I have linked a figure to better understand my problem. I've been struggling to devellop a domain coupling between two solvers. - I have an external mesh, really coarse, with fields at points, obtained through an home made potential solver - I have a small mesh, fine, on which I solve the equations of interFoam. When I force both the velocity and p_rhg as fixed values at the boundary, the coupling run, even If I know that I can't supply both of them physically. And descent results are obtained, althought a little bit scattered. When I supply zeroGradient on the outer boundaries of my small mesh and the velocity is supplied and forced, I obtain an error: Code:
--> FOAM FATAL ERROR: Continuity error cannot be removed by adjusting the outflow. Please check the velocity boundary conditions and/or run potentialFoam to initialise the outflow. Total flux : 3.70382 Specified mass inflow : 0.0365504 Specified mass outflow : 0.0360725 Adjustable mass outflow : 0 I currently perform three steps to get this patch set up with fixedValue - on potential Regions, from pointField -> volField - from volField on potential -> volField on fineMesh (through meshToMesh, and I have tested all interpolation method) - from volField on the fine mesh -> patch on the finemesh (patch.internalField(), but actually this is meshTomesh which does that directly.) I there any better way to do this? Or an idea for where I could/should search. Is there any interpolation method which is more continuous (for example the interpolation used by paraFoam for plotOverLine is way cleaner) Thank you in advance for any advice! Fabien |
|
July 3, 2019, 12:48 |
|
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
I did not undestand exactly what you are trying to do from your description but your mass imbalance comes from the Interpolation, i.e. you're trying to fix the velocity at all boundary of the inner domain. Since the interplolation scheme you're applying is not mass conservative this results in a mass increase or decreas in your innner domain. Usually OF tries to get rid of the global mass imbalance by applying some correction factors at the zeroGradiant boundaries. Since you fix all values it cannot get rid of the global mass imbalance.
I know that the cyclicAMI boundary conditions is mass convervative. Maybe you can have a look how this boundary condition is implemented. |
|
July 4, 2019, 05:04 |
|
#3 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Thank you for your answer, and sorry if I were unclear.
The velocity field I want to import from the outer region (coarser mesh) on the interFoam region (finer mesh) is divergence free (with of course a error from the computational method, but it should be lower than e-8, the hard coded value in adjustPhi.C) The problem is when I import from the outer mesh to the fine mesh, degradation of the quality of the solution are at play. The worst part being the use of meshToMesh which does takes into account only one cell or 2 cells values of the source field. I would like to implement or to find a better interpolation method. For cyclicAMI, the boundaries are mass conservative but it easier as the mass going out is feeded in the other side, am I right? |
|
July 4, 2019, 06:53 |
|
#4 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Just for clarification: Do the coarse and fine mesh share only the bounday or also some of the Volume?
I ask the question since meshToMesh can be used to perform an Interpolation between two meshes which share parts of their volume. Can you describe a bit better you workflow in order that I can get a better Picture what you're doing. |
|
July 4, 2019, 07:11 |
|
#5 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
The fine mesh is completely included in the coarse mesh. They are the same problems but with different sizes and discretisations.
So I think meshToMesh is suited in this case, but the interpolations methods are not well suited for a important difference in terms of discretisation. My workflow is: External solver: - With an external solver, I solve for U and p for all times - I convert those results into openFoam format -> external region New coupled solver: - I create a case with two regions * the external mesh: results already available * the "interFoam mesh". I do it with that methodology because i would like to implement latter the outer solver in the openFoam framework, and solve both interFoam and outer solver as done in the multiRegions solvers (but with overlapping meshes). and the runTime loop looks like, in pseudo code: Code:
while (runTime.run()) { runTime++; - read External Fields; - convert PointFields to VolField on External; - interpolate InterFoam region Patches From External; pimple loop { - solve InterFoam Region; } } So later the "read external" will be replaced by "compute external" in theory. |
|
July 4, 2019, 14:32 |
|
#6 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Just for clarification: what kind of boundary condition do you apply at the inner fine grid? fixed value or zero gradient
|
|
July 7, 2019, 06:23 |
|
#7 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
FixedValue, on both pressure (p_rgh) and velocity (U). Those values are interpolated from the outer coarse grid.
If I use ZeroGradient I wont be abble to set values from the outer grid, right? |
|
July 7, 2019, 06:49 |
|
#8 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Yes. But if on patch you set zero gradient an on the other fixed value it is better for the convergence
|
|
July 8, 2019, 06:40 |
|
#9 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Ok, I will try this, but the problem is my flow (waves) is mostly oscillatory, so there is no real physical reason for an inlet with fixedValue and outlet with zeroGradient.
And this does not change the fact that my values are not as correct as it could be on the inlet, due to the "bad" interpolation. |
|
July 8, 2019, 08:09 |
|
#10 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
There are inletOutlet boundary conditions available in OF: https://www.openfoam.com/documentati...conditions.php
So maybe one of this fits you Needs. But if not, you can derive of one of it and specify fixedValue if the flow goes into your Domain and zeroGradient if it goes out |
|
July 8, 2019, 11:11 |
|
#11 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
I'm looking at this, and I should indeed be better to use this kind of boundaries.
So I need, at every time step to fill the valueInlet (from the value I got from the external region). But when fill from a fixedValue patch the patch of U as: Code:
U.boundaryFieldRef()[patchId]=VfromExternal.boundaryField()[patchId]; Code:
inletValue uniform (0 0 0); I have read that "value" is meaningless in the inletOutlet patch, is that correct? looking at the code in inletOutletFvPatchField.H I read that "inletValue" is set inside "this->refValue()" But calling "U.boundaryFieldRef()[patchId]->refValue()" does not compile.. Have you an idea as why? Thanks again a lot for you help |
|
July 9, 2019, 01:46 |
|
#12 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Can you post the whole code and the exact compiler error? From the message you sent it is unclear what you did and for this reason find the error.
|
|
July 9, 2019, 02:02 |
|
#13 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
Maybe just a remark. What you are trying to do, I.e. embed a finer grid in a coarser in meteorology is common praxis since decades and the methodology is called nesting. You'll find plenty of literature on it.
|
|
July 9, 2019, 04:10 |
|
#14 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Everything here is on the fine mesh:
- I have VfromExternal[i] which is a volVectorField (where the boundaries are "fixed value", and imported from the external regions - I have U which I will solve. I just need to set its BC Objective: set the value inside the inletOutlet patch of U: Code:
forAll(mesh.boundaryMesh(), patchId) { if(U.boundaryField()[patchId].type()== "inletOutlet") { Info << "inletOutletFound" << endl; U.boundaryFieldRef()[patchId].refValue()=VfromExternal[i].boundaryField()[patchId]; } } The compiler error is pretty clear Code:
error: ‘class Foam::fvPatchField<Foam::Vector<double> >’ has no member named ‘refValue’ U.boundaryFieldRef()[patchId].refValue()=VfromExternal[i].boundaryField()[patchId]; Code:
U.boundaryFieldRef()[patchId]->refValue()=VfromExternal[i].boundaryField()[patchId]; Code:
./fluid/setRegionFluidFields.H:44:38: error: base operand of ‘->’ has non-pointer type ‘Foam::fvPatchField<Foam::Vector<double> >’ The problem is I cannot just equalize Code:
U.boundaryFieldRef()[patchId]=VfromExternal[i].boundaryField()[patchId]; Thanks again. I will also check your recommandation about nested! |
|
July 9, 2019, 09:38 |
|
#15 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
I have managed to use the inletOutlet for both p_rgh and the velocity U on every patch on the border of the fine mesh. The problem to set the pressure is I forgot to cast it into the correct type:
Code:
inletOutletFvPatchField<vector>& patchU = refCast<inletOutletFvPatchField<vector> >(U.boundaryFieldRef()[patchId]); patchU.refValue()=VfromExternal[i].boundaryField()[patchId]; patchU.updateCoeffs(); |
|
July 10, 2019, 11:08 |
|
#16 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 |
did you set the pressure to fixedValue where you have zeroGradient for U and vise versa?
|
|
Tags |
coupling, interpolation, meshtomesh, patch |
|
|