|
[Sponsors] |
August 8, 2018, 10:37 |
simple question about OpenFoam matrix class
|
#1 |
Senior Member
|
Hello,
I have one simple question about OpenFoam matrix class. In it's definition, the function 'allocate' says: Code:
void Foam::Matrix<Form, Type>::allocate() { if (n_ && m_) { v_ = new Type*[n_]; v_[0] = new Type[n_*m_]; for (register label i=1; i<n_; i++) { v_[i] = v_[i-1] + m_; } } } Code:
v_[0] = new Type[n_*m_]; Code:
v_ = new Type*[n_]; Why not doing something like: Code:
v_ = new Type * [n_]; for(i=0; i<n_;++i) v_[i] = new Type [m_]; |
|
August 9, 2018, 03:47 |
|
#2 |
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28 |
My guess is that two memory allocations
Code:
v_ = new Type*[n_]; v_[0] = new Type[n_*m_]; Code:
v_ = new Type * [n_]; for(i=0; i<n_;++i) v_[i] = new Type [m_]; The way it is implemented Code:
void Foam::Matrix<Form, Type>::allocate() { if (n_ && m_) { v_ = new Type*[n_]; v_[0] = new Type[n_*m_]; for (register label i=1; i<n_; i++) { v_[i] = v_[i-1] + m_; } } } |
|
August 10, 2018, 21:53 |
|
#3 | |
Senior Member
|
Quote:
I still don't get it. With this one Code:
v_[0] = new Type[n_*m_]; |
||
Tags |
matrix, openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Map of the OpenFOAM Forum - Understanding where to post your questions! | wyldckat | OpenFOAM | 10 | September 2, 2021 06:29 |
OpenFOAM v3.0+ ?? | SBusch | OpenFOAM | 22 | December 26, 2016 15:24 |
How to rewrite a standard OpenFOAM solver as a C++ class | cfbaptista | OpenFOAM Programming & Development | 7 | March 23, 2016 05:50 |
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 07:25 |
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug | unoder | OpenFOAM Installation | 11 | January 30, 2008 21:30 |