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

Dynamic code not compiling: codestream and #calc

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 2 Post By HPE
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 16, 2021, 11:13
Default Dynamic code not compiling: codestream and #calc
  #1
New Member
 
Join Date: Mar 2020
Posts: 16
Rep Power: 6
Geb1313 is on a distinguished road
Hi Foamers,

I am using OpenFoam-v2012 on WSL. When my cases have #calc or #codestream, dynamic code failed to compile giving the following error:
PHP Code:
 Create time

Could not load Creating block mesh from 
"system/blockMeshDict"
Using #calc at line 34 in file 
"/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/system/blockMeshDict"
Using #codeStream with "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.so"
"/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.so"
/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.socannot open shared object fileNo such file or directory
Creating 
new library in "dynamicCode/_62f249a623e510348c0dae9390b3984aa7beeadf/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.so"
Invoking wmake libso /mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/_62f249a623e510348c0dae9390b3984aa7beeadf
wmake libso 
/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/_62f249a623e510348c0dae9390b3984aa7beeadf
/opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/cc1error while loading shared librarieslibmpfr.so.4cannot open shared object fileNo such file or directory
/opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/cc1error while loading shared librarieslibmpfr.so.4cannot open shared object fileNo such file or directory
    ln
: ./lnInclude
    ld
libNULL.so
Could not load 
"/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.so"
/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.socannot open shared object fileNo such file or directory


--> FOAM FATAL IO ERROR: (openfoam-2012)
Failed loading library "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_62f249a623e510348c0dae9390b3984aa7beeadf.so"
Did you add all libraries to the 'libs' entry in system/controlDict?

file: /mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/system/blockMeshDict at line 17 to 32.

    From 
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 305.

FOAM exiting 
Any help please? Is this problem related to WSL or just I missed something?

Thank you
Gebray
Geb1313 is offline   Reply With Quote

Old   April 16, 2021, 16:59
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
Hi,


To reproduce the error, I think we need a minimal reproducible example.
HPE is offline   Reply With Quote

Old   April 17, 2021, 12:56
Default
  #3
New Member
 
Join Date: Mar 2020
Posts: 16
Rep Power: 6
Geb1313 is on a distinguished road
Quote:
Originally Posted by HPE View Post
Hi,


To reproduce the error, I think we need a minimal reproducible example.
Hi HPE,

For example let see this blockMeshdict :
Quote:
*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2012 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/

FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

scale 1;

xmin 0.0;
xmax 4.0;
ymin -0.5;
ymax 0.5;
zmin 0;
zmax 0.5;

//xcells 20;
//ycells 20;
//zcells 1;

deltax 0.05; //0.05
deltay 0.05; //0.05
deltaz 0.05; //0.05

lx #calc "$xmax - $xmin";
ly #calc "$ymax - $ymin";
lz #calc "$zmax - ($zmin)";

xcells #calc "round($lx/$deltax)";
ycells #calc "round($ly/$deltay)";
zcells #calc "round($lz/$deltaz)";

vertices
(
//BLOCK1

($xmin $ymin $zmin) //0
($xmax $ymin $zmin) //1
($xmax $ymax $zmin) //2
($xmin $ymax $zmin) //3
($xmin $ymin $zmax) //4
($xmax $ymin $zmax) //5
($xmax $ymax $zmax) //6
($xmin $ymax $zmax) //7

);

blocks
(
hex (0 1 2 3 4 5 6 7) (xcells ycells zcells) simpleGrading (1 1 1)
);

edges
(

);

boundary
(
top
{
type wall;
faces
(
(4 5 6 7)
);
}
left
{
type wall;
faces
(
(0 4 7 3)
);
}
right
{
type wall;
faces
(
(1 2 6 5)
);
}
bottom
{
type wall;
faces
(
(0 3 2 1)
);
}
front
{
type wall;
faces
(
(0 1 5 4)
);
}
back
{
type wall;
faces
(
(2 3 7 6)
);
}
);

mergePatchPairs
(

);

// ************************************************** *********************** //
Geb1313 is offline   Reply With Quote

Old   April 17, 2021, 15:30
Default
  #4
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 932
Rep Power: 12
HPE is on a distinguished road
One issue is the missing dollar sign for the following variables:

hex (0 1 2 3 4 5 6 7) (xcells ycells zcells) simpleGrading (1 1 1)

Having said that I strongly recommend you to use #eval expression instead of #calc. With #eval, you will not need to deal with any compilation. Please search 'eval' among the tutorial cases and OpenFOAM release notes.
olesen and Geb1313 like this.
HPE is offline   Reply With Quote

Old   April 17, 2021, 18:18
Default
  #5
New Member
 
Join Date: Mar 2020
Posts: 16
Rep Power: 6
Geb1313 is on a distinguished road
Hi HPE,
Nice! Half of my problem is solved. I used #eval instead of #calc. However still the problem with #codestream persisted to continue. I was running a dambreak using interfoam. I want to introduce initial conditions for alpha.water using #codestream like this:
Quote:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 0 0 0 0];

//internalField uniform 0;

internalField #codeStream
{
codeInclude
#{
#include "fvCFD.H"
#};

codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};

//libs needed to visualize BC in paraview
codeLibs
#{
-lmeshTools \
-lfiniteVolume
#};

code
#{
const IOdictionary& d = static_cast<const IOdictionary&>(dict);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
scalarField alpha(mesh.nCells(), 0.);

forAll(alpha, i)
{
const scalar x = mesh.C()[i][0];
const scalar y = mesh.C()[i][1];
const scalar z = mesh.C()[i][2];

if (y <= 0.2)
{
alpha[i] = 1.;
}
}

writeEntry(os, "", alpha);
#};
};
And the error message was similar which looks a compilation error like this:
Quote:

Using #codeStream at line 20 in file "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/0/alpha.water"
Using #codeStream with "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so"
Could not load "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so"
/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so: cannot open shared object file: No such file or directory
Creating new library in "dynamicCode/_9a2905356e5313e2ff419c83e22111805dc3aa4d/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so"
Invoking wmake libso /mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/_9a2905356e5313e2ff419c83e22111805dc3aa4d
wmake libso /mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/_9a2905356e5313e2ff419c83e22111805dc3aa4d
/opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
/opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/../libexec/gcc/x86_64-pc-linux-gnu/6.3.0/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory
ln: ./lnInclude
ld: libNULL.so
Could not load "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so"
/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so: cannot open shared object file: No such file or directory


--> FOAM FATAL IO ERROR: (openfoam-2012)
Failed loading library "/mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/dynamicCode/platforms/linux64Gcc63DPInt32Opt/lib/libcodeStream_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so"
Did you add all libraries to the 'libs' entry in system/controlDict?

file: /mnt/c/Users/gebrayha/OpenFoam/3Ddambreak/0/alpha.water at line 17.

From 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 305.

FOAM exiting
Geb1313 is offline   Reply With Quote

Old   April 18, 2021, 04:21
Default
  #6
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
You have Gcc63 as the compiler type, which makes it look like you have a separate gcc installation.
You should check the value of your LD_LIBRARY_PATH to verify that libmpfr (perhaps libgmp too) are accessible.

Since the compilation worked, but not the loading, use 'ldd -v' on the dynamically generated lib. Use Google or Stackoverflow or man if you aren't familiar with ldd.
Geb1313 likes this.
olesen is offline   Reply With Quote

Old   April 18, 2021, 07:46
Default
  #7
New Member
 
Join Date: Mar 2020
Posts: 16
Rep Power: 6
Geb1313 is on a distinguished road
Thank you for the reply olesen,
which gcc on the command line shows:
Quote:
/opt/OpenFOAM/OpenFOAM-v2012/ThirdParty/platforms/linux64/gcc-6.3.0/bin/gcc
I don't think the problem is related to separate gcc installation(?)
To use the ldd -v [file], the file "_9a2905356e5313e2ff419c83e22111805dc3 aa4d.so" is not existing. When I look in to dynamicCode folder, there is no platforms sub-folder.

Looking in to config.sh/setting, I found:
Quote:
_foamEtc -config compiler

# ThirdParty base for compilers
archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH"

case "$WM_COMPILER_TYPE-$WM_COMPILER" in
ThirdParty-Gcc*)
gccDir="$archDir/$gcc_version"
gmpDir="$archDir/${gmp_version:-gmp-system}"
mpfrDir="$archDir/${mpfr_version:-mpfr-system}"
mpcDir="$archDir/${mpc_version:-mpc-system}"

# Check that the compiler directory can be found
[ -d "$gccDir" ] || /bin/cat << GCC_NOT_FOUND 1>&2
================================================== =============================
Warning in $WM_PROJECT_DIR/etc/config.sh/settings:
Cannot find '$WM_COMPILER' compiler installation
$gccDir

Either install this compiler version, or use the system compiler by setting
WM_COMPILER_TYPE to 'system' in \$WM_PROJECT_DIR/etc/bashrc.
================================================== =============================
GCC_NOT_FOUND

_foamAddMan "$gccDir"/man
_foamAddPath "$gccDir"/bin

# Add ThirdParty compiler libraries to run-time environment
_foamAddLib "$gccDir/lib$WM_COMPILER_LIB_ARCH"

# Add gmp/mpfr/mpc libraries to run-time environment.
# Require that they exist, automatically find lib64/ or lib/.
_foamAddLibAuto "$gmpDir" && \
export GMP_ARCH_PATH="$gmpDir" # For non-system CGAL

_foamAddLibAuto "$mpfrDir" && \
export MPFR_ARCH_PATH="$mpfrDir" # For non-system CGAL

_foamAddLibAuto "$mpcDir"

if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
echo "Using ThirdParty compiler"
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})"
fi
;;
I am not sure whether this will help or not, but it is only this I could figure out about "mpfr" and "gmp".

Sorry my ignorance about linux system
Geb1313 is offline   Reply With Quote

Old   July 21, 2023, 10:17
Default
  #8
New Member
 
Mukul Chandra
Join Date: May 2023
Location: India
Posts: 4
Rep Power: 3
risktaker5 is on a distinguished road
have you find the solution of the compilation error you were facing. Same compilation error I am also facing. Please help in this regard.
risktaker5 is offline   Reply With Quote

Old   July 24, 2023, 03:34
Default
  #9
New Member
 
Join Date: Jun 2023
Location: Brest
Posts: 21
Rep Power: 3
CFDUser29 is on a distinguished road
I agree with Olesen, the problem stands in gcc.

I you work on a cluster, I recommend to look for the versions you have with <spack find gcc> and then use <spack load gcc...> with the latest version.

If you work on your laptop, find a way to install gcc, using gcc@12.2.0 solved my codeStream problem.
CFDUser29 is offline   Reply With Quote

Reply

Tags
calc, codestream, dynamiccode

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
"Invalid line number" when compiling at runtime satter_partier OpenFOAM Programming & Development 7 July 16, 2019 06:01


All times are GMT -4. The time now is 16:47.