Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
With what programming language or platform the following code has been written and is there any convertor from the following code to C# or FORTRAN?

#include "udf.h" /* must be at the beginning of every UDF */
#include "sg.h" /* must be at the beginning of this UDF */
#include "math.h" /* must be at the beginning of this UDF */
/*Set preprocessor directives here in order to change
behaviour of the routine:*/
#define not SCHEMEMFP /* shall MeanFreePath be scheme var.? */
#define SCHEMETMAC /* shall TMAC ... */
#define SCHEMEUDRLXCOEFF /* shall the under-relaxation
coefficient... */
#define not SCHEMEThAC /* shall ThAC ... */
#define not SCHEMESpHR /* shall SpHR ... */
#define SCHEMESIGMASQUARE /* shall sigma-square value... */
#define SCHEMEAMBPRESS /* shall ambient pressure value... */
34 A. Computational Routine
#define UNDERRLX /* shall slip veloc be under-relaxated in
severe cases? */
#define WALLMOTION /* shall wall-motion be regarded? */
/*
If the scheme variables are not used fall back to some default
values as below, also some constants are defined
*/
#ifndef SCHEMESIGMASQUARE
#define sigma_square 1.35305239e-19 /* squared value of
sigma(molecule diameter) */
#endif
#ifndef SCHEMEAMBPRESS
#define ambpress 101325 /* ambient pressure */
#endif
#ifndef SCHEMETMAC
#define TMAC 1.0 /* tangential momentum accomodation
coefficient */
#endif
#ifndef SCHEMEThAC
#define ThAC 1.0 /* thermal accomodation coefficient */
#endif
#ifndef SCHEMESpHR
#define SpHR 1.4 /* specific heat ratio; Air, Oxygen,
Nitrogen */
#endif
#ifndef SCHEMEUDRLXCOEFF
#define UDRLXCOEFF 0.02 /* under-relaxation coefficient */
#endif
#define Boltzmann 1.3806505e-23 /* Boltzmann constant */
#define PI 3.14159265358979323846 /* number pi */
#define SQRT_2 1.41421356237309504880 /* sqrt(2) */
A.1. Slip Velocity Routine 35


DEFINE_PROFILE(maxwell_slip_velocity_x_full,f_thread,index)
{
#ifdef SCHEMETMAC
real TMAC=1;
TMAC=RP_Get_Real("tmac");
#endif
real MeanFreePath=6.8e-8;
#ifdef SCHEMEMFP
MeanFreePath=RP_Get_Real("meanfreepath");
#endif
#ifdef SCHEMEUDRLXCOEFF
real UDRLXCOEFF=0.2;
UDRLXCOEFF=RP_Get_Real("udrlxcoeff");
#endif
#ifdef SCHEMESIGMASQUARE
real sigma_square=1.0e-19;
sigma_square=RP_Get_Real("sigmasquare");
#endif
#ifdef SCHEMEAMBPRESS
real ambpress;
ambpress=RP_Get_Real("ambpress");
#endif
face_t face;
cell_t cell;
36 A. Computational Routine
Thread *c_thread;
real slip, thcreep, dveloc;
real normal_slip, tangential_slip, tangential_thcreep;
real Coeff1[ND_ND], Coeff2[ND_ND];
real u[ND_ND];
/* call the routine that computes transformation coefficients,
once per iteration is sufficient
coord_coeff(f_thread) is called only in the velocity
$x$-coordinate routine and activated by the coordeval
scheme variable(integer) */
if (RP_Get_Integer("coordeval")==1) coord_coeff(f_thread)
if ((RP_Get_Integer("tempgradeval")>1)&&(Data_Valid_P()))
{
begin_f_loop(face,f_thread)
{
/* get cell and cell thread pointer */
cell=F_C0(face,f_thread);
c_thread=THREAD_T0(f_thread);
/* compute mean free path at every position */
#ifndef SCHEMEMFP
MeanFreePath = Boltzmann * F_T(face,f_thread) / (
sigma_square * (F_P(face,f_thread)+ambpress)*
PI * SQRT_2 ) ;
#endif
.
.
.
.
.
.
.


Thanks
Posted
Updated 8-Feb-10 3:01am
v3

This does look very much like C, but it doesn't look quite right to me to simply say that it is C. It definitely has an "attitude" associated with it. There are also lines scattered in there that look more like they are coming from a document (page footers & section headings) rather than from a source code file.

After a couple consultations with my friend Google, I have pinned it down.

This is not from a source code file. Some of these lines are not code. This is an extract from this document[^]. It is C code written as an add-in for a commercial software package, as you could have told from reading the beginning of the document. This company[^] seems to have bought, or be, the company that produced that software package. Which of their products is the one you are interested in, I'm not going to figure out for you.

Do note that this code is set up so that it can be compiled in different ways for different uses by changing #defines in the source code.

Beside a language change ( for what reason? ), you are evidently not going to be using the software package this was intended to work with. There is more going on here than "just" a conversion. I would say that the only converter that may work is a human who actually understands the situation you are dealing and can fill in what may be a lot of blanks.
 
Share this answer
 
v3
hi,this is a C++ code,used as a user defined function(UDF) in fluent commercial software
 
Share this answer
 
First, it looks like C++ to me. Second, learn how to use <pre> tags. Your code is supposed to be properly formatted when you post it here.
 
Share this answer
 
C# or FORTRAN! Which would you want - that is like saying "how do I convert this brink into either wine or cheese".

If you explained what you wanted to convert it for - that would help. One option if you wanted to run it under .net would be to use managed C++.

Converting this into either C# or FORTRAN will be hard and I doubt any converter would be able to tackle it - especially FORTRAN which is semantically dissimilar to C++ (or what ever that is - C, Objective C, C++) in a big way.
 
Share this answer
 
v2
you need to compile it in Fluent compiler using Visual studio ,it will be built in loaded in 2 steps, the functions used here are pre-defined functions,the code use datas from fluent,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900