|
[Sponsors] |
Accessing boundary patch dictionary within thermodynamic library |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 3, 2018, 06:11 |
Accessing boundary patch dictionary within thermodynamic library
|
#1 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi all and dear Foamers,
today I am stuck with a simple problem that I cannot resolve myself even though, I went through Doxgen and so on; actually the problem is related to the fact that I never saw something like that inside the source code . To keep it short. I want to access the boundary dictionary of a patch inside a new thermodynamic library. The field can be accessed easily within my thermodynamic library (I make it very detailed now): Code:
const volScalarField& myField = this->myField_; Code:
//- I get the dictionary of the T-File of the first boundary Info<< myField.boundaryField()[0] << endl; //- I want to get a dictionary of the first boundary in the T-File for further analysis; NOT WORKING const dictionary& foo = myField.boundaryField()[0]; Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 1 0 0 0]; internalField uniform 300; boundaryField { myWalls { type zeroGradient; myNewValue hehehe; } inletTop { type fixedValue; value uniform 305; } . . . .
Thank you in advance,
__________________
Keep foaming, Tobias Holzmann |
|
November 3, 2018, 09:39 |
|
#2 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
After lots of errors, I got an answer
Code:
IOobject T_Header ( "T", this->mesh().time().timeName(), this->mesh(), IOobject::MUST_READ ); IOdictionary T_File(T_Header); scalar abc = readScalar(T_File.subDict("boundaryField").subDict("myWalls").lookup("myNewValue"));
__________________
https://openfoam.top |
|
November 3, 2018, 09:43 |
|
#3 |
Senior Member
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 12 |
Here are some records:
Code:
error: class "Foam::fvPatchField<Foam::scalar={Foam::doubleScalar={double}}>" has no member "name" Info<<T_.boundaryField()[0].name()<<endl; Code:
error: class "Foam::GeometricField<Type, PatchField, GeoMesh>::Boundary [with Type=Foam::scalar={Foam::doubleScalar={double}}, PatchField=Foam::fvPatchField, GeoMesh=Foam::volMesh]" has no member "name" Info<<T_.boundaryField().name()<<endl; Code:
Info<<T_.boundaryField()[0]<<endl; Code:
type fixedValue; value uniform 29800; Code:
Info<<T_.boundaryField()<<endl; Code:
6 ( type fixedValue; value uniform 29800; type fixedValue; value uniform 290; type fixedValue; value uniform 2981; type zeroGradient; type zeroGradient; type zeroGradient; ) Code:
boundaryField { inner { type fixedValue; value uniform 29800; } outer { type fixedValue; value uniform 290; } coflow { type fixedValue; value uniform 2981; } bluffBody { type zeroGradient; } airBC { type zeroGradient; } outlet { type zeroGradient; } }
__________________
https://openfoam.top |
|
November 3, 2018, 09:59 |
|
#4 | |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Quote:
Hi, thanks for the checks. Okay that is a nice hack. I was not even thinking to build a new IOobject and use that as the object for looking up. Trying it now. Thanks again; sometimes I am thinking to complicated and try to avoid building new objects However, there should be away to access that stuff: Code:
Info<< T_.boundaryField()[0] << endl;
__________________
Keep foaming, Tobias Holzmann |
||
November 3, 2018, 14:53 |
|
#5 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Okay, it works, but if you stop your solver and restart, it does not work again because the volScalarField is placed again in the field. Furthermore, we induce ParaView problems.
__________________
Keep foaming, Tobias Holzmann |
|
November 3, 2018, 16:54 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Tobi: I don't have enough time to create a complete example, but here is the outline on how to do this in a way that works and abides to OpenFOAM's way of doing things:
Best regards, Bruno
__________________
|
|
November 3, 2018, 18:36 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi Bruno,
thanks for your feedback. As always, very exclusive -- the whole forum is updated by your knowledge right now. After your post, I remembered an easy accessible way Bernhard told me once. I did the following that works out perfectly now: Boundary Condition
Code:
methodName_ ( IOobject ( "methodName", p.boundaryMesh().mesh().time().timeName(), p.boundaryMesh().mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), 1 ) methodName_[0] = "whatEverIWantToStore"; Thermodynamic Library
Code:
if (this->T_.mesh().foundObject<IOList<word>>("methodName")) { Info<< "found" << endl; } else { Info<< "not found" << endl; }
__________________
Keep foaming, Tobias Holzmann |
|
November 3, 2018, 21:34 |
|
#8 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Oh, OK, I thought you wanted to have the data come through the fields, along with binding the information to the boundary conditions...
But that does remind me that we can append new dictionary data to existing dictionaries, as long as they are "dictionaries". For example, I was able sometime ago to bind additional dictionary data to the matrix solver blocks during runtime, even though the data is not written to fvSolution. That way I was able to exchange internal matrix solver data (the normalization factor to be specific) with the application-solver, without the need to rely on global variables. It's a fairly nice metadata storage feature in OpenFOAM as well |
|
November 5, 2018, 04:50 |
|
#9 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi Bruno, yes that was my first intention. However, based on the lack of C++ knowledge, the way I choose is easier . But an interesting point is the extension of already available dictionaries. After your hint, I re-read the IOobject/dictionary class. I will keep that in mind because it seems to be a better/reasonable solution in some cases.
__________________
Keep foaming, Tobias Holzmann |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] dynamicTopoFVMesh and pointDisplacement | RandomUser | OpenFOAM Meshing & Mesh Conversion | 6 | April 26, 2018 08:30 |
Question about adaptive timestepping | Guille1811 | CFX | 25 | November 12, 2017 18:38 |
Question about heat transfer coefficient setting for CFX | Anna Tian | CFX | 1 | June 16, 2013 07:28 |
[mesh manipulation] Using createPatch in place of couplePatches | sripplinger | OpenFOAM Meshing & Mesh Conversion | 8 | November 13, 2009 08:14 |
CheckMeshbs errors | ivanyao | OpenFOAM Running, Solving & CFD | 2 | March 11, 2009 03:34 |