- **OpenFOAM Programming & Development**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/*)

- - **surfaceScalarField into VolumeScalarField**
(*https://www.cfd-online.com/Forums/openfoam-programming-development/78541-surfacescalarfield-into-volumescalarfield.html*)

surfaceScalarField into VolumeScalarFieldhi dear foamers
i have an surface Scalar Field i want to change it into a volume Scalar Field whats ur suggestions ? my code is like below .... volVectorField mFlux=K*fvc::grad(T)/L; surfaceVectorField mFluxf=fvc::interpolate(mFlux); const surfaceVectorField& sf=mesh.Sf(); surfaceScalarField mvCoef=(mFluxf & sf); volScalarField mvCoefV= ??? mvCoef .... what should i substitute instead of "???" in above code ? :( |

Hi,
I think fvc::reconstruct(mvCoef) can do it for you. chai |

Hi nimasam,
your post is rather old, but I'm facing the same problem right now. I have to convert a surfaceScalarField into a volScalarField to directly save and visualize the Courant number in the cells. Did you find an easy way to interpolate the values? I'm not sure what fvc::reconstruct() is doing, and it also did not compile in the way I used it. A workaround is saving the surfaceScalarField directly and visualize it in ParaView using foamToVTK -surfaceFields. But thats just a workaround... Arne |

Can you post your errors+relevant code? fvc::reconstruct is more or less the opposite of fvc::interpolate.
Did you check out the Co utility? |

Thanks Bernhard,
I did not know the Co utility until now. Just implemented the same functionality within the solver, in if(runTime.outputTime()), and all is fine. Arne |

Dear All,
fvc::reconstruct operates only on Vector and Tensor fields. What about scalar fields ? Which command should we use to convert a surface field to volumetric field? |

Greetings Vignesh,
Some years ago I wrote a couple of neat utilities that help test the field reconstruct and interpolate features in OpenFOAM: https://github.com/wyldckat/reconstr...rpolate-fields Including a wiki page with some helpful tips on this topic: https://github.com/wyldckat/reconstr...te-fields/wiki Regarding your question, I wrote back then: https://github.com/wyldckat/reconstr...ctSurfaceField Quote:
Best regards, Bruno |

Dear Bruno,
Thank you very much for the reply and also for the neat explanation about the reconstruct option. :D Actually i am trying to reconstruct from a scalar surface field. It is not the outcome of the operation fvc::interpolate(volVectorField) & Mesh.Sf()I am sorry to ask again ..... Is there any way to reconstruct a scalarfield ? |

Hi Vignesh,
Can you provide more specific details? Because the answer seems simply to be: Code:
`fvc::reconstruct(surfScaField)` Best regards, Bruno |

Quote:
I was trying to smooth the volume fraction using the relation given below where is the volume fraction and the symbol implies interpolate from cell center to face and the other one is the reverse (interpolate back to center from face). Interpolating back to cell centers is the point where i got stuck. I tried using fvc::reconstruct(alphaF) but i got errors indicating you cannot do this operation. I found this smoothing function for volume fraction in this Paper Thanks for your help |

Dear All,
I need to calculate "volScalarField" from "surfaceScalarField", if I apply "reconstruct" on surfaceScalarField it gives me "volVectorField". Any Idea how I would achieve this? |

2 Attachment(s)
Greetings to all!
@vigneshTG: I've finally managed to look into this: Quote:
Curiously, I found about the following methods, which are all used in this file: applications/solvers/multiphase/interFoam/LTSInterFoam/setrDeltaT.H - fvc::smooth
- fvc::spread
- fvc::sweep
Quote:
The other thing that comes to mind is rhoCentralFoam, so you might want to look at it for ideas as well...Anyway, the schematic I came up is in the attached files: - Objective.jpg - This image shows the calculation you're looking for.
- reconstruct.jpg - This image shows what is done by "reconstruct". The calculations shown near the bottom right are attempts at getting the same kind of calculation, but that doesn't work.
So I went looking for the code that "fvc::reconstruct" has got inside it, and found it here: src/finiteVolume/finiteVolume/fvc/fvcReconstruct.C Quote:
- "SfHat" - surface field that has the normals of all faces on the mesh.
- "mesh.Sf()" - is a surface field that has mixed in the area of the face over each major direction of the normal, including said normal of the face.
- "surfaceSum" - similar to "fvc::reconstruct", but I had a look at "fvc::surfaceSum" and what it does is add the values of all faces into the cell they belong to. This gets you half way to where you want to get to.
In addition, there is one other interesting method named "fvc::reconstructMag", but this will unlikely give you the desired results. In addition, I very strongly advise you to test these functions with some basic calculations, where you have a simple mesh with simple values inside each cell of the mesh, so that you can then you verify if the calculations are done exactly the way you want them to be. -------------- @Tushar@cfd: Quote:
Which makes me need to ask you: did you even read the past few 4-5 posts above? And I hope you can look at the explanation I gave above to vigneshTG and that you understand that it isn't as simple as just converting a surface scalar field to a volume scalar field, since otherwise you might be simply be generating garbage values out of a perfectly nice surface field ;) Best regards, Bruno |

All times are GMT -4. The time now is 08:07. |