|
[Sponsors] |
November 9, 2018, 06:12 |
User Coding - Get number of iteration
|
#1 |
New Member
Join Date: Jun 2017
Posts: 11
Rep Power: 8 |
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)); } |
|
November 14, 2018, 05:13 |
|
#2 |
Senior Member
Sebastian Engel
Join Date: Jun 2011
Location: Germany
Posts: 566
Rep Power: 20 |
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)); } |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
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 |