|
[Sponsors] |
Adding a new variable as constructor in the LISA atomization Model |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 8, 2018, 09:45 |
Adding a new variable as constructor in the LISA atomization Model
|
#1 | |
Member
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13 |
Hi,
I am trying to add a new variable ("AVV") in the LISA atomization model but after several attempt I am still unsuccessful in adding it. This new variable is going to be read from a .txt file (this variable changes with pressure). I have made changes in the actual LISA atomisation.C and LISA atomisation.H file but it is giving a prototype error. I will be grateful, if anyone can tell how to add a new variable as a constructor in the LISA atomization. I have added the new model in the langrangian/spray/parcels/include/makeSprayParcelAtomizationModels.H. I have the added here the following section, where the changes has been done. My changes in the NewLISAAtomization.C Code:
#include "NewLISAAtomization.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class CloudType> Foam::NewLISAAtomization<CloudType>::NewLISAAtomization ( const dictionary& dict, const fvMesh& mesh, //Added const volVectorField& U, //Added CloudType& owner ) : AtomizationModel<CloudType>(dict, owner, typeName), //Modified mesh_(U.mesh()), //Added Cl_(readScalar(this->coeffDict().lookup("Cl"))), cTau_(readScalar(this->coeffDict().lookup("cTau"))), Q_(readScalar(this->coeffDict().lookup("Q"))), lisaExp_(readScalar(this->coeffDict().lookup("lisaExp"))), injectorDirection_(this->coeffDict().lookup("injectorDirection")), runTime_(U.time()), //Added AVV_ // New variable added ( IOobject ( "AVV", runTime_.timeName(), mesh_, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh_, dimensionedScalar("zero", dimensionSet(1, -3, 0, 0, 0, 0, 0) ,0.0) ), SMDCalcMethod_(this->coeffDict().lookup("SMDCalculationMethod")) { // Note: Would be good if this could be picked up from the injector injectorDirection_ /= mag(injectorDirection_); if (SMDCalcMethod_ == "method1") { SMDMethod_ = method1; } else if (SMDCalcMethod_ == "method2") { SMDMethod_ = method2; } else { SMDMethod_ = method2; Info<< "Warning: SMDCalculationMethod " << SMDCalcMethod_ << " unknown. Options are (method1 | method2). Using method2" << endl; } } Code:
#ifndef NewLISAAtomization_H #define NewLISAAtomization_H #include "AtomizationModel.H" #include "volFields.H" //Added #include "IOdictionary.H" //Added #include "autoPtr.H" //Added #include "runTimeSelectionTables.H" //Added // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ Class NewLISAAtomization Declaration \*---------------------------------------------------------------------------*/ template<class CloudType> class NewLISAAtomization : public AtomizationModel<CloudType> { public: //- Enumeration for SMD calculations enum SMDMethods { method1, method2 }; private: // Private data const fvMesh& mesh_; //Added scalar Cl_; scalar cTau_; scalar Q_; scalar lisaExp_; vector injectorDirection_; const Time& runTime_; //Added volScalarField AVV_; //Added word SMDCalcMethod_; SMDMethods SMDMethod_; public: //- Runtime type information TypeName("NewLISA"); // Constructors //- Construct from dictionary NewLISAAtomization(const dictionary&, CloudType&); //- Construct copy NewLISAAtomization(const NewLISAAtomization<CloudType>& am); //- Construct and return a clone virtual autoPtr<AtomizationModel<CloudType> > clone() const { return autoPtr<AtomizationModel<CloudType> > ( new NewLISAAtomization<CloudType>(*this) ); } //- Destructor virtual ~NewLISAAtomization(); // Member Functions const volScalarField& AVV() const { return AVV_; //Added } //- initial value of liquidCore virtual scalar initLiquidCore() const; Quote:
Thanks in advance. |
||
August 9, 2018, 15:19 |
|
#2 |
Senior Member
|
Hi,
Following your request in private message. You cannot change arbitrarily constructor interface. In general you have access to the mesh (and subsequently Time) through CloudType. In fact your error has nothing to do with OpenFOAM per se. You need basic knowledge of C++ to read the error. So: 1. Remove your additions to constructor signature. 2. Access mesh through owner variable. |
|
August 9, 2018, 16:10 |
|
#3 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Dear Vishal,
I see you were writing to several people. However, there is nothing left to say. Alex already gave the correct answer.
__________________
Keep foaming, Tobias Holzmann |
|
September 9, 2018, 10:24 |
|
#4 |
Member
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13 |
Hi Alexey,
Thanks for your input. I have now accessed the variables using owner, like this: Code:
rhog_(IOobject("rhog",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimensionSet(1,-3, 0, 0, 0, 0, 0) ,1.0)) But now I would like to define a function calcRhoBar as follows. Code:
template<class CloudType> Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomization ( const dictionary& dict, CloudType& owner ) : AtomizationModel<CloudType>(dict, owner, typeName), h_(IOobject("h",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimless, 0.0)), x_(IOobject("x",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimless, 0.0)), U_(IOobject("U",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimless, 0.0)), rhonew_(IOobject("rhonew",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimless, 0.0)), rhog_(IOobject("rhog",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero", dimensionSet(1,-3, 0, 0, 0, 0, 0) ,1.0)), rhoBar_(IOobject("rhoBar",this->owner_.mesh().time().timeName(),this->owner_.mesh(),IOobject::NO_READ,IOobject::AUTO_WRITE),this->owner_.mesh(),dimensionedScalar("zero",dimDensity ,0.0)) { calcRhoBar(x,h); if (U.time().timeName() == "0" && rhoOverwrite == 1) if (this->owner_.mesh().time().timeName() == "0" && rhoOverwrite == 1) { Info<< "WARNING: Over-riding initial condition and changing the density to the equilibrium value. \n"; rhonew = rhoBar_; rhonew.correctBoundaryConditions(); } } template<class CloudType> Foam::HRMLISAAtomization<CloudType>::HRMLISAAtomization ( const HRMLISAAtomization<CloudType>& am ) : AtomizationModel<CloudType>(am), h_(am.h_), x_(am.x_), rhonew_(am.rhonew_), rhog_(am.rhog_), rhoBar_(am.rhoBar_) {} Thanks a lot |
|
September 9, 2018, 10:56 |
|
#6 |
Member
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13 |
Thanks Tobi for the prompt reply.
I am attaching my .C and .H files, Kindly share some insight regarding the error I have mentioned above. Thanks. |
|
September 9, 2018, 11:09 |
|
#7 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
I have no time to compile your stuff (compile it myself) but can you please add the error message. Thanks.
__________________
Keep foaming, Tobias Holzmann |
|
September 9, 2018, 11:28 |
|
#8 | |
Member
vishal
Join Date: Mar 2013
Posts: 73
Rep Power: 13 |
Hi Tobi,
The error message is as follows: Quote:
Thanks. |
||
September 9, 2018, 14:55 |
|
#9 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi, the error
Code:
thermPoint1(thermoBase::New(U,IOobject("tPoint",this->owner_U.mesh().time().constant(),this->owner_U.db(),IOobject::NO_READ,IOobject::NO_WRITE ,true))), Code:
owner_U ???
__________________
Keep foaming, Tobias Holzmann |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding New Drag Model to MPPICFoam | surajkvs | OpenFOAM Running, Solving & CFD | 0 | May 4, 2018 05:03 |
howto model species transport with additional variable? | suiger | CFX | 2 | December 25, 2017 05:55 |
Error finding variable "THERMX" | sunilpatil | CFX | 8 | April 26, 2013 08:00 |
error in COMSOL:'ERROR:6164 Duplicate Variable' | bhushas | COMSOL | 1 | May 30, 2008 05:35 |
Fortran variable ED for K-OMEGA model | Viatcheslav Anissimov | CFX | 0 | August 31, 2000 07:41 |