|
[Sponsors] |
July 26, 2017, 17:12 |
invalid conversion error
|
#1 |
New Member
Saddam Hijazi
Join Date: May 2016
Posts: 17
Rep Power: 10 |
Hello all, I am having a problem in compiling a piece of code that is the related to the following method :
void reductionProblem::reconstruct_from_matrix(PtrList< volVectorField> rec_field2, PtrList<volVectorField> modes, label Nmodes, Eigen::MatrixXd coeff_matrix) { volVectorField tmp ( IOobject ( "tmp", modes[0].time().timeName(), modes[0].mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), modes[0].mesh(), dimensionedVector("zero", modes[0].dimensions(), vector::zero) ); for (label k = 0; k < coeff_matrix.rows(); k++) { tmp = tmp * 0; for (label i = 0; i < Nmodes; i++) { tmp += coeff_matrix(k, i)*modes[i]; } rec_field2.append(tmp); } } When I compile it, I got this error error: invalid conversion from ‘Foam:imensionedField<Foam::Vector<double>, Foam::volMesh>*’ to ‘Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>*’ [-fpermissive] ptrs_[i] = (a[i]).clone().ptr(); ^ Could you help me please in solving this problem. Thanks in advance. |
|
July 28, 2017, 13:41 |
|
#2 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
Code:
void reductionProblem::reconstruct_from_matrix ( PtrList< volVectorField>& rec_field2, const PtrList<volVectorField>& modes, const label Nmodes, const Eigen::MatrixXd& coeff_matrix ) { for (const label k = 0; k < coeff_matrix.rows(); ++k) { volVectorField* tmp = new volVectorField ( IOobject ( "tmp", modes[0].time().timeName(), modes[0].mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), false, //- I suppose you don't want it to be registered modes[0].mesh(), dimensionedVector("zero", modes[0].dimensions(), vector::zero) ); for (const label i = 0; i < Nmodes; ++i) { *tmp += coeff_matrix(k, i)*modes[i]; } rec_field2.append(tmp); } } |
|
September 21, 2017, 10:02 |
|
#3 |
New Member
ANKUR GARG
Join Date: Mar 2017
Posts: 23
Rep Power: 9 |
I am also getting the same kind of error.
error: invalid conversion from ‘Foam:imensionedField<Foam::Vector<double>, Foam::volMesh>*’ to ‘Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>*’ [-fpermissive] ptrs_[i] = (a[i]).clone().ptr(); I am using std::vector, in which i am trying to push a variable of type PtrList<volScalarField>. The piece of code is here: autoPtr<volScalarField> IDefaultPtr; const label s = nLambda_; PtrList<volScalarField>ILambda(s); forAll(ILambda, lambdaI) { IOobject IHeader ( dfm_intensityPrefix + Foam::name(rayI) + Foam::name(lambdaI), mesh_.time().timeName(), mesh_, IOobject::MUST_READ, IOobject::AUTO_WRITE ); ILambda.set ( lambdaI, new volScalarField(IHeader, mesh_) ); // Check if field exists and can be read if (IHeader.typeHeaderOk<volScalarField>(true)) { ILambda.set ( lambdaI, new volScalarField(IHeader, mesh_) ); } else { // Reset the MUST_READ flag IOobject noReadHeader(IHeader); ILambda.set ( lambdaI, new volScalarField(noReadHeader, IDefaultPtr()) ); } } vec_ILambda_.push_back(ILambda); Where vec_ILambda_ is declared as: std::vector< PtrList<volScalarField> > vec_ILambda_; |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch | gschaider | OpenFOAM Installation | 225 | August 25, 2015 19:43 |
Ansys Fluent 13.0 UDF compilation problem in Window XP (32 bit) | Yogini | Fluent UDF and Scheme Programming | 7 | October 3, 2012 07:24 |
Accessing phi from a fvPatchField at same patch | johndeas | OpenFOAM | 1 | September 13, 2010 20:23 |
checking the system setup and Qt version | vivek070176 | OpenFOAM Installation | 22 | June 1, 2010 12:34 |
Installation OF1.5-dev | ttdtud | OpenFOAM Installation | 46 | May 5, 2009 02:32 |