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

Matrix initialization/definition

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 16, 2014, 12:54
Default Matrix initialization/definition
  #1
Senior Member
 
Gonzalo
Join Date: Mar 2011
Location: Argentina
Posts: 122
Rep Power: 16
gfoam is on a distinguished road
Hi everybody:
I'm writing a UDF to calculate the aerodynamic forces over a structure, but as it has a lot of patches the tool Report ==>Forces is very tricky, so I'm writing this UDF. One of the inputs is the direction in wich the force is calculated, and there are several direction for that so I storage them in a two dimansional array. The problem is that when I try to compile the code I get the following error message:
Error: C:/Users/...: line 10: invalid type conversion: float -> array 3 of double

The statement where I try to initialize/define the matrix is the following:
real direction [2] [3]={{0.0, -0.12187, 0.992546}, {0.0, 0.0, 1.0}};

Could anybody tell me if I'm doing something wrong with that line of the UDF.
PS: That statement is the line 10. Thanks
Gonzalo

Last edited by gfoam; July 16, 2014 at 14:21.
gfoam is offline   Reply With Quote

Old   July 17, 2014, 02:36
Default
  #2
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
There is nothing wrong with the udf itself. However, the multidimensional array is not supported by interpreted udf. So you should either compile your udf, or use one dimensional array instead.
blackmask is offline   Reply With Quote

Old   July 17, 2014, 07:32
Default
  #3
Senior Member
 
Gonzalo
Join Date: Mar 2011
Location: Argentina
Posts: 122
Rep Power: 16
gfoam is on a distinguished road
OK, thank you for your response. Then I will try to compile it, or I will see if I can use a 1D array. Regards.
Gonzalo
gfoam is offline   Reply With Quote

Old   July 17, 2014, 21:04
Default
  #4
Senior Member
 
Join Date: Aug 2011
Posts: 421
Blog Entries: 1
Rep Power: 22
blackmask will become famous soon enough
You can define "direction" as an one-dimensional array and introduce some macro like
Code:
#define xxx(i, j) direction[i*3+j]
then you can use
Code:
xxx(i, j)
in place of
Code:
direction[i][j]
in your original code.
blackmask is offline   Reply With Quote

Old   July 21, 2014, 12:28
Default
  #5
Senior Member
 
Gonzalo
Join Date: Mar 2011
Location: Argentina
Posts: 122
Rep Power: 16
gfoam is on a distinguished road
Thank you, that's what I have done more o less, I didn't use a macro, but I did something similar to this:
direction[i*3+j]

to access the data storaged in a 1D array thinking it as a 2D array. But, than you so much for your help. Regards
Gonzalo
gfoam is offline   Reply With Quote

Reply


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
Matrix addressing maybee OpenFOAM Programming & Development 10 August 1, 2020 08:55
inverse of a matrix or solution of implicit equation romant OpenFOAM Programming & Development 4 August 6, 2013 10:02
more equation in block matrix system yhaomin2007 OpenFOAM 1 September 6, 2012 09:33
Force can not converge colopolo CFX 13 October 4, 2011 23:03
Elemtary matrix to CSR global matrix xueying Main CFD Forum 2 September 24, 2002 10:44


All times are GMT -4. The time now is 12:15.