CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   interpolation (

nandiganavishal February 6, 2013 20:46

Dear Foamers,

I would like to solve the following equation

fvm::laplacian(eps,Phi) == -alpha * Z1*C1-alpha*Z2*C2

where eps is spatially varying.

I have essentially two different values for eps. I know the value of eps at certain positions, which is "eps_1". The positions are obtained from another software. At all other positions, the value of eps is "eps_2." Hence, the eps variation is not exactly at the same point as the mesh defined in the OpenFOAM. I would like to know the following.

1. How to interpolate the eps at the mesh points in OpenFOAM ? Please provide the sytax for the same or let me know a suitable example where I could find one !!

2. How to provide the spatial eps variation directly in the initial guess (0 folder) folder in OpenFOAM after the first step.

Please let me know !!




duongquaphim February 7, 2013 14:59


I think you can find the answers for your questions pretty easy by googling this. However, here you might find the answer:

Question 1: I think you can take a look at There are explanations on different ways of interpolation implemented in OF.

Question 2: I think you can just create a new field (usually in createFields.H) as any scalar field (like pressure) and initialize it as you do with other fields.

Hope this answers your questions.


nandiganavishal February 7, 2013 18:50

1 Attachment(s)
Hi Duaong,

Thanks for the reply. I got your point for my second question.

However, regarding my first question, I read the interpolation schemes, but I still do not understand how to code it in openfoam. For instance attached is the positions file obtained from another software, and the meshfile generated by the openfoam blockmesh. For each position read from the positions file, I would like to assign a value of eps = 2 at the nearest neighbour cell center position. Correct me if I am wrong, the value of eps = 2 should be assigned at the cell center position and at the cell face right !! Finally at all other mesh points the value should be eps = 80

Can you please write the code in openFOAM language as to how to implement the above algorithm from the attached files.



nandiganavishal February 7, 2013 18:54

1 Attachment(s)
attached the blockmesh file

duongquaphim February 8, 2013 06:16

Hi Vishal,

I do not have a good answer for you at the moment. But reading the page, I think what you might want to do is to first assign your eps values to the correct points in OF mesh as you mentioned. Then you compose a pointField based on those values. And you might use pointVolInterpolation::interpolate(phi); to do the interpolation. Again, I do not sure if this will work but might be good to give a try.


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