CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF to change angular velocity after every timestep based on the previous value

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 9, 2022, 08:13
Default UDF to change angular velocity after every timestep based on the previous value
  #1
New Member
 
Join Date: Jul 2019
Posts: 14
Rep Power: 7
usr0830 is on a distinguished road
Hello,
I am trying to run a simulation where the angular velocity of a dynamic mesh zone changes every time step based on this equation of motion where moment_z is the moment on the two aerofoils defined as one wall.

omega_prev + = ((1/I) * (moment_z - (alpha * omega_prev)))
When I set up the dynamic mesh with the udf, the initialisation returns an "All compute processes received SIGFPE." error. I am not sure what the cause of this error is. Could someone more knowledgeable please help me solve this?

This is the UDF I am using:

Code:
Code:
#include "udf.h"
real current_dt;
real omega_old;
real omega_new;
real moment_z;
static I = 0.0275; /* Moment of inertia */
static alpha = 0.00626;
static real omega_prev = 0.0;
DEFINE_CG_MOTION (rotational_motion1, dt, vel, omega, time, dtime)
{
#if !RP_HOST
current_dt = RP_Get_Integer("time-step");
if (current_dt ==1)
omega_prev = -128;
else
omega_prev = omega[2];
Message("Omega_old1 is %g",omega_prev);
Domain *d =Get_Domain(1);
Thread *t_object = Lookup_Thread(d, 2);
real moment [ND_ND], cg[ND_ND], force [ND_ND];
Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE);
moment_z= moment [2]; 
/* Equation of motion */
omega_prev += ((1/I) * (moment_z - (alpha * omega_prev)));
Message("Omega_new1 is %g",omega_prev);
omega[2] = omega_prev;
#endif
}
Thank you!
usr0830 is offline   Reply With Quote

Old   November 10, 2022, 01:43
Default
  #2
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
show compilation log
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 11, 2022, 06:48
Default Compilation log
  #3
New Member
 
Join Date: Jul 2019
Posts: 14
Rep Power: 7
usr0830 is on a distinguished road
Dear Alexander,
Thank you for your response. Here is the compilation log for the udf.

Code:
Working...
for d in lnamd64/[23]*; do \
  ( \
    cd $d; \
	rm -rf *.{c,h,cpp,hpp}; \
    for f in ../../src/*.{c,h,cpp,hpp} ../../src/makefile ../../src/user.udf; do \
      if [ -f $f -a ! -f `basename $f` ]; then \
        echo "# linking to" $f "in" $d; \
        ln -s $f .; \
      fi; \
    done; \
    echo ""; \
    echo "# building library in" $d; \
    if [ "" = "1" ]; then \
	echo "# using gcc64"; \
	make ARCHC=gcc64 -k>makelog 2>&1; \
    else \
	if [ "" = "1" ]; then \
		echo "# using gcc"; \
		make ARCHC=gcc -k>makelog 2>&1; \
	else \
		make -k>makelog 2>&1; \
	fi; \
    fi;\
    cat makelog; \
  ) \
done
# linking to ../../src/rotCG_motion1.c in lnamd64/2ddp_host
# linking to ../../src/rotCG_motion2.c in lnamd64/2ddp_host

# building library in lnamd64/2ddp_host
make[1]: Entering directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host'
# Generating udf_names.c because of makefile rotCG_motion1.c
make[2]: Entering directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host'
make libudf.so "CFLAGS=-D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT=   " "LDFLAGS=-shared -lm"
make[3]: Entering directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host'
# Compiling rotCG_motion1.o because of rotCG_motion1.c
cc -D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT=     -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/`expr "\`pwd\`" : '.*/\(.*\)/[23].*'`/`basename "\`pwd\`"` -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/main -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/addon-wrapper -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/io -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/species -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/pbns -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/numerics -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/sphysics -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/storage -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/mphase -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/bc -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/models -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/material -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/amg -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/util -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/mesh -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/udf -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/ht -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/dx -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/turbulence -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/parallel -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/etc -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/ue -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/dpm -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/dbns -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/cortex/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/client/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/tgrid/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/multiport/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/multiport/mpi_wrapper/include -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/multiport/mpi_wrapper/src -I. -c rotCG_motion1.c
rotCG_motion1.c:7:13: warning: I defined but not used [-Wunused-variable]
 static real I = 0.0275; /* Moment of inertia */
             ^
rotCG_motion1.c:8:13: warning: alpha defined but not used [-Wunused-variable]
 static real alpha = 0.00626;
             ^
rotCG_motion1.c:9:13: warning: omega_prev defined but not used [-Wunused-variable]
 static real omega_prev = 0.0;
             ^
# Linking libudf.so because of udf_names.c rotCG_motion1.o
cc -shared -lm udf_names.o rotCG_motion1.o  -o libudf.so
make[3]: Leaving directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host'
make[2]: Leaving directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host'
make[1]: Leaving directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host'
# linking to ../../src/rotCG_motion1.c in lnamd64/2ddp_node
# linking to ../../src/rotCG_motion2.c in lnamd64/2ddp_node

# building library in lnamd64/2ddp_node
make[1]: Entering directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node'
# Generating udf_names.c because of makefile rotCG_motion1.c
make[2]: Entering directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node'
make libudf.so "CFLAGS=-D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT=   " "LDFLAGS=-shared -lm"
make[3]: Entering directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node'
# Compiling rotCG_motion1.o because of rotCG_motion1.c
cc -D_lnamd64 -D_GNU_SOURCE -fpic -shared -ansi -Wall -O -DPTR_RESTRICT=     -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/`expr "\`pwd\`" : '.*/\(.*\)/[23].*'`/`basename "\`pwd\`"` -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/main -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/addon-wrapper -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/io -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/species -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/pbns -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/numerics -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/sphysics -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/storage -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/mphase -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/bc -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/models -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/material -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/amg -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/util -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/mesh -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/udf -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/ht -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/dx -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/turbulence -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/parallel -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/etc -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/ue -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/dpm -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/src/dbns -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/cortex/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/client/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/tgrid/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/multiport/src -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/multiport/mpi_wrapper/include -I/usr045/ansys_inc/v182/fluent/fluent18.2.0/multiport/mpi_wrapper/src -I. -c rotCG_motion1.c
# Linking libudf.so because of udf_names.c rotCG_motion1.o
cc -shared -lm udf_names.o rotCG_motion1.o  -o libudf.so
make[3]: Leaving directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node'
make[2]: Leaving directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node'
make[1]: Leaving directory `/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node'

You can also see the 'log'-file in 
the working directory for this compilation history

Done.

Opening library "/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf"...
Library "/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_host/libudf.so" opened
Opening library "/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf"...
Library "/usr045/people/greeshma45/Desktop/DFBI_Trial/CG_Motion/libudf/lnamd64/2ddp_node/libudf.so" opened
	rotational_motion1
Done.

Opening
usr0830 is offline   Reply With Quote

Old   November 16, 2022, 21:58
Default
  #4
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
this is compilation log I got, when I tried to compile your code
fix these errors, put here revised version of code and describe problems if any
Code:
..\..\src\debug.c(18) : error C2275: 'Domain' : illegal use of this type as an expression
..\..\src\debug.c(18) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(19) : error C2275: 'Thread' : illegal use of this type as an expression
..\..\src\debug.c(19) : error C2065: 't_object' : undeclared identifier
..\..\src\debug.c(19) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(19) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
..\..\src\debug.c(19) : warning C4024: 'Lookup_Thread' : different types for formal and actual parameter 1
..\..\src\debug.c(20) : error C2275: 'real' : illegal use of this type as an expression
..\..\src\debug.c(20) : error C2146: syntax error : missing ';' before identifier 'moment'
..\..\src\debug.c(20) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(20) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(20) : error C2065: 'cg' : undeclared identifier
..\..\src\debug.c(20) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(20) : error C2065: 'force' : undeclared identifier
..\..\src\debug.c(20) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(21) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(21) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
..\..\src\debug.c(21) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 1
..\..\src\debug.c(21) : error C2065: 't_object' : undeclared identifier
..\..\src\debug.c(21) : warning C4047: 'function' : 'Thread *' differs in levels of indirection from 'int'
..\..\src\debug.c(21) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 2
..\..\src\debug.c(21) : error C2065: 'cg' : undeclared identifier
..\..\src\debug.c(21) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(21) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 3
..\..\src\debug.c(21) : error C2065: 'force' : undeclared identifier
..\..\src\debug.c(21) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(21) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 4
..\..\src\debug.c(21) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(21) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(21) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 5
..\..\src\debug.c(22) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(22) : error C2109: subscript requires array or pointer type
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 17, 2022, 10:00
Default Edited UDF
  #5
New Member
 
Join Date: Jul 2019
Posts: 14
Rep Power: 7
usr0830 is on a distinguished road
Hi Alexander,
Thank you for your response. I made a few changes to the UDF and the method. Instead of using the dynamic mesh method, now I am trying to use the UDF to change the rotational velocity in the Cell Zone conditions tab. I changed the UDF as follows. The rotor shown in the image should depend on the moments on the aerofoils (id 13 and 14). The code compiles without any errors for me. But it seems like the UDF is not being read as the first message I try to print does not appear on the console. There are no options to 'hook' the UDF other than in the Cell Zone conditions tab. Could you please help me solve this issue?


Code:
#include "udf.h"

real current_dt;
real omega_old;
real omega_new;
real moment_z;
real moment_z2;
real moment_R;
static real I = 0.0275; /* Moment of inertia */
static real alpha = 0.00626;
static real omega_prev = -128.0;
DEFINE_ZONE_MOTION (rotational_motion1,omega,axis,origin,velocity,time,dtime)
{
#if !RP_HOST
  Message("Begin udf1");
  omega_prev = omega[2];
  Message("Omega_old1 is %g",omega_prev);
  Domain *d =Get_Domain(1);
  Thread *t_object = Lookup_Thread(d, 13);
  Thread *t_object2 = Lookup_Thread(d, 14);
  real moment[ND_ND], cg[ND_ND], force[ND_ND];

  Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE);
  moment_z= moment[2]; 
  Compute_Force_And_Moment(d, t_object2, cg, force, moment, TRUE);
  moment_z2= moment[2]; 
   /* Equation of motion */
  moment_R = moment_z + moment_z2;
  omega_prev += ((1/I) * (moment_R- (alpha * omega_prev)));
  Message("Omega_new1 is %g",omega_prev);
  omega[2] = omega_prev;
  origin[0]= 0.0;
  origin[1]= 0.325;
  origin[2]= 0.0;
  N3V_D(axis,=,0.0,0.0,1.0);
 
#endif

}
Attached Images
File Type: png Rotor.png (54.7 KB, 2 views)
File Type: png Cell zone condition.png (95.6 KB, 4 views)
usr0830 is offline   Reply With Quote

Old   November 18, 2022, 00:27
Default
  #6
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
this is compilation log of your code "without errors"
Code:
..\..\src\debug.c(18) : error C2275: 'Domain' : illegal use of this type as an expression
..\..\src\debug.c(18) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(19) : error C2275: 'Thread' : illegal use of this type as an expression
..\..\src\debug.c(19) : error C2065: 't_object' : undeclared identifier
..\..\src\debug.c(19) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(19) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
..\..\src\debug.c(19) : warning C4024: 'Lookup_Thread' : different types for formal and actual parameter 1
..\..\src\debug.c(20) : error C2275: 'Thread' : illegal use of this type as an expression
..\..\src\debug.c(20) : error C2065: 't_object2' : undeclared identifier
..\..\src\debug.c(20) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(20) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
..\..\src\debug.c(20) : warning C4024: 'Lookup_Thread' : different types for formal and actual parameter 1
..\..\src\debug.c(21) : error C2275: 'real' : illegal use of this type as an expression
..\..\src\debug.c(21) : error C2146: syntax error : missing ';' before identifier 'moment'
..\..\src\debug.c(21) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(21) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(21) : error C2065: 'cg' : undeclared identifier
..\..\src\debug.c(21) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(21) : error C2065: 'force' : undeclared identifier
..\..\src\debug.c(21) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(23) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(23) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
..\..\src\debug.c(23) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 1
..\..\src\debug.c(23) : error C2065: 't_object' : undeclared identifier
..\..\src\debug.c(23) : warning C4047: 'function' : 'Thread *' differs in levels of indirection from 'int'
..\..\src\debug.c(23) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 2
..\..\src\debug.c(23) : error C2065: 'cg' : undeclared identifier
..\..\src\debug.c(23) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(23) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 3
..\..\src\debug.c(23) : error C2065: 'force' : undeclared identifier
..\..\src\debug.c(23) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(23) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 4
..\..\src\debug.c(23) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(23) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(23) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 5
..\..\src\debug.c(24) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(24) : error C2109: subscript requires array or pointer type
..\..\src\debug.c(25) : error C2065: 'd' : undeclared identifier
..\..\src\debug.c(25) : warning C4047: 'function' : 'Domain *' differs in levels of indirection from 'int'
..\..\src\debug.c(25) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 1
..\..\src\debug.c(25) : error C2065: 't_object2' : undeclared identifier
..\..\src\debug.c(25) : warning C4047: 'function' : 'Thread *' differs in levels of indirection from 'int'
..\..\src\debug.c(25) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 2
..\..\src\debug.c(25) : error C2065: 'cg' : undeclared identifier
..\..\src\debug.c(25) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(25) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 3
..\..\src\debug.c(25) : error C2065: 'force' : undeclared identifier
..\..\src\debug.c(25) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(25) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 4
..\..\src\debug.c(25) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(25) : warning C4047: 'function' : 'real *' differs in levels of indirection from 'int'
..\..\src\debug.c(25) : warning C4024: 'Compute_Force_And_Moment' : different types for formal and actual parameter 5
..\..\src\debug.c(26) : error C2065: 'moment' : undeclared identifier
..\..\src\debug.c(26) : error C2109: subscript requires array or pointer type
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Old   November 18, 2022, 00:34
Default
  #7
Senior Member
 
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34
AlexanderZ will become famous soon enoughAlexanderZ will become famous soon enough
Code:
#include "udf.h"

real current_dt;
real omega_old;
real omega_new;
real moment_z;
real moment_z2;
real moment_R;
static real I = 0.0275; /* Moment of inertia */
static real alpha = 0.00626;
static real omega_prev = -128.0;

DEFINE_ZONE_MOTION(rotational_motion1,omega,axis,origin,velocity,time,dtime)
{
	#if !RP_HOST
		Domain *d;
		Thread *t_object,*t_object2;
		real moment[ND_ND], cg[ND_ND], force[ND_ND];
		d =Get_Domain(1);
		Message0("Begin udf1");
		omega_prev = omega[2];
		Message0("Omega_old1 is %g",omega_prev);
		t_object = Lookup_Thread(d, 13);
		t_object2 = Lookup_Thread(d, 14);
		Compute_Force_And_Moment(d, t_object, cg, force, moment, TRUE);
		moment_z= moment[2]; 
		Compute_Force_And_Moment(d, t_object2, cg, force, moment, TRUE);
		moment_z2= moment[2]; 
		/* Equation of motion */
		moment_R = moment_z + moment_z2;
		omega_prev += ((1/I) * (moment_R- (alpha * omega_prev)));
		Message0("Omega_new1 is %g",omega_prev);
		omega[2] = omega_prev;
		origin[0]= 0.0;
		origin[1]= 0.325;
		origin[2]= 0.0;
		N3V_D(axis,=,0.0,0.0,1.0); 
	#endif
	return;
}
__________________
best regards


******************************
press LIKE if this message was helpful
AlexanderZ is offline   Reply With Quote

Reply

Tags
rotating domain, udf


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
udf for one dimensional linear motion based on force maccheese Fluent UDF and Scheme Programming 2 September 1, 2019 03:18
Fluent do not use my velocity field(by UDF) to solve energy equation tangleiplus Fluent UDF and Scheme Programming 6 January 21, 2019 22:28
UDF velocity inlet. Different values (compile - Fluent) asking FLUENT 0 July 13, 2018 18:02
adapt viscous resistance based on velocity / UDF Häwimeddel FLUENT 2 April 20, 2009 11:08
UDF For Angular velocity for gear pump Mustafa Ayad FLUENT 0 December 30, 2008 03:52


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