CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > CFD Freelancers

How to write udf code in visual studio

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 23, 2022, 14:18
Default How to write udf code in visual studio
  #1
New Member
 
Prasidh shetty
Join Date: Oct 2022
Posts: 10
Rep Power: 3
Spicy is on a distinguished road
I change the program for 3d.
But it's show the error msg that is udf library trying to load is not compiled for current platform.
I used visual Studio 2017 for as compiler. And some time it's give error fatal error C1189.
This is code. Please tell me how to avoid this error..


#include "udf.h"
DEFINE_GRID_MOTION(logarithmic, domain, dt, time, dtime)
{ Thread *tf=DT_THREAD(dt);
face_t f;
Node *v;
real NV_VEC(velocity),NV_VEC(axis);
real NV_VEC(origin),NV_VEC(rvec);
real loco;
real freq;
real amp;
real diam;
int n;
SET_DEFORMING_THREAD_FLAG(THREAD_T0(tf));
freq=200;
amp=0.00152;
diam=0.050;
loco=2*3.141592654*amp*freq*cos(2*3.141592654*freq *time);
Message("time=%f,omeg=%f\n",time,loco);
NV_S(velocity,=,0.0);
NV_D(axis,=,1.0,1.0,1.0);
NV_D(origin,=,0.0,0.0,0.0);
begin_f_loop(f, tf)
{ f_node_loop(f, tf, n)
{ v=F_NODE (f, tf, n);
if (NODE_POS_NEED_UPDATE(v))
{ NODE_POS_UPDATED(v);
velocity[2]=loco*(1-(4*(sqrt((NODE_X(v)*NODE_X(v))+(NODE_Y(v)*NODE_Y(v ))))*(sqrt((NODE_X(v)*NODE_X(v))+(NODE_Y(v)*NODE_Y (v)))))/(diam*diam)+((8*(sqrt((NODE_X(v)*NODE_X(v))+(NODE_ Y(v)*NODE_Y(v))))*(sqrt((NODE_X(v)*NODE_X(v))+(NOD E_Y(v)*NODE_Y(v)))))/(diam*diam))*(log((2*(sqrt((NODE_X(v)*NODE_X(v))+( NODE_Y(v)*NODE_Y(v))))+0.000000000001)/diam)));
NV_V_VS(rvec,=,NODE_COORD(v),+,velocity,*,dtime);
NV_V(NODE_COORD(v),=,rvec); } } }
end_f_loop (f, tf); }

This code is for 2d analysis of synthetic jet

I am using this code for 2d analysis in visual studio but it is showing many errors like-
1] cannot find the open source files.
2] identifier logarithmic undefined; identifier domain undefined; identifier dt undefined etc
3]expected an expression
and there are some more ... can help me solve this issue as I am not good at coding.
Spicy is offline   Reply With Quote

Old   November 23, 2022, 19:36
Default
  #2
New Member
 
wujun
Join Date: Apr 2012
Posts: 13
Rep Power: 13
309558927 is on a distinguished road
I just code it in fluent,it works successfully,no errors.
you'd better make some settings between the fluent and VS++.
The VS++ must include the header file like the "udf.h"or others.
please try it again,good luck!
309558927 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
Command line for fluent to run visual studio soankerabhinay FLUENT 9 October 20, 2021 20:33
Help. No Nmake.exe file in my visual studio code folder soankerabhinay FLUENT 2 September 18, 2021 21:19
Method to set environment variables for linking ANSYS Fluent 19.1 and visual studio 1 renrenxiong ANSYS 0 November 13, 2019 07:17
Error code: 126 when loading parallel UDF Coop Fluent UDF and Scheme Programming 0 July 13, 2018 08:33
Problem in compiling UDF with ANSYS Fluent 17.1 and Visual Studio 14.0 Spiker54321 Fluent UDF and Scheme Programming 2 October 27, 2016 09:09


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