|
[Sponsors] |
Accessing fields and dictionaries from within a BC implementation |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 5, 2005, 16:09 |
How can a field defined in the
|
#1 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
How can a field defined in the solver code be accessed from within the code of a boundary condition?
As explained here http://www.cfd-online.com/OpenFOAM_D...tml?1133622442, I'm trying to add Johnson and Jackson's BCs to the twoPhaseEulerFoam solver, but I can't have access to the solver fields. I get the error: /*---------------------------------------------------------------------------*\ | ========= | | | \ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \ / O peration | Version: 1.2 | | \ / A nd | Web: http://www.openfoam.org | | \/ M anipulation | | \*---------------------------------------------------------------------------*/ Exec : twoPhaseEulerFoam . Rhodes2D Date : Dec 05 2005 Time : 21:06:15 Host : dimension4400 PID : 13204 Root : /home/alberto/OpenFOAM/alberto-1.2/run/FluidBeds Case : Rhodes2D Nprocs : 1 Create time Create mesh for time = 0 Reading environmentalProperties Reading transportProperties --> FOAM FATAL ERROR : request for volScalarField alpha from objectRegistry region0 failed available objects of type volScalarField are 0 ( ) From function objectRegistry::lookupObject<type>(const word&) const in file /home/dm2/henry/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/objectRegistryTempl ates.C at line 122. FOAM aborting I try to read the alpha field as follows: const fvPatchField<scalar>& alpha = lookupPatchField<volScalarField, scalar > ( "alpha" ); Also, how can I have access to the kineticTheoryProperties dictionary from the BC code? I get an error message which tells me the dictionary can't be found if I try to read from it. Thanks in advance, Alberto
__________________
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. |
|
July 16, 2010, 04:29 |
|
#2 | |||||
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hi Alberto,
I had a similar problem: if you want to access the kineticTheoryProperties from the constant folder you can get it by Quote:
Quote:
Quote:
otherwise, the whole mesh vol<Type>Field can be read by eg. Quote:
Quote:
|
||||||
July 16, 2010, 10:24 |
|
#3 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
Goodness, no! Do NOT create a mesh every time you want to access something related to it..
You can access the objectRegistry using the fvPatch db() function: Code:
template<class Type> const Foam::objectRegistry& Foam::fvPatchField<Type>::db() const { return patch_.boundaryMesh().mesh(); } |
|
July 16, 2010, 10:56 |
|
#4 | ||
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hey Sandeep,
Thanks for your advice... I already realized it but did it like: Quote:
Quote:
Tobi |
|||
July 16, 2010, 11:05 |
eaxmple
|
#5 |
Member
Andrea Petronio
Join Date: Mar 2009
Location: Trieste, Italy
Posts: 43
Rep Power: 17 |
Hi,
this should be an example: Code:
const dimensionedScalar& readNu = db().lookupObject<IOdictionary>("transportProperties").lookup("nu"); Abdrea |
|
July 19, 2010, 04:55 |
|
#6 | |
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hi Andrea.
thanks for the quick reply, but there are two things... 1. your code does not work on my BC : Quote:
2. I don't want to read a dictionary IO but call a member function called Cp().... thx altough... my version works anyway... |
||
July 26, 2010, 18:47 |
Reading alpha and alphaEff
|
#7 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Hello everyone. I have a similar question to what has being asked. I think mine is easier to answer . Well, I am writing a post-processor to an LES simulation I performed and I am trying to read the thermal diffusivity and effective-thermal diffusivity, alpha and alphaEff. Is what I am doing correct:
IOdictionary LESProperties ( IOobject ( "LESProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionScalar alphaEff ( LESProperties.lookup("alphaEff") ); dimensionScalar alpha ( LESProperties.lookup("alpha") ); |
|
July 26, 2010, 18:51 |
|
#8 |
Senior Member
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 17 |
Hello everyone. I have a similar question. I am trying to write a post-processor and I need the values from the LESProperties and thermophysicalProperties, and I am not sure if the code I have here is correct. I am just working my way around OpenFOAM and trying to get comfortable with the code. Thanks.
// Read LESProperties & thermophysicalProperties IOdictionary LESProperties ( IOobject ( "LESProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ) ); dimensionScalar alphaEff ( LESProperties.lookup("alphaEff") ); dimensionScalar alpha ( LESProperties.lookup("alpha") ); |
|
September 14, 2010, 11:14 |
|
#9 |
New Member
Ozgur Kirlangic
Join Date: May 2009
Location: Istanbul
Posts: 16
Rep Power: 17 |
Hello,
I have got a question about the "use of IOdictionary for this purpose".. Does this mean that at every time step when the boundary condition is updated (or called), a disk I/O operation is performed for the value of "nu" ?? Does the name "IOdictionary" stand for that?? It is very important for me. Thank you, Ozgur |
|
January 4, 2011, 08:08 |
Access Data from same bc but different parameter
|
#10 |
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Hi All!
New Year, new problems, i am trying to figure out how to access a variable from a different parameter for the same patch at each timestep e.g., read the amplitude and frequency values from the velocity oscillatingFixedValue BC at the current time step and use them as input parameters for the pressure boundary condition. So far I manage to get: Code:
//load the internal velocity field const GeometricField<vector, fvPatchField, volMesh>& Ufield = this->db().objectRegistry:: lookupObject<GeometricField<vector, fvPatchField, volMesh> > ( "U" ); label patchi=this->patch().index(); Info << "Ufield Boundary" << Ufield.boundaryField()[patchi] << endl; Looking forward for quick reply... Tobias
__________________
Tobias Holzinger Chair of Thermodynamics, TU München |
|
January 7, 2011, 08:36 |
|
#11 | |
Member
Tobias Holzinger
Join Date: Mar 2009
Location: Munich, Germany
Posts: 46
Rep Power: 17 |
Quote:
Sorry I can't handle your code ... can you give a more detailed example?
__________________
Tobias Holzinger Chair of Thermodynamics, TU München |
||
December 6, 2011, 08:39 |
|
#12 |
Member
Rob
Join Date: Sep 2011
Posts: 55
Rep Power: 15 |
I have a similar problem.
In every loop I write out a constant scalar to "scalarDict" which is inside of the constant directory. The entry for the scalar is: fluxIn 0.21; Now I want to import this value and assign it to a boundary condition, e.g. flowRateInletvelocity. However, this does not work with any of the above posted hints. scalarDict is of type "IOdictionary" and is located in "createFields.H". The scalarDict.set(name, value) is inside the "solver.C" file. Compiling the solver via "wmake" works well without any error message. So, what kind of "lines" do I have to put inside my "U" file to successfully import the flowRate I need for my BC? Any kind of help would be appreciated. |
|
December 6, 2011, 10:30 |
|
#13 |
Member
Rob
Join Date: Sep 2011
Posts: 55
Rep Power: 15 |
Alright, I fixed it myself.
Since the scalarDict is updated on every timestep ( the value is just overwritten ). How can I manage to reload the value in my BC? For now the BC flowRate value is 3.8E-05 (the starting value) all the time. So it is not updated... |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
RhoSimpleFoam tutorial test case system dictionaries | flavio_pergolesi | OpenFOAM Running, Solving & CFD | 2 | April 17, 2014 09:41 |
Using wildcards regexes in dictionaries | chtrapp | OpenFOAM Pre-Processing | 4 | July 18, 2012 12:37 |
Passing parameters from dictionaries | ngj | OpenFOAM Running, Solving & CFD | 0 | June 29, 2008 12:25 |
Thermo dictionaries | grtabor | OpenFOAM Running, Solving & CFD | 0 | July 7, 2005 14:07 |
Dictionaries written by FoamX | Mattijs Janssens (Mattijs) | OpenFOAM Pre-Processing | 1 | January 3, 2005 14:44 |