|
[Sponsors] |
September 26, 2023, 11:17 |
error: ‘mesh’ was not declared in this scope
|
#1 |
Senior Member
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 8 |
Hi all,
I wanna utilized the codestream for my simulation. To this end, I have prepared "S" dictionary, which calculates the curl of velocity in computaional domain. Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2112 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; object S; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField #codeStream { libs ("utilityFunctionObjects.so"); codeInclude #{ #include "fvCFD.H" #}; codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude #}; codeLibs #{ -lmeshTools \ -lfiniteVolume #}; code #{ volScalarField S ( IOobject ( "S", mesh().time().timeName(), mesh(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh(), dimensionedScalar("S", dimensionSet(0, 0, 0, 0, 0, 0, 0), Zero) ); const objectRegistry& db(); const volVectorField& U = db().lookupObject<volVectorField>("U"); const fvMesh & mesh = U.mesh(); // Create a scalar field that contains the volume of each cell within the mesh const scalarField& v = mesh().V(); // Calculate the curl of the flow and then take the magnitude of it const volScalarField& magCurlU = mag(fvc::curl(U)); forAll(S, celli) { // For curl of velocity, use the line below S[celli] = pow(v[celli], 1.0/3.0) * magCurlU[celli]; } S.writeEntry("", os); #}; } boundaryField { inlet { type zeroGradient; } outlet { type zeroGradient; } top { type zeroGradient; } Bottom { type zeroGradient; } cylinder { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* // Code:
/home/myfoam/OpenFOAM/myfoam-v2112/run/tutorials/incompressible/pimpleFoam/LES/cylinder/0/S.#codeStream:47:5: error: ‘mesh’ was not declared in this scope /home/myfoam/OpenFOAM/myfoam-v2112/run/tutorials/incompressible/pimpleFoam/LES/cylinder/0/S.#codeStream:47:5: note: suggested alternative: ‘cosh’ /usr/lib/openfoam/openfoam2112/wmake/rules/General/transform:34: recipe for target 'Make/linux64GccDPInt32Opt/codeStreamTemplate.o' failed make: *** [Make/linux64GccDPInt32Opt/codeStreamTemplate.o] Error 1 --> FOAM FATAL IO ERROR: (openfoam-2112 patch=220610) Failed wmake "dynamicCode/_52a2dbf780a8697296fac2199c6f254fa84ab80e/platforms/linux64GccDPInt32Opt/lib/libcodeStream_52a2dbf780a8697296fac2199c6f254fa84ab80e.so" file: 0/S at line 17. 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 192. FOAM exiting thanks. Last edited by saeed jamshidi; September 26, 2023 at 14:28. |
|
November 8, 2024, 16:54 |
|
#2 |
New Member
Join Date: Mar 2024
Posts: 18
Rep Power: 2 |
Hi Saeed,
I'm facing the same issue when I was trying to use #codestream for customized functions. I came-across your post, I wonder if you got any solution for this issue. Would you mind sharing your solution or any suggestion how I can fix this issue? Thank you so much!! |
|
November 11, 2024, 04:33 |
|
#3 |
Senior Member
Join Date: Dec 2019
Location: Cologne, Germany
Posts: 369
Rep Power: 8 |
Code:
internalField #codeStream { code #{ const IOdictionary& d = static_cast<const IOdictionary&>(dict); const fvMesh& mesh = refCast<const fvMesh>(d.db()); scalarField fld(mesh.nCells(), 12.34); fld.writeEntry("", os); #}; //! Optional: codeInclude #{ #include "fvCFD.H" #}; //! Optional: codeOptions #{ -I$(LIB_SRC)/finiteVolume/lnInclude #}; }; https://www.openfoam.com/documentati...odeStream.html |
|
Tags |
#codestream, internal field |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile calcMassFlowC | aurore | OpenFOAM Programming & Development | 13 | March 23, 2018 08:43 |
error compiling modified applications | yvyan | OpenFOAM Programming & Development | 21 | March 1, 2016 05:53 |
Compile problem | ivanyao | OpenFOAM Running, Solving & CFD | 1 | October 12, 2012 10:31 |
checking the system setup and Qt version | vivek070176 | OpenFOAM Installation | 22 | June 1, 2010 13:34 |
How to get the max value of the whole field | waynezw0618 | OpenFOAM Running, Solving & CFD | 4 | June 17, 2008 06:07 |