mirror of
https://github.com/ParticulateFlow/CFDEMcoupling-PFM.git
synced 2025-12-08 06:37:44 +00:00
internal variable naming convention for registered particle properties: * suffix 'RegName_' indicates class-internal particle property usage; these names use the typeName of the class as prefix for uniqueness * suffix 'Name_' indicates particle properties also used in give/getData; these names can potentially cause a conflict if multiple models try to communicate a property with the same name (some of them can be customized via the couplingProperties dict to resolve this situation)
144 lines
4.3 KiB
C
144 lines
4.3 KiB
C
/*---------------------------------------------------------------------------*\
|
|
License
|
|
|
|
This 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.
|
|
|
|
This code 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 this code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
Copyright (C) 2015- Thomas Lichtenegger, JKU Linz, Austria
|
|
M.Efe Kinaci, JKU Linz, Austria
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
#include "error.H"
|
|
#include "reactantPerParticle.H"
|
|
#include "addToRunTimeSelectionTable.H"
|
|
|
|
#include "dataExchangeModel.H"
|
|
#include "IFstream.H"
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
namespace Foam
|
|
{
|
|
|
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
|
|
defineTypeNameAndDebug(reactantPerParticle, 0);
|
|
|
|
addToRunTimeSelectionTable
|
|
(
|
|
chemistryModel,
|
|
reactantPerParticle,
|
|
dictionary
|
|
);
|
|
|
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
|
|
|
// Construct from components
|
|
reactantPerParticle::reactantPerParticle
|
|
(
|
|
const dictionary& dict,
|
|
cfdemCloudEnergy& sm
|
|
)
|
|
:
|
|
chemistryModel(dict,sm),
|
|
propsDict_(dict.subDict(typeName + "Props")),
|
|
mesh_(sm.mesh()),
|
|
verbose_(propsDict_.lookupOrDefault<bool>("verbose",false)),
|
|
partReactantName_("reactantPerParticle"),
|
|
voidfractionFieldName_(propsDict_.lookupOrDefault<word>("voidfractionFieldName","voidfraction")),
|
|
voidfraction_(sm.mesh().lookupObject<volScalarField>(voidfractionFieldName_)),
|
|
particlesPerCell_
|
|
( IOobject
|
|
(
|
|
"particlesPerCell",
|
|
sm.mesh().time().timeName(),
|
|
sm.mesh(),
|
|
IOobject::NO_READ,
|
|
IOobject::NO_WRITE
|
|
),
|
|
sm.mesh(),
|
|
dimensionedScalar("zero", dimensionSet(0,0,0,0,0), 0)
|
|
),
|
|
loopCounter_(-1),
|
|
Nevery_(propsDict_.lookupOrDefault<label>("Nevery",1))
|
|
{
|
|
particleCloud_.checkCG(false);
|
|
particleCloud_.registerParticleProperty<double**>(partReactantName_,1);
|
|
}
|
|
|
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
|
|
reactantPerParticle::~reactantPerParticle()
|
|
{
|
|
}
|
|
|
|
// * * * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * * //
|
|
|
|
// * * * * * * * * * * * * * * * * Member Fct * * * * * * * * * * * * * * * //
|
|
|
|
void reactantPerParticle::execute()
|
|
{
|
|
loopCounter_++;
|
|
if (loopCounter_ % Nevery_ != 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
particlesPerCell_ *= 0.0;
|
|
|
|
label cellI=0;
|
|
scalar voidfraction(1);
|
|
scalar cellvolume(0.0);
|
|
scalar particlesPerCell(1.0);
|
|
double**& reactantPerParticle_ = particleCloud_.getParticlePropertyRef<double**>(partReactantName_);
|
|
|
|
// first create particles per cell field
|
|
for (int index=0; index<particleCloud_.numberOfParticles(); ++index)
|
|
{
|
|
cellI=particleCloud_.cellIDs()[index][0];
|
|
if (cellI >= 0)
|
|
{
|
|
particlesPerCell_[cellI] += 1.0;
|
|
}
|
|
}
|
|
|
|
// no fill array and communicate it
|
|
for (int index=0; index<particleCloud_.numberOfParticles(); ++index)
|
|
{
|
|
cellI=particleCloud_.cellIDs()[index][0];
|
|
if (cellI >= 0)
|
|
{
|
|
voidfraction = voidfraction_[cellI];
|
|
cellvolume = mesh_.V()[cellI];
|
|
particlesPerCell= particlesPerCell_[cellI];
|
|
reactantPerParticle_[index][0] = voidfraction * cellvolume / particlesPerCell;
|
|
}
|
|
|
|
if (verbose_) Info << "reactantPerParticle_" << reactantPerParticle_[index][0] << endl;
|
|
}
|
|
|
|
// give DEM data
|
|
particleCloud_.dataExchangeM().giveData(partReactantName_, "scalar-atom", reactantPerParticle_);
|
|
|
|
Info << "give data done" << endl;
|
|
}
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
} // End namespace Foam
|
|
|
|
// ************************************************************************* //
|