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

Cell loop contains 0 cells for only first iteration of timestep?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 16, 2020, 16:10
Default Cell loop contains 0 cells for only first iteration of timestep?
  #1
jhz
New Member
 
Join Date: Dec 2020
Posts: 19
Rep Power: 6
jhz is on a distinguished road
Hello,

I am using a DEFINE_ADJUST macro in a transient flow simulation. I am also using the documented thread/cell loops to access all cells, but I've found that for the first iteration of a timestep ONLY, there appear to be no cells inside the loop at all. I've included a very general, application-independent code snippet that can reproduce this phenomenon below.

When I print to console the counter number after the loop has ended, for the first iteration of the timestep it will always be 0. For every subsequent iteration in that same timestep until the solver converges, it will be a non-zero value appropriate to how many cells are actually inside the domain.

I am wondering whether there is an explanation for why this happens (possibly inherent to the way Fluent does its calculations)? If this is well-known, can someone point me to a specific part of the manual explaining this? Alternatively, if this is something that "just happens" then is there any way to circumvent this in implementing code that would calculate values in DEFINE_ADJUST which are passed to DEFINE_SOURCE? If for some reason I cannot loop over cells for the first iteration then that makes it seemingly impossible to calculate cell-dependent source terms.

Any help is appreciated, thanks!


Code:
#include "udf.h"

DEFINE_ADJUST(test_adjust,d)
{
    Thread *t;
    cell_t c;

    int counter = 0;

    thread_loop_c(t,d)
    {
        begin_c_loop(c,t)
            counter = counter + 1;
        end_c_loop(c,t)
    }

    Message("---------------------------------\n");
    Message("counter ended at %i\n", counter);
}
jhz is offline   Reply With Quote

Old   December 18, 2020, 03:44
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
DEFINE_ADJUST is executed before each iteration
and your code is not an exception
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply


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
[snappyHexMesh] snappyHexMesh sticking point natty_king OpenFOAM Meshing & Mesh Conversion 11 February 20, 2024 10:12
[blockMesh] Create internal faces as patch in blockMesh m.delta68 OpenFOAM Meshing & Mesh Conversion 14 July 12, 2018 15:43
How to loop the outer cells of the volume cell zone? gzsakuraz Fluent UDF and Scheme Programming 1 April 12, 2017 14:46
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
[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 21:25.