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

error: ‘mesh’ was not declared in this scope

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2023, 10:17
Default error: ‘mesh’ was not declared in this scope
  #1
Senior Member
 
Saeed Jamshidi
Join Date: Aug 2019
Posts: 214
Rep Power: 7
saeed jamshidi is on a distinguished road
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;
    }
}

// ************************************************************************* //
but, when i run it in openfoam i see some errors:
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
I would appreciate it if you helpe me to solve this problem.
thanks.

Last edited by saeed jamshidi; September 26, 2023 at 13:28.
saeed jamshidi is offline   Reply With Quote

Reply

Tags
#codestream, internal field


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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 07:43
error compiling modified applications yvyan OpenFOAM Programming & Development 21 March 1, 2016 04:53
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 09:31
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 12:34
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 05:07


All times are GMT -4. The time now is 09:49.