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

#codeStram error: ill defined primitiveEntry starting at keyword 'internalField'

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 6, 2024, 22:39
Default #codeStram error: ill defined primitiveEntry starting at keyword 'internalField'
  #1
New Member
 
chenxingyu
Join Date: Mar 2024
Posts: 2
Rep Power: 0
leoncly is on a distinguished road
hello,

I am extremely new to OpenFOAM, I'm trying to make a simulation of Spinodal decomposition of Benchmark with OpenFoam.I use #codeStream to write the initial conditions under 0 files. This is my codes:


/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
object c;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 0 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());
const scalar c_0=0.5;
const scalar epsilon=0.01;

scalarField c(mesh.nCells(),0.);

forAll(c,i)
{
scalar x = mesh.C()[i][0];
scalar y = mesh.C()[i][1];

c[i] = c_0 + epsilon * (
cos(0.105 * x) * cos(0.11 * y) +
pow(cos(0.13 * x) * cos(0.087 * y), 2) +
cos(0.025 * x - 0.15 * y) * cos(0.07 * x - 0.02 * y));
}
#};
}


boundaryField
{
bottom
{
type zeroGradient;
}
top
{
type zeroGradient;
}
left
{
type zeroGradient;
}
right
{
type zeroGradient;
}
frontAndBack
{
type empty;
}

}

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

When i run my case my terminal gives:
FOAM FATAL IO ERROR:
"ill defined primitiveEntry starting at keyword 'internalField' on line 18 and ending at line 88"

file: /home/cxy/OpenFOAM/cxy-9/run/Benchmark/cavity/0/c at line 88.

I checked multiple times but i don't find anything wrong and also my file is 84 lines long.

Please, help me to figure out this.
Many thanks.

Last edited by leoncly; March 7, 2024 at 01:08.
leoncly is offline   Reply With Quote

Old   March 7, 2024, 22:38
Default
  #2
New Member
 
chenxingyu
Join Date: Mar 2024
Posts: 2
Rep Power: 0
leoncly is on a distinguished road
Anybody help? I need you! Thank you 3000 times~
leoncly is offline   Reply With Quote

Old   June 10, 2024, 00:41
Default
  #3
New Member
 
tcg
Join Date: Aug 2016
Posts: 1
Rep Power: 0
thecosmosgod is on a distinguished road
Not sure if it would work in OF9, but below is what worked for me in OF6 for a temporal mixing layer case. Make sure both files are in 0 folder. I am getting all sorts of errors when I combine the files or remove #inputMode merge.

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    location    "0";
    object      U.orig;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "UCode"

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

internalField   $velocity;

boundaryField
{
    "(left|right|front|back)"
    {
        type            cyclic;
    }
    "(top|bottom)"
    {
        type            zeroGradient;
    }
}


// ************************************************************************* //
Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       IOobject;
    location    "0";
    object      UCode;
}

velocity #codeStream
{
    code
    #{
        const IOdictionary& d = static_cast<const IOdictionary&>(dict);
        const fvMesh& mesh = refCast<const fvMesh>(d.db());
        vectorField fld(mesh.nCells(), vector(0.0,0.0,0.0));

        const scalar U0 = 1.0;

        forAll(mesh.C(), cellI)
        {
            // cell center y coordinate
            scalar YC = mesh.C()[cellI].y();
            fld[cellI] = vector(U0*Foam::tanh(10.0*YC),0,0);
        }

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

    //- Optional:
    codeInclude
    #{
        #include "fvCFD.H"
    #};

    //- Optional:
    codeOptions
    #{
        -I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/meshTools/lnInclude
    #};
    codeLibs
    #{
        -lmeshTools -lfiniteVolume
    #};
};
#inputMode merge
thecosmosgod is offline   Reply With Quote

Reply

Tags
#codestream, internalfileds


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
big difference between clockTime and executionTime LM4112 OpenFOAM Running, Solving & CFD 21 February 15, 2019 04:05
[blockMesh] "ill defined primitiveEntry starting at keyword Boundary ..... Punt3r OpenFOAM Meshing & Mesh Conversion 3 June 12, 2016 10:16
icoFoam: ill defined primitiveEntry starting at Keyword 'value' sinatahmooresi OpenFOAM Running, Solving & CFD 4 December 20, 2015 15:14
[blockMesh] Can't find my mistake blockMeshDict jelzinga OpenFOAM Meshing & Mesh Conversion 8 March 19, 2015 02:08
[OpenFOAM] paraview/paraFoam crash "ill defined primitiveEntry" psosnows ParaView 4 June 22, 2012 04:20


All times are GMT -4. The time now is 20:56.