CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

Boundary type for patchToPatchInterpolation

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 12, 2013, 11:32
Default Boundary type for patchToPatchInterpolation
  #1
New Member
 
Florian
Join Date: Mar 2012
Location: Munich
Posts: 13
Rep Power: 6
Flor is on a distinguished road
Dear Foamers,

I am using of-1.6-ext and I have a question concerning the boundary type for patchToPatchInterpolation:

Which boundary type should I use such that it does not overwrite my interpolated values?

My interpolator looks like this (with patch2dID and patch3dID properly initiated before):

Code:
    patchToPatchInterpolation interpolator2d3d
    (
        mesh.boundaryMesh()[patch2dID],
        mesh3d.boundaryMesh()[patch3dID],     // to patch
    intersection::FULL_RAY,
    intersection::VECTOR
    );
And my interpolation is done in the follwoing manner:

Code:
    U.boundaryField()[patch3dID] = interpolator2d3d.faceInterpolate <vector>
      (
       U2d.boundaryField()[patch2dID]
       );

    Info << "U2dPatch = " << U2d.boundaryField()[patch2dID] << endl;
    Info << "U3dPatch = " << U.boundaryField()[patch3dID] << endl;
But now I have no clue which type of boundary condition to use. When I use fixedValue, the U.boundaryField()[patch3dID] is overwritten directly, the Info gives the fixed value as output. When I use for instance pressureInletOutletVelocity, the Info outputs the correct value, but it is not used further on. And with calculated I get an error saying that I am probably trying to solve for a default boundary condition.

Any suggestions anyone? Would be highly appreciated!

Thanks in advance
Florian
Flor is offline   Reply With Quote

Old   April 14, 2013, 15:00
Default
  #2
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 617
Rep Power: 21
bigphil will become famous soon enoughbigphil will become famous soon enough
Hi Florian,

I presume you are using patchToPatch to explicitly couple two regions?
Therefore, the boundary condition to use will depend on the coupling procedure you would like to use.
For example, in partitioned fluid-structure-interaction models they typically use Dirichlet-Neumann coupling where one of the coupled patches is Dirichlet (fixedValue) and the other coupled patch is Neumann (fixedGradient). So you would patchToPatch transfer the fluid pressure and shear stresses to the solid and then transfer the displacement to the fluid mesh.

So if you give some more information on your model then it might be easier to give advice.

Philip
bigphil is offline   Reply With Quote

Old   April 17, 2013, 05:30
Default
  #3
New Member
 
Florian
Join Date: Mar 2012
Location: Munich
Posts: 13
Rep Power: 6
Flor is on a distinguished road
Hi Philip,

thanks for your reply! You are right, I want to couple two regions explicitly. In one region I solve the Shallow Water Equations, in the other the full Navier-Stokes Equations using interFoam.

Now I want to transfer the velocity values at the outflow of the SWE-region to the inflow of the NSE-region. So only a one-way coupling for a start. Later on I want to do a two-way coupling, which might require an additional iteration procedure, but this will be the next step.

Best regards
Florian
Flor is offline   Reply With Quote

Old   April 30, 2013, 16:25
Default
  #4
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 617
Rep Power: 21
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by Flor
Hi Philip,

I am wondering whether you might have a hint on how to cope with the patchToPatchInterpolation? I am still stuck at the same point that I mentioned in my post in the forum. I only want to transfer the velocities from the 2D-region to the 3D-region, but the fixedValue-BC always overwrites the interpolated values...

Any idea?

Cheers
Florian
Hi Florian,

Can you outline your solution procedure here so I can understand what exactly you are trying to do i.e. solve some equation -> set velocity on BC on some patch -> etc.

Best regards,
Philip
bigphil is offline   Reply With Quote

Old   June 3, 2013, 13:35
Default
  #5
New Member
 
Florian
Join Date: Mar 2012
Location: Munich
Posts: 13
Rep Power: 6
Flor is on a distinguished road
Hi Philip,

sorry for the late reply, there's been quite a lot of other stuff to do plus a short vacation.

My solution procedure is the following:

- First I solve the shallow water equations on region0. This is a pseudo-2d-mesh with a unit height of 1

- Then I want to transfer the resulting velocity vectors from the outlet of region0 to the inlet of region3d.

- On region3d I solve the Navier Stokes Eqs using interFoam. Instead of a fixedValue I want to use the resulting velocities of region0 as Dirichlet-condition at the inlet.

The patchToPatch-interpolator mentioned above seems to work so far, when using it on some test field it performs the interpolation from my 2d-outlet on this test field. But interpolation on the inlet of region3d does not work. When using a fixedValue-bc on the inlet, I guess the const-declaration of the internal values of the patch prevents the interpolation to work. I've been thinking about using const_cast, but this seems to be a bit too rude...

Hope this helps to help :-)

Best regards
Florian
Flor is offline   Reply With Quote

Old   June 4, 2013, 06:18
Default
  #6
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 617
Rep Power: 21
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by Flor View Post
Hi Philip,

sorry for the late reply, there's been quite a lot of other stuff to do plus a short vacation.

My solution procedure is the following:

- First I solve the shallow water equations on region0. This is a pseudo-2d-mesh with a unit height of 1

- Then I want to transfer the resulting velocity vectors from the outlet of region0 to the inlet of region3d.

- On region3d I solve the Navier Stokes Eqs using interFoam. Instead of a fixedValue I want to use the resulting velocities of region0 as Dirichlet-condition at the inlet.

The patchToPatch-interpolator mentioned above seems to work so far, when using it on some test field it performs the interpolation from my 2d-outlet on this test field. But interpolation on the inlet of region3d does not work. When using a fixedValue-bc on the inlet, I guess the const-declaration of the internal values of the patch prevents the interpolation to work. I've been thinking about using const_cast, but this seems to be a bit too rude...

Hope this helps to help :-)

Best regards
Florian
Florian,

OK, when you solve equations in region0 I presume that the outlet boundary condition is a Neumann type (i.e. a fixedGradient of velocity)?

Then you want to take this velocity and set it as a Dirichlet condition (fixedValue of velocity) on the inlet of region3D? This is called Dirichlet-Neumann coupling (used in FSI, contact mechanics, region coupling, ).

Then after solving equations in region3D, do you want to update the gradient on the outlet of region0 based on the gradient on region3D inlet?

I think this should procedure should work, I believe your problems might be due to how you update the boundary conditions.
Something like this should work:
Code:
// solve equations in region 0

// then create interpolator
patchToPatchInterpolation outletToInletInterpolate
(
 mesh.boundaryMesh()[outletPatchIndex],    // from patch
 mesh.boundaryMesh()[inletPatchIndex],     // to patch
 intersection::VISIBLE,
 intersection::CONTACT_SPHERE
 );

// perform interpolation of outlet velocity to inlet patch
vectorField interpolatedInletU = outletToInletInterpolate.faceInterpolate<vector>
(
U.boundaryField()[outletPatchIndex]
);

// update inlet velocity boundary condition
// you should probably make sure that the patch is fixedValue
if(U.boundaryField().type() != fixedValueFvPatchVectorField::typeName)
FatalError << "inlet patch should be fixedValue!" << exit(FatalError);
// note that "==" is needed to reset actual boundary condition
// not just change patch values
U.boundaryField()[inletPatchIndex] == interpolatedInletU;

// then solve equation in region3D

// then you can update the gradient on the outlet of region0 if you want
Best regards,
Philip
bigphil is offline   Reply With Quote

Old   June 4, 2013, 08:39
Default
  #7
New Member
 
Florian
Join Date: Mar 2012
Location: Munich
Posts: 13
Rep Power: 6
Flor is on a distinguished road
Cool, now it's working! Thanks a lot, Philip!

I was missing the second equal sign, just like you presumed...

Best regards
Florian

PS: You forgot the inletPatchIndex in the type-checking. It should be

Code:
if(U.boundaryField()[inletPatchIndex].type() != fixedValueFvPatchVectorField::typeName)
        FatalError << "inlet patch should be fixedValue!" << exit(FatalError);
Just in case someone is copy-pasting it...
Flor is offline   Reply With Quote

Old   June 4, 2013, 09:27
Default
  #8
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 617
Rep Power: 21
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by Flor View Post
Cool, now it's working! Thanks a lot, Philip!

I was missing the second equal sign, just like you presumed...

Best regards
Florian

PS: You forgot the inletPatchIndex in the type-checking. It should be

Code:
if(U.boundaryField()[inletPatchIndex].type() != fixedValueFvPatchVectorField::typeName)
        FatalError << "inlet patch should be fixedValue!" << exit(FatalError);
Just in case someone is copy-pasting it...
Great.

Yep, thanks for the typo.

Philip
bigphil is offline   Reply With Quote

Old   September 21, 2015, 20:49
Default
  #9
Member
 
Join Date: Jul 2012
Posts: 63
Rep Power: 6
Carlen is on a distinguished road
I am just wondering if this works in parallel
Carlen is offline   Reply With Quote

Old   September 22, 2015, 07:50
Default
  #10
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 617
Rep Power: 21
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by Carlen View Post
I am just wondering if this works in parallel
To get it to work in parallel, you must use globalFaceZones, and the patchToPatchInterpolation must be zoneToZoneInterpolation.
The latest FSI solvers and solidContact BCs do this.

Best,
Philip
bigphil is offline   Reply With Quote

Old   September 22, 2015, 21:24
Default
  #11
Member
 
Join Date: Jul 2012
Posts: 63
Rep Power: 6
Carlen is on a distinguished road
Thank you philip,
can you kindly point me to where I can find the source code?
Carlen is offline   Reply With Quote

Old   January 28, 2016, 12:48
Default updating BCs
  #12
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 39
Rep Power: 4
ali.m.1 is on a distinguished road
Hi All

I've managed to follow this thread though, and get patchToPatchInterpolation working. I can see this by the info statements from the solver when running.
What I cannot do, is get the patch values to become the new BCs. Although the patch values are updating, they are not writing new boundary conditions. I think it's because I only have one loop in my solver, whereas I need 2 (at least). I'm trying to do the same as above, interpolate U1 from an outlet to an inlet.
Can anyone help? I've attached my .C file, sorry about the mess it's in.

Cheers

Ali

Edit: I have managed to get it to work now. I was solving both domains at the same time, instead of sequentially.
Attached Files
File Type: c myReactingTwoPhaseEulerFoam.C (5.9 KB, 2 views)

Last edited by ali.m.1; February 3, 2016 at 07:34. Reason: managed to make it work
ali.m.1 is offline   Reply With Quote

Old   February 4, 2016, 09:11
Default Updating pressure gradient
  #13
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 39
Rep Power: 4
ali.m.1 is on a distinguished road
Hi

Although I've managed to get velocity working fairly well, there is still a few issues:

I'm using reactingTwoPhaseEulerFoam. This first image shows on the water's velocity magnitude. The left pipe is using patchToPatchInterpolate for U, alpha, and p, whereas the right pipe is the 'standard', with no patches. You can see the patch on the left pipe, just before the bend. My aim is to get the left pipe looking like the right pipe, even although I have a baffle in there.



1) I cannot get the pressure fields to look correct. I've tried to do what Phil mentions in post #6, update the pressure gradient on the outlet, however I haven't managed this. I tried this by including another interpolator at the end of the while loop, but instead of going from outlet to inlet, it goes from inlet to outlet. See below image.



Also, I haven't managed to include k or epsilon in the patchToPatch, but I don't think I need to. Correct me if I'm wrong!

Any help is appreciated.

Ali

Edit: I've managed to get the pressure distributions much more similar. The differences were due to the boundary conditions. The two cases are not identical yet though, but this could just be due to the interpolation carried out, giving averaging errors. I'm still unsure about my last question though, should I also be interpolating k, epsilon, and nut? If so, how is this possible?

Last edited by ali.m.1; February 4, 2016 at 12:14. Reason: 1st problem solved
ali.m.1 is offline   Reply With Quote

Old   February 15, 2016, 12:20
Default
  #14
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 39
Rep Power: 4
ali.m.1 is on a distinguished road
Hello

I have managed to interpolate U, p, and Alpha, however the results are different, as I'm not interpolating k + epsilon.

Does anyone know how to define these in the .C file? I can find where they are calculated, but can't seem to define them. I've been trying for 2 days now...

Ali
ali.m.1 is offline   Reply With Quote

Old   February 15, 2016, 17:09
Default
  #15
Senior Member
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin,Ireland
Posts: 617
Rep Power: 21
bigphil will become famous soon enoughbigphil will become famous soon enough
Quote:
Originally Posted by ali.m.1 View Post
Hello

I have managed to interpolate U, p, and Alpha, however the results are different, as I'm not interpolating k + epsilon.

Does anyone know how to define these in the .C file? I can find where they are calculated, but can't seem to define them. I've been trying for 2 days now...

Ali
Hi Ali,

k + epsilon are defined in the turbulence model: see $FOAM_SRC/turbulenceModels/incompressible/RAS/kEpsilon.

So there are a few ways you could overwrite the k and epsilon boundary conditions; for example:
  • make a copy of the kEpsilon class and call it myKEpsilon and then you can add code to force the update of the boundary conditions;
  • lookup k and epsilon from the objectRegistry and use "const_cast" to overwrite the boundary conditions; but be careful as const_cast is typically not very elegant/safe.

Philip
bigphil is offline   Reply With Quote

Old   February 16, 2016, 08:27
Default
  #16
Member
 
Ali
Join Date: Oct 2013
Location: Scotland
Posts: 39
Rep Power: 4
ali.m.1 is on a distinguished road
Quote:
Originally Posted by bigphil View Post
Hi Ali,

k + epsilon are defined in the turbulence model: see $FOAM_SRC/turbulenceModels/incompressible/RAS/kEpsilon.

So there are a few ways you could overwrite the k and epsilon boundary conditions; for example:
  • make a copy of the kEpsilon class and call it myKEpsilon and then you can add code to force the update of the boundary conditions;
  • lookup k and epsilon from the objectRegistry and use "const_cast" to overwrite the boundary conditions; but be careful as const_cast is typically not very elegant/safe.

Philip
Hi Philip

Thanks a lot for getting back. I found the kEpsilon.H file, but the trouble I'm having is defining the variables in my .C file, as it cannot find them. Or they 'were not declared in this scope'. Is it because they are 'private' as defined in the .H file?
I'm happy to update the values of k + epsilon by using patchToPatch (like I do with 'p' for example), however I cannot define them as variables. What would I need to add to 'myKEpsilon.H' to enable me to interpolate k + epsilon? I hope this is clearer...

Thanks again

Ali

EDIT: I managed to use them by using
Code:
volScalarField& k = const_cast<volScalarField&>(mesh.lookupObject<volScalarField>("k.water"));
Now that I am interpolating all variables, my solution is still more than 10% different to my standard case (where there is no baffle). Do you think this just due to the fact that both of adjacent cells to the baffle have the same values, and therefore causing the solution to be different? I currently have a coarse mesh, so I will try with a finer one, and see if this makes a difference.

Last edited by ali.m.1; February 16, 2016 at 13:12.
ali.m.1 is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with boundary conditions: open to atmosphere Wolle OpenFOAM 2 April 11, 2011 07:32
Boundary condition setting for non-premixed combustion using reactingFoam skyopener OpenFOAM 0 May 23, 2010 22:55
RPM in Wind Turbine Pankaj CFX 9 November 23, 2009 05:05
pipe with buoyantFoam buoyancy, boundary conditions Thomas Baumann OpenFOAM 0 June 15, 2009 08:58
Problem with compile the setParabolicInlet ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50


All times are GMT -4. The time now is 04:28.