CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   coefficient calculation (a_P, a_nb) in unstructured meshes vs. structured meshes(FVM) (https://www.cfd-online.com/Forums/main/147177-coefficient-calculation-a_p-a_nb-unstructured-meshes-vs-structured-meshes-fvm.html)

t.teschner January 14, 2015 19:03

coefficient calculation (a_P, a_nb) in unstructured meshes vs. structured meshes(FVM)
 
I am currently trying to understand unstructured meshes and am implementing the diffusion equation on a simple 2D rectangular domain with an unstructured mesh. I did this a while back for structured meshes and I was calculating the neighbor coefficient as

a_i = \frac{\Gamma_i \Delta A_i}{\delta x_i}

where \Delta A_i and \delta x_i are the cross sectional area (per unit lenght) and the distance of two neighbor cells (cell center to cell center). The cross sectional area is simple \Delta y in the x direction and \Delta x in the y direction.
\delta x_i is defined \delta x = \sqrt{(x_1 - x_0)^2 + (y_1 - y_0)^2}.

The index 0 refers to the current cell and 1 to one of its neighbor.

a_P for each cell in turn is then calculated as the sum

a_P = \sum a_i

Hence, if \Gamma is positive, all a_P and \sum a_i must be positive for each cell as each component is positively defined (i defined \Delta x and \Delta y positive for each cell).

For unstructured meshes, the neighbor coefficients are calculated as

a_i = \frac{\Gamma_i}{\delta x_i}\frac{\vec{A}\cdot\vec{A}}{\vec{A}\cdot\vec{e_\xi}}

where \vec{A} = A_x \cdot \boldsymbol{i} + A_y \cdot \boldsymbol{j}
and \vec{e_\xi} = \frac{(x_1 - x_0)}{\delta \xi}\cdot\boldsymbol{i} + \frac{(y_1 - y_0)}{\delta \xi}\cdot\boldsymbol{j}.

If I expand \frac{\vec{A}\cdot\vec{A}}{\vec{A}\cdot\vec{e_\xi}} I get \frac{A_x A_x + A_y A_y}{A_x\frac{(x_1 - x_0)}{\delta \xi} + A_y\frac{(y_1 - y_0)}{\delta \xi}}

Since both (x_1 - x_0) and (y_1 - y_0) can take negative values, it is expected that both a_P and \sum a_i can take negative values.

Now I am not sure if that is to be expected (as for the structured code I get solely positive values) but I am having the feeling that this i causing some problems for my code.

So the question is probably more, is there any definition for face/unit vector of \xi for the direction they are pointing? Not sure if that is the only problem that I am having in the code, but at least its the only one I can identify to be not working at the moment. The gradient calculation seems to give physical results and I have tried to solve with and without the secondary gradient (cross diffusion term) to check if the error is coming from this term but it does not seem so.

I am using a face based approach where I solve over each face in the interior (followed by the boundary faces) where I add contribution to cell 0 (current cell I am in) and substract them from cell C1 (neighbor cell).

If anyone with experience with unstructured meshes and has a hunch what I am doing wrong I would appreciate the help.

mprinkey January 14, 2015 23:57

Quote:

Originally Posted by t.teschner (Post 527555)
Since both (x_1 - x_0) and (y_1 - y_0) can take negative values, it is expected that both a_P and \sum a_i can take negative values.

No, the values for the unstructured mesh formulation will be all positive. The issue is that the orientation of the face area vectors are fixed, and cell0 is always defined as the cell on the "back" side of the face while cell1 is defined as the cell on the "front" side of the face. If you do it this way, \vec{e_\xi} will be pointing in *almost* the same direction as \vec A and the dot products will all be positive. In the limit of no grid skewness, they will be parallel and you will get the same expressions you had for your structured Cartesian code.

Remember that the coefficients you are computing are really just approximating the summation of the gradient of the unknown quantity at the face dotted with the face area vector. The direction of the area vector assumes that flux is exiting cell0 and entering cell1.

Here is how it is done in ANSYS Fluent for reference--note Figure 3.2.2:

http://aerojet.engr.ucdavis.edu/flue...udf/node92.htm

t.teschner January 15, 2015 12:10

thanks, my area and unit vector where in fact pointing in different directions for some cells, problem is solved now and results look as expected. my cross diffusion term is making something odd but without it its ok. will try to track that bug down. but thanks again.


All times are GMT -4. The time now is 09:40.