CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Programming & Development

Defining a Matrix in OpenFOAM-1.6-ext

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

Like Tree3Likes
  • 2 Post By wyldckat
  • 1 Post By Daniel_Khazaei

Reply
 
LinkBack Thread Tools Display Modes
Old   October 21, 2013, 11:33
Default Defining a Matrix in OpenFOAM-1.6-ext
  #1
Senior Member
 
Daniel
Join Date: Mar 2013
Posts: 172
Rep Power: 9
Daniel_Khazaei will become famous soon enough
Hello foamers


I am trying to define a Matrix in my OpenFOAM solver but I have a few problems.
I try to describe my problem with an example:

Assuming I want to define a Matrix in the solver, this is what I do:

Matrix<scalar> A(n, m, 0.0);

Now when I want to compile the solver, it gives me the following error:

Code:
setInterfaceDisplacement.H:98: error: wrong number of template arguments (1, should be 2)
/opt/OpenFOAM/OpenFOAM-1.6-ext/src/OpenFOAM/lnInclude/Matrix.H:54: error: provided for ‘template<class Form, class Type> class Foam::Matrix’
I can understand that I need to add one more argument in declaration, but I don't know what does "class Form" mean?


regards
Daniel_Khazaei is offline   Reply With Quote

Old   November 26, 2013, 11:45
Default
  #2
New Member
 
Camille Bilger
Join Date: Jul 2013
Posts: 15
Rep Power: 3
kmou is on a distinguished road
Hi,

I am encountering the same problem and would be grateful if you could share how you resolved this problem. Thank you very much.
kmou is offline   Reply With Quote

Old   November 26, 2013, 18:11
Default
  #3
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,251
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings to all!

Actually, while I was tracking kmou's posts, this previous thread gave the hint: http://www.cfd-online.com/Forums/ope...t-compile.html
The solution seems to be to use "scalarSquareMatrix" instead of "Matrix<scalar>".

A bit more explanation:
  1. The definition of "scalarSquareMatrix" is made in the file "src/OpenFOAM/matrices/scalarMatrices/scalarSquareMatrix.H", where it defines the class based on the "SquareMatrix" template:
    Code:
    class scalarSquareMatrix
    :
        public SquareMatrix<scalar>
  2. The template class "SquareMatrix" is defined in the file "src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.H", as follows:
    Code:
    template<class Type>
    class SquareMatrix
    :
        public Matrix<SquareMatrix<Type>, Type>
    Namely, said "class Form" is "SquareMatrix<Type>" in this case... pretty confusing template voodoo, isn't it?
Either way, the quick solution is indicated in the post #3 at the aforementioned thread .

Best regards,
Bruno
hua1015 and Daniel_Khazaei like this.
wyldckat is offline   Reply With Quote

Old   November 27, 2013, 12:46
Default
  #4
Senior Member
 
Daniel
Join Date: Mar 2013
Posts: 172
Rep Power: 9
Daniel_Khazaei will become famous soon enough
thanks for the suggestion...

I had resolved that issue a few weeks ago. I have changed the declaration as follow:

Matrix <scalarField,scalar> A (n,m)

---------


squareScalarMatrix is working fine on square matrices but how can I define a matrix with one column or one row?

like this one:

Matrix <scalarField,scalar> A (n,1) or A (1,n)

-------

OK I have fixed the last one by using rectangular matrix
Daniel_Khazaei is offline   Reply With Quote

Old   November 27, 2013, 14:26
Default
  #5
Senior Member
 
Daniel
Join Date: Mar 2013
Posts: 172
Rep Power: 9
Daniel_Khazaei will become famous soon enough
Quote:
Originally Posted by kmou View Post
Hi,

I am encountering the same problem and would be grateful if you could share how you resolved this problem. Thank you very much.
you need to add the following headers to your program:

#include "scalarSquareMatrix.H" --->> for square type matrix

if you want to define a square matrix: A (n,n) and initiate it with 0

scalarSquareMatrix A(n, 0.0);


#include "RectangularMatrix.H" ---->> for rectangular matrix

if you want to define a rectangular matrix: A (n,m)

RectangularMatrix <scalar> A(n,m);
wyldckat likes this.
Daniel_Khazaei is offline   Reply With Quote

Old   December 2, 2013, 06:06
Default
  #6
New Member
 
Camille Bilger
Join Date: Jul 2013
Posts: 15
Rep Power: 3
kmou is on a distinguished road
Thank you Daniel and Bruno for your replies.
So new classes of matrices have been created, such as SquareMatrix and RectangularMatrix, which effectively correspond do the "Form" that is required. Thus, for each Matrix<scalar> that I have, I will need to make a decision as to if it is a Square matrix, or a Rectangular matrix or Diagonal matrix etc...
kmou is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solver Compiling error - OF 1.6 ext. raditz OpenFOAM Programming & Development 8 November 4, 2012 10:53
OpenFOAM 1.6 and 1.7 with interFoam, groovyBC give different strange results Arnoldinho OpenFOAM 7 December 9, 2010 17:29
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25
Cross-compiling OpenFOAM 1.6 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 7 January 19, 2010 16:39
OpenFOAM version 1.6 details lakeat OpenFOAM Running, Solving & CFD 42 August 26, 2009 21:47


All times are GMT -4. The time now is 04:42.