Merge remote branch 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2010-06-23 13:23:56 +02:00
64 changed files with 153316 additions and 168 deletions

View File

@ -1,6 +1,6 @@
autoPtr<hCombustionThermo> thermo
autoPtr<basicPsiThermo> thermo
(
hCombustionThermo::New(mesh)
basicPsiThermo::New(mesh)
);
const volScalarField& h = thermo->h();

View File

@ -157,6 +157,8 @@ $(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C
$(derivedFvPatchFields)/waveTransmissive/waveTransmissiveFvPatchFields.C
$(derivedFvPatchFields)/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C
$(derivedFvPatchFields)/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C
$(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C
fvsPatchFields = fields/fvsPatchFields
$(fvsPatchFields)/fvsPatchField/fvsPatchFields.C
@ -354,4 +356,13 @@ fieldSources = $(general)/fieldSources
$(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C
$(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C
basicSource = $(general)/fieldSources/basicSource
$(basicSource)/basicSource/basicSource.C
$(basicSource)/basicSource/basicSourceIO.C
$(basicSource)/basicSource/basicSourceList.C
$(basicSource)/basicSource/IObasicSourceList.C
$(basicSource)/actuationDiskSource/actuationDiskSource.C
$(basicSource)/explicitSource/explicitSource.C
LIB = $(FOAM_LIBBIN)/libfiniteVolume

View File

@ -0,0 +1,193 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*----------------------------------------------------------------------------*/
#include "actuationDiskSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "geometricOneField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(actuationDiskSource, 0);
addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::actuationDiskSource::checkData()
{
if (magSqr(diskArea_) <= VSMALL)
{
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);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::actuationDiskSource::actuationDiskSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
)
:
basicSource(name, dict, mesh),
cellZoneID_(mesh.cellZones().findZoneID(this->cellSetName())),
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;
bool foundZone = (cellZoneID_ != -1);
reduce(foundZone, orOp<bool>());
if (!foundZone && Pstream::master())
{
FatalErrorIn
(
"Foam::actuationDiskSource::actuationDiskSource"
"(const word&, const dictionary&, const fvMesh&)"
) << "cannot find porous cellZone " << this->name()
<< exit(FatalError);
}
checkData();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::actuationDiskSource::addSu(fvMatrix<vector>& UEqn)
{
if (cellZoneID_ == -1)
{
return;
}
bool compressible = false;
if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0))
{
compressible = true;
}
const labelList& cells = mesh_.cellZones()[cellZoneID_];
const scalarField& V = this->mesh().V();
vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi();
if (compressible)
{
addActuationDiskAxialInertialResistance
(
Usource,
cells,
V,
this->mesh().lookupObject<volScalarField>("rho"),
U
);
}
else
{
addActuationDiskAxialInertialResistance
(
Usource,
cells,
V,
geometricOneField(),
U
);
}
}
void Foam::actuationDiskSource::writeData(Ostream& os) const
{
os << indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl;
if (dict_.found("note"))
{
os.writeKeyword("note") << string(dict_.lookup("note"))
<< token::END_STATEMENT << nl;
}
os << indent << "actuationDisk";
dict_.write(os);
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::actuationDiskSource::read(const dictionary& dict)
{
if (basicSource::read(dict))
{
const dictionary& sourceDict = dict.subDict(name());
const dictionary& subDictCoeffs =
sourceDict.subDict(typeName + "Coeffs");
subDictCoeffs.readIfPresent("diskDir", diskDir_);
subDictCoeffs.readIfPresent("Cp", Cp_);
subDictCoeffs.readIfPresent("Ct", Ct_);
subDictCoeffs.readIfPresent("diskArea", diskArea_);
checkData();
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,215 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::actuationDiskSource
Description
Actuation disk zone definition.
Constant values for momentum source for actuation disk
T = 2*rho*A*sqr(Uo)*a*(1-a)
U1 = (1 -a)Uo
where:
A: disk area
Uo: upstream velocity
a: 1 - Cp/Ct
U1: velocity at the disk
SourceFiles
actuationDiskSource.C
actuationDiskSourceTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef actuationDiskSource_H
#define actuationDiskSource_H
#include "IOdictionary.H"
#include "coordinateSystem.H"
#include "coordinateSystems.H"
#include "wordList.H"
#include "labelList.H"
#include "DimensionedField.H"
#include "volFieldsFwd.H"
#include "fvMatricesFwd.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class actuationDiskSource Declaration
\*---------------------------------------------------------------------------*/
class actuationDiskSource
:
public basicSource
{
// Private data
//- Cell zone ID
label cellZoneID_;
//- Sub dictionary with actuationDisk information
const dictionary& dict_;
//- Disk area normal
vector diskDir_;
//- Power coefficient
scalar Cp_;
//- Thrust coefficient
scalar Ct_;
//- Disk area
scalar diskArea_;
// Private Member Functions
//- Check data
void checkData();
//- Add resistance to the UEqn
template<class RhoFieldType>
void addActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,
const scalarField& V,
const RhoFieldType& rho,
const vectorField& U
) const;
//- Disallow default bitwise copy construct
actuationDiskSource(const actuationDiskSource&);
//- Disallow default bitwise assignment
void operator=(const actuationDiskSource&);
public:
//- Runtime type information
TypeName("actuationDiskSource");
// Constructors
//- Construct from components
actuationDiskSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~actuationDiskSource()
{}
// Member Functions
// Access
//- cellZone number
label zoneId() const
{
return cellZoneID_;
}
//- Return Cp
scalar Cp() const
{
return Cp_;
}
//- Return Ct
scalar Ct() const
{
return Ct_;
}
//- Normal disk direction
const vector& diskDir() const
{
return diskDir_;
}
//- Disk area
scalar diskArea() const
{
return diskArea_;
}
// Public Functions
//-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<scalar, volMesh>& field){}
//- Add source to vector field
virtual void addSu(DimensionedField<vector, volMesh>& field){}
// I-O
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "actuationDiskSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*----------------------------------------------------------------------------*/
#include "actuationDiskSource.H"
#include "volFields.H"
#include "fvMatrix.H"
#include "fvm.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class RhoFieldType>
void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance
(
vectorField& Usource,
const labelList& cells,
const scalarField& V,
const RhoFieldType& rho,
const vectorField& U
) const
{
scalar a = 1.0 - Cp_/Ct_;
scalar totVol = 0.0;
scalarField T(cells.size());
vector uniDiskDir = diskDir_/mag(diskDir_);
tensor E(tensor::zero);
E.xx() = uniDiskDir.x();
E.yy() = uniDiskDir.y();
E.zz() = uniDiskDir.z();
vectorField U1 = (1.0 - a)*U;
forAll(cells, i)
{
totVol += V[cells[i]];
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U1[cells[i]])*a/(1.0 - a);
}
forAll(cells, i)
{
Usource[cells[i]] += ((V[cells[i]]/totVol)*T[i]*E) & U1[cells[i]];
}
}
// ************************************************************************* //

View File

@ -0,0 +1,65 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IObasicSourceList::IObasicSourceList
(
const fvMesh& mesh
)
:
IOdictionary
(
IOobject
(
"sourcesProperties",
mesh.time().constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
basicSourceList(mesh, *this)
{}
bool Foam::IObasicSourceList::read()
{
if (regIOobject::read())
{
basicSourceList::read(*this);
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -21,55 +21,73 @@ License
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::IObasicSourceList
Description
IObasicSourceList
SourceFiles
IObasicSourceList.C
\*---------------------------------------------------------------------------*/
#include "error.H"
#ifndef IObasicSourceList_H
#define IObasicSourceList_H
#include "dispersionModel.H"
#include "noDispersion.H"
#include "basicSourceList.H"
#include "IOdictionary.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
/*---------------------------------------------------------------------------*\
Class IObasicSourceList Declaration
\*---------------------------------------------------------------------------*/
autoPtr<dispersionModel> dispersionModel::New
(
const dictionary& dict,
spray& sm
)
class IObasicSourceList
:
public IOdictionary,
public basicSourceList
{
word dispersionModelType
(
dict.lookup("dispersionModel")
);
private:
Info<< "Selecting dispersionModel "
<< dispersionModelType << endl;
// Private Member Functions
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(dispersionModelType);
//- Disallow default bitwise copy construct
IObasicSourceList(const IObasicSourceList&);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalError
<< "dispersionModel::New(const dictionary&, const spray&) : "
<< endl
<< " unknown dispersionModelType type "
<< dispersionModelType
<< ", constructor not in hash table" << endl << endl
<< " Valid dispersionModel types are :" << endl;
Info<< dictionaryConstructorTablePtr_->sortedToc() << abort(FatalError);
}
//- Disallow default bitwise assignment
void operator=(const IObasicSourceList&);
return autoPtr<dispersionModel>(cstrIter()(dict, sm));
}
public:
// Constructors
//- Construct from components with list of field names
IObasicSourceList(const fvMesh& mesh);
//- Destructor
virtual ~IObasicSourceList()
{}
//- Read dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,283 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "basicSource.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(basicSource, 0);
defineRunTimeSelectionTable(basicSource, dictionary);
}
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
const Foam::wordList Foam::basicSource::selectionModeTypeNames_
(
IStringStream("(points cellSet cellZone all)")()
);
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::basicSource::selectionModeType Foam::basicSource::wordToSelectionModeType
(
const word& smtName
) const
{
forAll(selectionModeTypeNames_, i)
{
if (smtName == selectionModeTypeNames_[i])
{
return selectionModeType(i);
}
}
FatalErrorIn
(
"basicSource::selectionModeType"
"basicSource::wordToSelectionModeType"
"("
"const word&"
")"
) << "Unknown selectionMode type " << smtName
<< ". Valid selectionMode types are:" << nl << selectionModeTypeNames_
<< exit(FatalError);
return selectionModeType(0);
}
Foam::word Foam::basicSource::selectionModeTypeToWord
(
const selectionModeType& smtType
) const
{
if (smtType > selectionModeTypeNames_.size())
{
return "UNKNOWN";
}
else
{
return selectionModeTypeNames_[smtType];
}
}
void Foam::basicSource::setSelection(const dictionary& dict)
{
switch (selectionMode_)
{
case smPoints:
{
// Do nothing. It should be sorted out by derived class
break;
}
case smCellSet:
{
dict.lookup("cellSet") >> cellSetName_;
break;
}
case smCellZone:
{
dict.lookup("cellZone") >> cellSetName_;
break;
}
case smAll:
{
break;
}
default:
{
FatalErrorIn
(
"basicSource::setSelection(const dictionary&)"
) << "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
<< exit(FatalError);
}
}
}
void Foam::basicSource::setCellSet()
{
Info<< incrIndent << indent << "Source: " << name_ << endl;
switch (selectionMode_)
{
case smPoints:
{
break;
}
case smCellSet:
{
Info<< indent << "- selecting cells using cellSet "
<< cellSetName_ << endl;
cellSet selectedCells(mesh_, cellSetName_);
cells_ = selectedCells.toc();
break;
}
case smCellZone:
{
Info<< indent << "- selecting cells using cellZone "
<< cellSetName_ << endl;
label zoneID = mesh_.cellZones().findZoneID(cellSetName_);
if (zoneID == -1)
{
FatalErrorIn("basicSource<Type>::setCellIds()")
<< "Cannot find cellZone " << cellSetName_ << endl
<< "Valid cellZones are " << mesh_.cellZones().names()
<< exit(FatalError);
}
cells_ = mesh_.cellZones()[zoneID];
break;
}
case smAll:
{
Info<< indent << "- selecting all cells" << endl;
cells_ = identity(mesh_.nCells());
break;
}
default:
{
FatalErrorIn("basicSource<Type>::setCellIds()")
<< "Unknown selectionMode "
<< selectionModeTypeNames_[selectionMode_]
<< ". Valid selectionMode types are" << selectionModeTypeNames_
<< exit(FatalError);
}
}
// Set volume information
if (selectionMode_ != smPoints)
{
V_ = 0.0;
forAll(cells_, i)
{
V_ += mesh_.V()[cells_[i]];
}
reduce(V_, sumOp<scalar>());
Info<< indent << "- selected "
<< returnReduce(cells_.size(), sumOp<label>())
<< " cell(s) with volume " << V_ << nl << decrIndent << endl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSource::basicSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
)
:
name_(name),
mesh_(mesh),
dict_(dict),
active_(readBool(dict_.lookup("active"))),
timeStart_(readScalar(dict_.lookup("timeStart"))),
duration_(readScalar(dict_.lookup("duration"))),
selectionMode_(wordToSelectionModeType(dict_.lookup("selectionMode"))),
cellSetName_("none"),
V_(1.0)
{
setSelection(dict_);
setCellSet();
}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::basicSource> Foam::basicSource::New
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
)
{
word typeModel(dict.lookup("typeModel"));
Info<< "Selecting model type " << typeModel << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(typeModel);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"basicSource::New(const volVectorField&, "
"const surfaceScalarField&, transportModel&)"
) << "Unknown Model type " << typeModel
<< nl << nl
<< "Valid model types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<basicSource>(cstrIter()(name, dict, mesh));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::basicSource::isActive()
{
if
(
active_
&& (mesh_.time().value() >= timeStart_)
&& (mesh_.time().value() <= timeEnd())
)
{
// Update the cell set if the mesh is changing
if (mesh_.changing())
{
setCellSet();
}
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,384 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::basicSource
Description
Basic source abtract class
Sources described by:
source1
{
typeModel actuationDiskSource; // explicitSource
active on; // on/off switch
timeStart 0.0; // start time
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
cellSet c0; // cellSet name
actuationDiskSourceCoeffs
{
diskDir (-1 0 0); // orientation of the disk
Cp 0.53; // Cp
Ct 0.58; // Ct
diskArea 40; // disk area
}
}
source2
{
typeModel explicitSource;
active on;
timeStart 0.0;
duration 1000.0;
selectionMode points;
cellSet c0;
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
{
k 30.7;
epsilon 1.5;
}
}
}
SourceFiles
basicSource.C
basicSourceIO.C
\*---------------------------------------------------------------------------*/
#ifndef basicSource_H
#define basicSource_H
#include "fvMatrices.H"
#include "cellSet.H"
#include "volFieldsFwd.H"
#include "DimensionedField.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class fvMesh;
/*---------------------------------------------------------------------------*\
Class basicSource Declaration
\*---------------------------------------------------------------------------*/
class basicSource
{
public:
// Public data
//- Enumeration for selection mode types
enum selectionModeType
{
smPoints,
smCellSet,
smCellZone,
smAll
};
//- Word list of selection mode type names
static const wordList selectionModeTypeNames_;
protected:
// Protected data
//- Source name
word name_;
//- Reference to the mesh database
const fvMesh& mesh_;
//- Dictionary containing the data of the source
const dictionary& dict_;
//- Source active flag
bool active_;
//- Time start
scalar timeStart_;
//- Duration
scalar duration_;
//- Cell selection mode
selectionModeType selectionMode_;
//- Name of cell set for "cellSet" and "cellZone" selectionMode
word cellSetName_;
//- Set of cells to apply source to
labelList cells_;
//- Sum of cell volumes
scalar V_;
// Protected functions
//- Helper function to convert from a word to a selectionModeType
selectionModeType wordToSelectionModeType(const word& smtName) const;
//- Helper function to convert from a selectionModeType to a word
word selectionModeTypeToWord(const selectionModeType& smtType) const;
//- Set the cellSet or points selection
void setSelection(const dictionary& dict);
//- Set the cell set based on the user input selection mode
void setCellSet();
public:
//- Runtime type information
TypeName("basicSource");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
basicSource,
dictionary,
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
),
(name, dict, mesh)
);
// Constructors
//- Construct from components
basicSource
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
);
//- Return clone
autoPtr<basicSource> clone() const
{
notImplemented
(
"autoPtr<basicSource> clone() const"
);
return autoPtr<basicSource>(NULL);
}
//- Return pointer to new basicSource object created
// on the freestore from an Istream
class iNew
{
//- Reference to the mesh database
const fvMesh& mesh_;
const word& name_;
public:
iNew
(
const fvMesh& mesh,
const word& name
)
:
mesh_(mesh),
name_(name)
{}
autoPtr<basicSource> operator()(Istream& is) const
{
//const word name(is);
const dictionary dict(is);
return autoPtr<basicSource>
(
basicSource::New
(
name_,
dict,
mesh_
)
);
}
};
// Selectors
//- Return a reference to the selected basicSource model
static autoPtr<basicSource> New
(
const word& name,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~basicSource()
{}
// Member Functions
// Access
//- Return const access to the source name
inline const word& name() const;
//- Return const access to the mesh database
inline const fvMesh& mesh() const;
//- Return dictionay
inline const dictionary& dictCoeffs() const;
//- Return const access to the source active flag
inline bool active() const;
//- Return const access to the time start
inline scalar timeStart() const;
//- Return const access to the duration
inline scalar duration() const;
//- Return const access to the time end
inline scalar timeEnd() const;
//- Return const access to the cell selection mode
inline const selectionModeType& selectionMode() const;
//- Return const access to the name of cell set for "cellSet"
// selectionMode
inline const word& cellSetName() const;
//- Return const access to the total cell volume
inline scalar V() const;
//- Return const access to the cell set
inline const labelList& cells() const;
// Edit
//- Return access to the source name
inline word& name();
//- Return access to the source active flag
inline bool& active();
//- Return access to the time start
inline scalar& timeStart();
//- Return access to the duration
inline scalar& duration();
//- Return access to the cell selection mode
inline selectionModeType& selectionMode();
//- Return access to the list of points for "points" selectionMode
inline List<point>& points();
//- Return access to the name of cell set for "cellSet"
// selectionMode
inline word& cellSetName();
//- Return access to the total cell volume
inline scalar& V();
//- Return access to the cell set
inline labelList& cells();
// Checks
//- Is the source active?
bool isActive();
// Evaluation
//- Add all explicit sources
virtual void addExplicitSources() = 0;
//- Add source to scalar field
virtual void addSu(DimensionedField<scalar, volMesh>& field) = 0;
//- Add source to vector field
virtual void addSu(DimensionedField<vector, volMesh>& field) = 0;
//- Add source term to vector fvMatrix
virtual void addSu(fvMatrix<vector>& Eqn) = 0;
//- Add source term to scalar fvMatrix
virtual void addSu(fvMatrix<scalar>& Eqn) = 0;
// I-O
//- Write the source properties
virtual void writeData(Ostream&) const = 0;
//- Read source dictionary
virtual bool read(const dictionary& dict) = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "basicSourceI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,144 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "basicSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::word& Foam::basicSource::name() const
{
return name_;
}
inline const Foam::fvMesh& Foam::basicSource::mesh() const
{
return mesh_;
}
inline const Foam::dictionary& Foam::basicSource::dictCoeffs() const
{
return dict_;
}
inline bool Foam::basicSource::active() const
{
return active_;
}
inline Foam::scalar Foam::basicSource::timeStart() const
{
return timeStart_;
}
inline Foam::scalar Foam::basicSource::duration() const
{
return duration_;
}
inline Foam::scalar Foam::basicSource::timeEnd() const
{
return timeStart_ + duration_;
}
inline const Foam::basicSource::selectionModeType&
Foam::basicSource::selectionMode() const
{
return selectionMode_;
}
inline const Foam::word& Foam::basicSource::cellSetName() const
{
return cellSetName_;
}
inline Foam::scalar Foam::basicSource::V() const
{
return V_;
}
inline const Foam::labelList& Foam::basicSource::cells() const
{
return cells_;
}
inline Foam::word& Foam::basicSource::name()
{
return name_;
}
inline bool& Foam::basicSource::active()
{
return active_;
}
inline Foam::scalar& Foam::basicSource::timeStart()
{
return timeStart_;
}
inline Foam::scalar& Foam::basicSource::duration()
{
return duration_;
}
inline Foam::word& Foam::basicSource::cellSetName()
{
return cellSetName_;
}
inline Foam::basicSource::selectionModeType&
Foam::basicSource::selectionMode()
{
return selectionMode_;
}
inline Foam::scalar& Foam::basicSource::V()
{
return V_;
}
inline Foam::labelList& Foam::basicSource::cells()
{
return cells_;
}
// ************************************************************************* //

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "basicSource.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSource::writeData(Ostream& os) const
{
os << indent << name_ << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("active") << active_ << token::END_STATEMENT << nl;
os.writeKeyword("timeStart") << timeStart_ << token::END_STATEMENT << nl;
os.writeKeyword("duration") << duration_ << token::END_STATEMENT << nl;
os.writeKeyword("selectionMode")
<< selectionModeTypeToWord(selectionMode_) << nl;
switch (selectionMode_)
{
case smPoints:
{
break;
}
case smCellSet:
{
os.writeKeyword("cellSet") << cellSetName_
<< token::END_STATEMENT << nl;
break;
}
default:
{
FatalErrorIn
(
"basicSource::writeData"
"("
"Ostream&, "
"bool"
") const"
) << "Unknown selectionMode "
<< selectionModeTypeToWord(selectionMode_)
<< abort(FatalError);
}
}
os << decrIndent << indent << token::END_BLOCK << endl;
}
bool Foam::basicSource::read(const dictionary& dict)
{
const dictionary& sourceDict = dict.subDict(name_);
active_ = readBool(sourceDict.lookup("active"));
timeStart_ = readScalar(sourceDict.lookup("timeStart"));
duration_ = readScalar(sourceDict.lookup("duration"));
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,182 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "basicSourceList.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSourceList::basicSourceList
(
const fvMesh& mesh,
const dictionary& dict
)
:
PtrList<basicSource>(),
mesh_(mesh)
{
label count = 0;
forAllConstIter(dictionary, dict, iter)
{
// safety:
if (iter().isDict())
{
count ++;
}
}
this->setSize(count);
label i = 0;
forAllConstIter(dictionary, dict, iter)
{
const word& name = iter().keyword();
const dictionary& dict = iter().dict();
this->set
(
i++,
basicSource::New(name, dict, mesh)
);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::basicSourceList::addSu(fvMatrix<scalar>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(Eqn);
}
}
}
void Foam::basicSourceList::addSu(fvMatrix<vector>& Eqn)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(Eqn);
}
}
}
void Foam::basicSourceList::addExplicitSources()
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addExplicitSources();
}
}
}
void Foam::basicSourceList::addSu
(
DimensionedField<scalar, volMesh>& field
)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(field);
}
}
}
void Foam::basicSourceList::addSu
(
DimensionedField<vector, volMesh>& field
)
{
forAll(*this, i)
{
if (this->operator[](i).isActive())
{
this->operator[](i).addSu(field);
}
}
}
bool Foam::basicSourceList::read(const dictionary& dict)
{
forAll(*this, i)
{
this->operator[](i).read(dict);
}
return true;
}
bool Foam::basicSourceList::writeData(Ostream& os) const
{
// Write size of list
os << nl << this->size();
// Write beginning of contents
os << nl << token::BEGIN_LIST;
// Write list contents
forAll(*this, i)
{
os << nl;
this->operator[](i).writeData(os);
}
// Write end of contents
os << token::END_LIST << token::END_STATEMENT << nl;
// Check state of IOstream
return os.good();
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const basicSourceList& sources
)
{
sources.writeData(os);
return os;
}
// ************************************************************************* //

View File

@ -0,0 +1,130 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::basicsourceList
Description
List of explict sources
SourceFile
basicSourceList.C
\*---------------------------------------------------------------------------*/
#ifndef basicSourceList_H
#define basicSourceList_H
#include "PtrList.H"
#include "DimensionedField.H"
#include "basicSource.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class basicSourceList Declaration
\*---------------------------------------------------------------------------*/
class basicSourceList
:
public PtrList<basicSource>
{
private:
// Private data
//- Reference to the mesh database
const fvMesh& mesh_;
// Private Member Functions
//- Disallow default bitwise copy construct
basicSourceList(const basicSourceList&);
//- Disallow default bitwise assignment
void operator=(const basicSourceList&);
public:
// Constructors
//- Construct from components with list of field names
basicSourceList(const fvMesh& mesh, const dictionary& dict);
//- Destructor
virtual ~basicSourceList()
{}
// Member Functions
// Evaluation
//- Add all explicit sources
void addExplicitSources();
//- Add source to scalar field
void addSu(DimensionedField<scalar, volMesh>& field);
//- Add source to vector field
void addSu(DimensionedField<vector, volMesh>& field);
//- Add source terms to scalar fvMatrix
void addSu(fvMatrix<scalar>& Eq);
//- Add source terms to vector fvMatrix
void addSu(fvMatrix<vector>& Eq);
// I-O
//- Read dictionary
virtual bool read(const dictionary& dict);
//- Write data to Istream
virtual bool writeData(Ostream& os) const;
//- Ostream operator
friend Ostream& operator<<
(
Ostream& os,
const basicSourceList& sources
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,253 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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();
}
// * * * * * * * * * * * * 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];
}
}
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,295 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "explicitSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#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,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/>.
\*---------------------------------------------------------------------------*/
#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;
}
// ************************************************************************* //

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

@ -0,0 +1,173 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "cylindricalInletVelocityFvPatchVectorField.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "surfaceFields.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::
cylindricalInletVelocityFvPatchVectorField::
cylindricalInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchField<vector>(p, iF),
axialVelocity_(0),
centre_(pTraits<vector>::zero),
axis_(pTraits<vector>::zero),
rpm_(0),
radialVelocity_(0)
{}
Foam::
cylindricalInletVelocityFvPatchVectorField::
cylindricalInletVelocityFvPatchVectorField
(
const cylindricalInletVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
axialVelocity_(ptf.axialVelocity_),
centre_(ptf.centre_),
axis_(ptf.axis_),
rpm_(ptf.rpm_),
radialVelocity_(ptf.radialVelocity_)
{}
Foam::
cylindricalInletVelocityFvPatchVectorField::
cylindricalInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchField<vector>(p, iF, dict),
axialVelocity_(readScalar(dict.lookup("axialVelocity"))),
centre_(dict.lookup("centre")),
axis_(dict.lookup("axis")),
rpm_(readScalar(dict.lookup("rpm"))),
radialVelocity_(readScalar(dict.lookup("radialVelocity")))
{}
Foam::
cylindricalInletVelocityFvPatchVectorField::
cylindricalInletVelocityFvPatchVectorField
(
const cylindricalInletVelocityFvPatchVectorField& ptf
)
:
fixedValueFvPatchField<vector>(ptf),
axialVelocity_(ptf.axialVelocity_),
centre_(ptf.centre_),
axis_(ptf.axis_),
rpm_(ptf.rpm_),
radialVelocity_(ptf.radialVelocity_)
{}
Foam::
cylindricalInletVelocityFvPatchVectorField::
cylindricalInletVelocityFvPatchVectorField
(
const cylindricalInletVelocityFvPatchVectorField& ptf,
const DimensionedField<vector, volMesh>& iF
)
:
fixedValueFvPatchField<vector>(ptf, iF),
axialVelocity_(ptf.axialVelocity_),
centre_(ptf.centre_),
axis_(ptf.axis_),
rpm_(ptf.rpm_),
radialVelocity_(ptf.radialVelocity_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::cylindricalInletVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
vector hatAxis = axis_/mag(axis_);
vectorField r = (patch().Cf() - centre_);
vectorField d = r - (hatAxis & r)*hatAxis;
vectorField tangVelo =
(rpm_*constant::mathematical::pi/30.0)*(hatAxis)^d;
operator==(tangVelo + axis_*axialVelocity_ + radialVelocity_*d);
fixedValueFvPatchField<vector>::updateCoeffs();
}
void Foam::cylindricalInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchField<vector>::write(os);
os.writeKeyword("axialVelocity") << axialVelocity_ <<
token::END_STATEMENT << nl;
os.writeKeyword("centre") << centre_ << token::END_STATEMENT << nl;
os.writeKeyword("axis") << axis_ << token::END_STATEMENT << nl;
os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << nl;
os.writeKeyword("radialVelocity") << radialVelocity_ <<
token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchVectorField,
cylindricalInletVelocityFvPatchVectorField
);
}
// ************************************************************************* //

View File

@ -0,0 +1,175 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::cylindricalInletVelocityFvPatchVectorField
Description
Describes an inlet vector boundary condition in cylindrical coordinates
given a central axis, central point, rpm, axial and radial velocity.
Example of the boundary condition specification:
@verbatim
inlet
{
type cylindricalInletVelocity;
axis (0 0 1);
centre (0 0 0);
axialVelocity 30;
rpm 100;
radialVelocity -10;
}
@endverbatim
SourceFiles
cylindricalInletVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef cylindricalInletVelocityFvPatchVectorField_H
#define cylindricalInletVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class cylindricalInletVelocityFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class cylindricalInletVelocityFvPatchVectorField
:
public fixedValueFvPatchVectorField
{
// Private data
//- Axial velocity
const scalar axialVelocity_;
//- Central point
const vector centre_;
//- Axis
const vector axis_;
//- RPM
const scalar rpm_;
//- Radial velocity
const scalar radialVelocity_;
public:
//- Runtime type information
TypeName("cylindricalInletVelocity");
// Constructors
//- Construct from patch and internal field
cylindricalInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
cylindricalInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// flowRateInletVelocityFvPatchVectorField
// onto a new patch
cylindricalInletVelocityFvPatchVectorField
(
const cylindricalInletVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
cylindricalInletVelocityFvPatchVectorField
(
const cylindricalInletVelocityFvPatchVectorField&
);
//- Construct and return a clone
virtual tmp<fvPatchVectorField> clone() const
{
return tmp<fvPatchVectorField>
(
new cylindricalInletVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
cylindricalInletVelocityFvPatchVectorField
(
const cylindricalInletVelocityFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchVectorField> clone
(
const DimensionedField<vector, volMesh>& iF
) const
{
return tmp<fvPatchVectorField>
(
new cylindricalInletVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -8,10 +8,10 @@
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 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 2 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
@ -19,14 +19,15 @@ 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/>.
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::swirlFlowRateInletVelocityFvPatchVectorField
Description
Describes a volumetric/mass flow normal vector boundary condition by its
magnitude as an integral over its area, with a swirl component determined
magnitude as an integral over its area with a swirl component determined
by the RPM
The basis of the patch (volumetric or mass) is determined by the
@ -41,19 +42,11 @@ Description
type swirlFlowRateInletVelocity;
flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s]
rpm 100;
value uniform (0 0 0); // placeholder
}
@endverbatim
Note
- The value is positive inwards
- May not work correctly for transonic inlets
- Swirl is defined in RPM about the patch centre-axis according
to a right-hand rule (inwards axis).
- Primarily useful for planar patches.
See Also
Foam::flowRateInletVelocityFvPatchVectorField
SourceFiles
swirlFlowRateInletVelocityFvPatchVectorField.C
@ -88,7 +81,7 @@ class swirlFlowRateInletVelocityFvPatchVectorField
//- Name of the density field used to normalize the mass flux
word rhoName_;
//- Swirl rate [rpm]
//- RPM
scalar rpm_;
@ -177,18 +170,6 @@ public:
return flowRate_;
}
//- Return the swirl rpm
scalar rpm() const
{
return rpm_;
}
//- Return reference to the swirl rpm to allow adjustment
scalar& rpm()
{
return rpm_;
}
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();

View File

@ -317,18 +317,15 @@ bool Foam::KinematicParcel<ParcelType>::move(TrackData& td)
case TrackData::tpRotationalTrack:
{
Info<< "No rotational tracking implementation" << endl;
notImplemented("TrackData::tpRotationalTrack");
break;
}
default:
{
FatalErrorIn
(
"KinematicParcel<ParcelType>::move(TrackData& td)"
) << td.part()
<< " is an invalid part of the tracking method."
FatalErrorIn("KinematicParcel<ParcelType>::move(TrackData& td)")
<< td.part() << " is an invalid part of the tracking method."
<< abort(FatalError);
}
}

View File

@ -62,6 +62,7 @@ class polyLine
//- Disallow default bitwise assignment
void operator=(const polyLine&);
protected:
// Protected data
@ -75,17 +76,18 @@ protected:
//- The rational (0-1) cumulative parameter value for each point
scalarList param_;
// Protected Member Functions
//- Precalculate the rational cumulative parameter value
// and the line-length
void calcParam();
//- Return the line segment and the local parameter [0..1]
// corresponding to the global lambda [0..1]
label localParameter(scalar& lambda) const;
public:
// Constructors

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

@ -19,6 +19,7 @@ dynSmagorinsky/dynSmagorinsky.C
LRRDiffStress/LRRDiffStress.C
DeardorffDiffStress/DeardorffDiffStress.C
spectEddyVisc/spectEddyVisc.C
dynLagrangian/dynLagrangian.C
scaleSimilarity/scaleSimilarity.C
mixedSmagorinsky/mixedSmagorinsky.C

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "dynLagrangian.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace LESModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(dynLagrangian, 0);
addToRunTimeSelectionTable(LESModel, dynLagrangian, dictionary);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void dynLagrangian::updateSubGridScaleFields
(
const tmp<volTensorField>& gradU
)
{
nuSgs_ = (flm_/fmm_)*delta()*sqrt(k(gradU));
nuSgs_.correctBoundaryConditions();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
dynLagrangian::dynLagrangian
(
const volVectorField& U,
const surfaceScalarField& phi,
transportModel& transport,
const word& turbulenceModelName
)
:
LESModel(typeName, U, phi, transport, turbulenceModelName),
GenEddyVisc(U, phi, transport),
flm_
(
IOobject
(
"flm",
runTime_.timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
fmm_
(
IOobject
(
"fmm",
runTime_.timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
theta_
(
dimensioned<scalar>::lookupOrAddToDict
(
"theta",
coeffDict_,
1.5
)
),
simpleFilter_(U.mesh()),
filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
filter_(filterPtr_()),
flm0_("flm0", flm_.dimensions(), 0.0),
fmm0_("fmm0", fmm_.dimensions(), VSMALL)
{
updateSubGridScaleFields(fvc::grad(U));
printCoeffs();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void dynLagrangian::correct(const tmp<volTensorField>& gradU)
{
LESModel::correct(gradU);
volSymmTensorField S = dev(symm(gradU()));
volScalarField magS = mag(S);
volVectorField Uf = filter_(U());
volSymmTensorField Sf = dev(symm(fvc::grad(Uf)));
volScalarField magSf = mag(Sf);
volSymmTensorField L = dev(filter_(sqr(U())) - (sqr(filter_(U()))));
volSymmTensorField M = 2.0*sqr(delta())*(filter_(magS*S) - 4.0*magSf*Sf);
volScalarField invT =
(1.0/(theta_.value()*delta()))*pow(flm_*fmm_, 1.0/8.0);
volScalarField LM = L && M;
fvScalarMatrix flmEqn
(
fvm::ddt(flm_)
+ fvm::div(phi(), flm_)
==
invT*LM
- fvm::Sp(invT, flm_)
);
flmEqn.relax();
flmEqn.solve();
bound(flm_, flm0_);
volScalarField MM = M && M;
fvScalarMatrix fmmEqn
(
fvm::ddt(fmm_)
+ fvm::div(phi(), fmm_)
==
invT*MM
- fvm::Sp(invT, fmm_)
);
fmmEqn.relax();
fmmEqn.solve();
bound(fmm_, fmm0_);
updateSubGridScaleFields(gradU);
}
bool dynLagrangian::read()
{
if (GenEddyVisc::read())
{
filter_.read(coeffDict());
theta_.readIfPresent(coeffDict());
return true;
}
else
{
return false;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,186 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::incompressible::LESModels::dynLagrangian
Description
Lagrangian Two Equations Eddy Viscosity Model for incompressible
flows
@verbatim
B = 2/3*k*I - 2*nuSgs*dev(D)
Beff = 2/3*k*I - 2*nuEff*dev(D)
where
D = symm(grad(U))
nuSgs = (flm/fmm)*delta^2*sqrt(2)*|D|
nuEff = nuSgs + nu
Two relaxation equations are used to evaluate flm and fmm:
d/dt(flm) + div(U*flm)
=
(1/T)*(L && M - flm)
d/dt(fmm) + div(U*fmm)
=
(1/T)*(M && M - flm)
where
L = F(U.U) - F(U).F(U)
M = 2.0 delta^2 (F(|D|.D) - 4 F(|D|).F(D))
T = 1.5*delta*(flm.fmm)^(-1.0/8.0)
@endverbatim
Reference:
1. Charles Meneveau, Thomas Lund and William Cabot
"A Lagrangian dynamic subgrid-scale model of turbulence"
J. Fluid Mech (1996), vol 319, pp. 353-385
SourceFiles
dynLagrangian.C
\*---------------------------------------------------------------------------*/
#ifndef dynLagrangian_H
#define dynLagrangian_H
#include "GenEddyVisc.H"
#include "simpleFilter.H"
#include "LESfilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace LESModels
{
/*---------------------------------------------------------------------------*\
Class dynLagrangian Declaration
\*---------------------------------------------------------------------------*/
class dynLagrangian
:
public GenEddyVisc
{
// Private data
volScalarField flm_;
volScalarField fmm_;
dimensionedScalar theta_;
simpleFilter simpleFilter_;
autoPtr<LESfilter> filterPtr_;
LESfilter& filter_;
dimensionedScalar flm0_;
dimensionedScalar fmm0_;
// Private Member Functions
//- Update sub-grid scale fields
void updateSubGridScaleFields
(
const tmp<volTensorField>& gradU
);
// Disallow default bitwise copy construct and assignment
dynLagrangian(const dynLagrangian&);
dynLagrangian& operator=(const dynLagrangian&);
public:
//- Runtime type information
TypeName("dynLagrangian");
// Constructors
//- Construct from components
dynLagrangian
(
const volVectorField& U,
const surfaceScalarField& phi,
transportModel& transport,
const word& turbulenceModelName = turbulenceModel::typeName
);
//- Destructor
virtual ~dynLagrangian()
{}
// Member Functions
//- 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
virtual tmp<volScalarField> k() const
{
return k(fvc::grad(U()));
}
//- Return the effective diffusivity for k
tmp<volScalarField> DkEff() const
{
return tmp<volScalarField>
(
new volScalarField("DkEff", nuSgs_ + nu())
);
}
//- Correct Eddy-Viscosity and related properties
virtual void correct(const tmp<volTensorField>& gradU);
//- Read LESProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace LESModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -44,8 +44,8 @@ derivedFvPatchFields/turbulentHeatFluxTemperature/turbulentHeatFluxTemperatureFv
derivedFvPatchFields/turbulentMixingLengthDissipationRateInlet/turbulentMixingLengthDissipationRateInletFvPatchScalarField.C
derivedFvPatchFields/turbulentMixingLengthFrequencyInlet/turbulentMixingLengthFrequencyInletFvPatchScalarField.C
derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C
derivedFvPatchFields/ABLInletEpsilon/ABLInletEpsilonFvPatchScalarField.C
derivedFvPatchFields/ABLInletVelocity/ABLInletVelocityFvPatchVectorField.C
derivedFvPatchFields/atmBoundaryLayerInletEpsilon/atmBoundaryLayerInletEpsilonFvPatchScalarField.C
derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C
backwardsCompatibility/wallFunctions/backwardsCompatibilityWallFunctions.C

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "ABLInletEpsilonFvPatchScalarField.H"
#include "atmBoundaryLayerInletEpsilonFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
@ -39,7 +39,8 @@ namespace incompressible
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField::
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
@ -49,13 +50,15 @@ ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
Ustar_(0),
z_(pTraits<vector>::zero),
z0_(0),
kappa_(0.41)
kappa_(0.41),
zGround_(0)
{}
ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField::
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const ABLInletEpsilonFvPatchScalarField& ptf,
const atmBoundaryLayerInletEpsilonFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
@ -65,11 +68,13 @@ ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
Ustar_(ptf.Ustar_),
z_(ptf.z_),
z0_(ptf.z0_),
kappa_(ptf.kappa_)
kappa_(ptf.kappa_),
zGround_(ptf.zGround_)
{}
ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField::
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
@ -80,12 +85,21 @@ ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
Ustar_(readScalar(dict.lookup("Ustar"))),
z_(dict.lookup("z")),
z0_(readScalar(dict.lookup("z0"))),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41))
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
zGround_(readScalar(dict.lookup("zGround")))
{
if (mag(z_) < SMALL)
{
FatalErrorIn("ABLInletEpsilonFvPatchScalarField(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);
}
@ -95,32 +109,33 @@ ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
}
ABLInletEpsilonFvPatchScalarField::ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField::
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const ABLInletEpsilonFvPatchScalarField& fcvpvf,
const atmBoundaryLayerInletEpsilonFvPatchScalarField& blpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(fcvpvf, iF),
Ustar_(fcvpvf.Ustar_),
z_(fcvpvf.z_),
z0_(fcvpvf.z0_),
kappa_(fcvpvf.kappa_)
fixedValueFvPatchScalarField(blpsf, iF),
Ustar_(blpsf.Ustar_),
z_(blpsf.z_),
z0_(blpsf.z0_),
kappa_(blpsf.kappa_),
zGround_(blpsf.zGround_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ABLInletEpsilonFvPatchScalarField::updateCoeffs()
void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
{
const vectorField& c = patch().Cf();
scalarField coord = (c & z_);
scalarField::operator=(pow(Ustar_, 3.0)/(kappa_*(coord + z0_)));
scalarField::operator=(pow3(Ustar_)/(kappa_*(coord - zGround_ + z0_)));
}
// Write
void ABLInletEpsilonFvPatchScalarField::write(Ostream& os) const
void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
os.writeKeyword("Ustar")
@ -131,13 +146,19 @@ void ABLInletEpsilonFvPatchScalarField::write(Ostream& os) const
<< z0_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa")
<< kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("zGround")
<< zGround_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, ABLInletEpsilonFvPatchScalarField);
makePatchTypeField
(
fvPatchScalarField,
atmBoundaryLayerInletEpsilonFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField
Description
Boundary condition specifies a epsilon inlet for the atmospheric boundary
@ -31,7 +31,7 @@ Description
ABLInletVelocity.
@verbatim
epsilon = Ustar^3 / (K(z + z0))
epsilon = Ustar^3 / (K(z - zGround + z0))
where:
@ -39,6 +39,7 @@ Description
K is karman's constant
z is the verical coordinate
z0 is the surface roughness lenght
zGround minium vlaue in z direction
@endverbatim
@ -49,12 +50,12 @@ Description
Journal of Wind Engineering and Industrial Aerodynamics 95(2007) 355-369.
SourceFiles
ABLInletEpsilonFvPatchScalarField.C
atmBoundaryLayerInletEpsilonFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef ABLInletEpsilonFvPatchScalarField_H
#define ABLInletEpsilonFvPatchScalarField_H
#ifndef atmBoundaryLayerInletEpsilonFvPatchScalarField_H
#define atmBoundaryLayerInletEpsilonFvPatchScalarField_H
#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
@ -67,16 +68,16 @@ namespace incompressible
{
/*---------------------------------------------------------------------------*\
Class ABLInletEpsilonFvPatchScalarField Declaration
Class atmBoundaryLayerInletEpsilonFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class ABLInletEpsilonFvPatchScalarField
class atmBoundaryLayerInletEpsilonFvPatchScalarField
:
public fixedValueFvPatchScalarField
{
// Private data
//- Peak velocity magnitude
//- Frictional velocity
scalar Ustar_;
//- Direction of the z-coordinate
@ -88,34 +89,38 @@ class ABLInletEpsilonFvPatchScalarField
//- Von Karman constant
scalar kappa_;
//- Minimum corrdinate value in z direction
scalar zGround_;
public:
//- Runtime type information
TypeName("ABLInletEpsilon");
TypeName("atmBoundaryLayerInletEpsilon");
// Constructors
//- Construct from patch and internal field
ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given ABLInletEpsilonFvPatchScalarField
// onto a new patch
ABLInletEpsilonFvPatchScalarField
//- Construct by mapping given
// atmBoundaryLayerInletEpsilonFvPatchScalarField onto a new patch
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const ABLInletEpsilonFvPatchScalarField&,
const atmBoundaryLayerInletEpsilonFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
@ -126,14 +131,14 @@ public:
{
return tmp<fvPatchScalarField>
(
new ABLInletEpsilonFvPatchScalarField(*this)
new atmBoundaryLayerInletEpsilonFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
ABLInletEpsilonFvPatchScalarField
atmBoundaryLayerInletEpsilonFvPatchScalarField
(
const ABLInletEpsilonFvPatchScalarField&,
const atmBoundaryLayerInletEpsilonFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
@ -145,7 +150,7 @@ public:
{
return tmp<fvPatchScalarField>
(
new ABLInletEpsilonFvPatchScalarField(*this, iF)
new atmBoundaryLayerInletEpsilonFvPatchScalarField(*this, iF)
);
}

View File

@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "ABLInletVelocityFvPatchVectorField.H"
#include "atmBoundaryLayerInletVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
@ -39,7 +39,8 @@ namespace incompressible
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField::
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF
@ -50,13 +51,17 @@ ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
n_(pTraits<vector>::zero),
z_(pTraits<vector>::zero),
z0_(0),
kappa_(0.41)
kappa_(0.41),
Uref_(0),
Href_(0),
zGround_(0)
{}
ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField::
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const ABLInletVelocityFvPatchVectorField& ptf,
const atmBoundaryLayerInletVelocityFvPatchVectorField& ptf,
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
const fvPatchFieldMapper& mapper
@ -67,11 +72,15 @@ ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
n_(ptf.n_),
z_(ptf.z_),
z0_(ptf.z0_),
kappa_(ptf.kappa_)
kappa_(ptf.kappa_),
Uref_(ptf.Uref_),
Href_(ptf.Href_),
zGround_(ptf.zGround_)
{}
ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField::
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const fvPatch& p,
const DimensionedField<vector, volMesh>& iF,
@ -79,57 +88,87 @@ ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
)
:
fixedValueFvPatchVectorField(p, iF),
Ustar_(readScalar(dict.lookup("Ustar"))),
Ustar_(0),
n_(dict.lookup("n")),
z_(dict.lookup("z")),
z0_(readScalar(dict.lookup("z0"))),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41))
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
Uref_(readScalar(dict.lookup("Uref"))),
Href_(readScalar(dict.lookup("Href"))),
zGround_(readScalar(dict.lookup("zGround")))
{
if (mag(n_) < SMALL || mag(z_) < SMALL)
if (mag(n_) < SMALL || mag(z_) < SMALL || mag(z0_) < SMALL)
{
FatalErrorIn("ABLInletVelocityFvPatchVectorField(dict)")
<< "n or z given with zero size 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);
}
n_ /= mag(n_);
z_ /= mag(z_);
Ustar_ = kappa_*Uref_/(log((Href_ + z0_)/min(z0_ , 0.001)));
evaluate();
}
ABLInletVelocityFvPatchVectorField::ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField::
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const ABLInletVelocityFvPatchVectorField& 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_)
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_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ABLInletVelocityFvPatchVectorField::updateCoeffs()
void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
{
const vectorField& c = patch().Cf();
scalarField coord = (c & z_);
vectorField::operator=(n_*(Ustar_/kappa_)*log((coord + z0_)/z0_));
scalarField Un(coord.size());
forAll(coord, i)
{
if((coord[i] - zGround_) < Href_)
{
Un[i] = (Ustar_/kappa_)*log((coord[i] - zGround_ + z0_)/z0_);
}
else
{
Un[i] = (Uref_);
}
}
vectorField::operator=(n_*Un);
fixedValueFvPatchVectorField::updateCoeffs();
}
// Write
void ABLInletVelocityFvPatchVectorField::write(Ostream& os) const
void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const
{
fvPatchVectorField::write(os);
os.writeKeyword("Ustar")
<< Ustar_ << token::END_STATEMENT << nl;
os.writeKeyword("z0")
<< z0_ << token::END_STATEMENT << nl;
os.writeKeyword("n")
@ -138,13 +177,23 @@ void ABLInletVelocityFvPatchVectorField::write(Ostream& os) const
<< z_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa")
<< kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("Uref")
<< Uref_ << token::END_STATEMENT << nl;
os.writeKeyword("Href")
<< Href_ << token::END_STATEMENT << nl;
os.writeKeyword("zGround")
<< zGround_ << token::END_STATEMENT << nl;
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchVectorField, ABLInletVelocityFvPatchVectorField);
makePatchTypeField
(
fvPatchVectorField,
atmBoundaryLayerInletVelocityFvPatchVectorField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField
Description
Boundary condition specifies a atmospheric boundary layer (ABL)
@ -31,7 +31,7 @@ Description
flow direction n and direction of the parabolic coordinate z.
@verbatim
U = (Ustar/K) ln((z + z0)/z0)
U = (Ustar/K) ln((z - zGround + z0)/z0)
where:
@ -39,6 +39,7 @@ Description
K is karman's constant
z0 is the surface roughness lenght
z is the verical coordinate
zGround is the minumum coordinate value in z direction.
and:
@ -63,12 +64,12 @@ NOTE: D.M. Hargreaves and N.G. Wright recommend Gamma epsilon in the k-epsilon
reference
SourceFiles
ABLInletVelocityFvPatchVectorField.C
atmBoundaryLayerInletVelocityFvPatchVectorField.C
\*---------------------------------------------------------------------------*/
#ifndef ABLInletVelocityFvPatchVectorField_H
#define ABLInletVelocityFvPatchVectorField_H
#ifndef atmBoundaryLayerInletVelocityFvPatchVectorField_H
#define atmBoundaryLayerInletVelocityFvPatchVectorField_H
#include "fvPatchFields.H"
#include "fixedValueFvPatchFields.H"
@ -81,16 +82,16 @@ namespace incompressible
{
/*---------------------------------------------------------------------------*\
Class ABLInletVelocityFvPatchVectorField Declaration
Class atmBoundaryLayerInletVelocityFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/
class ABLInletVelocityFvPatchVectorField
class atmBoundaryLayerInletVelocityFvPatchVectorField
:
public fixedValueFvPatchVectorField
{
// Private data
//- Friction velocity
//- Frictional velocity
scalar Ustar_;
//- Flow direction
@ -105,34 +106,44 @@ class ABLInletVelocityFvPatchVectorField
//- Von Karman constant
scalar kappa_;
//- Reference velocity
scalar Uref_;
//- Reference hight
scalar Href_;
//- Minimum corrdinate value in z direction
scalar zGround_;
public:
//- Runtime type information
TypeName("ABLInletVelocity");
TypeName("atmBoundaryLayerInletVelocity");
// Constructors
//- Construct from patch and internal field
ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&
);
//- Construct from patch, internal field and dictionary
ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const dictionary&
);
//- Construct by mapping given ABLInletVelocityFvPatchVectorField
// onto a new patch
ABLInletVelocityFvPatchVectorField
//- Construct by mapping given
// atmBoundaryLayerInletVelocityFvPatchVectorField onto a new patch
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const ABLInletVelocityFvPatchVectorField&,
const atmBoundaryLayerInletVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
@ -143,14 +154,14 @@ public:
{
return tmp<fvPatchVectorField>
(
new ABLInletVelocityFvPatchVectorField(*this)
new atmBoundaryLayerInletVelocityFvPatchVectorField(*this)
);
}
//- Construct as copy setting internal field reference
ABLInletVelocityFvPatchVectorField
atmBoundaryLayerInletVelocityFvPatchVectorField
(
const ABLInletVelocityFvPatchVectorField&,
const atmBoundaryLayerInletVelocityFvPatchVectorField&,
const DimensionedField<vector, volMesh>&
);
@ -162,14 +173,14 @@ public:
{
return tmp<fvPatchVectorField>
(
new ABLInletVelocityFvPatchVectorField(*this, iF)
new atmBoundaryLayerInletVelocityFvPatchVectorField(*this, iF)
);
}
// Member functions
//- Return max value
//- Return Ustar
scalar& Ustar()
{
return Ustar_;
@ -181,7 +192,7 @@ public:
return n_;
}
//- Return y direction
//- Return z direction
vector& z()
{
return z_;

View File

@ -0,0 +1,63 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 1 -1 0 0 0 0];
internalField uniform $flowVelocity;
boundaryField
{
#include "include/ABLConditions"
outlet
{
type inletOutlet;
inletValue uniform (0 0 0);
value $internalField;
}
inlet
{
type atmBoundaryLayerInletVelocity;
Uref $Uref;
Href $Href;
n $windDirection;
z $zDirection;
z0 $z0;
value $internalField;
zGround $zGround;
}
"terrain_.*"
{
type fixedValue;
value uniform (0 0 0);
}
ground
{
type fixedValue;
value uniform (0 0 0);
}
#include "include/sideAndTopPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
#include "include/initialConditions"
internalField uniform $turbulentEpsilon;
boundaryField
{
#include "include/ABLConditions"
"terrain_.*"
{
type epsilonWallFunction;
Cmu 0.09;
kappa 0.4;
E 9.8;
value $internalField;
}
outlet
{
type zeroGradient;
}
inlet
{
type atmBoundaryLayerInletEpsilon;
Ustar $Ustar;
z $zDirection;
z0 $z0;
value $internalField;
zGround $zGround;
}
ground
{
type zeroGradient;
}
#include "include/sideAndTopPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,17 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Ustar 0.82;
Uref 10.0;
Href 20;
z0 0.1;
turbulentKE 1.3;
windDirection (1 0 0);
zDirection (0 0 1);
zGround 935.0;
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
inlet
{
type fixedValue;
value $internalField;
}
// ************************************************************************* //

View File

@ -0,0 +1,14 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
flowVelocity (0 0 0);
pressure 0;
turbulentKE 1.3;
turbulentEpsilon 0.01;
// ************************************************************************* //

View File

@ -0,0 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
top
{
type slip;
}
sides
{
type slip;
}
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 2 -2 0 0 0 0];
internalField uniform $turbulentKE;
boundaryField
{
#include "include/ABLConditions"
outlet
{
type inletOutlet;
inletValue uniform 0.0;
value $internalField;
}
inlet
{
type fixedValue;
value uniform $turbulentKE;
}
"terrain_.*"
{
type kqRWallFunction;
value uniform 0.0;
}
ground
{
type zeroGradient;
}
#include "include/sideAndTopPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,56 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
inlet
{
type calculated;
value uniform 0;
}
outlet
{
type calculated;
value uniform 0;
}
"terrain_.*"
{
type nutkRoughWallFunction;
Ks 0.2; //Ks = 20 Z0
Cs 0.5;
value uniform 0.0;
}
ground
{
type calculated;
value uniform 0;
}
#include "include/sideAndTopPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "include/initialConditions"
dimensions [0 2 -2 0 0 0 0];
internalField uniform $pressure;
boundaryField
{
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value $internalField;
}
"terrain_.*"
{
type zeroGradient;
}
ground
{
type zeroGradient;
}
#include "include/sideAndTopPatches"
}
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -rf VTK
#rm -rf constant/cellToRegion constant/polyMesh/sets
rm -rf constant/polyMesh/sets
#rm -rf constant/cellLevel
#rm -rf constant/cellZones
#rm -rf constant/faceZones
#rm -rf constant/faces
#rm -rf constant/neighbour
#rm -rf constant/owner
#rm -rf constant/pointZones
#rm -rf constant/points
#rm -rf constant/refinementHistory
#rm -rf constant/surfaceIndex
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication snappyHexMesh -overwrite
runApplication setSet -batch makeZones
runApplication setsToZones -noFlipMap
runApplication windSimpleFoam
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,34 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
RASModel kEpsilon;
turbulence on;
printCoeffs on;
kEpsilonCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
C3 -0.33;
sigmak 1.0;
sigmaEps 1.11; //Original value:1.44
Prt 1.0;
}
// ************************************************************************* //

View File

@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: http://www.openfoam.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
/*
( 581761 4.78575e+06 1000)
( 581861 4.78575e+06 1000)
( 581861 4.78585e+06 1000)
( 581761 4.78585e+06 1000)
( 581761 4.78575e+06 1100)
( 581861 4.78575e+06 1100)
( 581861 4.78585e+06 1100)
( 581761 4.78585e+06 1100)
*/
( 581321 4.78537e+06 930)
( 582290 4.78537e+06 930)
( 582290 4.78624e+06 930)
( 581321 4.78624e+06 930)
( 581321 4.78537e+06 1500)
( 582290 4.78537e+06 1500)
( 582290 4.78624e+06 1500)
( 581321 4.78624e+06 1500)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (30 30 20) simpleGrading (1 1 1)
);
edges
(
);
patches
(
patch outlet
(
(2 6 5 1)
)
patch sides
(
(1 5 4 0)
(3 7 6 2)
)
patch inlet
(
(0 4 7 3)
)
wall ground
(
(0 3 2 1)
)
patch top
(
(4 5 6 7)
)
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
6
(
outlet
{
type patch;
nFaces 922;
startFace 364825;
}
sides
{
type patch;
nFaces 1834;
startFace 365747;
}
inlet
{
type patch;
nFaces 923;
startFace 367581;
}
ground
{
type wall;
nFaces 0;
startFace 368504;
}
top
{
type patch;
nFaces 900;
startFace 368504;
}
terrain_patch0
{
type wall;
nFaces 18201;
startFace 369404;
}
)
// ************************************************************************* //

View File

@ -0,0 +1,55 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object sourcesProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
disk1
{
typeModel actuationDiskSource;
active on; // on/off switch
timeStart 0.0; // start time
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
cellSet actuationDisk1; // cellSet name when selectionMode = cellSet
cellZone actuationDisk1; // cellZone name when selectionMode = cellZone
actuationDiskSourceCoeffs
{
diskDir (-1 0 0); // orientation of the disk
Cp 0.53; // Cp
Ct 0.58; // Ct
diskArea 40; // disk area
}
}
disk2
{
typeModel actuationDiskSource;
active on; // on/off switch
timeStart 0.0; // start time
duration 1000.0; // duration
selectionMode cellSet; // cellSet // points //cellZone
cellSet actuationDisk2; // cellSet name when selectionMode = cellSet
cellZone actuationDisk2; // cellZone name when selectionMode = cellZone
actuationDiskSourceCoeffs
{
diskDir (-1 0 0); // orientation of the disk
Cp 0.53; // Cp
Ct 0.58; // Ct
diskArea 40; // disk area
}
}
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1.5e-05;
// ************************************************************************* //

View File

@ -0,0 +1,2 @@
cellSet actuationDisk1 new boxToCell (581850.5 4785805 1061) (581850.8 4785815 1071)
cellSet actuationDisk2 new boxToCell (581754 4785658 1065) (581754.4 4785668 1075)

View File

@ -0,0 +1,47 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application simpleFoam;
startFrom latestTime;
startTime 0;
stopAt endTime;
endTime 5000;
deltaT 1;
writeControl timeStep;
writeInterval 50;
purgeWrite 0;
writeFormat ascii;
writePrecision 12;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 1;
method hierarchical;
// method metis;
// method ptscotch;
simpleCoeffs
{
n (4 1 1);
delta 0.001;
}
hierarchicalCoeffs
{
n (1 1 1);
delta 0.001;
order xyz;
}
manualCoeffs
{
dataFile "cellDecomposition";
}
metisCoeffs
{
//n (5 1 1);
//cellWeightsFile "constant/cellWeightsFile";
}
// ************************************************************************* //

View File

@ -0,0 +1,60 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
grad(U) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss upwind grad(U);
div((nuEff*dev(grad(U).T()))) Gauss linear;
div(phi,epsilon) Gauss upwind;
div(phi,k) Gauss upwind;
}
laplacianSchemes
{
default Gauss linear limited 0.333;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default limited 0.333;
}
fluxRequired
{
default no;
p;
}
// ************************************************************************* //

View File

@ -0,0 +1,80 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-6;
relTol 0.01;
maxIter 300;
};
U
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-6;
relTol 0.01;
};
k
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-6;
relTol 0.01;
};
epsilon
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-6;
relTol 0.01;
};
omega
{
solver smoothSolver;
smoother GaussSeidel;
tolerance 1e-6;
relTol 0.1;
};
}
SIMPLE
{
nNonOrthogonalCorrectors 1;
convergence 1e-3;
}
relaxationFactors
{
p 0.3;
U 0.7;
k 0.7;
epsilon 0.7;
}
cache
{
grad(U);
}
// ************************************************************************* //

View File

@ -0,0 +1,431 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Which of the steps to run
castellatedMesh true;
snap true;
addLayers false;
// Geometry. Definition of all surfaces. All surfaces are of class
// searchableSurface.
// Surfaces are used
// - to specify refinement for any mesh cell intersecting it
// - to specify refinement for any mesh cell inside/outside/near
// - to 'snap' the mesh boundary to the surface
geometry
{
windTurbine1
{
type searchableBox;
min (581845 4785805 1061);
max (581855 4785815 1071);
}
windTurbine2
{
type searchableBox;
min (581740 4785658 1065);
max (581771 4785671 1079);
}
terrain.stl
{
type triSurfaceMesh;
name terrain;
//tolerance 1E-5; // optional:non-default tolerance on intersections
//maxTreeDepth 10; // optional:depth of octree. Decrease only in case
// of memory limitations.
// Per region the patchname. If not provided will be <name>_<region>.
/*
regions
{
secondSolid
{
name mySecondPatch;
}
}
*/
}
/*
sphere2
{
type searchableSphere;
centre (1.5 1.5 1.5);
radius 1.03;
}
*/
};
// Settings for the castellatedMesh generation.
castellatedMeshControls
{
// Refinement parameters
// ~~~~~~~~~~~~~~~~~~~~~
// If local number of cells is >= maxLocalCells on any processor
// switches from from refinement followed by balancing
// (current method) to (weighted) balancing before refinement.
maxLocalCells 1000000;
// Overall cell limit (approximately). Refinement will stop immediately
// upon reaching this number so a refinement level might not complete.
// Note that this is the number of cells before removing the part which
// is not 'visible' from the keepPoint. The final number of cells might
// actually be a lot less.
maxGlobalCells 2000000;
// The surface refinement loop might spend lots of iterations refining just a
// few cells. This setting will cause refinement to stop if <= minimumRefine
// are selected for refinement. Note: it will at least do one iteration
// (unless the number of cells to refine is 0)
minRefinementCells 0;
// Allow a certain level of imbalance during refining
// (since balancing is quite expensive)
// Expressed as fraction of perfect balance (= overall number of cells /
// nProcs). 0=balance always.
maxLoadUnbalance 0.10;
// Number of buffer layers between different levels.
// 1 means normal 2:1 refinement restriction, larger means slower
// refinement.
nCellsBetweenLevels 1;
// Explicit feature edge refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies a level for any cell intersected by its edges.
// This is a featureEdgeMesh, read from constant/triSurface for now.
features
(
//{
// file "someLine.eMesh";
// level 2;
//}
);
// Surface based refinement
// ~~~~~~~~~~~~~~~~~~~~~~~~
// Specifies two levels for every surface. The first is the minimum level,
// every cell intersecting a surface gets refined up to the minimum level.
// The second level is the maximum level. Cells that 'see' multiple
// intersections where the intersections make an
// angle > resolveFeatureAngle get refined up to the maximum level.
refinementSurfaces
{
terrain
{
// Surface-wise min and max refinement level
level (2 2);
// Optional region-wise level specification
/*
regions
{
windTurbine
{
level (3 3);
}
}
*/
//- Optional angle to detect small-large cell situation
// perpendicular to the surface. Is the angle of face w.r.t.
// the local surface normal. Use on flat(ish) surfaces only.
// Otherwise leave out or set to negative number.
//perpendicularAngle 10;
//- Optional faceZone and (for closed surface) cellZone with
// how to select the cells that are in the cellZone
// (inside / outside / specified insidePoint)
//faceZone sphere;
//cellZone sphere;
//cellZoneInside inside; //outside/insidePoint
}
}
resolveFeatureAngle 2;
// Region-wise refinement
// ~~~~~~~~~~~~~~~~~~~~~~
// Specifies refinement level for cells in relation to a surface. One of
// three modes
// - distance. 'levels' specifies per distance to the surface the
// wanted refinement level. The distances need to be specified in
// descending order.
// - inside. 'levels' is only one entry and only the level is used. All
// cells inside the surface get refined up to the level. The surface
// needs to be closed for this to be possible.
// - outside. Same but cells outside.
refinementRegions
{
windTurbine1
{
mode inside;
levels ((6 6));
}
windTurbine2
{
mode inside;
levels ((6 6));
}
//sphere.stl
//{
// mode distance;
// levels ((1.0 5) (2.0 3));
//}
}
// Mesh selection
// ~~~~~~~~~~~~~~
// After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even
// after refinement.
locationInMesh (581770 4.78580e+06 1050);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
}
// Settings for the snapping.
snapControls
{
//- Number of patch smoothing iterations before finding correspondence
// to surface
nSmoothPatch 3;
//- Relative distance for points to be attracted by surface feature point
// or edge. True distance is this factor times local
// maximum edge length.
tolerance 4.0;
//- Number of mesh displacement relaxation iterations.
nSolveIter 30;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
}
// Settings for the layer addition.
addLayersControls
{
// Are the thickness parameters below relative to the undistorted
// size of the refined cell outside layer (true) or absolute sizes (false).
relativeSizes true;
// Per final patch (so not geometry!) the layer information
layers
{
sphere.stl_firstSolid
{
nSurfaceLayers 1;
}
maxY
{
nSurfaceLayers 1;
}
}
// Expansion factor for layer mesh
expansionRatio 1.0;
//- Wanted thickness of final added cell layer. If multiple layers
// is the thickness of the layer furthest away from the wall.
// See relativeSizes parameter.
finalLayerThickness 0.3;
//- Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// See relativeSizes parameter.
minThickness 0.25;
//- If points get not extruded do nGrow layers of connected faces that are
// also not grown. This helps convergence of the layer addition process
// close to features.
// Note: changed(corrected) w.r.t 16x! (didn't do anything in 16x)
nGrow 0;
// Advanced settings
//- When not to extrude surface. 0 is flat surface, 90 is when two faces
// make straight angle.
featureAngle 60;
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
nRelaxIter 5;
// Number of smoothing iterations of surface normals
nSmoothSurfaceNormals 1;
// Number of smoothing iterations of interior mesh movement direction
nSmoothNormals 3;
// Smooth layer thickness over surface patches
nSmoothThickness 10;
// Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5;
// Reduce layer growth where ratio thickness to medial
// distance is large
maxThicknessToMedialRatio 0.3;
// Angle used to pick up medial axis points
// Note: changed(corrected) w.r.t 16x! 90 degrees corresponds to 130 in 16x.
minMedianAxisAngle 90;
// Create buffer region for new layer terminations
nBufferCellsNoExtrude 0;
// Overall max number of layer addition iterations. The mesher will exit
// if it reaches this number of iterations; possibly with an illegal
// mesh.
nLayerIter 50;
// Max number of iterations after which relaxed meshQuality controls
// get used. Up to nRelaxIter it uses the settings in meshQualityControls,
// after nRelaxIter it uses the values in meshQualityControls::relaxed.
nRelaxedIter 20;
}
// Generic mesh quality settings. At any undoable phase these determine
// where to undo.
meshQualityControls
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 65;
//- Max skewness allowed. Set to <0 to disable.
maxBoundarySkewness 20;
maxInternalSkewness 4;
//- Max concaveness allowed. Is angle (in degrees) below which concavity
// is allowed. 0 is straight face, <0 would be convex face.
// Set to 180 to disable.
maxConcave 80;
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
// Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable.
minVol 1e-13;
//- Minimum tet volume. Is absolute volume of the tet formed by the
// face-centre decomposition triangle and the cell centre.
// Set to a sensible fraction of the smallest cell volume expected.
// Set to very negative number (e.g. -1E30) to disable.
minTetVol 1e-20;
//- Minimum face area. Set to <0 to disable.
minArea -1;
//- Minimum face twist. Set to <-1 to disable. dot product of face normal
//- and face centre triangles normal
minTwist 0.05;
//- minimum normalised cell determinant
//- 1 = hex, <= 0 = folded or flattened illegal cell
minDeterminant 0.001;
//- minFaceWeight (0 -> 0.5)
minFaceWeight 0.05;
//- minVolRatio (0 -> 1)
minVolRatio 0.01;
//must be >0 for Fluent compatibility
minTriangleTwist -1;
//- if >0 : preserve single cells with all points on the surface if the
// resulting volume after snapping (by approximation) is larger than
// minVolCollapseRatio times old volume (i.e. not collapsed to flat cell).
// If <0 : delete always.
//minVolCollapseRatio 0.5;
// Advanced
//- Number of error distribution iterations
nSmoothScale 4;
//- amount to scale back displacement at error points
errorReduction 0.75;
// Optional : some meshing phases allow usage of relaxed rules.
// See e.g. addLayersControls::nRelaxedIter.
relaxed
{
//- Maximum non-orthogonality allowed. Set to 180 to disable.
maxNonOrtho 75;
}
}
// Advanced
// Flags for optional output
// 0 : only write final meshes
// 1 : write intermediate meshes
// 2 : write volScalarField with cellLevel for postprocessing
// 4 : write current intersections as .obj files
debug 0;
// Merge tolerance. Is fraction of overall bounding box of initial mesh.
// Note: the write tolerance needs to be higher than this.
mergeTolerance 1E-6;
// ************************************************************************* //

View File

@ -0,0 +1,3 @@
windSimpleFoam.C
EXE = $(FOAM_APPBIN)/windSimpleFoam

View File

@ -0,0 +1,14 @@
EXE_INC = \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
EXE_LIBS = \
-lincompressibleRASModels \
-lincompressibleTransportModels \
-lfiniteVolume \
-lmeshTools

View File

@ -0,0 +1,19 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
+ turbulence->divDevReff(U)
);
UEqn().relax();
// Add resistance on the actuation disks
actuationDisks.addSu(UEqn());
eqnResidual = solve
(
UEqn() == -fvc::grad(p)
).initialResidual();
maxResidual = max(eqnResidual, maxResidual);

View File

@ -0,0 +1,9 @@
// check convergence
if (maxResidual < convergenceCriterion)
{
Info<< "reached convergence criterion: " << convergenceCriterion << endl;
runTime.writeAndEnd();
Info<< "latestTime = " << runTime.timeName() << endl;
}

View File

@ -0,0 +1,45 @@
Info<< "Reading field p\n" << endl;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
# include "createPhi.H"
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell(p, mesh.solutionDict().subDict("SIMPLE"), pRefCell, pRefValue);
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::RASModel> turbulence
(
incompressible::RASModel::New(U, phi, laminarTransport)
);
IObasicSourceList actuationDisks(mesh);

View File

@ -0,0 +1,7 @@
// initialize values for convergence checks
scalar eqnResidual = 1, maxResidual = 0;
scalar convergenceCriterion = 0;
simple.readIfPresent("convergence", convergenceCriterion);

View File

@ -0,0 +1,41 @@
p.boundaryField().updateCoeffs();
volScalarField AU = UEqn().A();
U = UEqn().H()/AU;
UEqn.clear();
phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);
// Non-orthogonal pressure corrector loop
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(1.0/AU, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
// retain the residual from the first iteration
if (nonOrth == 0)
{
pEqn.solve();
}
else
{
pEqn.solve();
}
if (nonOrth == nNonOrthCorr)
{
phi -= pEqn.flux();
}
}
# include "continuityErrs.H"
// Explicitly relax pressure for momentum corrector
p.relax();
// Momentum corrector
U -= fvc::grad(p)/AU;
U.correctBoundaryConditions();

View File

@ -0,0 +1,85 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Application
windSimpleFoam
Description
Steady-state solver for incompressible, turbulent flow with external
source in the momentum equation.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "RASModel.H"
#include "IObasicSourceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "initContinuityErrs.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "readSIMPLEControls.H"
#include "initConvergenceCheck.H"
p.storePrevIter();
// Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"
#include "pEqn.H"
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
#include "convergenceCheck.H"
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //