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

‘mesh’ was not declared in this scope

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 3 Post By alexeym
  • 2 Post By tooran
  • 1 Post By tooran

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 8, 2014, 03:04
Default ‘mesh’ was not declared in this scope
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Hi guys,

I wanna change d0 as a dimensionedScalar to a volScalarField. So I revise the code:

in solvers/compressibleTwoPhaseEulerFoam/phaseModel/diameterModels/isothermalDiameter.C

Code:
class isothermal
:
    public diameterModel
{
    // Private data

        //- Reference diameter for the isothermal expansion
        //dimensionedScalar d0_; This is original
        volScalarField d0_;
    

        //- Reference pressure for the isothermal expansion
        dimensionedScalar p0_;
	
	//- Reference pressure for the isothermal expansion
        dimensionedScalar n0_;


public:
.....................
in solvers/compressibleTwoPhaseEulerFoam/phaseModel/diameterModels/isothermalDiameter.H
Code:
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::diameterModels::isothermal::isothermal
(
    const dictionary& dict,
    const phaseModel& phase
)
:
    diameterModel(dict, phase),
    d0_
    (
        IOobject
        (
            "d0",
            mesh.time().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ),   
    //d0_("d0", dimLength, dict.lookup("d0")), This is original
    p0_("p0", dimPressure, dict.lookup("p0")),
    n0_("n0", dimDensity, dict.lookup("n0"))
{}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
When I wmake libso, it said:
Code:
SOURCE=diameterModels/isothermalDiameter/isothermalDiameter.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam222/src/transportModels/incompressible/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/isothermalDiameter.o
diameterModels/isothermalDiameter/isothermalDiameter.C: In constructor ‘Foam::diameterModels::isothermal::isothermal(const Foam::dictionary&, const Foam::phaseModel&)’:
diameterModels/isothermalDiameter/isothermalDiameter.C:63:13: error: ‘mesh’ was not declared in this scope
make: *** [Make/linux64GccDPOpt/isothermalDiameter.o] Error 1
a@a:~/OpenFOAM/myCase/solvers/compressibleTwoPhaseEulerFoam/phaseModel$
So how should I handle this? Thanks in advance.
sharonyue is offline   Reply With Quote

Old   April 8, 2014, 03:28
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

as phase is a child class of volScalarField it has mesh() method which will return constant reference to the mesh. So the code can be:

Code:
    d0_
    (
        IOobject
        (
            "d0",
            phase.mesh().time().timeName(),
            phase.mesh(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        phase.mesh()
    ),
or

Code:
    d0_
    (
        IOobject
        (
            "d0",
            phase.time().timeName(),
            phase.db(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        phase.mesh()
    ),
Elham, sharonyue and SHUBHAM9595 like this.
alexeym is offline   Reply With Quote

Old   April 8, 2014, 03:33
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
@Alexey Matveichev

Solved! so quick! Thanks very much.!!
sharonyue is offline   Reply With Quote

Old   August 25, 2017, 14:43
Default error: ‘constrainP1’ was not declared in this scope constrainP1(p1, U1,rAU1)
  #4
New Member
 
Alireza
Join Date: Apr 2017
Posts: 1
Rep Power: 0
Alee reza is on a distinguished road
Hi guys,
I wanna solve some new equation with icoFoam so i added my new equation in icoFaom .When I wmake , it said:[icoOTDFoam.C:139:70: error: ‘constrainHbyA1’ was not declared in this scope
volVectorField HbyA1(constrainHbyA1(rAU1*U1Eqn.H(), U1, p1));][]
and this is my solver .C

[/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.

OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.

Application
icoFoam

Description
Transient solver for incompressible, laminar flow of Newtonian fluids.

\*---------------------------------------------------------------------------*/

#include "fvCFD.H"
#include "pisoControl.H"

#include "pisoControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

pisoControl piso(mesh);

#include "createFields.H"
#include "initContinuityErrs.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Info<< "\nStarting time loop\n" << endl;

while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;

#include "CourantNo.H"

// Momentum predictor

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

if (piso.momentumPredictor())
{
solve(UEqn == -fvc::grad(p));
}

// --- PISO loop
while (piso.correct())
{
volScalarField rAU(1.0/UEqn.A());

volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p));
///H/ap that is equal to U in old version
surfaceScalarField phiHbyA
(
"phiHbyA",
fvc::flux(HbyA)
+ fvc::interpolate(rAU)*fvc::ddtCorr(U, phi)
);
///phiHbyA is like new phi
adjustPhi(phiHbyA, U, p);

// Update the pressure BCs to ensure flux consistency
constrainPressure(p, U, phiHbyA, rAU);

// Non-orthogonal pressure corrector loop
while (piso.correctNonOrthogonal())
{
// Pressure corrector

fvScalarMatrix pEqn
(
fvm::laplacian(rAU, p) == fvc::div(phiHbyA)
);

pEqn.setReference(pRefCell, pRefValue);

pEqn.solve(mesh.solver(p.select(piso.finalInnerIte r())));

if (piso.finalNonOrthogonalIter())
{
phi = phiHbyA - pEqn.flux();
}
}

#include "continuityErrs.H"

U = HbyA - rAU*fvc::grad(p);
U.correctBoundaryConditions();
}
/////////////////////////////////////////////////////////%%%******
// first mode predictor

fvVectorMatrix U1Eqn
(
fvm::ddt(U1)
+ fvm::div(phi, U1)
+ fvm::div(phi1,U)
- fvm::laplacian(nu, U1)

);

if (piso.momentumPredictor())
{
solve(U1Eqn == -fvc::grad(p1));
}

// --- PISO loop
while (piso.correct())
{
volScalarField rAU1(1.0/U1Eqn.A());

volVectorField HbyA1(constrainHbyA1(rAU1*U1Eqn.H(), U1, p1));

surfaceScalarField phiHbyA1
(
"phiHbyA1",
fvc::flux(HbyA1)
+ fvc::interpolate(rAU1)*fvc::ddtCorr(U1, phi1)
);
///phiHbyA is like new phi
adjustPhi1(phiHbyA1, U1, p1);///Think

constrainP1(p1, U1, phiHbyA1, rAU1);

// Non-orthogonal pressure corrector loop
while (piso.correctNonOrthogonal())
{
// Pressure corrector

fvScalarMatrix p1Eqn
(
fvm::laplacian(rAU1, p1) == fvc::div(phiHbyA1)
);

p1Eqn.setReference(pRefCell, pRefValue);

p1Eqn.solve(mesh.solver(p1.select(piso.finalInnerI ter())));

if (piso.finalNonOrthogonalIter())
{
phi1 = phiHbyA1 - p1Eqn.flux();
}
}

#include "continuityErrs.H"

U1 = HbyA1 - rAU1*fvc::grad(p1);
U1.correctBoundaryConditions();
}



runTime.write();




Info<< "End\n" << endl;

return 0;
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}

}


// ************************************************** *********************** //][/QUOTE]
what should I do? Thanks in advance.

Last edited by Alee reza; September 3, 2017 at 07:37. Reason: i did not mention my problem.
Alee reza is offline   Reply With Quote

Old   February 27, 2020, 12:48
Default error: ‘mesh’ was not declared in this scope
  #5
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
Hi all,
I am trying to change a HerschelBulkley in a viscosity model of openfoam.


I want to add a if-condition as follows:


if y<2m then calculate strain rate ....


so I write following loop in the HerschelBulkley.C:


forAll ( mesh.C(), celli) //loop through cell centres
{
if mesh.C().component(vector::y)< scalar (2.0)

{
return
(
min
(
nu0_,
(tau0_ + k_*rtone*pow(tone*sr(), n_))
/(max(sr(), dimensionedScalar ("vSmall", dimless/dimTime, vSmall)))
)
);
}

else {.....


But it shows me error :


error: ‘mesh’ was not declared in this scope
forAll ( mesh.C(), celli) //loop through cell centres



could you please help me?
tooran is offline   Reply With Quote

Old   March 5, 2020, 14:44
Default undefined symbol: _ZN4Foam
  #6
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
I solved my problem by adding the following sentences at HerschelBulkley.C

const objectRegistry& db();
const volVectorField& U = db().lookupObject<volVectorField>("U");
const fvMesh & mesh = U.mesh();


It is compiled without error but when I run my case it shows me error :




undefined symbol: _ZN4Foam15viscosityModels2dbEv


Now I found that I should change my option file in MAKE Folder. But I do not know how I should change my option !.


Could anyone help me?
Thanks
tooran is offline   Reply With Quote

Old   March 6, 2020, 20:08
Default
  #7
New Member
 
tooran
Join Date: Nov 2016
Posts: 23
Rep Power: 9
tooran is on a distinguished road
I declare the mesh in the scope by adding:
const fvMesh& mesh = U_.mesh();




It compiles with out error and I run it with solver, it works fine.
saeed jamshidi likes this.
tooran 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
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 19:18.