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

How to create the internalField with #codeStream

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 3, 2016, 12:48
Default How to create the internalField with #codeStream
  #1
New Member
 
Join Date: Jun 2014
Posts: 22
Rep Power: 12
chun is on a distinguished road
Dear all,

I tried to use #codeStream to create the internalField in OpenFoam 4.1.

The code is at the following:

Code:
internalField   #codeStream
{
    code
    #{
        scalar x0=-0.6;
        scalar y0=0;
        const IOdictionary& d = static_cast<const IOdictionary&>(dict);
        const fvMesh& mesh = refCast<const fvMesh>(d.db());
        scalarField newField(mesh.nCells(), 0);// fld(mesh.nCells(), 1.2) or fld(mesh.nCells())
        // to set a position-dependent value
        forAll(mesh.C(), i)
        {
            scalar x = mesh.C()[i].x();
            scalar y = mesh.C()[i].y();
            scalar rSqr = magSqr(x-x0) + magSqr(y-y0);
            scalar r = sqrt(rSqr);
            newField[i] =exp(- pow(r,1));
        } 
        newField.writeEntry("", os); // now return the value of fld as the internal field value
    #};

    codeInclude
    #{
        #include "fvCFD.H"
    #};
 
    codeOptions
    #{
        -I$(LIB_SRC)/finiteVolume/lnInclude
    #};
};
The above code works just fun in OpenFoam 2.3.0, but does not works in OpenFoam 4.1.

The error code in OF4.1 is the following:

Code:
Using #codeStream at line 19 in file "/u/user/OpenFOAM/user-4.1/case1/0/T"
Using #codeStream with "/u/user/OpenFOAM/user-4.1/case1/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_5fb0fb15ace670c74f854b9267f149e18da51df6.so"
Creating new library in "dynamicCode/_5fb0fb15ace670c74f854b9267f149e18da51df6/platforms/linux64GccDPInt32Opt/lib/libcodeStream_5fb0fb15ace670c74f854b9267f149e18da51df6.so"
Invoking "wmake -s libso /u/user/OpenFOAM/user-4.1/case1/dynamicCode/_5fb0fb15ace670c74f854b9267f149e18da51df6"
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file codeStreamTemplate.C
could not open file cyclicAMILduInterface.H for source file codeStreamTemplate.C due to No such file or directory
could not open file cyclicAMIPolyPatch.H for source file codeStreamTemplate.C due to No such file or directory
In file included from /opt/openfoam4/src/finiteVolume/lnInclude/ddtScheme.C:30:0,
                 from /opt/openfoam4/src/finiteVolume/lnInclude/ddtScheme.H:337,
                 from /opt/openfoam4/src/finiteVolume/lnInclude/fvcDdt.C:28,
                 from /opt/openfoam4/src/finiteVolume/lnInclude/fvcDdt.H:199,
                 from /opt/openfoam4/src/finiteVolume/lnInclude/fvc.H:44,
                 from /opt/openfoam4/src/finiteVolume/lnInclude/fvCFD.H:8,
                 from /u/user/OpenFOAM/user-4.1/case1/0/T.#codeStream:36:
/opt/openfoam4/src/finiteVolume/lnInclude/cyclicAMIFvPatch.H:39:35: fatal error: cyclicAMILduInterface.H: No such file or directory
compilation terminated.
/opt/openfoam4/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt32Opt/codeStreamTemplate.o' failed
make: *** [Make/linux64GccDPInt32Opt/codeStreamTemplate.o] Error 1


--> FOAM FATAL IO ERROR: 
Failed wmake "dynamicCode/_5fb0fb15ace670c74f854b9267f149e18da51df6/platforms/linux64GccDPInt32Opt/lib/libcodeStream_5fb0fb15ace670c74f854b9267f149e18da51df6.so"
Is anyone can kindly answer them for me? Thanks
chun is offline   Reply With Quote

Old   November 5, 2016, 05:42
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Code:
$ pwd
$HOME/OpenFOAM/OpenFOAM-4.1/src
$ find . -name 'cyclicAMILduInterface.H'
./meshTools/AMIInterpolation/patches/cyclicAMI/cyclicAMIPolyPatch/cyclicAMIPolyPatch.H
./meshTools/lnInclude/cyclicAMIPolyPatch.H
your codeOptions block contains only -I$(LIB_SRC)/finiteVolume/lnInclude, add also -I$(LIB_SRC)/meshTools/lnInclude.
chengyu and kooki_13 like this.
alexeym is offline   Reply With Quote

Old   April 25, 2017, 11:25
Default
  #3
New Member
 
Yu Cheng
Join Date: Aug 2014
Posts: 15
Rep Power: 12
chengyu is on a distinguished road
The answer given by Alexey is exact solution for OF version >2.4.0. Thank you

Yu
chengyu is offline   Reply With Quote

Old   May 6, 2017, 11:35
Default
  #4
Member
 
Di Cheng
Join Date: May 2010
Location: Beijing, China
Posts: 47
Rep Power: 16
chengdi is on a distinguished road
Hi, Alexey

Your solution works for OpenFOAM 201612+, however, when it comes to post-process using paraFOAM ( rather than paraview only). It shows some error like this:

---------------------------------------------------------------------
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_f72d8df02b71ca83b7c6dc9d8f194b2d2d74 8bbd.so"
Invoking wmake libso /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/_f72d8df02b71ca83b7c6dc9d8f194b2d2d748bbd
wmake libso /home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/_f72d8df02b71ca83b7c6dc9d8f194b2d2d748bbd


--> FOAM FATAL IO ERROR:
Failed loading library "/home/di/OpenFOAM/di-v1612+/run/forwardStepMod3/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_f72d8df02b71ca83b7c6dc9d8f194b2d2d74 8bbd.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(con st Foam::dictionary&, const Foam::dictionary&))(Foam::Ostream&, const Foam::dictionary&)
in file db/dictionary/functionEntries/codeStream/codeStream.C at line 309.

FOAM exiting
---------------------------------------------------------------------

Do you have any idea to load the library correctly?
chengdi 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
internalField condition mchehab2 OpenFOAM Running, Solving & CFD 14 November 10, 2022 14:28
create the file *.foam phongstar OpenFOAM 12 October 14, 2018 19:06
[GAMBIT] How to plot S pipe mariam.sara ANSYS Meshing & Geometry 36 November 7, 2013 16:22
[ANSYS Meshing] is it possible to create virtual edges on the blades er_ijaz ANSYS Meshing & Geometry 0 November 3, 2013 06:15
[DesignModeler] Design Modeller create surface papis ANSYS Meshing & Geometry 0 October 31, 2013 14:52


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