CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   PtrList error while trying to define an array of volScalarFields (

adhiraj February 13, 2012 17:49

PtrList error while trying to define an array of volScalarFields
Hi all,
I am trying to implement a model where I need to solve for a number of (3 or 6, depending on the case setup) transport equations. I thought of using a PtrList for this. I followed what is being done in

for the variable Y.
However, when I add the line

PtrList<volScalarField> Moments_;
in the header file, and the following in the constructor initializer list:

I get the following on compiling:

/home/adhiraj/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/PtrList.C: In copy constructor ‘Foam::PtrList<T>::PtrList(const Foam::PtrList<T>&) [with T = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]’:
MOMIC/MOMIC.H:62:7: instantiated from here
/home/adhiraj/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/PtrList.C:54:9: error: invalid conversion from ‘Foam:: DimensionedField<double, Foam::volMesh>*’ to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>*’ [-fpermissive]
make: *** [Make/linux64GccDPOpt/MOMIC.o] Error 1
nMoments_ is of type const label, and it is defined and initialized before Moments_.
Any ideas what is wrong here?

adhiraj February 15, 2012 13:27

I don't understand why the copy constructor is being called at all.
It seems that the same method works in some classes, and that makes it very confusing.

adhiraj February 15, 2012 18:26

I was trying to create a new instance of the object with "new", and that was the problem.

All times are GMT -4. The time now is 03:56.