CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   interpolation method on unstructured meshes (https://www.cfd-online.com/Forums/main/12326-interpolation-method-unstructured-meshes.html)

harry September 28, 2006 13:54

interpolation method on unstructured meshes
 
I am writing a code based on a unstructured flow solver. As you know that FVM provides us the value of a depedent variable on cell center, but I need its value on grid vertex to implement particle tracing. Obviously, an interpolation approach is required for this task. Hence, what kind of interpolation methods is the best choice? your adice is appreciated.

Regards,

Harry

HelpfulSoul October 2, 2006 13:20

Re: interpolation method on unstructured meshes
 
There are many methods that could be used.

Simplest approach is to assume a second order Taylor series expansion and then us a least squares fit to the neighbouring cell centres.

There seems to be a lot of interest in the use of Radial Basis Functions (RBF), but I'm not sure it offers a great deal more (except the possibility of passing through the supporting data exactly).

Harry October 2, 2006 15:51

Re: interpolation method on unstructured meshes
 
Thanks, HelpfulSoul.

In fact, I try to use gradient calculated by Least squares to do this job, the results are disappointed, particle behaviour is very strange.

Would you please redirect me to some journals or books.

Thanks again.

HelpfulSoul October 2, 2006 16:21

Re: interpolation method on unstructured meshes
 
Unfortunatley I can't be of much help as my books, papers, notes are currently all in large brown packing cases somewhere between my current home and the place I am moving to. The key reference (although getting on a bit now) though remains that by Barth and is available as a download from his web-site.

Harry October 2, 2006 16:28

Re: interpolation method on unstructured meshes
 
Hi,HelpfulSoul

Would you please post the link here, I try to search it using key work Barth, but get losts of results. Hence I am lost since I know nothing about him.

I would appreciate your help.

Harry

HelpfulSoul October 2, 2006 16:30

Re: interpolation method on unstructured meshes
 
http://people.nas.nasa.gov/~barth/

Renato. October 2, 2006 22:07

Re: interpolation method on unstructured meshes
 
Hi Harry,

if I understood your question you're trying to convert a cell based data in a point based data. In Finite Element Method most of the data is point (node in FEM jargon) based and sometimes we need to do the same kind of computation -- node to element or element to node translation. The simplest method, that I know, for doing this can be summarized, for a tetrahedral mesh, in the following steps:

Firstly we'll compute the "nodal volume"

1). For each element do 1.1) Recover the element nodes 1.2) Compute the element volume 1.3) NodalVolume(i) = NodalVolume(i) + (1/4)*ElementVolume

note: 1/4 because the element is a tetrahedron (4 nodes)

Now, we'll compute the nodal data contribution for each element

2). For each element do 2.1) Recover the element node 2.2) Recover the Element Data 2.3) Compute the Element Volume 2.4) NodalData(i) = NodalData(i) + (1/4)*ElementVolume*ElementData

In the last step we need to weight the nodal contribution by the nodal volume

3). For each node do: 3.1) NodalData(i) = NodalData(i)/NodalVolume(i)

It's easy to understand what is written in the pseudo-code above. Draw some triangles surrounding a node in a piece of paper, split each triangle in 3 by their edges. Now, follow the algorithm to see how it works ;o)

Hope this help you

Regards

Renato.

ps.: Some post-processors like ParaView have filters to do the same kind of computation. In PV you can use the "Cell Data to Point Data" or "Point Data to Cell Data" filters to do it.


Harry October 2, 2006 23:02

Re: interpolation method on unstructured meshes
 
Very detailed description! Thank you very much. Yes, I am trying to get point data from cell data. The mesh of CFD code is polyhedron. The solution of CFD code provides cell data. For postprocessing, I need point data. the key point is that I need a general method to acquire data at a arbitary point in the domain of interest. What I intend to do is,

First, I need find the cell which includes the specified point (it is relatively easy).

Second, I evaluate the specified point according to all point (namely,vertex/vertices of a cell) data of the cell . (maybe I should evaluate the specified point on base of its neighboring cells. But this seems very diffcult as its number is various in a unstructured grid.)

Using tetrahedral decomposition should be a choice, but the speed is a problem, especially when point (particle) number is big.

zxaar October 2, 2006 23:23

Re: interpolation method on unstructured meshes
 
yesterday, i wrote export program to fieldview, i had cell centered data, and needed node based data as you want. All I did was volume weighted averaging.

So the node data = (Sum(phi_at_cell * cell_volume) ) / (totalvolumes of cells this node is connected):

It seems to be giving me good results, when viewed with fieldview.

Here is the piece of code that does it I know could be confusing but look at the portion in bold it would make sense:

========================================

[/i]

void DataExportManager::InterpolateDataToNodes(zReal *phiAtNodes, zReal *phiAtCells,

UnsCVCluster *unsCVClusterSolver, MeshNodeManager *nodeManager)

{

// /this interpolates the data from cells centers to the node centers

/// we do the volume weighted averaging

int i = 0, NNodes = 0, NCells = 0;

int size = 0;

double *p_vol ;

double *p_volTotal; // MemCluster *p_memCluster;

int *CellsStartNodes;

int *CellsEndNodes;

CellsStartNodes = nodeManager->CellsStartNodes ;

CellsEndNodes = nodeManager->CellsEndNodes ;

NNodes = nodeManager->TotalNodes ;

NCells = unsCVClusterSolver->TotalSize ;

p_vol = &(unsCVClusterSolver->Volume[0] ) ;

p_volTotal = new double [NNodes + 2] ;

for (i = 0; i <= NNodes; i++)

{

*(p_volTotal + i) = 0;

*(phiAtNodes + i) = 0;

} ///for i ends here

int nclusters = 0, iclus = 0;

int t = 0, t_st = 0, t_end = 0;

int iCell = 0, n = 0;

int nodes_st = 0, nodes_end = 0;

int width = 0;

nclusters = nodeManager->memClusters.size();

double dval = 0;

for (i = 0; i < nclusters; i++)

{

//we will treat each cluster separately

nodes_st = nodeManager->memClusters[i].IndexDatum + 1;

nodes_end = nodeManager->memClusters[i].IndexMax;

for ( n = nodes_st; n <= nodes_end; n++)

{

////

t_st = *(CellsStartNodes + n);

t_end = *(CellsEndNodes + n);

width = t_end - t_st + 1 ;

for ( t = t_st; t <= t_end; t++)

{

iCell = *(nodeManager->memClusters.IData + t) ;

dval = *(p_vol + iCell) ;

*(p_volTotal + n) = *(p_volTotal + n) + dval ;

*(phiAtNodes + n) = *(phiAtNodes + n) + (*(phiAtCells + iCell)) * dval ;


} /// for ends here // printf("\n" );

} // for n ends here

}/// for clusters done

for (i = 1; i <= NNodes; i++)

{

*(phiAtNodes + i) = (zReal)( (*(phiAtNodes + i)) / ( *(p_volTotal + i) + 1.0E-20 ) );
} ///for i ends here

delete [] p_volTotal ;

} ///void ends here


Harry October 3, 2006 01:10

Re: interpolation method on unstructured meshes
 
Thanks, zxaar. the related method in my code is inverse distance weighting (little like volume weighting, but simpler). I think the two method are no problem for postprocessing. But for particle tracing, It is not good enough (particle behavior looks very strange if inverse distance weighting is used). You can image that I first get point data from cell data, then utilize the second-hand data to calculate the value of an arbitary point in a cell. Obviously error is magnified.

BTW: it is difficult to do this job by volume weighting in polyhedral meshes as particle point keeps changing.


All times are GMT -4. The time now is 16:35.