|
[Sponsors] |
April 25, 2019, 14:28 |
'mesh' was not declared in this scope
|
#1 |
Member
Join Date: Apr 2016
Posts: 30
Rep Power: 10 |
Hi all,
I am trying to add a new particle force in src/lagrangian/intermediate/submodels/Kinematic/ParticleForces In the formulation I want to use wallDist(mesh) to calculate the vector perpendicular to the wall. I added #include "wallDist.H" and the following is .C file Code:
/*---------------------------------------------------------------------------*\ ========= | \\ / 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/>. \*---------------------------------------------------------------------------*/ #include "MicroLift.H" //#include "createMesh.H" #include "mathematicalConstants.H" #include "fundamentalConstants.H" #include "demandDrivenData.H" #include "turbulenceModel.H" #include "wallPointData.H" #include "wallDist.H" using namespace Foam::constant; // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template<class CloudType> Foam::scalar Foam::MicroLift<CloudType>::erfInv(const scalar y) const { const scalar a = 0.147; scalar k = 2.0/(mathematical::pi*a) + 0.5*log(1.0 - y*y); scalar h = log(1.0 - y*y)/a; scalar x = sqrt(-k + sqrt(k*k - h)); if (y < 0.0) { return -x; } else { return x; } } template<class CloudType> Foam::tmp<Foam::volScalarField> Foam::MicroLift<CloudType>::kModel() const { const objectRegistry& obr = this->owner().mesh(); const word turbName = IOobject::groupName ( turbulenceModel::propertiesName, this->owner().U().group() ); if (obr.foundObject<turbulenceModel>(turbName)) { const turbulenceModel& model = obr.lookupObject<turbulenceModel>(turbName); return model.k(); } else { FatalErrorInFunction << "Turbulence model not found in mesh database" << nl << "Database objects include: " << obr.sortedToc() << abort(FatalError); return tmp<volScalarField>(nullptr); } } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class CloudType> Foam::MicroLift<CloudType>::MicroLift ( CloudType& owner, const fvMesh& mesh, const dictionary& dict ) : ParticleForce<CloudType>(owner, mesh, dict, typeName, true), rndGen_(owner.rndGen()), lambda_(readScalar(this->coeffs().lookup("lambda"))), turbulence_(readBool(this->coeffs().lookup("turbulence"))), kPtr_(nullptr), ownK_(false) {} template<class CloudType> Foam::MicroLift<CloudType>::MicroLift ( const MicroLift& bmf ) : ParticleForce<CloudType>(bmf), rndGen_(bmf.rndGen_), lambda_(bmf.lambda_), turbulence_(bmf.turbulence_), kPtr_(nullptr), ownK_(false) {} // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // template<class CloudType> Foam::MicroLift<CloudType>::~MicroLift() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CloudType> void Foam::MicroLift<CloudType>::cacheFields(const bool store) { if (turbulence_) { if (store) { tmp<volScalarField> tk = kModel(); if (tk.isTmp()) { kPtr_ = tk.ptr(); ownK_ = true; } else { kPtr_ = &tk(); ownK_ = false; } } else { if (ownK_ && kPtr_) { deleteDemandDrivenData(kPtr_); ownK_ = false; } } } } template<class CloudType> Foam::forceSuSp Foam::MicroLift<CloudType>::calcCoupled ( const typename CloudType::parcelType& p, const scalar dt, const scalar mass, const scalar Re, //const scalar uc, const scalar muc ) const { forceSuSp value(Zero, 0.0); const scalar dp = p.d(); const vector uc = p.Uc(); const scalar rhoc = p.rhoc(); const scalar h = 100e-6; const scalar Tc = 310.5; scalar f = 0; f = rhoc*mag(uc)*mag(uc)*dp*dp*dp*dp/(h*h); const label celli = p.cell(); volScalarField dis = wallDist(mesh).y(); volVectorField ncap = wallDist(mesh).n(); scalar gauss_x = ncap[celli].x(); scalar gauss_y = ncap[celli].y(); scalar gauss_z = ncap[celli].z(); const vector dir(gauss_x, gauss_y, gauss_z); value.Su() = f*dir; // Random& rnd = this->owner().rndGen(); return value; } // ************************************************************************* // Code:
lnInclude/MicroLift.C: In member function ‘virtual Foam::forceSuSp Foam::MicroLift<CloudType>::calcCoupled(const typename CloudType::parcelType&, Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar) const’: lnInclude/MicroLift.C:184:32: error: ‘mesh’ was not declared in this scope volScalarField dis = wallDist(mesh).y(); ^ lnInclude/MicroLift.C: In instantiation of ‘Foam::forceSuSp Foam::MicroLift<CloudType>::calcCoupled(const typename CloudType::parcelType&, Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar) const [with CloudType = Foam::KinematicCloud<Foam::Cloud<Foam::KinematicParcel<Foam::particle> > >; typename CloudType::parcelType = Foam::KinematicParcel<Foam::particle>; Foam::scalar = double]’: parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C:48:49: required from here lnInclude/MicroLift.C:180:18: warning: unused variable ‘Tc’ [-Wunused-variable] const scalar Tc = 310.5; ^ |
|
April 26, 2019, 09:05 |
|
#2 |
Senior Member
|
Hi,
The error is quite self-explanatory. There is no mesh variable, declared in the method. You can access mesh thought mesh method of the parent class. So your code should be something like: Code:
... volScalarField dis = wallDist(mesh()).y(); volVectorField ncap = wallDist(mesh()).n(); ... |
|
April 26, 2019, 13:47 |
|
#3 |
Member
Join Date: Apr 2016
Posts: 30
Rep Power: 10 |
Hi Alexey,
Thank you for your response.However when I used mesh() instead of mesh, I got the following error:- Code:
In file included from lnInclude/MicroLift.H:162:0, from lnInclude/makeParcelForces.H:49, from parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C:31: lnInclude/MicroLift.C: In member function ‘virtual Foam::forceSuSp Foam::MicroLift<CloudType>::calcCoupled(const typename CloudType::parcelType&, Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar) const’: lnInclude/MicroLift.C:184:37: error: there are no arguments to ‘mesh’ that depend on a template parameter, so a declaration of ‘mesh’ must be available [-fpermissive] volScalarField dis = wallDist(mesh()).y(); ^ lnInclude/MicroLift.C:184:37: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) lnInclude/MicroLift.C:185:38: error: there are no arguments to ‘mesh’ that depend on a template parameter, so a declaration of ‘mesh’ must be available [-fpermissive] volVectorField ncap = wallDist(mesh()).n(); ^ lnInclude/MicroLift.C: In instantiation of ‘Foam::forceSuSp Foam::MicroLift<CloudType>::calcCoupled(const typename CloudType::parcelType&, Foam::scalar, Foam::scalar, Foam::scalar, Foam::scalar) const [with CloudType = Foam::KinematicCloud<Foam::Cloud<Foam::KinematicParcel<Foam::particle> > >; typename CloudType::parcelType = Foam::KinematicParcel<Foam::particle>; Foam::scalar = double]’: parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.C:48:49: required from here lnInclude/MicroLift.C:180:18: warning: unused variable ‘Tc’ [-Wunused-variable] const scalar Tc = 310.5; ^ make: *** [Make/linux64GccDPInt32Opt/parcels/derived/basicKinematicParcel/makeBasicKinematicParcelSubmodels.o] Error 1 Your help in this matter is greatly appreciated. Thanks and Regards, Shantanu Vachhani |
|
April 26, 2019, 17:24 |
|
#4 |
Senior Member
|
Hi,
In fact, you have two choices: 1. Since class constructor receives constant fvMesh reference as a parameter, you can create my_lovely_mesh_ property in MicroLift class, initialise it in the constructor, and then use it in any method of the class. 2. In general, in ParticleForce children mesh is accessed as this->mesh(). |
|
Tags |
icouncoupledkinematic, lagrangian, mesh, particle forces, walldist patch distance |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
foamToTecplot360 | thomasduerr | OpenFOAM Post-Processing | 121 | June 11, 2021 11:05 |
Problem running perturbUCyl | sen.1986 | OpenFOAM | 17 | June 4, 2019 06:56 |
erros when compiling simpleSRFFoam | examosty | OpenFOAM Installation | 12 | April 26, 2010 19:53 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |
Compiling problems with hello worldC | fw407 | OpenFOAM Installation | 21 | January 6, 2008 18:38 |