CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Visualization & Post-Processing Software > ParaView

[OpenFOAM] How to correctly show the result of #codeStream# internalField?

Register Blogs Community New Posts Updated Threads Search

Like Tree19Likes

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   May 7, 2017, 06:38
Exclamation How to correctly show the result of #codeStream# internalField?
  #1
Member
 
Di Cheng
Join Date: May 2010
Location: Beijing, China
Posts: 47
Rep Power: 16
chengdi is on a distinguished road
Hi, everyone

I just used codeStream to generate some initial condtion and codedFixedValue to generate some boundary condtion. The codedFixedValue BC can be correctly executed and loaded using paraFoam (I am using OF1612+ in docker), however, the codeStream initial condition can be correctly interpreted and executed but cannot be loaded in paraFoam.


I was running the forwardStep with following "0/U" file
Code:
/*--------------------------------*- C++ -*----------------------------------*\

| =========                 |                                                 |

| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |

|  \\    /   O peration     | Version:  plus                                  |

|   \\  /    A nd           | Web:      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 (3 0 0);



internalField  #codeStream

{

    code

    #{

        const IOdictionary& d = static_cast<const IOdictionary&>(dict);

        const fvMesh& mesh = refCast<const fvMesh>(d.db());

        

        vectorField T(mesh.nCells());



        const vectorField& CC = mesh.C(); //cell center 

        

        forAll(CC,cellI)

        {

            

            //spatial coordinates, type: scalar

        	scalar x = CC[cellI].x();

        	scalar y = CC[cellI].y(); 

        	scalar z = CC[cellI].z();

        	

        	T[cellI] = vector(3+0.2*sin(10*x),0,0);

        }

                

        //void Foam::Field<Type>::writeEntry(const word& keyword, Ostream& os) const

        T.writeEntry("", os); 

    #};



    //! Optional:

    codeInclude

    #{

        #include "fvCFD.H"

    #};





    //! Optional:

    codeOptions

    #{

        -I$(LIB_SRC)/finiteVolume/lnInclude \

        -I$(LIB_SRC)/meshTools/lnInclude

    #};



    //! libs:

    codeLibs

    #{

        -lmeshTools

    #};

};



boundaryField

{



    inlet

    {

        type            codedMixed;

        refValue        uniform (3 0 0); //default value

        refGradient     uniform (0 0 0); //default value

	valueFraction   uniform 1;

        redirectType    linearOscillatingBC; //name of new BC type

        code

        #{

        const vectorField& Cf = patch().Cf(); // get face center coordinate;

        

        scalar ymax = max(Cf&vector(0,1,0)); // `&` is dot product

        scalar ymin = min(Cf&vector(0,1,0));

        // Info<<"ymax="<<ymax<<",ymin="<<ymin<<nl;

        

        vectorField& rvf = this->refValue();

        vectorField& rgf = this->refGrad();

        scalarField& vf = this->valueFraction();

        

        //temporal coordinate, type: scalar

        scalar t =this->db().time().value(); // get time

        //Oscillating parameters

        scalar omega = 5;

        scalar A = 0.2;

        scalar tt = (1+A*sin(omega*t)); // temporal term, separated

        

        forAll(Cf,faceI)

        {

        	//spatial coordinates, type: scalar

        	//scalar x = Cf[faceI].x();

        	scalar y = Cf[faceI].y(); 

        	//scalar z = Cf[faceI].z();

        	rvf[faceI] = vector(((y-ymin)/(ymax-ymin)+2.5)*tt,0.0,0.0); 

        	rgf[faceI] = Zero;

        	vf[faceI] = 1.0;

        }



        #};

        

        //I do not know why I need to add those things

        //codeInclude

        //#{

        //    #include "fvCFD.H"

        //#};

        

        //codeOptions

        //#{

        //    -I$(LIB_SRC)/finiteVolume/lnInclude

        //#};

    }



    outlet

    {

        type            inletOutlet;

        inletValue      uniform (3 0 0);

        value           uniform (3 0 0);

    }



    bottom

    {

        type            symmetryPlane;

    }



    top

    {

        type            symmetryPlane;

    }



    obstacle

    {

        type            slip;

    }



    defaultFaces

    {

        type            empty;

    }

}



// ************************************************************************* //
And here is the output of crashing paraFoam when I try to load the data.
Code:
Created temporary 'forwardStepMod3.OpenFOAM'
Using #codeStream at line 21 in file "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/0/U"
Using #codeStream with "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665a90f.so"
Invoking wmake libso /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/_ba5ce8457724532859ca03bd0612f92a5665a90f
wmake libso /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/_ba5ce8457724532859ca03bd0612f92a5665a90f


--> FOAM FATAL IO ERROR: 
Failed loading library "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665a90f.so"
Did you add all libraries to the 'libs' entry in system/controlDict?

file: /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/0/U from line 17 to line 17.

    From function static void (* Foam::functionEntries::codeStream::getFunction(const Foam::dictionary&, const Foam::dictionary&))(Foam::Ostream&, const Foam::dictionary&)
    in file db/dictionary/functionEntries/codeStream/codeStream.C at line 309.

FOAM exiting
I also tried to add "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665 a90f.so" to my system/controlDict 's libs entry. Here is the output:

Code:
Created temporary 'forwardStepMod3.OpenFOAM'
--> FOAM Warning : 
    From function void* Foam::dlOpen(const Foam::fileName&, bool)
    in file POSIX.C at line 1244
    dlopen error : /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665a90f.so: undefined symbol: _ZTIN4Foam6fvMeshE
--> FOAM Warning : 
    From function bool Foam::dlLibraryTable::open(const Foam::fileName&, bool)
    in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 101
    could not load "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665a90f.so"
Using #codeStream at line 21 in file "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/0/U"
Using #codeStream with "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665a90f.so"
Invoking wmake libso /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/_ba5ce8457724532859ca03bd0612f92a5665a90f
wmake libso /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/_ba5ce8457724532859ca03bd0612f92a5665a90f


--> FOAM FATAL IO ERROR: 
Failed loading library "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_ba5ce8457724532859ca03bd0612f92a5665a90f.so"
Did you add all libraries to the 'libs' entry in system/controlDict?

file: /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/0/U from line 17 to line 17.

    From function static void (* Foam::functionEntries::codeStream::getFunction(const Foam::dictionary&, const Foam::dictionary&))(Foam::Ostream&, const Foam::dictionary&)
    in file db/dictionary/functionEntries/codeStream/codeStream.C at line 309.

FOAM exiting
I thought "_ZTIN4Foam6fvMeshE" must be something important. However, there is only one result from Google and I cannot see any related information in it.
tariq, tonnykz and Rodolfo Puraca like this.
chengdi is offline   Reply With Quote

 

Tags
codestream, openfoam, parafoam


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
Difference of the max function result with full field, internalField and boundaryFiel cyss38 OpenFOAM Programming & Development 1 October 2, 2018 05:39
CFD post cannot load results-Error appeared? mariam.sara ANSYS 9 September 17, 2018 15:23
[Workbench] Current result file may not contain requested result data zhizhuo ANSYS Meshing & Geometry 0 December 13, 2017 04:18
Simulation won't show turbulence pete_87 OpenFOAM Running, Solving & CFD 4 June 25, 2014 11:35
Geometry show in Result Display ShFlow FLOW-3D 3 January 11, 2009 20:51


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