ENH: Adding:

1) basicSource for explicit sources(ActuationDisk and
	   explicit source so far)
	2) cylindricalInlet BC
	3) swirlMassFlowRate BC
	4) dynamicLagrangian LES incompressible turbulence model
	5) atmospheric boundary layer inlet BC for velocity and
	   epsilon
This commit is contained in:
sergio
2010-06-22 15:21:12 +01:00
parent 1a2973c4f4
commit ddcf2ee997
27 changed files with 3489 additions and 80 deletions

View File

@ -0,0 +1,321 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "HashSet.H"
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(explicitSource, 0);
addToRunTimeSelectionTable
(
basicSource,
explicitSource,
dictionary
);
}
const Foam::wordList Foam::explicitSource::volumeModeTypeNames_
(
IStringStream("(absolute specific)")()
);
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::explicitSource::setSelectedCellsFromPoints()
{
labelHashSet selectedCells;
forAll(points_, i)
{
label cellI = this->mesh().findCell(points_[i]);
if (cellI >= 0)
{
selectedCells.insert(cellI);
}
label globalCellI = returnReduce(cellI, maxOp<label>());
if (globalCellI < 0)
{
WarningIn
(
"explicitSource::setSelectedCellsFromPoints()"
)
<< "Unable to find owner cell for point " << points_[i]
<< endl;
}
}
this->cells() = selectedCells.toc();
}
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
Foam::explicitSource::wordToVolumeModeType
(
const word& vmtName
) const
{
forAll(volumeModeTypeNames_, i)
{
if (vmtName == volumeModeTypeNames_[i])
{
return volumeModeType(i);
}
}
FatalErrorIn
(
"explicitSource<Type>::volumeModeType"
"explicitSource<Type>::wordToVolumeModeType(const word&)"
) << "Unknown volumeMode type " << vmtName
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
<< exit(FatalError);
return volumeModeType(0);
}
Foam::word Foam::explicitSource::volumeModeTypeToWord
(
const volumeModeType& vmtType
) const
{
if (vmtType > volumeModeTypeNames_.size())
{
return "UNKNOWN";
}
else
{
return volumeModeTypeNames_[vmtType];
}
}
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
)
{
scalarFields_.clear();
vectorFields_.clear();
wordList fieldTypes(dict.toc().size());
wordList fieldNames(dict.toc().size());
forAll(dict.toc(), i)
{
const word& fieldName = dict.toc()[i];
IOobject io
(
fieldName,
this->mesh().time().timeName(0),
this->mesh(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (io.headerOk())
{
fieldTypes[i] = io.headerClassName();
fieldNames[i] = dict.toc()[i];
}
else
{
FatalErrorIn
(
"explicitSource::setFieldData"
) << "header not OK " << io.name()
<< exit(FatalError);
}
}
addField(scalarFields_, fieldTypes, fieldNames, dict);
addField(vectorFields_, fieldTypes, fieldNames, dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::explicitSource::explicitSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, dict, mesh),
scalarFields_(0, *this),
vectorFields_(0, *this),
dict_(dict.subDict(typeName + "Coeffs")),
volumeMode_(wordToVolumeModeType(dict_.lookup("volumeMode"))),
points_(),
volSource_(this->cells().size(), 1.0)
{
setFieldData(dict_.subDict("fieldData"));
// Set points if selectionMode is smPoints
if (this->selectionMode() == smPoints)
{
dict_.lookup("points") >> points_;
setSelectedCellsFromPoints();
volSource_.setSize(points_.size(), 1.0);
}
const labelList& cellList = this->cells();
scalar V = 0.0;
if (volumeMode_ == vmAbsolute)
{
forAll(cellList, cellI)
{
volSource_[cellI] = mesh.V()[cellList[cellI]];
V += volSource_[cellI];
}
}
else
{
forAll(cellList, cellI)
{
V += mesh.V()[cellList[cellI]];
}
}
reduce(V, sumOp<scalar>());
Info<< "- selected " << returnReduce(cellList.size(), sumOp<label>())
<< " cell(s) with Volume: " << V << " in time activated sources "
<< endl;
}
void Foam::explicitSource::addSu
(
fvMatrix<scalar>& Eqn
)
{
Field<scalar>& source = Eqn.source();
scalar data = scalarFields_[Eqn.psi().name()];
addSources<scalar>(source, data);
}
void Foam::explicitSource::addSu
(
fvMatrix<vector>& Eqn
)
{
Field<vector>& source = Eqn.source();
vector data = vectorFields_[Eqn.psi().name()];
addSources<vector>(source, data);
}
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
)
{
vector data = vectorFields_[field.name()];
addSources<vector>(field, data);
}
void Foam::explicitSource::addExplicitSources()
{
scalarFields_.applySources();
vectorFields_.applySources();
}
// ************************************************************************* //

View File

@ -0,0 +1,289 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::explicitSource
Description
Explicit source.
Sources described by:
explicitSourceCoeffs
{
points // list of points when selectionMode = points
(
(-0.088 0.007 -0.02)
(-0.028 0.007 -0.02)
);
volumeMode specific; //absolute
fieldData // field data - usage for multiple fields
{
k 30.7;
epsilon 1.5;
}
}
SourceFiles
explicitSource.C
\*---------------------------------------------------------------------------*/
#ifndef explicitSource_H
#define explicitSource_H
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class explicitSource Declaration
\*---------------------------------------------------------------------------*/
class explicitSource
:
public basicSource
{
// Private classes
template<class Type>
class fieldList
:
public HashTable<Type>
{
explicitSource& OwnerPtr_;
public:
//- null Constructor
fieldList()
:
HashTable<Type>(0),
OwnerPtr_()
{}
//- Constructor
fieldList(label size, explicitSource& ownerPtr)
:
HashTable<Type>(size),
OwnerPtr_(ownerPtr)
{}
void applySources()
{
typedef GeometricField<Type, fvPatchField, volMesh>
geometricField;
forAll(this->toc(), i)
{
geometricField& field = const_cast<geometricField&>
(
OwnerPtr_.mesh().lookupObject<geometricField>
(this->toc()[i])
);
Type data = this->operator[](field.name());
OwnerPtr_.addSources<Type>(field.internalField(), data);
}
}
};
private:
// Private cdata
//- List of field types
fieldList<scalar> scalarFields_;
fieldList<vector> vectorFields_;
//- Add field names and values to field table for types.
template<class Type>
void addField
(
HashTable<Type>& fields,
const wordList& fieldTypes,
const wordList& fieldNames,
const dictionary& dict_
);
//- Add data to field source
template<class Type>
void addSources
(
Field<Type>& fieldSource,
Type& data
) const;
public:
// Public data
//- Enumeration for volume types
enum volumeModeType
{
vmAbsolute,
vmSpecific
};
//- Word list of volume mode type names
static const wordList volumeModeTypeNames_;
protected:
// Protected data
//- Sub dictionary for time activated explicit sources
const dictionary& dict_;
//- Volume mode
volumeModeType volumeMode_;
//- List of points for "points" selectionMode
List<point> points_;
//- Volume of the explicit source
scalarList volSource_;
// Protected functions
//- Helper function to convert from a word to a volumeModeType
volumeModeType wordToVolumeModeType(const word& vtName) const;
//- Helper function to convert from a volumeModeType to a word
word volumeModeTypeToWord(const volumeModeType& vtType) const;
//- Set the local field data
void setFieldData(const dictionary& dict);
//- Set selected cells when smPoint is used
void setSelectedCellsFromPoints();
public:
//- Runtime type information
TypeName("explicitSource");
// Constructors
//- Construct from components
explicitSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
);
//- Return clone
autoPtr<explicitSource> clone() const
{
notImplemented
(
"autoPtr<explicitSource> clone() const"
);
return autoPtr<explicitSource>(NULL);
}
// Member Functions
// Access
//- Return const access to the volume mode
inline const volumeModeType& volumeMode() const;
// Edit
//- Return access to the volume mode
inline volumeModeType& volumeMode();
//- Return points
inline const List<point>& points() const;
// Evaluation
//-Source term to fvMatrix<vector>
virtual void addSu(fvMatrix<vector>& UEqn);
//-Source term to fvMatrix<scalar>
virtual void addSu(fvMatrix<scalar>& UEqn);
//- Add all explicit source
virtual void addExplicitSources();
//- Add source to scalar field
virtual void addSu(DimensionedField<vector, volMesh>& field);
//- Add source to vector field
virtual void addSu(DimensionedField<scalar, volMesh>& field);
// I-O
//- Write the source properties
virtual void writeData(Ostream&) const;
//- Read fieldData in sub-dictionary
virtual bool read(const dictionary& dict);
//- Ostream operator
friend Ostream& operator<<
(
Ostream& os,
const explicitSource& source
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "explicitSourceIO.C"
#include "explicitSourceI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::explicitSource::volumeModeType&
Foam::explicitSource::volumeMode() const
{
return volumeMode_;
}
inline Foam::explicitSource::volumeModeType&
Foam::explicitSource::volumeMode()
{
return volumeMode_;
}
inline const Foam::List<Foam::point>&
Foam::explicitSource::points() const
{
return points_;
}
// ************************************************************************* //

View File

@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
#include "explicitSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::explicitSource::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("volumeMode") << volumeModeTypeToWord(volumeMode_)
<< token::END_STATEMENT << nl;
if (scalarFields_.size() > 0)
{
os.writeKeyword("scalarFields") << scalarFields_
<< token::END_STATEMENT << nl;
}
if (vectorFields_.size() > 0)
{
os.writeKeyword("vectorFields") << vectorFields_
<< token::END_STATEMENT << nl;
}
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::explicitSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs = sourceDict.subDict(typeName + "Coeffs");
setFieldData(subDictCoeffs.subDict("fieldData"));
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const explicitSource& source
)
{
source.writeData(os);
return os;
}
// ************************************************************************* //