|
[Sponsors] |
[HowTo]pointVectorField to volVectorField ??? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 27, 2017, 10:20 |
[HowTo]pointVectorField to volVectorField ???
|
#1 | ||
New Member
Join Date: Nov 2016
Posts: 16
Rep Power: 9 |
Dear Foamer:
I want to read a flow field from Tecplot data into the OpenFOAM. The fluid information is based on fluid nodes, however, in OpenFOAM the fluid information is based on cells. So I want to do an interpolation. The way I think so far is that I read the fluid information into a pointVectorField, then interpolate to the volVectorField. In the creatFields.H, I wrote: Quote:
Quote:
I'm not sure if I doing in the right way or not Can anyone help me on this problem Thanks in advance! ycui |
|||
January 27, 2017, 10:41 |
|
#2 |
Senior Member
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 252
Rep Power: 21 |
I have never worked with the interpolation class, so I do not know how to use it.
However, I do know that in "dynamicRefineFvMesh" there is a local implementation to convert between cell data and point data. Have a look at the method "maxPointField", "maxCellField" and/or "cellToPoint" [path for OF4.0]: Code:
${FOAM_SRC}/dynamicFvMesh/dynamicRefineFvMesh |
|
January 27, 2017, 11:26 |
|
#3 | |
New Member
Join Date: Nov 2016
Posts: 16
Rep Power: 9 |
Quote:
It seems there is no function like pointToVol after version 1.6, only has function volToPoint. |
||
February 1, 2017, 05:49 |
|
#4 |
New Member
Join Date: Nov 2016
Posts: 16
Rep Power: 9 |
I have fixed this problem, few comments:
1. copy the pointVolInterpolation from an older version of OF, then compile; 2. pointVolInterpolation is a namespace and cannot be defined in creatFields.H, should be defined in other location; 3. define the point data as pointVectorFields with pointMesh, and define the volume data as volVectorFields with mesh, then do the interpolation. 4. the difference before and after the interpolation depends on the velocity fluctuations. |
|
October 2, 2019, 02:41 |
|
#5 |
Senior Member
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10 |
Hello YCUI,
I am trying to do the same. I copied the pointVectorField to my solver. I am getting the following error: undefined reference to `Foam:ointVolInterpolation:ointVolInterpolatio n(Foam:ointMesh const&, Foam::fvMesh const&)' My piece of code const pointMesh pMesh(mesh); volPointInterpolation vpi(mesh); pointVectorField pointn = vpi.interpolate(gradPsi); pointVolInterpolation pvi(pMesh, mesh); Also these header files are defined before main function #include "volPointInterpolation.H" #include "pointVolInterpolation.H" #include "pointMesh.H" #include "pointFields.H" |
|
October 3, 2019, 11:04 |
|
#6 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Hi,
I don't use the pointVolInterpolation but a function called interpolatePointToCell inside a loop The loop looks like: Code:
forAll(mesh , idCell) { gradPsiAtCell[idCell] = interpolatePointToCell(gradPsi, idCell) } and you need to Code:
#include "interpolatePointToCell.H" Fabien |
|
October 4, 2019, 06:17 |
|
#7 |
Senior Member
krishna kant
Join Date: Feb 2016
Location: Hyderabad, India
Posts: 133
Rep Power: 10 |
Hello Fabian,
Thanks for your answer. It works beautifully. Can I get a little insight of the code interpolatepointToCell(trying to do it myself also but so far no success). Like VolPointInterpolation and PointVolInterpolation interpolates using inverse distance weight function. what does interpolatepointToCell do ? |
|
October 4, 2019, 07:38 |
|
#8 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
To be honnest I didn't look into the code either. A fast check into the code show that its seems to be a simple average of all the values at the points surrounding the cell.
Code:
template<class Type> Type Foam::interpolatePointToCell ( const GeometricField<Type, pointPatchField, pointMesh>& ptf, const label celli ) { const primitiveMesh& mesh = ptf.mesh()(); // get the cell from the indice of the cell const cell& cFaces = mesh.cells()[celli]; // list of point surounding the cell labelHashSet pointHad(10*cFaces.size()); Type sum = Zero; // for all face "f" of the input cell forAll(cFaces, i) { const face& f = mesh.faces()[cFaces[i]]; // for all facePoint "fp" of the face, v being the global indice of that point. forAll(f, fp) { label v = f[fp]; if (pointHad.insert(v)) // I guess that it inserts only if not already // present and return true in that case { sum += ptf[v]; } } } return sum/pointHad.size(); } From this, it would be very easy to copy and modify to have an inverse distance wieghting. Something like Code:
if (pointHad.insert(v)) { const scalar dist=mag(mesh().points()[v]-cFaces.centre()) sum += ptf[v]*dist; sumDist+ = dist } ... return sum/sumDist Fabien Last edited by frobaux; October 4, 2019 at 10:06. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Initialize a uniform 0 volVectorField | Schag | OpenFOAM | 4 | July 24, 2024 03:18 |
Interpolation of a volVectorField onto processor patches | Mithrandirrr | OpenFOAM Programming & Development | 2 | April 5, 2023 18:36 |
making a volVectorField | sina_mech | OpenFOAM Programming & Development | 7 | July 7, 2016 15:49 |
Multiplication of two volVectorField | ChGr | OpenFOAM Programming & Development | 1 | May 30, 2016 12:08 |
copy/write a same volVectorField to every time step folder | hy1112006 | OpenFOAM Programming & Development | 0 | April 18, 2016 23:33 |