michielm |
October 18, 2012 04:56 |
lookup alpha1 from boundary patch
Hi,
I am trying to read the value of alpha1 in the boundary cells to apply it in a boundary condition, but until now I am unsuccesful. I have tried two different routes, both resulting in compilation errors.
The first thing I tried was to acces the mesh and extract alpha1 from it like this
Code:
const fvMesh& mesh = patch().boundaryMesh().mesh();
const volScalarField& alpha1 = mesh.lookupObject<volScalarField>("alpha1");
but this resulted in this massive error message
Code:
CAHCoxVoinovAngleFvPatchScalarField.C: In member function ‘virtual Foam::tmp<Foam::Field<double> > Foam::CAHCoxVoinovAngleFvPatchScalarField::theta(const Foam::fvPatchVectorField&, const Foam::fvsPatchVectorField&) const’:
CAHCoxVoinovAngleFvPatchScalarField.C:145: warning: unused variable ‘alpha1’
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C: In member function ‘const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]’:
CAHCoxVoinovAngleFvPatchScalarField.C:146: instantiated from here
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:104: error: cannot dynamic_cast ‘iter.Foam::HashTable<T, Key, Hash>::const_iterator::operator() [with T = Foam::regIOobject*, Key = Foam::word, Hash = Foam::string::hash]()’ (of type ‘class Foam::regIOobject* const’) to type ‘const struct Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>*’ (target is not pointer or reference to complete type)
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:111: error: incomplete type ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’ used in nested name specifier
CAHCoxVoinovAngleFvPatchScalarField.C:146: instantiated from here
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:128: error: incomplete type ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’ used in nested name specifier
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:128: error: incomplete type ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>’ used in nested name specifier
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/typeInfo.H: In function ‘bool Foam::isA(const Type&) [with TestType = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>, Type = Foam::regIOobject]’:
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:40: instantiated from ‘Foam::wordList Foam::objectRegistry::names() const [with Type = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]’
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:128: instantiated from ‘const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>]’
CAHCoxVoinovAngleFvPatchScalarField.C:146: instantiated from here
/opt/apps/openfoam-2.1.0//OpenFOAM-2.1.0/src/OpenFOAM/lnInclude/typeInfo.H:136: error: cannot dynamic_cast ‘(const Foam::regIOobject*)t’ (of type ‘const class Foam::regIOobject*’) to type ‘const struct Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>*’ (target is not pointer or reference to complete type)
make: *** [Make/linux64GccDPOpt/CAHCoxVoinovAngleFvPatchScalarField.o] Error 1
Then a colleague suggested to use 'lookupPatchField' instead, like this:
Code:
const fvPatchField<scalar>& alpha1 = patch().lookupPatchField<volScalarField, scalar>("alpha1");
but alpha1 doesn't seem to exist in the patchField:
Code:
CAHCoxVoinovAngleFvPatchScalarField.C: In member function ‘virtual Foam::tmp<Foam::Field<double> > Foam::CAHCoxVoinovAngleFvPatchScalarField::theta(const Foam::fvPatchVectorField&, const Foam::fvsPatchVectorField&) const’:
CAHCoxVoinovAngleFvPatchScalarField.C:150: error: no matching function for call to ‘Foam::fvPatch::lookupPatchField(const char [7]) const’
CAHCoxVoinovAngleFvPatchScalarField.C:149: warning: unused variable ‘alpha1’
make: *** [Make/linux64GccDPOpt/CAHCoxVoinovAngleFvPatchScalarField.o] Error 1
Could someone please explain what is wrong in the two strategies above, or explain to me what the correct way of looking up alpha1 is?!
|