|
[Sponsors] |
October 18, 2012, 04:56 |
lookup alpha1 from boundary patch
|
#1 |
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 15 |
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"); 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 Code:
const fvPatchField<scalar>& alpha1 = patch().lookupPatchField<volScalarField, scalar>("alpha1"); 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 |
|
October 25, 2012, 11:43 |
|
#2 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 17 |
Something like this might work for you:
Code:
//get the patch ID number label patchID = mesh.boundaryMesh().findPatchID("myPatchNameString"); //Lookup the desired alpha values on the patch you want const fvPatchField<scalar>& alphaPatchField = alpha1.boundaryField()[patchID] //local face value access forAll(cPatch,faceI) { scalar patchAlphaValue = alphaPatchField[faceI]; } |
|
October 26, 2012, 03:35 |
|
#3 |
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 15 |
Thanks for the response!
I have tried this, but I get the error that 'alpha1' is not declared in this scope. So before I will be able to use your piece of code I first have to lookup alpha1 from somewhere and that is where it goes wrong. Do you perhaps know how I can look up alpha1 from the mesh or the patch or something like it?! |
|
October 26, 2012, 04:13 |
|
#4 |
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 15 |
I just found out what the issue was: apparently alpha1 should not be read as a volScalarField but as a scalarField. I don't really understand why. But if i use this it works:
Code:
const fvMesh& mesh = patch().boundaryMesh().mesh(); const scalarField& alpha1 = mesh.lookupObject<scalarField>("alpha1"); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] No layers in a small gap | bobburnquist | OpenFOAM Meshing & Mesh Conversion | 6 | August 26, 2015 09:38 |
domain imbalance for enrgy equation | happy | CFX | 14 | September 6, 2012 01:54 |
[Other] StarToFoam error | Kart | OpenFOAM Meshing & Mesh Conversion | 1 | February 4, 2010 04:38 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 06:51 |
[Gmsh] Import gmsh msh to Foam | adorean | OpenFOAM Meshing & Mesh Conversion | 24 | April 27, 2005 08:19 |