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

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