
[Sponsors] 
October 21, 2013, 11:33 
Defining a Matrix in OpenFOAM1.6ext

#1 
Senior Member
Daniel
Join Date: Mar 2013
Posts: 219
Rep Power: 14 
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/OpenFOAM1.6ext/src/OpenFOAM/lnInclude/Matrix.H:54: error: provided for ‘template<class Form, class Type> class Foam::Matrix’ regards 

November 26, 2013, 11:45 

#2 
Member
Camille Bilger
Join Date: Jul 2013
Posts: 42
Rep Power: 6 
Hi,
I am encountering the same problem and would be grateful if you could share how you resolved this problem. Thank you very much. 

November 26, 2013, 18:11 

#3 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,020
Blog Entries: 39
Rep Power: 109 
Greetings to all!
Actually, while I was tracking kmou's posts, this previous thread gave the hint: http://www.cfdonline.com/Forums/ope...tcompile.html The solution seems to be to use "scalarSquareMatrix" instead of "Matrix<scalar>". A bit more explanation:
Best regards, Bruno
__________________
Last edited by wyldckat; March 27, 2016 at 04:25. Reason: repaired link 

November 27, 2013, 12:46 

#4 
Senior Member
Daniel
Join Date: Mar 2013
Posts: 219
Rep Power: 14 
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 

November 27, 2013, 14:26 

#5  
Senior Member
Daniel
Join Date: Mar 2013
Posts: 219
Rep Power: 14 
Quote:
#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); 

December 2, 2013, 06:06 

#6 
Member
Camille Bilger
Join Date: Jul 2013
Posts: 42
Rep Power: 6 
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... 

March 23, 2016, 11:19 
Matrix with different dimensions for different elements (kg,m,N,etc)

#7 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 5 
Hi guys i have a problem related to matrices. I have to define and write a matrix in which every element have different dimensions. for example 1st element has dimensions in kilogram 2nd in meters 3rd in second like that. Please guide me how can i do that.


March 27, 2016, 02:50 

#9 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 5 
Thank you. but there should be a way...... coz..........


March 27, 2016, 06:27 

#10 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,020
Blog Entries: 39
Rep Power: 109 
If you had provided an example I could have worked with, it would have be easier/faster for me to figure it out.
Anyway, this is an example of how to do it: Code:
SquareMatrix<dimensionedScalar> hmm(3); hmm[0][0].dimensions().reset(dimLength); hmm[0][0] = dimensionedScalar("cookie1",dimLength,3.0); hmm[0][1] = 10.0; hmm[0][2] = 4.0; hmm[1][0] = 2.0; hmm[1][1] = 3.0; hmm[1][2] = 10.0; hmm[2][0] = 2.0; hmm[2][1] = 6.0; hmm[2][2] = 1.0; 

March 27, 2016, 06:54 

#11 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 5 


March 27, 2016, 09:42 

#13 
Member
Muhammad Usman
Join Date: Feb 2014
Posts: 91
Rep Power: 5 
its matrix for mass in mass damper spring system. actually i am working with some kind of fluid and vehicle dynamics interface. Yes this matrix is gonna be multiplied by a vector


March 27, 2016, 10:04 

#14  
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,020
Blog Entries: 39
Rep Power: 109 
Hi Muhammad,
Quote:
There is a thread explaining how to provide information, so that this kind of vague exchange of information doesn't happen: http://www.cfdonline.com/Forums/ope...gethelp.html Best regards, Bruno 

April 16, 2016, 20:55 

#15  
Senior Member
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 436
Rep Power: 17 
Quote:
Regards!
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D. Research Scientist Research Center for Computational Methods (CIMEC)  CONICET/UNL Tel: 543424511594 Int. 7032 Colectora Ruta Nac. 168 / Paraje El Pozo (3000) Santa Fe  Argentina. http://www.cimec.org.ar Last edited by wyldckat; April 17, 2016 at 10:28. Reason: added quote, because this post was moved from another thread with the same question 

Thread Tools  
Display Modes  


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 
Crosscompiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingww64  wyldckat  OpenFOAM Announcements from Other Sources  3  September 8, 2010 06:25 
Crosscompiling OpenFOAM 1.6 on Linux for Windows 32 and 64bits with Mingww64  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 