|
[Sponsors] |
April 28, 2012, 06:57 |
Lookup transportproperties from BC
|
#1 |
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 16 |
Hi,
I am currently adapting the dynamicAlphaContactAngle BC and I want to access transportProperties. I found online (http://albertopassalacqua.com/?p=947) that the following piece of code should take care of that: Code:
// Extract the dictionary from the database const dictionary& transportProperties = db().lookupObject<IOdictionary> ( "transportProperties" ); // Exctract subdictionary from the main dictionary dictionary mySubDict ( transportProperties.subDict("mySubDict") ); // Extracting scalar value dimensionedScalar myScalar(mySubDict.lookup("myScalar")); Code:
/fhome/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/objectRegistryTemplates.C: In member function `const Type& Foam::objectRegistry::lookupObject(const Foam::word&) const [with Type = Foam::IOdictionary]':newDynAngleFvPatchScalarField.C:153: instantiated from here /fhome/OpenFOAM/OpenFOAM-1.7.1/src/OpenFOAM/lnInclude/objectRegistryTemplates.C:130: error: cannot dynamic_cast `(const Foam::Time*)((const Foam::objectRegistry*)this)->Foam::objectRegistry::time_' (of type `const struct Foam::Time*') to type `const class Foam::objectRegistry*' (source is a pointer to incomplete type) make: *** [Make/linux64GccDPOpt/newDynAngleFvPatchScalarField.o] Error 1 Last edited by michielm; April 28, 2012 at 11:37. |
|
April 29, 2012, 02:07 |
|
#2 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
Hi Michiel,
I have the code compiling in one of the boundary conditions I implemented (posted below as example). I think the error is somewhere else Code:
const dictionary& transportProperties = db().lookupObject<IOdictionary> ( "transportProperties" ); const dictionary& kineticTheoryProperties = db().lookupObject<IOdictionary> ( "kineticTheoryProperties" ); dictionary phaseaDictionary ( transportProperties.subDict("phasea") ); dimensionedScalar rhoa(phaseaDictionary.lookup("rho")); Best,
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. Last edited by alberto; April 29, 2012 at 02:07. Reason: removed redundant signature |
|
April 29, 2012, 04:11 |
|
#3 |
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 16 |
Hi Alberto,
Thanks for the quick response. If I comment out this piece of code, the library compiles as it should (and can be used with interFoam). So maybe there is something earlier in my code that has a weird interaction with the lookup piece? Anyway, the rest of the member functions section (which is the only part I touched), is added below: Code:
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::tmp<Foam::scalarField> Foam::newDynAngleFvPatchScalarField::theta ( const fvPatchVectorField& Up, const fvsPatchVectorField& nHat ) const { if (uTheta_ < SMALL) { return tmp<scalarField>(new scalarField(size(), theta0_)); } const vectorField nf(patch().nf()); // Calculated the component of the velocity parallel to the wall vectorField Uwall(Up.patchInternalField() - Up); Uwall -= (nf & Uwall)*nf; // Find the direction of the interface parallel to the wall vectorField nWall(nHat - (nf & nHat)*nf); // Normalise nWall nWall /= (mag(nWall) + SMALL); // Calculate Uwall resolved normal to the interface parallel to // the interface scalarField uwall(nWall & Uwall); // MM: Define result as a new 0 scalarField to fill with the new theta later on scalarField& result = *new scalarField(uwall.size(),scalar(0)); // MM: IMPORTANT: theta0_ is in degrees! Therefore: define pi and // use that to recalculate theta0_ scalar pi(4.*atan(1.)) ; scalar theta0_rad(theta0_/180.0*pi); 152 //MM: trying to access transport properties for the value of nu 153 const dictionary& transportProperties = db().lookupObject<IOdictionary>("transportProperties"); 155 // Exctract subdictionary from the main dictionary 156 dictionary mySubDict 157 ( 158 transportProperties.subDict("phase1") 159 ); 161 // Extracting scalar value 162 dimensionedScalar myScalar(mySubDict.lookup("nu")); 164 Info << "this should be nu:" << myScalar << endl; //MM: loop over all uwall[i], because power of scalarField is not allowed // i checked with Matlab that the implementation yields the correct numerical answers forAll(uwall,i) { result[i] = 180.0/pi*pow(max(pow(theta0_rad,3.0)-40.6098*uwall[i],0),1./3.); } //MM: The original equation // return theta0_ + (thetaA_ - thetaR_)*tanh(uwall/uTheta_); //MM: Return of the new calculation return result; } Is there any change that it is a version issue?! I'm using OF-1.7.1 (as you might have seen already in the error message) Cheers, Last edited by michielm; April 29, 2012 at 04:27. Reason: Additional suggestion |
|
April 29, 2012, 04:53 |
|
#4 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
I modified the BC in ~/OpenFOAM/OpenFOAM-2.1.x/src/transportModels/twoPhaseInterfaceProperties/alphaContactAngle/dynamicAlphaContactAngle/ including your exact lines of code, and it compiles. I am not sure what's going on in your code.
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
April 29, 2012, 07:48 |
|
#5 |
Member
Michiel
Join Date: Oct 2010
Location: Delft, Netherlands
Posts: 97
Rep Power: 16 |
Thanks for trying that!
Since the newDynContactAngle was a separately compiled library (copied from the dynamicAlphaContactAngle) I decided to try putting the piece of code directly in the dynamicAlphaContactAngle.C file and recompile it. Just to see whether I messed up when copying and recompiling the new library. Probably I didn't, because I get the same error message again. So either my openfoam installation has some error somewhere, or there is a difference between 1.7.1 and 2.1.x that causes the problem. I think I'll switch to 2.1.x. In both cases I mention above I have to recompile OpenFOAM so I might as well. I haven't done much custom coding yet so working with the newest version will help me in the future anyway. Thanks again for the help, it's much appreciated! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
transportProperties: CrossPowerLawCoeffs...? | klausb | OpenFOAM Running, Solving & CFD | 2 | March 25, 2016 15:45 |
Dynamic Viscosity at transportproperties dictionary | NickolasPl | Main CFD Forum | 0 | June 2, 2011 15:06 |
Convergence on anisotropic tetahedral meshes | pbo | OpenFOAM Running, Solving & CFD | 12 | December 14, 2010 12:59 |
Error with 'vanAlbada' scheme | Julian K. | OpenFOAM Running, Solving & CFD | 0 | June 18, 2009 10:31 |
Buoyancydriven cavity flow | anita | OpenFOAM Running, Solving & CFD | 3 | March 26, 2008 11:24 |