Some renaming and restructuring.

This commit is contained in:
Thomas Lichtenegger
2016-08-01 07:14:45 +02:00
parent 561f7fa865
commit 3ff2ae9daa
9 changed files with 589 additions and 211 deletions

View File

@ -1,6 +1,6 @@
recBase/recBase.C
recModel/recModel.C
recModel/newRecModel.C
standardRecModel/standardRecModel.C
recModel/recModel/recModel.C
recModel/recModel/newRecModel.C
recModel/standardRecModel/standardRecModel.C
LIB = $(FOAM_USER_LIBBIN)/librecurrence

View File

@ -64,6 +64,9 @@ recModel::recModel
)
),
verbose_(false),
volScalarFieldNames_(recProperties_.lookup("volScalarFields")),
volVectorFieldNames_(recProperties_.lookup("volVectorFields")),
surfaceScalarFieldNames_(recProperties_.lookup("surfaceScalarFields")),
recTime("dataBase", "", "../system", "../constant", false),
timeDirs(recTime.times()),
numRecFields(label(timeDirs.size())),

View File

@ -51,6 +51,10 @@ protected:
bool verbose_;
const wordList volScalarFieldNames_;
const wordList volVectorFieldNames_;
const wordList surfaceScalarFieldNames_;
Foam::Time recTime;
instantList timeDirs;
label numRecFields;
@ -93,8 +97,6 @@ protected:
virtual scalar norm(label,label) = 0;
private:
void readTimeSeries();
scalar checkTimeStep();
@ -147,15 +149,17 @@ public:
virtual void updateRecFields() = 0;
virtual void setRecFields() = 0;
virtual const volScalarField* voidfraction() const = 0;
virtual const volVectorField* U() const = 0;
virtual const volVectorField* Us() const = 0;
virtual const surfaceScalarField* phi() const = 0;
virtual const surfaceScalarField* phiS() const = 0;
virtual void exportVolScalarField(word, volScalarField&) const = 0;
virtual void exportVolVectorField(word, volVectorField&) const = 0;
virtual void exportSurfaceScalarField(word, surfaceScalarField&) const = 0;
virtual tmp<volScalarField> tvoidfraction() const = 0;
virtual tmp<volVectorField> tU() const = 0;
virtual tmp<volVectorField> tUs() const = 0;
// virtual const volScalarField* voidfraction() const = 0;
// virtual const volVectorField* U() const = 0;
// virtual const volVectorField* Us() const = 0;
// virtual const surfaceScalarField* phi() const = 0;
// virtual const surfaceScalarField* phiS() const = 0;
scalar recTimeStep() const
{
return recTimeStep_;

View File

@ -56,23 +56,26 @@ standardRecModel::standardRecModel
:
recModel(dict,base),
propsDict_(dict.subDict(typeName + "Props")),
voidfractionFieldName_(propsDict_.lookup("voidfractionRecFieldName")),
UFieldName_(propsDict_.lookup("velRecFieldName")),
UsFieldName_(propsDict_.lookup("granVelRecFieldName")),
phiFieldName_(propsDict_.lookup("phiRecFieldName")),
phiSFieldName_(propsDict_.lookup("granPhiRecFieldName")),
readPhi_(propsDict_.lookupOrDefault<bool>("readPhi",false)),
readPhiS_(propsDict_.lookupOrDefault<bool>("readPhiS",false)),
voidfractionRecpl(numRecFields),
URecpl(numRecFields),
UsRecpl(numRecFields),
phiRecpl(numRecFields),
phiSRecpl(numRecFields),
voidfractionRec_(NULL),
URec_(NULL),
UsRec_(NULL),
phiRec_(NULL),
phiSRec_(NULL),
// voidfractionFieldName_(propsDict_.lookup("voidfractionRecFieldName")),
// UFieldName_(propsDict_.lookup("velRecFieldName")),
// UsFieldName_(propsDict_.lookup("granVelRecFieldName")),
// phiFieldName_(propsDict_.lookup("phiRecFieldName")),
// phiSFieldName_(propsDict_.lookup("granPhiRecFieldName")),
// readPhi_(propsDict_.lookupOrDefault<bool>("readPhi",false)),
// readPhiS_(propsDict_.lookupOrDefault<bool>("readPhiS",false)),
// voidfractionRecpl(numRecFields),
// URecpl(numRecFields),
// UsRecpl(numRecFields),
// phiRecpl(numRecFields),
// phiSRecpl(numRecFields),
volScalarFieldList_(volScalarFieldNames_.size()),
volVectorFieldList_(volVectorFieldNames_.size()),
surfaceScalarFieldList_(surfaceScalarFieldNames_.size()),
// voidfractionRec_(NULL),
// URec_(NULL),
// UsRec_(NULL),
// phiRec_(NULL),
// phiSRec_(NULL),
normType_(propsDict_.lookup("normType")),
refVol_(readScalar(propsDict_.lookup("refVol"))),
refVel_(1.0)
@ -80,6 +83,15 @@ standardRecModel::standardRecModel
if (normType_=="solidPhaseMomentum")
refVel_=readScalar(propsDict_.lookup("refVel"));
for(int i=0; i<volScalarFieldNames_.size(); i++)
volScalarFieldList_[i].setSize(numRecFields);
for(int i=0; i<volVectorFieldNames_.size(); i++)
volVectorFieldList_[i].setSize(numRecFields);
for(int i=0; i<surfaceScalarFieldNames_.size(); i++)
surfaceScalarFieldList_[i].setSize(numRecFields);
readFieldSeries();
// make sure each processor has the same sequence of fields
@ -126,7 +138,7 @@ standardRecModel::standardRecModel
virtualTimeIndex=sequenceStart;
virtualTimeIndexNext=virtualTimeIndex+1;
setRecFields();
// setRecFields();
writeRecMatrix();
writeRecPath();
@ -152,68 +164,90 @@ void standardRecModel::updateRecFields()
sequenceEnd=virtualTimeIndexList[virtualTimeIndexListPos].second();
virtualTimeIndexNext=sequenceStart;
}
if (!voidfractionRecpl(virtualTimeIndex) || !URecpl(virtualTimeIndex) || !UsRecpl(virtualTimeIndex))
{
FatalError
<< "standardRecModel::updateRecFields() : "
<< endl
<< " trying to set pointer to non-existent field. "<< endl << endl
<< abort(FatalError);
}
// if (!voidfractionRecpl(virtualTimeIndex) || !URecpl(virtualTimeIndex) || !UsRecpl(virtualTimeIndex))
// {
// FatalError
// << "standardRecModel::updateRecFields() : "
// << endl
// << " trying to set pointer to non-existent field. "<< endl << endl
// << abort(FatalError);
// }
if (verbose_)
Info << "\nUpdating virtual time index to " << virtualTimeIndex << ".\n" << endl;
setRecFields();
// setRecFields();
}
void standardRecModel::setRecFields()
// void standardRecModel::setRecFields()
// {
// voidfractionRec_=voidfractionRecpl(virtualTimeIndex);
// URec_=URecpl(virtualTimeIndex);
// UsRec_=UsRecpl(virtualTimeIndex);
// phiRec_=phiRecpl(virtualTimeIndex);
// phiSRec_=phiSRecpl(virtualTimeIndex);
// if (verbose_)
// Info << "Recurrence fields set.\n" << endl;
// }
// const volScalarField* standardRecModel::voidfraction() const
// {
// return voidfractionRec_;
// }
//
// const volVectorField* standardRecModel::U() const
// {
// return URec_;
// }
//
// const volVectorField* standardRecModel::Us() const
// {
// return UsRec_;
// }
//
// const surfaceScalarField* standardRecModel::phi() const
// {
// return phiRec_;
// }
//
// const surfaceScalarField* standardRecModel::phiS() const
// {
// return phiSRec_;
// }
void standardRecModel::exportVolScalarField(word fieldname, volScalarField& field) const
{
voidfractionRec_=voidfractionRecpl(virtualTimeIndex);
URec_=URecpl(virtualTimeIndex);
UsRec_=UsRecpl(virtualTimeIndex);
phiRec_=phiRecpl(virtualTimeIndex);
phiSRec_=phiSRecpl(virtualTimeIndex);
if (verbose_)
Info << "Recurrence fields set.\n" << endl;
for(int i=0; i<volScalarFieldNames_.size(); i++)
if(volScalarFieldNames_[i].match(fieldname))
{
field = volScalarFieldList_[i][virtualTimeIndex];
return;
}
FatalError<<"standardRecModel: Could not find volScalarField with name " << fieldname << abort(FatalError);
}
const volScalarField* standardRecModel::voidfraction() const
void standardRecModel::exportVolVectorField(word fieldname, volVectorField& field) const
{
return voidfractionRec_;
for(int i=0; i<volVectorFieldNames_.size(); i++)
if(volVectorFieldNames_[i].match(fieldname))
{
field = volVectorFieldList_[i][virtualTimeIndex];
return;
}
FatalError<<"standardRecModel: Could not find volVectorField with name " << fieldname << abort(FatalError);
}
const volVectorField* standardRecModel::U() const
void standardRecModel::exportSurfaceScalarField(word fieldname, surfaceScalarField& field) const
{
return URec_;
}
const volVectorField* standardRecModel::Us() const
{
return UsRec_;
}
const surfaceScalarField* standardRecModel::phi() const
{
return phiRec_;
}
const surfaceScalarField* standardRecModel::phiS() const
{
return phiSRec_;
}
tmp<volScalarField> standardRecModel::tvoidfraction() const
{
return voidfractionRecpl[virtualTimeIndex];
}
tmp<volVectorField> standardRecModel::tU() const
{
return URecpl[virtualTimeIndex];
}
tmp<volVectorField> standardRecModel::tUs() const
{
return UsRecpl[virtualTimeIndex];
for(int i=0; i<surfaceScalarFieldNames_.size(); i++)
if(surfaceScalarFieldNames_[i].match(fieldname))
{
field = surfaceScalarFieldList_[i][virtualTimeIndex];
return;
}
FatalError<<"standardRecModel: Could not find surfaceScalarField with name " << fieldname << abort(FatalError);
}
void standardRecModel::readFieldSeries()
@ -236,66 +270,15 @@ void standardRecModel::readFieldSeries()
Info << "Reading at t = " << recTime.timeName() << endl;
}
voidfractionRecpl.set
(
timeIndexList(recTime.timeName()),
new volScalarField
for(int i=0; i<volScalarFieldNames_.size(); i++)
volScalarFieldList_[i].set
(
IOobject
(
voidfractionFieldName_,
recTime.timePath(),
base_.mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
base_.mesh()
)
);
URecpl.set
(
timeIndexList(recTime.timeName()),
new volVectorField
(
IOobject
(
UFieldName_,
recTime.timePath(),
base_.mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
base_.mesh()
)
);
UsRecpl.set
(
timeIndexList(recTime.timeName()),
new volVectorField
(
IOobject
(
UsFieldName_,
recTime.timePath(),
base_.mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
base_.mesh()
)
);
if (readPhi_)
{
phiRecpl.set
(
timeIndexList(recTime.timeName()),
new surfaceScalarField
timeIndexList(recTime.timeName()),
new volScalarField
(
IOobject
(
phiFieldName_,
volScalarFieldNames_[i],
recTime.timePath(),
base_.mesh(),
IOobject::MUST_READ,
@ -303,38 +286,35 @@ void standardRecModel::readFieldSeries()
),
base_.mesh()
)
);
}
else
{
phiRecpl.set
(
);
for(int i=0; i<volVectorFieldNames_.size(); i++)
volVectorFieldList_[i].set
(
timeIndexList(recTime.timeName()),
new volVectorField
(
IOobject
(
volVectorFieldNames_[i],
recTime.timePath(),
base_.mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
base_.mesh()
)
);
for(int i=0; i<surfaceScalarFieldNames_.size(); i++)
surfaceScalarFieldList_[i].set
(
timeIndexList(recTime.timeName()),
new surfaceScalarField
(
IOobject
(
phiFieldName_,
recTime.timePath(),
base_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
linearInterpolate(URecpl.last()*voidfractionRecpl.last()) & base_.mesh().Sf()
)
);
}
if (readPhiS_)
{
phiSRecpl.set
(
timeIndexList(recTime.timeName()),
new surfaceScalarField
(
IOobject
(
phiSFieldName_,
surfaceScalarFieldNames_[i],
recTime.timePath(),
base_.mesh(),
IOobject::MUST_READ,
@ -342,27 +322,135 @@ void standardRecModel::readFieldSeries()
),
base_.mesh()
)
);
}
else
{
phiSRecpl.set
(
timeIndexList(recTime.timeName()),
new surfaceScalarField
(
IOobject
(
phiSFieldName_,
recTime.timePath(),
base_.mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
linearInterpolate(UsRecpl.last()*(1-voidfractionRecpl.last())) & base_.mesh().Sf()
)
);
}
);
// voidfractionRecpl.set
// (
// timeIndexList(recTime.timeName()),
// new volScalarField
// (
// IOobject
// (
// voidfractionFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// ),
// base_.mesh()
// )
// );
//
// URecpl.set
// (
// timeIndexList(recTime.timeName()),
// new volVectorField
// (
// IOobject
// (
// UFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// ),
// base_.mesh()
// )
// );
// UsRecpl.set
// (
// timeIndexList(recTime.timeName()),
// new volVectorField
// (
// IOobject
// (
// UsFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// ),
// base_.mesh()
// )
// );
//
// if (readPhi_)
// {
// phiRecpl.set
// (
// timeIndexList(recTime.timeName()),
// new surfaceScalarField
// (
// IOobject
// (
// phiFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// ),
// base_.mesh()
// )
// );
// }
// else
// {
// phiRecpl.set
// (
// timeIndexList(recTime.timeName()),
// new surfaceScalarField
// (
// IOobject
// (
// phiFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::NO_READ,
// IOobject::NO_WRITE
// ),
// linearInterpolate(URecpl.last()*voidfractionRecpl.last()) & base_.mesh().Sf()
// )
// );
// }
//
// if (readPhiS_)
// {
// phiSRecpl.set
// (
// timeIndexList(recTime.timeName()),
// new surfaceScalarField
// (
// IOobject
// (
// phiSFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::MUST_READ,
// IOobject::NO_WRITE
// ),
// base_.mesh()
// )
// );
// }
// else
// {
// phiSRecpl.set
// (
// timeIndexList(recTime.timeName()),
// new surfaceScalarField
// (
// IOobject
// (
// phiSFieldName_,
// recTime.timePath(),
// base_.mesh(),
// IOobject::NO_READ,
// IOobject::NO_WRITE
// ),
// linearInterpolate(UsRecpl.last()*(1-voidfractionRecpl.last())) & base_.mesh().Sf()
// )
// );
// }
}

View File

@ -68,40 +68,45 @@ public:
void updateRecFields();
void setRecFields();
// void setRecFields();
const volScalarField* voidfraction() const;
const volVectorField* U() const;
const volVectorField* Us() const;
const surfaceScalarField* phi() const;
const surfaceScalarField* phiS() const;
// const volScalarField* voidfraction() const;
// const volVectorField* U() const;
// const volVectorField* Us() const;
// const surfaceScalarField* phi() const;
// const surfaceScalarField* phiS() const;
void exportVolScalarField(word, volScalarField&) const;
void exportVolVectorField(word, volVectorField&) const;
void exportSurfaceScalarField(word, surfaceScalarField&) const;
tmp<volScalarField> tvoidfraction() const;
tmp<volVectorField> tU() const;
tmp<volVectorField> tUs() const;
private:
dictionary propsDict_;
word voidfractionFieldName_;
word UFieldName_;
word UsFieldName_;
word phiFieldName_;
word phiSFieldName_;
bool readPhi_,readPhiS_;
// word voidfractionFieldName_;
// word UFieldName_;
// word UsFieldName_;
// word phiFieldName_;
// word phiSFieldName_;
// bool readPhi_,readPhiS_;
PtrList<volScalarField> voidfractionRecpl;
PtrList<volVectorField> URecpl;
PtrList<volVectorField> UsRecpl;
PtrList<surfaceScalarField> phiRecpl;
PtrList<surfaceScalarField> phiSRecpl;
// PtrList<volScalarField> voidfractionRecpl;
// PtrList<volVectorField> URecpl;
// PtrList<volVectorField> UsRecpl;
// PtrList<surfaceScalarField> phiRecpl;
// PtrList<surfaceScalarField> phiSRecpl;
const volScalarField *voidfractionRec_;
const volVectorField *URec_;
const volVectorField *UsRec_;
const surfaceScalarField *phiRec_;
const surfaceScalarField *phiSRec_;
List<PtrList<volScalarField> volScalarFieldList_;
List<PtrList<volVectorField> volVectorFieldList_;
List<PtrList<surfaceScalarField> surfaceScalarFieldList_;
// const volScalarField *voidfractionRec_;
// const volVectorField *URec_;
// const volVectorField *UsRec_;
// const surfaceScalarField *phiRec_;
// const surfaceScalarField *phiSRec_;
word normType_;
scalar refVol_;

View File

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------*\
CFDEMcoupling academic - Open Source CFD-DEM coupling
Contributing authors:
Thomas Lichtenegger
Copyright (C) 2015- Johannes Kepler University, Linz
-------------------------------------------------------------------------------
License
This file is part of CFDEMcoupling academic.
CFDEMcoupling academic 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.
CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "recNorm.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
autoPtr<recNorm> recNorm::New
(
const dictionary& dict,
recBase& base
)
{
word recNormType
(
dict.lookup("recNorm")
);
Info<< "Selecting recNorm "
<< recNormType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(recNormType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalError
<< "recNorm::New(const dictionary&, const spray&) : "
<< endl
<< " unknown recNormType type "
<< recNormType
<< ", constructor not in hash table" << endl << endl
<< " Valid recNorm types are :"
<< endl;
Info<< dictionaryConstructorTablePtr_->toc()
<< abort(FatalError);
}
return autoPtr<recNorm>(cstrIter()(dict,base));
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,86 @@
/*---------------------------------------------------------------------------*\
CFDEMcoupling academic - Open Source CFD-DEM coupling
Contributing authors:
Thomas Lichtenegger
Copyright (C) 2015- Johannes Kepler University, Linz
-------------------------------------------------------------------------------
License
This file is part of CFDEMcoupling academic.
CFDEMcoupling academic 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.
CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "recNorm.H"
#include <unistd.h>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(recNorm, 0);
defineRunTimeSelectionTable(recNorm, dictionary);
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
recNorm::recNorm
(
const dictionary& dict,
recBase& base
)
:
base_(base),
recProperties_(dict),
controlDict_
(
IOobject
(
"controlDict",
base.mesh().time().system(),
base.mesh(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
verbose_(false)
{
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
recNorm::~recNorm()
{}
// * * * * * * * * * * * * * public Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,116 @@
/*---------------------------------------------------------------------------*\
CFDEMcoupling academic - Open Source CFD-DEM coupling
Contributing authors:
Thomas Lichtenegger
Copyright (C) 2015- Johannes Kepler University, Linz
-------------------------------------------------------------------------------
License
This file is part of CFDEMcoupling academic.
CFDEMcoupling academic 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.
CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#ifndef recNorm_H
#define recNorm_H
#include "recBase.H"
#include "fvCFD.H"
#include "HashTable.H"
#include "labelPair.H"
#include "OFstream.H"
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class recNorm Declaration
\*---------------------------------------------------------------------------*/
class recNorm
{
protected:
// Protected data
recBase& base_;
const dictionary& recProperties_;
IOdictionary controlDict_;
bool verbose_;
public:
//- Runtime type information
TypeName("recNorm");
// Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
recNorm,
dictionary,
(
const dictionary& dict,
recBase& base
),
(dict,base)
);
// Constructors
//- Construct from components
recNorm
(
const dictionary& dict,
recBase& base
);
// Destructor
virtual ~recNorm();
// Selector
static autoPtr<recNorm> New
(
const dictionary& dict,
recBase& base
);
// Member Functions
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //