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/)
-   -   Reading in Custom Field for Multiple Blocks using blockMesh (https://www.cfd-online.com/Forums/openfoam-programming-development/203628-reading-custom-field-multiple-blocks-using-blockmesh.html)

AustinG July 2, 2018 20:02

Reading in Custom Field for Multiple Blocks using blockMesh
 
Hello,



I'm new here and I've looked through several forums and google searches with no luck on this issue, but feel free to redirect me if I have overlooked something. I am trying to read in a custom volScalarField, "R", using blockMesh. Should be pretty straight forward but I have a few blocks and I want a different value of "R" in one of the blocks. See the code snippets below.


blockMeshDict:


Code:

.
.
blocks
(
    hex ( . . . ) Region_0 ( . . . ) simpleGrading ( . . . )
    hex ( . . . ) Region_1 ( . . . ) simpleGrading ( . . . )
    .
    .
    .

    hex ( . . . ) Region_5 ( . . . ) simpleGrading ( . . . )
);
.
.

R:


Code:

.
.
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      R;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -2 0 0 0 0];

internalField
{
    Region_0
    {
        type            fixedValue;
        value          0;
    }

    Region_1
    {
        type            fixedValue;
        value          0;
    }
.
.
.
    Region_5
    {
        type            fixedValue;
        value          10E10;
    }
}
.
.
.

createFields.H:


Code:

.
.
Info <<"Reading field R\n" <<endl;
volScalarField R
(
    IOobject
    (
      IOobject::groupName("R",continuousPhaseName),
      runTime.timeName(),
      mesh,
      IOobject::MUST_READ,
      IOobject::AUTO_WRITE
    ),
    mesh
);
.
.

When I run blockMesh I get no error, but when I try to run my solver I get the following message:


Code:



Reading field R



--> FOAM FATAL IO ERROR:
Attempt to return dictionary entry as a primitive

file: . . . /0/R.internalField from line 23 to line 54.

    From function virtual Foam::ITstream& Foam::dictionaryEntry::stream() const
    in file db/dictionary/dictionaryEntry/dictionaryEntry.C at line 83.

FOAM aborting


Any help is appreciated!

clapointe July 3, 2018 10:28

If you're only trying to set the values of R in one of your regions, why not try the setFields utility? The utility allows you to set the values of a field within a subsection of cells -- selected with boxToCell, for example. Here is a link to an example from one of the tutorials : https://github.com/OpenFOAM/OpenFOAM.../setFieldsDict.

Caelan

AustinG July 5, 2018 18:10

Hi Caelan,


That seems to do the trick for this case! Thanks for the help


Austin


All times are GMT -4. The time now is 08:15.