CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Dictionary update from a boundary condition: is it possible?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By JoeFriend

Reply
 
LinkBack Thread Tools Display Modes
Old   August 10, 2017, 11:27
Post Dictionary update from a boundary condition: is it possible?
  #1
New Member
 
Join Date: Oct 2016
Posts: 16
Rep Power: 3
JoeFriend is on a distinguished road
Hello, I've read that it is possible to update a parameter from a dictionary from the main solver writing the following in the runTime loop:

Code:
myDict.set("name",value);
Is it possible to do this from a boundary condition?

I'm doing the following (all these in the BC code)
1- I call the parameter
2- After some operations, the value of the parameter changes
3- I set the parameter to the dictionary

Everything compiles and runs OK, but the parameter doesn't get updated...I would appreciate any help
JoeFriend is offline   Reply With Quote

Old   August 10, 2017, 17:46
Default
  #2
Member
 
Luis Eduardo
Join Date: Jan 2011
Posts: 32
Rep Power: 9
lebc is on a distinguished road
Hi Joe,

I've been trying to do it on the ABL Inlet boundary conditions, I want to update the Uref after some iterations, but even if I change its values manually it won't change.

The only way I found to do it is by changing, for example, the U file section where the boundary conditions are. This is actually not feasible if you want to run lots of cases, and I didn't use it.

I am really hopping someone can answer to your question with an effective way of doing it!

Best regards,
Luis
lebc is offline   Reply With Quote

Old   August 10, 2017, 20:04
Default
  #3
Senior Member
 
Bobi
Join Date: Oct 2012
Location: Chicago, Illinois
Posts: 433
Rep Power: 9
babakflame is on a distinguished road
Hey Fellows

Searching a little bit would be beneficial sometimes

Snippet for redefining fixedGradient boundary condition for a patch inside solver

objectRegistry::lookupObject<scalar>

If you need further elaboration, let me know


Regards
babakflame is offline   Reply With Quote

Old   August 11, 2017, 17:10
Default
  #4
New Member
 
Join Date: Oct 2016
Posts: 16
Rep Power: 3
JoeFriend is on a distinguished road
Thank you Bobi for your quick response.

In the link you suggested they update the dictionary from the runTime loop, but I was asking if this update dict.set("name",value) could be made from a BC.

Specifically this is my case: the parameter in the dictionary contains the total mass of my physical domain, and from an specific patch, part of this mass is being lost, so based on what is lost I need to update the value of the total mass.

Maybe I can do this from the main solver...but I still haven't figure out how. Making it from the BC instead would be straight forward.

Regards!
JoeFriend is offline   Reply With Quote

Old   August 14, 2017, 16:36
Default
  #5
Senior Member
 
Bobi
Join Date: Oct 2012
Location: Chicago, Illinois
Posts: 433
Rep Power: 9
babakflame is on a distinguished road
Hi JoeFriend

AFAIK, at the boundaries, you can use <refCast> to assign a custom relation (like fixed flux) to boundaries. I believe you need to add couple of lines as a header file and add it to the main solver, to recalculate and update your total mass within the solver.

Regards
babakflame is offline   Reply With Quote

Old   August 16, 2017, 12:34
Default
  #6
New Member
 
Join Date: Oct 2016
Posts: 16
Rep Power: 3
JoeFriend is on a distinguished road
Hey Bobi, thanks for your help. Its finally working. Apparently its not possible to update a dictionary using the set() function, but it is possible to update subdictionaries, so I had to create one. This is how my dictionary file was before...

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      batchProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

BatchMass               1;


// ************************************************************************* //
...and this is how it looks now

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "constant";
    object      batchProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Mass
{
BatchMass               1;
}

// ************************************************************************* //
Regards!
babakflame likes this.
JoeFriend is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFD analaysis of Pelton turbine amodpanthee CFX 29 March 30, 2017 18:31
Centrifugal fan-reverse flow in outlet lesds to a mass in flow field xiexing CFX 3 March 29, 2017 10:00
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28
Error finding variable "THERMX" sunilpatil CFX 8 April 26, 2013 07:00
asking for Boundary condition in FLUENT Destry FLUENT 0 July 27, 2010 00:55


All times are GMT -4. The time now is 10:24.