CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to define the list of vector when a vector has n components (http://www.cfd-online.com/Forums/openfoam/108544-how-define-list-vector-when-vector-has-n-components.html)

fumiya October 26, 2012 00:58

How to define the list of vector when a vector has n components
 
Hi,

I can define the list of vector by the following
when a vector has "three" components:

label Np = mesh.points().size();
List<vector> N(Np, vector::zero);

What should I do if I want to define the list of
vector when a vector has "n" components(n: positive integer)?

Best regards,
Fumiya

ngj October 26, 2012 04:10

Good morning Fumiya

You could do the following

Code:

List<scalarField> var( size_0 );

forAll( var, vari )
{
    scalarField & v( var[vari] );
    v.setSize( size_1, 0.0);

    // Fill the scalarField with its content
}

You could also do the same with vectorField, tensorField, pointField, labelList, etc.

Kind regards,

Niels


All times are GMT -4. The time now is 10:41.