STYLE: minor code style changes + move template funcs into separate files

This commit is contained in:
andy
2010-06-23 11:30:04 +01:00
parent 2d85507d51
commit cf43a1043e
22 changed files with 208 additions and 209 deletions

View File

@ -34,10 +34,8 @@ License
namespace Foam
{
defineTypeNameAndDebug(actuationDiskSource, 0);
addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
defineTypeNameAndDebug(actuationDiskSource, 0);
addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
}
@ -45,20 +43,22 @@ addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
void Foam::actuationDiskSource::checkData()
{
if
(
magSqr(diskArea_) <= VSMALL
|| Cp_ <= VSMALL
|| Ct_ <= VSMALL
|| diskDir_ == vector::zero
)
if (magSqr(diskArea_) <= VSMALL)
{
FatalIOErrorIn
(
"Foam::actuationDiskSource::checkData()",
dict_
) << "diskArea, Cp or Ct is small "
<< "or disk direction not specified"
FatalErrorIn("Foam::actuationDiskSource::checkData()")
<< "diskArea is approximately zero"
<< exit(FatalIOError);
}
if (Cp_ <= VSMALL || Ct_ <= VSMALL)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
<< "Cp and Ct must be greater than zero"
<< exit(FatalIOError);
}
if (mag(diskDir_) < VSMALL)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
<< "disk direction vector is approximately zero"
<< exit(FatalIOError);
}
}
@ -75,11 +75,11 @@ Foam::actuationDiskSource::actuationDiskSource
:
basicSource(name, dict, mesh),
cellZoneID_(mesh.cellZones().findZoneID(this->cellSetName())),
diskDir_(vector::zero),
Cp_(0),
Ct_(0),
diskArea_(0),
dict_(dict.subDict(typeName + "Coeffs"))
dict_(dict.subDict(typeName + "Coeffs")),
diskDir_(dict_.lookup("diskDir")),
Cp_(readScalar(dict_.lookup("Cp"))),
Ct_(readScalar(dict_.lookup("Ct"))),
diskArea_(readScalar(dict_.lookup("diskArea")))
{
Info<< " - creating actuation disk zone: "
<< this->name() << endl;
@ -98,11 +98,6 @@ Foam::actuationDiskSource::actuationDiskSource
<< exit(FatalError);
}
dict_.readIfPresent("diskDir", diskDir_);
dict_.readIfPresent("Cp", Cp_);
dict_.readIfPresent("Ct", Ct_);
dict_.readIfPresent("diskArea", diskArea_);
checkData();
}
@ -132,7 +127,7 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
addActuationDiskAxialInertialResistance
(
Usource,
cells,//this->cells(),
cells,
V,
this->mesh().lookupObject<volScalarField>("rho"),
U
@ -143,7 +138,7 @@ void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
addActuationDiskAxialInertialResistance
(
Usource,
cells,//this->cells(),
cells,
V,
geometricOneField(),
U

View File

@ -62,7 +62,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class actuationDiskSource Declaration
Class actuationDiskSource Declaration
\*---------------------------------------------------------------------------*/
class actuationDiskSource
@ -74,6 +74,9 @@ class actuationDiskSource
//- Cell zone ID
label cellZoneID_;
//- Sub dictionary with actuationDisk information
const dictionary& dict_;
//- Disk area normal
vector diskDir_;
@ -86,9 +89,6 @@ class actuationDiskSource
//- Disk area
scalar diskArea_;
//- Sub dictionary with actuationDisk information
const dictionary& dict_;
// Private Member Functions

View File

@ -61,4 +61,5 @@ void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance
}
}
// ************************************************************************* //

View File

@ -58,10 +58,7 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
IObasicSourceList
(
const IObasicSourceList&
);
IObasicSourceList(const IObasicSourceList&);
//- Disallow default bitwise assignment
void operator=(const IObasicSourceList&);
@ -72,18 +69,15 @@ public:
// Constructors
//- Construct from components with list of field names
IObasicSourceList
(
const fvMesh& mesh
);
IObasicSourceList(const fvMesh& mesh);
// Destructor
//- Destructor
virtual ~IObasicSourceList()
{}
//- Read dictionary
//- Read dictionary
virtual bool read();
};

View File

@ -39,8 +39,7 @@ namespace Foam
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
const Foam::wordList Foam::basicSource::
selectionModeTypeNames_
const Foam::wordList Foam::basicSource::selectionModeTypeNames_
(
IStringStream("(points cellSet cellZone all)")()
);
@ -48,8 +47,7 @@ selectionModeTypeNames_
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::basicSource::selectionModeType
Foam::basicSource::wordToSelectionModeType
Foam::basicSource::selectionModeType Foam::basicSource::wordToSelectionModeType
(
const word& smtName
) const
@ -93,16 +91,13 @@ Foam::word Foam::basicSource::selectionModeTypeToWord
}
void Foam::basicSource::setSelection
(
const dictionary& dict
)
void Foam::basicSource::setSelection(const dictionary& dict)
{
switch (selectionMode_)
{
case smPoints:
{
//Do nothing. It should be sorted out by derived class//
// Do nothing. It should be sorted out by derived class
break;
}
case smCellSet:
@ -236,11 +231,7 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
const fvMesh& mesh
)
{
word typeModel;
{
dict.lookup("typeModel") >> typeModel;
}
word typeModel(dict.lookup("typeModel"));
Info<< "Selecting model type " << typeModel << endl;
@ -254,9 +245,9 @@ Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
"basicSource::New(const volVectorField&, "
"const surfaceScalarField&, transportModel&)"
) << "Unknown Model type " << typeModel
<< endl << endl
<< "Valid model types are :" << endl
<< dictionaryConstructorTablePtr_->toc()
<< nl << nl
<< "Valid model types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}

View File

@ -27,7 +27,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::basicSource::name() const
{
return name_;
@ -75,8 +74,7 @@ Foam::basicSource::selectionMode() const
}
inline const Foam::word&
Foam::basicSource::cellSetName() const
inline const Foam::word& Foam::basicSource::cellSetName() const
{
return cellSetName_;
}
@ -88,8 +86,7 @@ inline Foam::scalar Foam::basicSource::V() const
}
inline const Foam::labelList&
Foam::basicSource::cells() const
inline const Foam::labelList& Foam::basicSource::cells() const
{
return cells_;
}

View File

@ -27,7 +27,6 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSource::writeData(Ostream& os) const
{
os << indent << name_ << nl

View File

@ -61,6 +61,7 @@ Foam::basicSourceList::basicSourceList
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -177,4 +178,5 @@ Foam::Ostream& Foam::operator<<
return os;
}
// ************************************************************************* //

View File

@ -63,10 +63,7 @@ private:
// Private Member Functions
//- Disallow default bitwise copy construct
basicSourceList
(
const basicSourceList&
);
basicSourceList(const basicSourceList&);
//- Disallow default bitwise assignment
void operator=(const basicSourceList&);
@ -77,14 +74,10 @@ public:
// Constructors
//- Construct from components with list of field names
basicSourceList
(
const fvMesh& mesh,
const dictionary& dict
);
basicSourceList(const fvMesh& mesh, const dictionary& dict);
// Destructor
//- Destructor
virtual ~basicSourceList()
{}

View File

@ -66,12 +66,9 @@ void Foam::explicitSource::setSelectedCellsFromPoints()
if (globalCellI < 0)
{
WarningIn
(
"explicitSource::setSelectedCellsFromPoints()"
)
<< "Unable to find owner cell for point " << points_[i]
<< endl;
WarningIn("explicitSource::setSelectedCellsFromPoints()")
<< "Unable to find owner cell for point " << points_[i]
<< endl;
}
}
@ -79,20 +76,6 @@ void Foam::explicitSource::setSelectedCellsFromPoints()
}
template<class Type>
void Foam::explicitSource::addSources
(
Field<Type>& fieldSource,
Type& data
) const
{
forAll(this->cells(), i)
{
fieldSource[this->cells()[i]] = data/volSource_[i];
}
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::explicitSource::volumeModeType
@ -136,49 +119,8 @@ Foam::word Foam::explicitSource::volumeModeTypeToWord
}
}
template <class Type>
void Foam::explicitSource::addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& fieldDataDict
)
{
forAll (fieldTypes, fieldI)
{
word fieldName = fieldNames[fieldI];
word fieldType = fieldTypes[fieldI];
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
if
(
(
fieldType
== GeometricField<Type, fvPatchField, volMesh>::typeName
) &&
(
this->mesh().foundObject<geometricField>(fieldName)
)
)
{
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
(
fieldName,
pTraits<Type>::zero
);
fields.insert(fieldName, fieldValue);
}
}
}
void Foam::explicitSource::setFieldData
(
const dictionary& dict
)
void Foam::explicitSource::setFieldData(const dictionary& dict)
{
scalarFields_.clear();
vectorFields_.clear();
@ -271,10 +213,7 @@ Foam::explicitSource::explicitSource
}
void Foam::explicitSource::addSu
(
fvMatrix<scalar>& Eqn
)
void Foam::explicitSource::addSu(fvMatrix<scalar>& Eqn)
{
Field<scalar>& source = Eqn.source();
scalar data = scalarFields_[Eqn.psi().name()];
@ -282,10 +221,7 @@ void Foam::explicitSource::addSu
}
void Foam::explicitSource::addSu
(
fvMatrix<vector>& Eqn
)
void Foam::explicitSource::addSu(fvMatrix<vector>& Eqn)
{
Field<vector>& source = Eqn.source();
vector data = vectorFields_[Eqn.psi().name()];
@ -293,29 +229,25 @@ void Foam::explicitSource::addSu
}
void Foam::explicitSource::addSu
(
DimensionedField<scalar, volMesh>& field
)
void Foam::explicitSource::addSu(DimensionedField<scalar, volMesh>& field)
{
scalar data = scalarFields_[field.name()];
addSources<scalar>(field, data);
}
void Foam::explicitSource::addSu
(
DimensionedField<vector, volMesh>& field
)
void Foam::explicitSource::addSu(DimensionedField<vector, volMesh>& field)
{
vector data = vectorFields_[field.name()];
addSources<vector>(field, data);
}
void Foam::explicitSource::addExplicitSources()
{
scalarFields_.applySources();
vectorFields_.applySources();
}
// ************************************************************************* //

View File

@ -284,6 +284,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "explicitSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -69,11 +69,7 @@ bool Foam::explicitSource::read(const dictionary& dict)
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const explicitSource& source
)
Foam::Ostream& Foam::operator<<(Ostream& os, const explicitSource& source)
{
source.writeData(os);
return os;

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ 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/>.
\*---------------------------------------------------------------------------*/
template<class Type>
void Foam::explicitSource::addSources
(
Field<Type>& fieldSource,
Type& data
) const
{
forAll(this->cells(), i)
{
fieldSource[this->cells()[i]] = data/volSource_[i];
}
}
template <class Type>
void Foam::explicitSource::addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& fieldDataDict
)
{
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
forAll (fieldTypes, fieldI)
{
word fieldName = fieldNames[fieldI];
word fieldType = fieldTypes[fieldI];
if
(
(
fieldType
== GeometricField<Type, fvPatchField, volMesh>::typeName
) &&
(
this->mesh().foundObject<geometricField>(fieldName)
)
)
{
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
(
fieldName,
pTraits<Type>::zero
);
fields.insert(fieldName, fieldValue);
}
}
}
// ************************************************************************* //

View File

@ -68,19 +68,19 @@ class cylindricalInletVelocityFvPatchVectorField
// Private data
//- Axial velocity
scalar axialVelocity_;
const scalar axialVelocity_;
//- Central point
vector centre_;
const vector centre_;
//- Axis
vector axis_;
const vector axis_;
//- RPM
scalar rpm_;
const scalar rpm_;
//- Radial velocity
scalar radialVelocity_;
const scalar radialVelocity_;
public:

View File

@ -508,10 +508,7 @@ Foam::ODEChemistryModel<CompType, ThermoType>::tc() const
{
const Reaction<ThermoType>& R = reactions_[i];
omega
(
R, c, Ti, pi, pf, cf, lRef, pr, cr, rRef
);
omega(R, c, Ti, pi, pf, cf, lRef, pr, cr, rRef);
forAll(R.rhs(), s)
{

View File

@ -91,7 +91,7 @@ protected:
//- Chemistry solver
autoPtr<chemistrySolver<CompType, ThermoType> > solver_;
//- Chemical source term [kg/m3/s]
//- List of reaction rate per specie [kg/m3/s]
PtrList<scalarField> RR_;

View File

@ -138,11 +138,11 @@ void dynLagrangian::correct(const tmp<volTensorField>& gradU)
fvScalarMatrix flmEqn
(
fvm::ddt(flm_)
+ fvm::div(phi(), flm_)
==
invT*LM
- fvm::Sp(invT, flm_)
fvm::ddt(flm_)
+ fvm::div(phi(), flm_)
==
invT*LM
- fvm::Sp(invT, flm_)
);
flmEqn.relax();
@ -154,11 +154,11 @@ void dynLagrangian::correct(const tmp<volTensorField>& gradU)
fvScalarMatrix fmmEqn
(
fvm::ddt(fmm_)
+ fvm::div(phi(), fmm_)
==
invT*MM
- fvm::Sp(invT, fmm_)
fvm::ddt(fmm_)
+ fvm::div(phi(), fmm_)
==
invT*MM
- fvm::Sp(invT, fmm_)
);
fmmEqn.relax();

View File

@ -84,7 +84,7 @@ namespace LESModels
{
/*---------------------------------------------------------------------------*\
Class dynLagrangian Declaration
Class dynLagrangian Declaration
\*---------------------------------------------------------------------------*/
class dynLagrangian
@ -104,6 +104,8 @@ class dynLagrangian
dimensionedScalar flm0_;
dimensionedScalar fmm0_;
// Private Member Functions
//- Update sub-grid scale fields
@ -141,14 +143,13 @@ public:
// Member Functions
//- Return SGS kinetic energy
//- Return SGS kinetic energy
tmp<volScalarField> k(const tmp<volTensorField>& gradU) const
{
return 2.0*sqr(delta())*magSqr(dev(symm(gradU)));
}
//- Return SGS kinetic energy
//- Return SGS kinetic energy
virtual tmp<volScalarField> k() const
{
return k(fvc::grad(U()));

View File

@ -90,8 +90,16 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
{
if (mag(z_) < SMALL)
{
FatalErrorIn("atmBoundaryLayerInletEpsilonFvPatchScalarField(dict)")
<< "z is not correct"
FatalErrorIn
(
"atmBoundaryLayerInletEpsilonFvPatchScalarField"
"("
"const fvPatch&, "
"const DimensionedField<scalar, volMesh>&, "
"const dictionary&"
")"
)
<< "magnitude of z vector must be greater than zero"
<< abort(FatalError);
}
@ -104,16 +112,16 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField::
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const atmBoundaryLayerInletEpsilonFvPatchScalarField& fcvpvf,
const atmBoundaryLayerInletEpsilonFvPatchScalarField& blpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(fcvpvf, iF),
Ustar_(fcvpvf.Ustar_),
z_(fcvpvf.z_),
z0_(fcvpvf.z0_),
kappa_(fcvpvf.kappa_),
zGround_(fcvpvf.zGround_)
fixedValueFvPatchScalarField(blpsf, iF),
Ustar_(blpsf.Ustar_),
z_(blpsf.z_),
z0_(blpsf.z0_),
kappa_(blpsf.kappa_),
zGround_(blpsf.zGround_)
{}
@ -123,11 +131,10 @@ void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
{
const vectorField& c = patch().Cf();
scalarField coord = (c & z_);
scalarField::operator=(pow(Ustar_, 3.0)/(kappa_*(coord - zGround_ + z0_)));
scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
}
// Write
void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);

View File

@ -92,6 +92,7 @@ class atmBoundaryLayerInletEpsilonFvPatchScalarField
//- Minimum corrdinate value in z direction
scalar zGround_;
public:
//- Runtime type information

View File

@ -99,8 +99,16 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
{
if (mag(n_) < SMALL || mag(z_) < SMALL || mag(z0_) < SMALL)
{
FatalErrorIn("atmBoundaryLayerInletVelocityFvPatchVectorField(dict)")
<< "n, z or z0 given are close to zero is not correct"
FatalErrorIn
(
"atmBoundaryLayerInletVelocityFvPatchVectorField"
"("
"const fvPatch&, "
"const DimensionedField<vector, volMesh>&, "
"onst dictionary&"
")"
)
<< "magnitude of n, z and z0 vectors must be greater than zero"
<< abort(FatalError);
}
@ -116,19 +124,19 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField::
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const atmBoundaryLayerInletVelocityFvPatchVectorField& fcvpvf,
const atmBoundaryLayerInletVelocityFvPatchVectorField& blpvf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchVectorField(fcvpvf, iF),
Ustar_(fcvpvf.Ustar_),
n_(fcvpvf.n_),
z_(fcvpvf.z_),
z0_(fcvpvf.z0_),
kappa_(fcvpvf.kappa_),
Uref_(fcvpvf.Uref_),
Href_(fcvpvf.Href_),
zGround_(fcvpvf.zGround_)
fixedValueFvPatchVectorField(blpvf, iF),
Ustar_(blpvf.Ustar_),
n_(blpvf.n_),
z_(blpvf.z_),
z0_(blpvf.z0_),
kappa_(blpvf.kappa_),
Uref_(blpvf.Uref_),
Href_(blpvf.Href_),
zGround_(blpvf.zGround_)
{}
@ -158,7 +166,6 @@ void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
}
// Write
void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);

View File

@ -115,6 +115,7 @@ class atmBoundaryLayerInletVelocityFvPatchVectorField
//- Minimum corrdinate value in z direction
scalar zGround_;
public:
//- Runtime type information
@ -138,8 +139,8 @@ public:
const dictionary&
);
//- Construct by mapping given atmBoundaryLayerInletVelocityFvPatchVectorField
// onto a new patch
//- Construct by mapping given
// atmBoundaryLayerInletVelocityFvPatchVectorField onto a new patch
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const atmBoundaryLayerInletVelocityFvPatchVectorField&,