CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Dictionary update from a boundary condition: is it possible? (https://www.cfd-online.com/Forums/openfoam-programming-development/191454-dictionary-update-boundary-condition-possible.html)

JoeFriend August 10, 2017 11:27

Dictionary update from a boundary condition: is it possible?
 
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 :)

lebc August 10, 2017 17:46

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

babakflame August 10, 2017 20:04

Hey Fellows

Searching a little bit would be beneficial sometimes ;);)

https://www.cfd-online.com/Forums/op...de-solver.html

https://www.cfd-online.com/Forums/op...ct-scalar.html

If you need further elaboration, let me know


Regards

JoeFriend August 11, 2017 17:10

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!

babakflame August 14, 2017 16:36

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

JoeFriend August 16, 2017 12:34

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!


All times are GMT -4. The time now is 18:01.