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

writeEntry while using codeStream(OFv1906 v.s. OF7)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 13, 2020, 02:48
Question writeEntry while using codeStream(OFv1906)
  #1
New Member
 
Join Date: May 2016
Posts: 11
Rep Power: 9
samwong is on a distinguished road
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.?

Last edited by samwong; March 13, 2020 at 05:15. Reason: misunderstand the situation
samwong is offline   Reply With Quote

Old   March 13, 2020, 04:22
Default
  #2
New Member
 
Join Date: May 2016
Posts: 11
Rep Power: 9
samwong is on a distinguished road
Anyone? please help
samwong is offline   Reply With Quote

Old   March 13, 2020, 11:39
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by samwong View Post
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
olesen is offline   Reply With Quote

Old   February 2, 2022, 08:55
Default codestream for Taylor-Green Vortex initial conditions
  #4
New Member
 
Konstantinos Missios
Join Date: Mar 2017
Location: Copenhagen, Denmark.
Posts: 12
Rep Power: 9
missios is on a distinguished road
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
missios is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM.org] OpenFOAM installation problem (of7 not working) tenichols19 OpenFOAM Installation 3 September 20, 2019 02:24


All times are GMT -4. The time now is 00:27.