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);
}
}
}
// ************************************************************************* //