CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

Count number of cells

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 28, 2023, 02:43
Default Count number of cells
  #1
Member
 
BM
Join Date: Sep 2021
Posts: 35
Rep Power: 5
blyatman is on a distinguished road
I am trying to extract the number of cells in each cell zone (for use in a separate calculation) with the following UDF:
Code:
#include “udf.h”
#include “prox.h”

DEFINE_ON_DEMAND(compute)
{
    #if !RP_HOST

    Domain *domain;
    Thread *tc;

    domain = Get_Domain(ROOT_DOMAIN_ID);

    if (I_AM_NODE_ZERO_P)
    {
        int ntc = 0;
        int nc;
        thread_loop_c(tc,domain)
        {
            ntc += 1;
            nc = 0;
            begin_c_loop(c,tc)
            {
                nc += 1;
            }
            end_c_loop(c,tc)
            Message(“Number of cells: %d\n”,nc);
        }
        Message(“Number of cell threads: %d\n”,ntc);
    }

    #endif
}
I tested this on a mesh with a single cell zone containing 39585 cells. Running the above UDF gives me 10372 cells. If I replace the cell loop with “nc = THREAD_N_ELEMENTS(tc)“, I get 10624 cells. Not sure what’s going on here, as either approaches do not give me the correct number.

I am also only doing the loop over node 0 for other reasons which I won't get in to.
blyatman is offline   Reply With Quote

Reply

Tags
udf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seakeeping Solver:Crashed akbarbagusd Fidelity CFD 0 November 5, 2021 13:42
decomposePar problem: Cell 0contains face labels out of range vaina74 OpenFOAM Pre-Processing 37 July 20, 2020 06:38
[snappyHexMesh] Error snappyhexmesh - Multiple outside loops avinashjagdale OpenFOAM Meshing & Mesh Conversion 53 March 8, 2019 10:42
[mesh manipulation] Mesh Refinement Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Meshing & Mesh Conversion 42 January 8, 2017 13:55
[snappyHexMesh] snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Meshing & Mesh Conversion 2 March 27, 2011 22:11


All times are GMT -4. The time now is 15:17.