# Face pressure interpolation scheme based on linear interpolation

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

 June 17, 2021, 18:48 Face pressure interpolation scheme based on linear interpolation #1 Member   Zé Join Date: Feb 2020 Posts: 90 Rep Power: 4 Hello to all, I would like to create a new interpolation scheme for the face pressure. Traditionally this is estimated by a linear interpolation scheme, where: where is an interpolation factor. Can anyone point me to which class(classes) I should change in OpenFoam to implement something based on this linear interpolation scheme for the pressure? Best Regards!

 June 18, 2021, 10:39 #2 Senior Member   Join Date: Apr 2020 Location: UK Posts: 469 Rep Power: 11 Typically pressure enters the transport equations through the laplacian term, and the discretisation of this is linear because that is consistent with the finite volume approach. Using anything other than linear is pretty unorthodox, but I guess you could try setting the laplacianScheme for pressure to something other than linear ... i would strongly recommend rethinking this, though. Can I ask why you want to apply something other than linear?

June 18, 2021, 11:21
#3
Member

Join Date: Feb 2020
Posts: 90
Rep Power: 4
Quote:
 Originally Posted by Tobermory Typically pressure enters the transport equations through the laplacian term, and the discretisation of this is linear because that is consistent with the finite volume approach. Using anything other than linear is pretty unorthodox, but I guess you could try setting the laplacianScheme for pressure to something other than linear ... i would strongly recommend rethinking this, though. Can I ask why you want to apply something other than linear?

Hi,

Sure, I want to define a density weighted interpolation scheme for the face pressure:

Where:

This is for multi-phase flow where the linear interpolation should introduce considerable numerical errors if the pressure gradient at cell P and N differ greatly.

 June 19, 2021, 19:21 #4 Member   Zé Join Date: Feb 2020 Posts: 90 Rep Power: 4 So, I guess a good starting point could be the linear interpolation scheme at: Code: /OpenFOAM/OpenFOAM-v2012/src/finiteVolume/interpolation/surfaceInterpolation/schemes/linear and change the weights() function. Since this->mesh().surfaceInterpolation::weights() will get the linear interpolation weights I think I just need to access the density at cell P and N. But I am not sure on how to do this. Any suggestions would be highly appreciated.

 June 20, 2021, 11:34 #5 Senior Member   Join Date: Apr 2020 Location: UK Posts: 469 Rep Power: 11 The cell values on either side of a given face are addressed using the lduAddressing functions lower() and upper(), with the face number being the index. Take a look at fvmDiv for an example of them in action, and good luck.

 June 22, 2021, 14:57 #6 Member   Zé Join Date: Feb 2020 Posts: 90 Rep Power: 4 Hello to all, Some new updates. When you do fvc::grad(p), the solver will go though several files, namely: fvcGrad.C, gradScheme.C, linear.H , surfaceInterpolation.C, basicFvGeometryScheme.C (if you do not have the linear weights), surfaceInterpolationScheme.C. Of special importance to this problem are the surfaceInterpolationScheme.C and linear.H files. In linear.H the weights will be computed as: Code: forAll(owner, facei) { // Note: mag in the dot-product. // For all valid meshes, the non-orthogonality will be less than // 90 deg and the dot-product will be positive. For invalid // meshes (d & s <= 0), this will stabilise the calculation // but the result will be poor. scalar SfdOwn = mag(Sf[facei] & (Cf[facei] - C[owner[facei]])); scalar SfdNei = mag(Sf[facei] & (C[neighbour[facei]] - Cf[facei])); w[facei] = SfdNei/(SfdOwn + SfdNei); } and in the surfaceInterpolationScheme.C the dotInterpolate function will be called for the interpolation procedure, where the values at the face will be calculated as: Code: for (label fi=0; fi

February 10, 2022, 13:53
#7
Senior Member

René Thibault
Join Date: Dec 2019
Posts: 103
Rep Power: 5
Hi Shibi!

Really glad that you were able to find a solution to your challenge.

I am trying to implement a new interpolation scheme also, but for the velocity U.

My friend and I tried a different approach then yours, but it doesn't work for some reason and I cant find the bug. It compile and everything without error, but the results are not affected at all.

Here is the link to the GitHub repository:
https://github.com/RTibo/OpenFOAM-Ne...ation-Scheme-U

So, I was thinking about changing the method by using a 'weighting' factor and then I found your post.

It basically the same thing that I'm trying to implement. The only thing that will differ probably is the 'weighting' factor equation (eq. 45, see image).

Since I needed the same equation in my previous code, the 'weight' equation factor is already coded, but I don't know where to implement this 'weight' factor code snippet in the file linear.H.

Since you said in your last post that you make it work by using the file linear.H as a starting point, which template functions you redefine exactly?

Thank you very much for your help and consideration.

Best Regards,

René

Link of the paper (Eq. 44 & 45): https://onlinelibrary.wiley.com/doi/10.1002/fld.2709
Attached Images
 IntU.png (42.1 KB, 18 views)

 February 13, 2022, 14:27 #8 Member   Zé Join Date: Feb 2020 Posts: 90 Rep Power: 4 If you only want to change the weights, write a new weights function. See if this is useful: https://github.com/UnnamedMoose/Basi...discretisation

 February 14, 2022, 09:20 #9 Senior Member   René Thibault Join Date: Dec 2019 Location: Canada Posts: 103 Rep Power: 5 Thanks for answering! From what I look quickly, the scheme of the tutorial interpolate the actual weights from the center of cells to the face of the cells (horizontal and vertical). The weights function that I need to code is depending of 'z' (see eq. 45 in my previous post), but it only apply at the horizontal face of the cells. That means, the weights of the vertical face of the cell is 1. So, what I conclude is, I don't need to interpolate the weights from the center of the cells, but assign the weights of the horizontal face of the cell directly. Then, use this 'weights' as 'lambda' in the file 'surfaceInterpolationScheme.C'. I don't know if I can make it work that way? Or is there a better approach? What is your thoughts? Thank you again for replying! René Last edited by Tibo99; February 14, 2022 at 16:39.