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

Create a user code

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 13, 2015, 02:36
Default Create a user code
  #1
New Member
 
Hoang Nhan Hien
Join Date: Jan 2014
Posts: 1
Rep Power: 0
HN_Hoang is on a distinguished road
Hi, I have tried to create a user code in star ccm+. I did a simple example given in the user guide of star ccm+ version 10.04.009 (window os), but it is not successful. I used visual studio 2013 as recommended in the user guide to compile source files (including uclib.h, uclib.c and zeroGradT.c).

First I compile uclib.c to create uclib.obj, then link this uclib.obj to UserFunctions.lib of star ccm+ to generate libuser.dll

There is no problem with the first step, but the second step is always wrong. The error is:
"ublib.obj : error LNK2019: unresolved external symbol zeroGradT referencetion uclib
libuser.dll : fatal error LNK1120: 1 unresolved externals"

I checked the define of zeroGradT function, but it seems to be okey. Could anyone help me find the solution for this problem? Thanks!

++++++++++++++++++++++++++

#ifndef UCLIB_H
#define UCLIB_H
#ifdef DOUBLE_PRECISION
typedef double Real;
#else
typedef float Real;
#endif
typedef double CoordReal;

#ifdef __cplusplus
extern "C" {
#endif
#if defined(WIN32) || defined(_WINDOWS) || defined(_WINNT)
# define USERFUNCTION_EXPORT __declspec(dllexport)
# define USERFUNCTION_IMPORT __declspec(dllimport)
#else
# define USERFUNCTION_EXPORT
# define USERFUNCTION_IMPORT
#endif

extern void USERFUNCTION_IMPORT ucarg(void *, char *, char *, int);
extern void USERFUNCTION_IMPORT ucfunc(void *, char *, char *);
extern void USERFUNCTION_IMPORT ucfunction(void *, char *, char *, int, ...);

void USERFUNCTION_EXPORT uclib();
#ifdef __cplusplus
}
#endif

#endif


+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++

#include "uclib.h"

void zeroGradT(Real*, int, int*, Real*);

void USERFUNCTION_EXPORT uclib()
{
ucfunc(zeroGradT, "BoundaryProfile", "Zero Gradient Temperature");
ucarg (zeroGradT, "Face", "FaceCellIndex", sizeof(int[2]));
ucarg (zeroGradT, "Cell", "Temperature", sizeof(Real));
}

+++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++

#include "uclib.h"

void USERFUNCTION_EXPORT zeroGradT(Real *result, int size, int (*fc)[2], Real *T)
{
int i;
for (i = 0; i != size; ++i)
{
result[i] = T[fc[i][0]];
}
}

Last edited by HN_Hoang; November 16, 2015 at 03:29.
HN_Hoang is offline   Reply With Quote

Old   March 25, 2019, 20:38
Default
  #2
New Member
 
Subhadip Das
Join Date: Jan 2019
Location: Windsor, Canada
Posts: 4
Rep Power: 3
Subhadip is on a distinguished road
Hi..I am new to Star-ccm+ community. Can you please explain the procedure to use a user code? Do I need to compile the user code in C and attach to the sim file? How can I use this newly added user code with the simulation?? To my understanding, it is absolutely different from using a field function. Please help. Thanks.
Subhadip is offline   Reply With Quote

Reply

Tags
user code

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
User code in CCM+ ggulgulia STAR-CCM+ 2 May 28, 2015 01:23
Unable to create dll, lib files to run User Functions in CFX lucky_m_m CFX 0 July 19, 2013 02:23
How to create an user defined function? Cagdas FLUENT 1 September 5, 2007 20:02
user friendly cfd code waqar Main CFD Forum 19 August 18, 2000 16:31
Open source CFD code development, possible? Dr. Yazid Bindar Main CFD Forum 27 July 18, 2000 00:18


All times are GMT -4. The time now is 22:05.