|
[Sponsors] |
November 15, 2021, 12:46 |
accessing dimensionedScalar from coded BC
|
#1 |
New Member
Raoul
Join Date: Apr 2021
Posts: 16
Rep Power: 5 |
Hi everyone,
I am currently trying to access a dimensionedScalar from the coded bc, however I am a bit stuck. Basically I am calculating the dimensionedScalar "myVar" within the solver, to then use it in the equations as a coefficient (so the value is never modified in the routine). I also need such value in the BC, however I cannot access it through Code:
db().lookupObject<dimensionedScalar>("myVar"); Code:
dimensionedScalar myVar ( IOobject ( "myVar", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ), mesh, dimensionedScalar("myVar", dimensionSet(0,2,0,0,0,0,0), Foam::scalar(0)) ); Do you have any advice for me? Thanks in advance. |
|
November 18, 2021, 06:59 |
|
#2 |
New Member
Raoul
Join Date: Apr 2021
Posts: 16
Rep Power: 5 |
Ok I have figured out this solution, which works fine for me. It is probably not the best option in terms of code optimization but here it is.
In the main code of the solver I evaluate my dimensionedScalar as: Code:
dimensionedScalar A = <expression>; Code:
IOdictionary coeffsDict ( IOobject ( "coeffsDict", runTime.constant(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ) ); Code:
coeffsDict.set( "a", A.value() ); Code:
dimensionedScalar A_ ( "A_", dimensionSet(0,2,0,0,0,0,0), db().lookupObject<IOdictionary>("coeffsDict").lookup("a") ); |
|
November 19, 2021, 11:47 |
|
#3 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
That will not work. All registered items must derive from a regIOobject. The closest you can have would be a UniformDimensionedField. |
||
Tags |
boundaryconditions, dimensionedscalar |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
accessing 0 time directory in coded functionObject | JM27 | OpenFOAM Programming & Development | 3 | May 26, 2023 17:50 |
Accessing transportProperties from coded functionObject | Shibi | OpenFOAM Programming & Development | 1 | April 19, 2021 16:26 |
coded functionObjects behaving not as expected | alexfells | OpenFOAM | 2 | October 28, 2020 04:58 |
accessing 0 time directory in coded functionObject | JM27 | OpenFOAM Post-Processing | 0 | November 21, 2018 09:41 |
dimensionedScalar not updating, stuck on initial values | backscatter | OpenFOAM Programming & Development | 2 | August 7, 2018 21:30 |