mirror of
https://github.com/ParticulateFlow/CFDEMcoupling-PFM.git
synced 2025-12-08 06:37:44 +00:00
use PtrLists for subModels. includes some cleanup for commandModel acessors.
This commit is contained in:
@ -154,6 +154,7 @@ cfdemCloud::cfdemCloud
|
|||||||
turbulenceModelType_
|
turbulenceModelType_
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
forceModel_(nrForceModels()),
|
||||||
locateModel_
|
locateModel_
|
||||||
(
|
(
|
||||||
locateModel::New
|
locateModel::New
|
||||||
@ -162,14 +163,7 @@ cfdemCloud::cfdemCloud
|
|||||||
*this
|
*this
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
/*momCoupleModel_
|
momCoupleModel_(nrMomCoupleModels()),
|
||||||
(
|
|
||||||
momCoupleModel::New
|
|
||||||
(
|
|
||||||
couplingProperties_,
|
|
||||||
*this
|
|
||||||
)
|
|
||||||
),*/
|
|
||||||
dataExchangeModel_
|
dataExchangeModel_
|
||||||
(
|
(
|
||||||
dataExchangeModel::New
|
dataExchangeModel::New
|
||||||
@ -235,7 +229,9 @@ cfdemCloud::cfdemCloud
|
|||||||
couplingProperties_,
|
couplingProperties_,
|
||||||
*this
|
*this
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
liggghtsCommand_(liggghtsCommandModelList_.size()),
|
||||||
|
otherForceModel_(otherForceModels_.size())
|
||||||
{
|
{
|
||||||
#include "versionInfo.H"
|
#include "versionInfo.H"
|
||||||
global buildInfo(couplingProperties_,*this);
|
global buildInfo(couplingProperties_,*this);
|
||||||
@ -276,57 +272,70 @@ cfdemCloud::cfdemCloud
|
|||||||
FatalError << "CFDEMcoupling does not support adjustable time steps."
|
FatalError << "CFDEMcoupling does not support adjustable time steps."
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|
||||||
momCoupleModel_ = new autoPtr<momCoupleModel>[momCoupleModels_.size()];
|
forAll(momCoupleModel_, modeli)
|
||||||
for (int i=0;i<momCoupleModels_.size();i++)
|
|
||||||
{
|
{
|
||||||
momCoupleModel_[i] = momCoupleModel::New
|
momCoupleModel_.set
|
||||||
|
(
|
||||||
|
modeli,
|
||||||
|
momCoupleModel::New
|
||||||
(
|
(
|
||||||
couplingProperties_,
|
couplingProperties_,
|
||||||
*this,
|
*this,
|
||||||
momCoupleModels_[i]
|
momCoupleModels_[modeli]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
forceModel_ = new autoPtr<forceModel>[nrForceModels()];
|
forAll(forceModels_, modeli)
|
||||||
for (int i=0;i<nrForceModels();i++)
|
|
||||||
{
|
{
|
||||||
forceModel_[i] = forceModel::New
|
forceModel_.set
|
||||||
|
(
|
||||||
|
modeli,
|
||||||
|
forceModel::New
|
||||||
(
|
(
|
||||||
couplingProperties_,
|
couplingProperties_,
|
||||||
*this,
|
*this,
|
||||||
forceModels_[i]
|
forceModels_[modeli]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// run liggghts commands from cfdem
|
// run liggghts commands from cfdem
|
||||||
liggghtsCommand_ = new autoPtr<liggghtsCommandModel>[liggghtsCommandModelList_.size()];
|
forAll(liggghtsCommand_, modeli)
|
||||||
for (int i=0;i<liggghtsCommandModelList_.size();i++)
|
|
||||||
{
|
{
|
||||||
liggghtsCommand_[i] = liggghtsCommandModel::New
|
liggghtsCommand_.set
|
||||||
|
(
|
||||||
|
modeli,
|
||||||
|
liggghtsCommandModel::New
|
||||||
(
|
(
|
||||||
liggghtsCommandDict_,
|
liggghtsCommandDict_,
|
||||||
*this,
|
*this,
|
||||||
liggghtsCommandModelList_[i],
|
liggghtsCommandModelList_[modeli],
|
||||||
i
|
modeli
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
otherForceModel_ = new autoPtr<otherForceModel>[otherForceModels_.size()];
|
forAll(otherForceModel_, modeli)
|
||||||
for (int i=0;i<otherForceModels_.size();i++)
|
for (int i=0;i<otherForceModels_.size();i++)
|
||||||
{
|
{
|
||||||
otherForceModel_[i] = otherForceModel::New
|
otherForceModel_.set
|
||||||
|
(
|
||||||
|
modeli,
|
||||||
|
otherForceModel::New
|
||||||
(
|
(
|
||||||
couplingProperties_,
|
couplingProperties_,
|
||||||
*this,
|
*this,
|
||||||
otherForceModels_[i]
|
otherForceModels_[modeli]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dataExchangeM().setCG();
|
dataExchangeM().setCG();
|
||||||
Switch cgWarnOnly_(couplingProperties_.lookupOrDefault<Switch>("cgWarnOnly", true));
|
Switch cgWarnOnly(couplingProperties_.lookupOrDefault<Switch>("cgWarnOnly", true));
|
||||||
if (!cgOK_ && cg_ > 1)
|
if (!cgOK_ && cg_ > 1)
|
||||||
{
|
{
|
||||||
if (cgWarnOnly_)
|
if (cgWarnOnly)
|
||||||
Warning << "at least one of your models is not fit for cg !!!" << endl;
|
Warning << "at least one of your models is not fit for cg !!!" << endl;
|
||||||
else
|
else
|
||||||
FatalError << "at least one of your models is not fit for cg !!!" << abort(FatalError);
|
FatalError << "at least one of your models is not fit for cg !!!" << abort(FatalError);
|
||||||
@ -575,16 +584,9 @@ scalar cfdemCloud::voidfraction(int index) const
|
|||||||
return voidfractions()[index][0];
|
return voidfractions()[index][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
label cfdemCloud::liggghtsCommandModelIndex(word name) const
|
label cfdemCloud::liggghtsCommandModelIndex(const word& name) const
|
||||||
{
|
{
|
||||||
forAll(liggghtsCommandModelList_,i)
|
return findIndex(liggghtsCommandModelList_, name);
|
||||||
{
|
|
||||||
if(liggghtsCommand()[i]().name() == name)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * WRITE * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * WRITE * * * * * * * * * * * * * //
|
||||||
@ -841,7 +843,7 @@ void cfdemCloud::otherForces(volVectorField& forcefield)
|
|||||||
forcefield.primitiveFieldRef() = vector::zero;
|
forcefield.primitiveFieldRef() = vector::zero;
|
||||||
forcefield.boundaryFieldRef() = vector::zero;
|
forcefield.boundaryFieldRef() = vector::zero;
|
||||||
for (int i=0;i<otherForceModels_.size();i++)
|
for (int i=0;i<otherForceModels_.size();i++)
|
||||||
forcefield += otherForceModel_[i]().exportForceField();
|
forcefield += otherForceModel_[i].exportForceField();
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -180,11 +180,11 @@ protected:
|
|||||||
|
|
||||||
const turbulenceModel& turbulence_;
|
const turbulenceModel& turbulence_;
|
||||||
|
|
||||||
autoPtr<forceModel>* forceModel_;
|
PtrList<forceModel> forceModel_;
|
||||||
|
|
||||||
autoPtr<locateModel> locateModel_;
|
autoPtr<locateModel> locateModel_;
|
||||||
|
|
||||||
autoPtr<momCoupleModel>* momCoupleModel_;
|
PtrList<momCoupleModel> momCoupleModel_;
|
||||||
|
|
||||||
autoPtr<dataExchangeModel> dataExchangeModel_;
|
autoPtr<dataExchangeModel> dataExchangeModel_;
|
||||||
|
|
||||||
@ -202,9 +202,9 @@ protected:
|
|||||||
|
|
||||||
autoPtr<meshMotionModel> meshMotionModel_;
|
autoPtr<meshMotionModel> meshMotionModel_;
|
||||||
|
|
||||||
autoPtr<liggghtsCommandModel>* liggghtsCommand_;
|
mutable PtrList<liggghtsCommandModel> liggghtsCommand_;
|
||||||
|
|
||||||
autoPtr<otherForceModel>* otherForceModel_;
|
PtrList<otherForceModel> otherForceModel_;
|
||||||
|
|
||||||
// Protected member functions
|
// Protected member functions
|
||||||
virtual void getDEMdata();
|
virtual void getDEMdata();
|
||||||
@ -272,7 +272,7 @@ public:
|
|||||||
|
|
||||||
scalar voidfraction(int) const;
|
scalar voidfraction(int) const;
|
||||||
|
|
||||||
label liggghtsCommandModelIndex(word) const;
|
label liggghtsCommandModelIndex(const word&) const;
|
||||||
|
|
||||||
inline void setCG(double);
|
inline void setCG(double);
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ public:
|
|||||||
|
|
||||||
inline const wordList& liggghtsCommandModelList() const;
|
inline const wordList& liggghtsCommandModelList() const;
|
||||||
|
|
||||||
inline autoPtr<liggghtsCommandModel>* liggghtsCommand() const;
|
inline liggghtsCommandModel& liggghtsCommand(const label) const;
|
||||||
|
|
||||||
inline const turbulenceModel& turbulence() const;
|
inline const turbulenceModel& turbulence() const;
|
||||||
|
|
||||||
|
|||||||
@ -349,9 +349,9 @@ inline const wordList& cfdemCloud::liggghtsCommandModelList() const
|
|||||||
return liggghtsCommandModelList_;
|
return liggghtsCommandModelList_;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline autoPtr<liggghtsCommandModel>* cfdemCloud::liggghtsCommand() const
|
inline liggghtsCommandModel& cfdemCloud::liggghtsCommand(const label modeli) const
|
||||||
{
|
{
|
||||||
return liggghtsCommand_;
|
return liggghtsCommand_[modeli];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const turbulenceModel& cfdemCloud::turbulence() const
|
inline const turbulenceModel& cfdemCloud::turbulence() const
|
||||||
|
|||||||
@ -229,10 +229,11 @@ bool twoWayMPI::couple(int i) const
|
|||||||
// Check if exact timing is needed
|
// Check if exact timing is needed
|
||||||
// get time for execution
|
// get time for execution
|
||||||
// store time for execution in list
|
// store time for execution in list
|
||||||
if(particleCloud_.liggghtsCommand()[i]().exactTiming())
|
liggghtsCommandModel& lcm = particleCloud_.liggghtsCommand(i);
|
||||||
|
if(lcm.exactTiming())
|
||||||
{
|
{
|
||||||
exactTiming = true;
|
exactTiming = true;
|
||||||
DynamicList<scalar> h = particleCloud_.liggghtsCommand()[i]().executionsWithinPeriod(TSstart(),TSend());
|
DynamicList<scalar> h = lcm.executionsWithinPeriod(TSstart(),TSend());
|
||||||
|
|
||||||
forAll(h,j)
|
forAll(h,j)
|
||||||
{
|
{
|
||||||
@ -261,7 +262,7 @@ bool twoWayMPI::couple(int i) const
|
|||||||
Info << "Foam::twoWayMPI::couple(i): lcModel=" << lcModel << endl;
|
Info << "Foam::twoWayMPI::couple(i): lcModel=" << lcModel << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(particleCloud_.liggghtsCommand()[i]().type()=="runLiggghts")
|
if(lcm.type()=="runLiggghts")
|
||||||
runComNr=i;
|
runComNr=i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,22 +279,22 @@ bool twoWayMPI::couple(int i) const
|
|||||||
{
|
{
|
||||||
// set run command till interrupt
|
// set run command till interrupt
|
||||||
DEMstepsRun += DEMstepsToInterrupt[j];
|
DEMstepsRun += DEMstepsToInterrupt[j];
|
||||||
particleCloud_.liggghtsCommand()[runComNr]().set(DEMstepsToInterrupt[j]);
|
particleCloud_.liggghtsCommand(runComNr).set(DEMstepsToInterrupt[j]);
|
||||||
const char* command = particleCloud_.liggghtsCommand()[runComNr]().command(0);
|
const char* command = particleCloud_.liggghtsCommand(runComNr).command(0);
|
||||||
Info << "Executing run command: '"<< command <<"'"<< endl;
|
Info << "Executing run command: '"<< command <<"'"<< endl;
|
||||||
lmp->input->one(command);
|
lmp->input->one(command);
|
||||||
|
|
||||||
// run liggghts command with exact timing
|
// run liggghts command with exact timing
|
||||||
command = particleCloud_.liggghtsCommand()[lcModel[j]]().command(0);
|
command = particleCloud_.liggghtsCommand(lcModel[j]).command(0);
|
||||||
Info << "Executing command: '"<< command <<"'"<< endl;
|
Info << "Executing command: '"<< command <<"'"<< endl;
|
||||||
lmp->input->one(command);
|
lmp->input->one(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the run
|
// do the run
|
||||||
if(particleCloud_.liggghtsCommand()[runComNr]().runCommand(couplingStep()))
|
if(particleCloud_.liggghtsCommand(runComNr).runCommand(couplingStep()))
|
||||||
{
|
{
|
||||||
particleCloud_.liggghtsCommand()[runComNr]().set(couplingInterval() - DEMstepsRun);
|
particleCloud_.liggghtsCommand(runComNr).set(couplingInterval() - DEMstepsRun);
|
||||||
const char* command = particleCloud_.liggghtsCommand()[runComNr]().command(0);
|
const char* command = particleCloud_.liggghtsCommand(runComNr).command(0);
|
||||||
Info << "Executing run command: '"<< command <<"'"<< endl;
|
Info << "Executing run command: '"<< command <<"'"<< endl;
|
||||||
lmp->input->one(command);
|
lmp->input->one(command);
|
||||||
}
|
}
|
||||||
@ -301,16 +302,13 @@ bool twoWayMPI::couple(int i) const
|
|||||||
// do the other non exact timing models
|
// do the other non exact timing models
|
||||||
forAll(particleCloud_.liggghtsCommandModelList(),i)
|
forAll(particleCloud_.liggghtsCommandModelList(),i)
|
||||||
{
|
{
|
||||||
if
|
liggghtsCommandModel& lcm = particleCloud_.liggghtsCommand(i);
|
||||||
(
|
if (! lcm.exactTiming() && lcm.runCommand(couplingStep()) )
|
||||||
! particleCloud_.liggghtsCommand()[i]().exactTiming() &&
|
|
||||||
particleCloud_.liggghtsCommand()[i]().runCommand(couplingStep())
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
commandLines=particleCloud_.liggghtsCommand()[i]().commandLines();
|
commandLines = lcm.commandLines();
|
||||||
for(int j=0;j<commandLines;j++)
|
for(int j=0;j<commandLines;j++)
|
||||||
{
|
{
|
||||||
const char* command = particleCloud_.liggghtsCommand()[i]().command(j);
|
const char* command = lcm.command(j);
|
||||||
Info << "Executing command: '"<< command <<"'"<< endl;
|
Info << "Executing command: '"<< command <<"'"<< endl;
|
||||||
lmp->input->one(command);
|
lmp->input->one(command);
|
||||||
}
|
}
|
||||||
@ -322,12 +320,13 @@ bool twoWayMPI::couple(int i) const
|
|||||||
{
|
{
|
||||||
forAll(particleCloud_.liggghtsCommandModelList(),i)
|
forAll(particleCloud_.liggghtsCommandModelList(),i)
|
||||||
{
|
{
|
||||||
if(particleCloud_.liggghtsCommand()[i]().runCommand(couplingStep()))
|
liggghtsCommandModel& lcm = particleCloud_.liggghtsCommand(i);
|
||||||
|
if (lcm.runCommand(couplingStep()))
|
||||||
{
|
{
|
||||||
commandLines=particleCloud_.liggghtsCommand()[i]().commandLines();
|
commandLines = lcm.commandLines();
|
||||||
for(int j=0;j<commandLines;j++)
|
for(int j=0;j<commandLines;j++)
|
||||||
{
|
{
|
||||||
const char* command = particleCloud_.liggghtsCommand()[i]().command(j);
|
const char* command = lcm.command(j);
|
||||||
Info << "Executing command: '"<< command <<"'"<< endl;
|
Info << "Executing command: '"<< command <<"'"<< endl;
|
||||||
lmp->input->one(command);
|
lmp->input->one(command);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -401,12 +401,12 @@ bool twoWayMany2Many::couple(int i) const
|
|||||||
forAll(particleCloud_.liggghtsCommandModelList(),i)
|
forAll(particleCloud_.liggghtsCommandModelList(),i)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (particleCloud_.liggghtsCommand()[i]().runCommand(couplingStep()))
|
if (particleCloud_.liggghtsCommand(i).runCommand(couplingStep()))
|
||||||
{
|
{
|
||||||
label commandLines = particleCloud_.liggghtsCommand()[i]().commandLines();
|
label commandLines = particleCloud_.liggghtsCommand(i).commandLines();
|
||||||
for (int j=0; j<commandLines; j++)
|
for (int j=0; j<commandLines; j++)
|
||||||
{
|
{
|
||||||
const char* command = particleCloud_.liggghtsCommand()[i]().command(j);
|
const char* command = particleCloud_.liggghtsCommand(i).command(j);
|
||||||
Info << "Executing command: '" << command << "'" << endl;
|
Info << "Executing command: '" << command << "'" << endl;
|
||||||
lmp->input->one(command);
|
lmp->input->one(command);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,16 +88,14 @@ forceModel::forceModel
|
|||||||
probeIt_(sm.probeM().active()),
|
probeIt_(sm.probeM().active()),
|
||||||
requiresEx_(false),
|
requiresEx_(false),
|
||||||
forceSubModels_(0),
|
forceSubModels_(0),
|
||||||
forceSubModel_(NULL)
|
forceSubModel_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
forceModel::~forceModel()
|
forceModel::~forceModel()
|
||||||
{
|
{}
|
||||||
delete [] forceSubModel_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
|
||||||
/*tmp<volScalarField> forceModel::provideScalarField()
|
/*tmp<volScalarField> forceModel::provideScalarField()
|
||||||
@ -180,17 +178,21 @@ void forceModel::setForceSubModels(dictionary& dict)
|
|||||||
forceSubModels_.setSize(1, "ImEx");
|
forceSubModels_.setSize(1, "ImEx");
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] forceSubModel_;
|
forceSubModel_.clear();
|
||||||
forceSubModel_ = new autoPtr<forceSubModel>[nrForceSubModels()];
|
forceSubModel_.setSize(nrForceSubModels());
|
||||||
Info << "nrForceSubModels()=" << nrForceSubModels() << endl;
|
Info << "nrForceSubModels()=" << nrForceSubModels() << endl;
|
||||||
for (int i=0;i<nrForceSubModels();i++)
|
forAll(forceSubModels_, modeli)
|
||||||
{
|
{
|
||||||
forceSubModel_[i] = forceSubModel::New
|
forceSubModel_.set
|
||||||
|
(
|
||||||
|
modeli,
|
||||||
|
forceSubModel::New
|
||||||
(
|
(
|
||||||
dict,
|
dict,
|
||||||
particleCloud_,
|
particleCloud_,
|
||||||
*this,
|
*this,
|
||||||
forceSubModels_[i]
|
forceSubModels_[modeli]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ protected:
|
|||||||
|
|
||||||
wordList forceSubModels_;
|
wordList forceSubModels_;
|
||||||
|
|
||||||
autoPtr<forceSubModel>* forceSubModel_;
|
mutable PtrList<forceSubModel> forceSubModel_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ public:
|
|||||||
|
|
||||||
inline const wordList& forceSubModels() { return forceSubModels_; }
|
inline const wordList& forceSubModels() { return forceSubModels_; }
|
||||||
|
|
||||||
inline forceSubModel& forceSubM(int i) const { return forceSubModel_[i](); }
|
inline forceSubModel& forceSubM(int i) const { return forceSubModel_[i]; }
|
||||||
|
|
||||||
inline int nrForceSubModels() const { return forceSubModels_.size(); }
|
inline int nrForceSubModels() const { return forceSubModels_.size(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user