CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   How to calculate cell area?? (https://www.cfd-online.com/Forums/fluent-udf/200036-how-calculate-cell-area.html)

sat_fire March 22, 2018 07:15

How to calculate cell area??
 
Hi Everyone,
I am writing UDF for Energy source term in axis-symmetric case which is varying for every cell in the zone thread.I need to multiply area of that cell to corresponding cell energy source term.
please tell me how can I find Area for each cell in axis symmetric case ?

ATIKADAR September 10, 2021 00:04

Hi. I am just wondering did you figure out how to get each cell surface area? I also need to calculate each cell surface area to apply an energy source term.

TIA

AlexanderZ September 13, 2021 02:58

look for macro
Code:

F_AREA(A,f,t);

ATIKADAR September 14, 2021 04:40

Thanks for the reply.

I have tried F_AREA(A,f,t) to calculate each cell surface area inside DEFINE_SOURCE macro and got an error. It seems like DEFINE_SOURCE macro is for cell whereas F_AREA(A,f,t) is for face. Should I need to use any face loop inside DEFINE_SOURCE macro to get each cell surface area?

My intended source term is like = Surface_area_of_cell * T_cell / Cell_volume

AlexanderZ September 14, 2021 08:37

I have no idea, what exactly you need.
this code make a loop over faces of each boundary and calculates source according to your condition for the first row of cells adjusted to that boundaries

Code:

#include "udf.h"

DEFINE_ADJUST(my_adjust,d)
{
        cell_t c0;
        Thread *t,*t0;
        face_t f;
        real A[ND_ND],source;

        thread_loop_f(t,d)
        {
                begin_f_loop(f,t)
                {
                        if (BOUNDARY_FACE_THREAD_P(t))
                        {
                                c0 = F_C0(f,t);
                                t0 = THREAD_T0(t);
                                F_AREA(A, f, t);
                                source = A*C_T(c0,t0)/C_VOLUME(c0,t0);
                                C_UDMI(c0,t0,0) = source;
                        }
                }
                end_f_loop(f,t)
        }
}

DEFINE_SOURCE(my_source,c,t)
{
        return C_UDMI(c,t,0);
}


pakk September 14, 2021 14:59

It makes no sense to use the cell surface area in your source, because it is mesh dependent. Your source would depend on the mesh, a finer mesh gives a higher source.

ATIKADAR September 14, 2021 15:09

Thanks for raising an important question that I didn't consider before. My source term is spatial cell temperature dependent via 'Source = h * A * T' equation. Is there any way I can avoid cell surface area in the source term since temperature would be different in each cell?

pakk September 14, 2021 15:15

Which psysical equation for source are you trying to model? The psysical equation should only have physical things, like temperature, material properties, physical lengths... Not mesh sizes, they are not physical.

(i don't understand your worry about different temperatures, there is nothing problematic about that.)

ATIKADAR September 14, 2021 15:25

I am trying to model only the Energy equation. So, I should use the total surface area of the domain (that is a known geometrical parameter) instead of the cell surface area (which is a mesh-dependent quantity)?

pakk September 15, 2021 02:29

That is not what I mean.

You have a source. Describe that source with a physical equation. Until you do that, I have no idea if and how the source relates to an area. There are millions of ways to define a source, I have no idea which source is present in your problem.

Source has units W/m3, so give me something that has units W/m3.


All times are GMT -4. The time now is 04:37.