CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   multidimensional Field<> (https://www.cfd-online.com/Forums/openfoam-programming-development/92393-multidimensional-field.html)

linch September 13, 2011 07:50

multidimensional Field<>
 
Hi Foamers,

is there an elegant way to declare multimedensional fields? Something similar to a multidimensional array e.g. scalar[n4][n3][n2][n1] my4DArray;

This implementation seems to works, but is really inelegant (please don't laugh to loud at this stupid solution):
Code:

Field <scalar>                              dummy1D(n1,scalar(0.0));
Field <Field <scalar> >                    dummy2D(n2,dummy1D);
Field <Field <Field <scalar> > >            dummy3D(n3,dummy2D);
Field <Field <Field <Field <scalar> > > >  my4DField(n4,dummy3D);

Furthermore there are dummies remaining and soiling the code. Do you have an idea, how n-dimensional fields should be defined?

Best regards,
illya


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