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/)
-   -   writeEntry while using codeStream(OFv1906 v.s. OF7) (https://www.cfd-online.com/Forums/openfoam-programming-development/225080-writeentry-while-using-codestream-ofv1906-v-s-of7.html)

samwong March 13, 2020 02:48

writeEntry while using codeStream(OFv1906)
 
Hi all,

I followed the tutorial,
https://wiki.openfoam.com/Programming2
http://www.wolfdynamics.com/wiki/pro...streamINIT.pdf
and tried to learn using codeStream in Dictionary to set B.C.
And I found that OFv1906 has a different definition of writeEntry.

with the original line,
writeEntry(os, "", alpha);
this error pop up
error: ‘Foam::scalarField {aka class Foam::Field<double>}’ has no member named ‘writeEntry ’

then I follow the instruction in
src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H
and change the line to
alpha.writeEntry("",os);

this error pop up
/home/sam/OpenFOAM/sam-v1906/run/codeStream_INIT/fillBox_BCIC/0/alpha.water.#codeStream:59:15: error: ‘Foam::scalarField {aka class Foam::Field<double>}’ has no member named ‘writeEntry ’

What's happening.?

samwong March 13, 2020 04:22

Anyone? please help

olesen March 13, 2020 11:39

Quote:

Originally Posted by samwong (Post 761489)
Hi all,

I followed the tutorial,
https://wiki.openfoam.com/Programming2
http://www.wolfdynamics.com/wiki/pro...streamINIT.pdf
and tried to learn using codeStream in Dictionary to set B.C.
And I found that OFv1906 has a different definition of writeEntry.

with the original line,
writeEntry(os, "", alpha);
this error pop up
error: ‘Foam::scalarField {aka class Foam::Field<double>}’ has no member named ‘writeEntry ’

then I follow the instruction in
src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H
and change the line to
alpha.writeEntry("",os);

this error pop up
/home/sam/OpenFOAM/sam-v1906/run/codeStream_INIT/fillBox_BCIC/0/alpha.water.#codeStream:59:15: error: ‘Foam::scalarField {aka class Foam::Field<double>}’ has no member named ‘writeEntry ’

What's happening.?




The second one with

Code:

field.writeEntry(keyword, os);

must work. Need to check if there is something else wrong.



https://develop.openfoam.com/Develop...d/Field.H#L361

missios February 2, 2022 08:55

codestream for Taylor-Green Vortex initial conditions
 
I just wanted to add a small implementation based on the above discussion. It is not the same field but the procedure remains sort of similar.


So, scope of the folowing code stream is the generation of Taylor-Green Vortex initial conditions in order to simulate some canonical DNS case. The files that codestream needs to be used is the velocity file U under the 0 directory as well as the pressure file p under the same directory.


Here are attached the code snippets of those files



First is given the U file

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v2006                                |
|  \\  /    A nd          | Website:  www.openfoam.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

//internalField  uniform (0 0 0);

internalField  #codeStream
{
        codeInclude
        #{
            #include "fvCFD.H"
        #};
        codeOptions
        #{
            -I$(LIB_SRC)/finiteVolume/lnInclude \
            -I$(LIB_SRC)/meshTools/lnInclude
        #};
        codeLibs
        #{
            -lmeshTools \
            -lfiniteVolume
        #};
        code
        #{
            const IOdictionary& d = static_cast<const IOdictionary&>(dict);
            const fvMesh& mesh = refCast<const fvMesh>(d.db());
            vectorField U_0(mesh.nCells(), Foam::Vector<double>(0.,0.,0.));

            forAll(U_0, i)
            {
                const scalar x = mesh.C()[i][0];
                const scalar y = mesh.C()[i][1];
                const scalar z = mesh.C()[i][2];
                U_0[i] = Foam::Vector<double>(-Foam::cos(x)
                *Foam::sin(y), Foam::sin(x)
                *Foam::cos(y), 0.); 
            }

            U_0.writeEntry("",os)  ;
        #};
    };

boundaryField
{
    upperBoundary     
    {
        type            cyclic;
    }

    lowerBoundary     
    {
        type            cyclic;
    }

    leftBoundary
    {
        type            cyclic;
    }

    rightBoundary
    {
        type            cyclic;
    }

    frontAndBack   
    {
        type            empty;
    }
}
// ************************************************************************* //



and in the same logic is generated the p file
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  v2006                                |
|  \\  /    A nd          | Website:  www.openfoam.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volScalarField;
    object      p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

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

//internalField  uniform 0;
internalField  #codeStream
{
        codeInclude
        #{
            #include "fvCFD.H"
        #};
        codeOptions
        #{
            -I$(LIB_SRC)/finiteVolume/lnInclude \
            -I$(LIB_SRC)/meshTools/lnInclude
        #};
        codeLibs
        #{
            -lmeshTools \
            -lfiniteVolume
        #};
        code
        #{
            const IOdictionary& d = static_cast<const IOdictionary&>(dict);
            const fvMesh& mesh = refCast<const fvMesh>(d.db());
            scalarField p_0(mesh.nCells(), 0.);
            forAll(p_0, i)
            { 
                const scalar x = mesh.C()[i][0];
                const scalar y = mesh.C()[i][1];
                const scalar z = mesh.C()[i][2];
                p_0[i]=-0.25*(Foam::cos(2*x) + Foam::cos(2*y));
            }
            p_0.writeEntry("",os)  ;
        #};
    };


boundaryField
{
    upperBoundary
    {
        type            cyclic;
    }

    lowerBoundary
    {
        type            cyclic;
    }
   
    leftBoundary
    {
        type            cyclic;
    }

    rightBoundary
    {
        type            cyclic;
    }

    frontAndBack   
    {
        type            empty;
    }
}


// ************************************************************************* //

I hope this can be useful.



Best

K


All times are GMT -4. The time now is 07:17.