CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > Siemens > STAR-CCM+

User Coding - Get number of iteration

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 9, 2018, 06:12
Default User Coding - Get number of iteration
  #1
New Member
 
Join Date: Jun 2017
Posts: 11
Rep Power: 8
lee_2017 is on a distinguished road
Dear Members,


I am working with the User Code of CCM+ v1302 and right now I am struggling to get the number of the current iteration. To keep it simple, I just copied the part of the code which belongs to the loading in of the iteration number. This code prints out a false iteration number to the terminal and furthermore does not display the number in the scalar scene of the sim file.

Does anyone of you know how the exact code has to look like to get the iteration number? Thank you!


Code:
#include "uclib.h"
#include <math.h>
#include <stdio.h>
 
void Test(CoordReal *result, CoordReal *I)
{   
  printf("Iteration = %d\n",I);
  result = I;
}
 
void uclib()
{
  /* Register user functions here */
  ucfunc(Test, "ScalarFieldFunction", "Test User Coding");
  ucarg(Test, "Cell", "$Iteration", sizeof(CoordReal));
}
lee_2017 is offline   Reply With Quote

Old   November 14, 2018, 05:13
Default
  #2
Senior Member
 
Sebastian Engel
Join Date: Jun 2011
Location: Germany
Posts: 566
Rep Power: 20
bluebase will become famous soon enough
Hi Lee,

Comparing the snippet to the documentation's example: yours is missing to fill the result vector's components but instead replaces the vector result with a 1 component vector.

The argument size is explicitly needed, according to the documentation.
Try the snippet below.


Best regards,
Sebastian

Code:
#include "uclib.h"
#include <math.h>
#include <stdio.h>
 
void TestFunc(CoordReal *result, int size, CoordReal *I)
{   
     int i;
     for (i = 0; i != size; ++i)
     {
          result[i] = I[i];
     }
}
 
void uclib()
{
  /* Register user functions here */
  ucfunc(TestFunc, "ScalarFieldFunction", "Test User Coding");
  ucarg(TestFunc, "Cell", "$Iteration", sizeof(CoordReal));
}
bluebase is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Foam::error::PrintStack almir OpenFOAM Running, Solving & CFD 91 December 21, 2022 05:50
[snappyHexMesh] SnappyHexMesh for internal Flow vishwa OpenFOAM Meshing & Mesh Conversion 24 June 27, 2016 09:54
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
simpleFoam parallel AndrewMortimer OpenFOAM Running, Solving & CFD 12 August 7, 2015 19:45
User coding on NT w2k Philip Jones Siemens 0 November 26, 2001 04:43


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