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

Combining 2 scalarList into scalarListList?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 30, 2013, 07:33
Default Combining 2 scalarList into scalarListList?
  #1
CKH
New Member
 
Kie Hian
Join Date: Aug 2011
Location: Singapore
Posts: 19
Rep Power: 14
CKH is on a distinguished road
Dear foamers,

This might be more of a C++ question...

I've got a function that is supposed to return List that is made up of 2 scalarLists, i.e. scalarListList dsf(2) whereby dsf[0] = scalarList dsf0 and dsf[1] = scalarList dsf1

My code extract is as follows:
Code:
scalarListList testMesh::calcDSF
(
    const scalar xi_ ,
    const scalar eta_
) const
{
    Info<<"Calculating shape functions derivatives"<<endl;

    scalarList dSfdXi(8);
    scalarList dSfdEta(8);
    scalarListList dsf(2);

    // calculate shape func derivative wrt to Xi: dSfdXi
    dSfdXi[0] =  ....................
    ........
    dSfdXi[7] = ........................;

    // calculate shape func derivative wrt to eta: dSfdEta
    dSfdEta[0] = ...............;
    ..............
    dSfdEta[7] = ............;

    dsf[0] = dSfdXi;
    dsf[1] = dSfdEta;

    return dsf;
}
The above code compiles but stops halfway when run.....I believe it has to do with the allocation of memory because by tweaking the order of scalarList / scalarListList initialization, the code runs to different points.

My objective is to create a 2 x 8 matrix where the 1st column stores the dSfdXi values and the 2nd column the dSfdEta values (for calculating jacobian, transforming to parametric coordinates).

Any ideas or alternative implementation (instead of using OF's Lists) would be much appreciated!

Thanks!

ckh
CKH is offline   Reply With Quote

Old   May 30, 2013, 09:39
Default
  #2
CKH
New Member
 
Kie Hian
Join Date: Aug 2011
Location: Singapore
Posts: 19
Rep Power: 14
CKH is on a distinguished road
Doing a more thorough search through the forums, I believe an autoPtr might be needed, i.e.

Code:
List< autoPtr<scalarList> > dsf(2);

dsf[0].setSize(8);
dsf[0][0] = /* some code to calculate each of the dSfdXi...
...
dsf[0][7] = .... */

dsf[1].setSize(8);
dsf[1][0] = /* some more code  to calculate each of the dSfdEta...
...
dsf[1][7] = .... */
Any ideas / comments would be much appreciated!!

Thanks in advance!

ckh
CKH 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
Combining CFD-Post Report Information fatirishman53 ANSYS 0 October 14, 2012 14:59
[blockMesh] A script for combining two blockMeshDict yingfeng OpenFOAM Meshing & Mesh Conversion 0 August 26, 2009 16:05
combining dynamic mesh functions sean_mcintyre OpenFOAM Running, Solving & CFD 0 August 3, 2009 14:52
Combining BCs: wall - outlet. Boundary layer disappears MartinaF OpenFOAM Running, Solving & CFD 1 July 20, 2009 18:14
Combining Transient results after a backup Dre CFX 9 February 18, 2008 08:43


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