mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Adding:
1) basicSource for explicit sources(ActuationDisk and explicit source so far) 2) cylindricalInlet BC 3) swirlMassFlowRate BC 4) dynamicLagrangian LES incompressible turbulence model 5) atmospheric boundary layer inlet BC for velocity and epsilon
This commit is contained in:
@ -0,0 +1,196 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|| Cp_ <= VSMALL
|
||||
|| Ct_ <= VSMALL
|
||||
|| diskDir_ == vector::zero
|
||||
)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"Foam::actuationDiskSource::checkData()",
|
||||
dict_
|
||||
) << "diskArea, Cp or Ct is small "
|
||||
<< "or disk direction not specified"
|
||||
<< 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())),
|
||||
diskDir_(vector::zero),
|
||||
Cp_(0),
|
||||
Ct_(0),
|
||||
diskArea_(0),
|
||||
dict_(dict.subDict(typeName + "Coeffs"))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
dict_.readIfPresent("diskDir", diskDir_);
|
||||
dict_.readIfPresent("Cp", Cp_);
|
||||
dict_.readIfPresent("Ct", Ct_);
|
||||
dict_.readIfPresent("diskArea", diskArea_);
|
||||
|
||||
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,//this->cells(),
|
||||
V,
|
||||
this->mesh().lookupObject<volScalarField>("rho"),
|
||||
U
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
addActuationDiskAxialInertialResistance
|
||||
(
|
||||
Usource,
|
||||
cells,//this->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;
|
||||
}
|
||||
}
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,213 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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_;
|
||||
|
||||
//- Disk area normal
|
||||
vector diskDir_;
|
||||
|
||||
//- Power coefficient
|
||||
scalar Cp_;
|
||||
|
||||
//- Thrust coefficient
|
||||
scalar Ct_;
|
||||
|
||||
//- Disk area
|
||||
scalar diskArea_;
|
||||
|
||||
//- Sub dictionary with actuationDisk information
|
||||
const dictionary& dict_;
|
||||
|
||||
|
||||
// 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
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
# include "actuationDiskSourceTemplates.C"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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]];
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::IObasicSourceList
|
||||
|
||||
Description
|
||||
IObasicSourceList
|
||||
|
||||
SourceFiles
|
||||
IObasicSourceList.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IObasicSourceList_H
|
||||
#define IObasicSourceList_H
|
||||
|
||||
#include "basicSourceList.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "autoPtr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IObasicSourceList Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IObasicSourceList
|
||||
:
|
||||
public IOdictionary,
|
||||
public basicSourceList
|
||||
{
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
IObasicSourceList
|
||||
(
|
||||
const IObasicSourceList&
|
||||
);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const IObasicSourceList&);
|
||||
|
||||
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,292 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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") >> 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
|
||||
<< endl << endl
|
||||
<< "Valid model types are :" << endl
|
||||
<< dictionaryConstructorTablePtr_->toc()
|
||||
<< 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,83 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,180 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,137 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,321 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "explicitSource.H"
|
||||
#include "fvMesh.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(explicitSource, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
basicSource,
|
||||
explicitSource,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
const Foam::wordList Foam::explicitSource::volumeModeTypeNames_
|
||||
(
|
||||
IStringStream("(absolute specific)")()
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::explicitSource::setSelectedCellsFromPoints()
|
||||
{
|
||||
labelHashSet selectedCells;
|
||||
|
||||
forAll(points_, i)
|
||||
{
|
||||
label cellI = this->mesh().findCell(points_[i]);
|
||||
if (cellI >= 0)
|
||||
{
|
||||
selectedCells.insert(cellI);
|
||||
}
|
||||
|
||||
label globalCellI = returnReduce(cellI, maxOp<label>());
|
||||
|
||||
if (globalCellI < 0)
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"explicitSource::setSelectedCellsFromPoints()"
|
||||
)
|
||||
<< "Unable to find owner cell for point " << points_[i]
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
this->cells() = selectedCells.toc();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::explicitSource::addSources
|
||||
(
|
||||
Field<Type>& fieldSource,
|
||||
Type& data
|
||||
) const
|
||||
{
|
||||
forAll(this->cells(), i)
|
||||
{
|
||||
fieldSource[this->cells()[i]] = data/volSource_[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
Foam::explicitSource::volumeModeType
|
||||
Foam::explicitSource::wordToVolumeModeType
|
||||
(
|
||||
const word& vmtName
|
||||
) const
|
||||
{
|
||||
forAll(volumeModeTypeNames_, i)
|
||||
{
|
||||
if (vmtName == volumeModeTypeNames_[i])
|
||||
{
|
||||
return volumeModeType(i);
|
||||
}
|
||||
}
|
||||
|
||||
FatalErrorIn
|
||||
(
|
||||
"explicitSource<Type>::volumeModeType"
|
||||
"explicitSource<Type>::wordToVolumeModeType(const word&)"
|
||||
) << "Unknown volumeMode type " << vmtName
|
||||
<< ". Valid volumeMode types are:" << nl << volumeModeTypeNames_
|
||||
<< exit(FatalError);
|
||||
|
||||
return volumeModeType(0);
|
||||
}
|
||||
|
||||
|
||||
Foam::word Foam::explicitSource::volumeModeTypeToWord
|
||||
(
|
||||
const volumeModeType& vmtType
|
||||
) const
|
||||
{
|
||||
if (vmtType > volumeModeTypeNames_.size())
|
||||
{
|
||||
return "UNKNOWN";
|
||||
}
|
||||
else
|
||||
{
|
||||
return volumeModeTypeNames_[vmtType];
|
||||
}
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
void Foam::explicitSource::addField
|
||||
(
|
||||
HashTable<Type>& fields,
|
||||
const wordList& fieldTypes,
|
||||
const wordList& fieldNames,
|
||||
const dictionary& fieldDataDict
|
||||
)
|
||||
{
|
||||
forAll (fieldTypes, fieldI)
|
||||
{
|
||||
word fieldName = fieldNames[fieldI];
|
||||
word fieldType = fieldTypes[fieldI];
|
||||
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> geometricField;
|
||||
|
||||
if
|
||||
(
|
||||
(
|
||||
fieldType
|
||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
||||
) &&
|
||||
(
|
||||
this->mesh().foundObject<geometricField>(fieldName)
|
||||
)
|
||||
)
|
||||
{
|
||||
Type fieldValue = fieldDataDict.lookupOrDefault<Type>
|
||||
(
|
||||
fieldName,
|
||||
pTraits<Type>::zero
|
||||
);
|
||||
|
||||
fields.insert(fieldName, fieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::explicitSource::setFieldData
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
scalarFields_.clear();
|
||||
vectorFields_.clear();
|
||||
|
||||
wordList fieldTypes(dict.toc().size());
|
||||
wordList fieldNames(dict.toc().size());
|
||||
|
||||
forAll(dict.toc(), i)
|
||||
{
|
||||
const word& fieldName = dict.toc()[i];
|
||||
IOobject io
|
||||
(
|
||||
fieldName,
|
||||
this->mesh().time().timeName(0),
|
||||
this->mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
if (io.headerOk())
|
||||
{
|
||||
fieldTypes[i] = io.headerClassName();
|
||||
fieldNames[i] = dict.toc()[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"explicitSource::setFieldData"
|
||||
) << "header not OK " << io.name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
addField(scalarFields_, fieldTypes, fieldNames, dict);
|
||||
addField(vectorFields_, fieldTypes, fieldNames, dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::explicitSource::explicitSource
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh
|
||||
)
|
||||
:
|
||||
basicSource(name, dict, mesh),
|
||||
scalarFields_(0, *this),
|
||||
vectorFields_(0, *this),
|
||||
dict_(dict.subDict(typeName + "Coeffs")),
|
||||
volumeMode_(wordToVolumeModeType(dict_.lookup("volumeMode"))),
|
||||
points_(),
|
||||
volSource_(this->cells().size(), 1.0)
|
||||
{
|
||||
setFieldData(dict_.subDict("fieldData"));
|
||||
|
||||
// Set points if selectionMode is smPoints
|
||||
if (this->selectionMode() == smPoints)
|
||||
{
|
||||
dict_.lookup("points") >> points_;
|
||||
setSelectedCellsFromPoints();
|
||||
volSource_.setSize(points_.size(), 1.0);
|
||||
}
|
||||
|
||||
const labelList& cellList = this->cells();
|
||||
scalar V = 0.0;
|
||||
if (volumeMode_ == vmAbsolute)
|
||||
{
|
||||
forAll(cellList, cellI)
|
||||
{
|
||||
volSource_[cellI] = mesh.V()[cellList[cellI]];
|
||||
V += volSource_[cellI];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(cellList, cellI)
|
||||
{
|
||||
V += mesh.V()[cellList[cellI]];
|
||||
}
|
||||
}
|
||||
|
||||
reduce(V, sumOp<scalar>());
|
||||
|
||||
Info<< "- selected " << returnReduce(cellList.size(), sumOp<label>())
|
||||
<< " cell(s) with Volume: " << V << " in time activated sources "
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::explicitSource::addSu
|
||||
(
|
||||
fvMatrix<scalar>& Eqn
|
||||
)
|
||||
{
|
||||
Field<scalar>& source = Eqn.source();
|
||||
scalar data = scalarFields_[Eqn.psi().name()];
|
||||
addSources<scalar>(source, data);
|
||||
}
|
||||
|
||||
|
||||
void Foam::explicitSource::addSu
|
||||
(
|
||||
fvMatrix<vector>& Eqn
|
||||
)
|
||||
{
|
||||
Field<vector>& source = Eqn.source();
|
||||
vector data = vectorFields_[Eqn.psi().name()];
|
||||
addSources<vector>(source, data);
|
||||
}
|
||||
|
||||
|
||||
void Foam::explicitSource::addSu
|
||||
(
|
||||
DimensionedField<scalar, volMesh>& field
|
||||
)
|
||||
{
|
||||
scalar data = scalarFields_[field.name()];
|
||||
addSources<scalar>(field, data);
|
||||
}
|
||||
|
||||
|
||||
void Foam::explicitSource::addSu
|
||||
(
|
||||
DimensionedField<vector, volMesh>& field
|
||||
)
|
||||
{
|
||||
vector data = vectorFields_[field.name()];
|
||||
addSources<vector>(field, data);
|
||||
}
|
||||
|
||||
void Foam::explicitSource::addExplicitSources()
|
||||
{
|
||||
scalarFields_.applySources();
|
||||
vectorFields_.applySources();
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,289 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::explicitSource
|
||||
|
||||
Description
|
||||
Explicit source.
|
||||
|
||||
Sources described by:
|
||||
|
||||
explicitSourceCoeffs
|
||||
{
|
||||
points // list of points when selectionMode = points
|
||||
(
|
||||
(-0.088 0.007 -0.02)
|
||||
(-0.028 0.007 -0.02)
|
||||
);
|
||||
volumeMode specific; //absolute
|
||||
fieldData // field data - usage for multiple fields
|
||||
{
|
||||
k 30.7;
|
||||
epsilon 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
SourceFiles
|
||||
explicitSource.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef explicitSource_H
|
||||
#define explicitSource_H
|
||||
|
||||
#include "cellSet.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "DimensionedField.H"
|
||||
#include "basicSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class explicitSource Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class explicitSource
|
||||
:
|
||||
public basicSource
|
||||
{
|
||||
// Private classes
|
||||
|
||||
template<class Type>
|
||||
class fieldList
|
||||
:
|
||||
public HashTable<Type>
|
||||
{
|
||||
|
||||
explicitSource& OwnerPtr_;
|
||||
|
||||
public:
|
||||
|
||||
//- null Constructor
|
||||
fieldList()
|
||||
:
|
||||
HashTable<Type>(0),
|
||||
OwnerPtr_()
|
||||
{}
|
||||
|
||||
|
||||
//- Constructor
|
||||
fieldList(label size, explicitSource& ownerPtr)
|
||||
:
|
||||
HashTable<Type>(size),
|
||||
OwnerPtr_(ownerPtr)
|
||||
{}
|
||||
|
||||
|
||||
void applySources()
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh>
|
||||
geometricField;
|
||||
|
||||
forAll(this->toc(), i)
|
||||
{
|
||||
geometricField& field = const_cast<geometricField&>
|
||||
(
|
||||
OwnerPtr_.mesh().lookupObject<geometricField>
|
||||
(this->toc()[i])
|
||||
);
|
||||
|
||||
Type data = this->operator[](field.name());
|
||||
OwnerPtr_.addSources<Type>(field.internalField(), data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// Private cdata
|
||||
|
||||
//- List of field types
|
||||
fieldList<scalar> scalarFields_;
|
||||
fieldList<vector> vectorFields_;
|
||||
|
||||
//- Add field names and values to field table for types.
|
||||
template<class Type>
|
||||
void addField
|
||||
(
|
||||
HashTable<Type>& fields,
|
||||
const wordList& fieldTypes,
|
||||
const wordList& fieldNames,
|
||||
const dictionary& dict_
|
||||
);
|
||||
|
||||
|
||||
//- Add data to field source
|
||||
template<class Type>
|
||||
void addSources
|
||||
(
|
||||
Field<Type>& fieldSource,
|
||||
Type& data
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// Public data
|
||||
|
||||
//- Enumeration for volume types
|
||||
enum volumeModeType
|
||||
{
|
||||
vmAbsolute,
|
||||
vmSpecific
|
||||
};
|
||||
|
||||
//- Word list of volume mode type names
|
||||
static const wordList volumeModeTypeNames_;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Sub dictionary for time activated explicit sources
|
||||
const dictionary& dict_;
|
||||
|
||||
//- Volume mode
|
||||
volumeModeType volumeMode_;
|
||||
|
||||
//- List of points for "points" selectionMode
|
||||
List<point> points_;
|
||||
|
||||
//- Volume of the explicit source
|
||||
scalarList volSource_;
|
||||
|
||||
|
||||
// Protected functions
|
||||
|
||||
//- Helper function to convert from a word to a volumeModeType
|
||||
volumeModeType wordToVolumeModeType(const word& vtName) const;
|
||||
|
||||
//- Helper function to convert from a volumeModeType to a word
|
||||
word volumeModeTypeToWord(const volumeModeType& vtType) const;
|
||||
|
||||
//- Set the local field data
|
||||
void setFieldData(const dictionary& dict);
|
||||
|
||||
//- Set selected cells when smPoint is used
|
||||
void setSelectedCellsFromPoints();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("explicitSource");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
explicitSource
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const fvMesh& mesh
|
||||
);
|
||||
|
||||
//- Return clone
|
||||
autoPtr<explicitSource> clone() const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"autoPtr<explicitSource> clone() const"
|
||||
);
|
||||
return autoPtr<explicitSource>(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return const access to the volume mode
|
||||
inline const volumeModeType& volumeMode() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Return access to the volume mode
|
||||
inline volumeModeType& volumeMode();
|
||||
|
||||
//- Return points
|
||||
inline const List<point>& points() const;
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//-Source term to fvMatrix<vector>
|
||||
virtual void addSu(fvMatrix<vector>& UEqn);
|
||||
|
||||
//-Source term to fvMatrix<scalar>
|
||||
virtual void addSu(fvMatrix<scalar>& UEqn);
|
||||
|
||||
//- Add all explicit source
|
||||
virtual void addExplicitSources();
|
||||
|
||||
//- Add source to scalar field
|
||||
virtual void addSu(DimensionedField<vector, volMesh>& field);
|
||||
|
||||
//- Add source to vector field
|
||||
virtual void addSu(DimensionedField<scalar, volMesh>& field);
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write the source properties
|
||||
virtual void writeData(Ostream&) const;
|
||||
|
||||
//- Read fieldData in sub-dictionary
|
||||
virtual bool read(const dictionary& dict);
|
||||
|
||||
//- Ostream operator
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const explicitSource& source
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "explicitSourceIO.C"
|
||||
#include "explicitSourceI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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_;
|
||||
}
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,83 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "explicitSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::explicitSource::writeData(Ostream& os) const
|
||||
{
|
||||
os << indent << name_ << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
os.writeKeyword("volumeMode") << volumeModeTypeToWord(volumeMode_)
|
||||
<< token::END_STATEMENT << nl;
|
||||
|
||||
if (scalarFields_.size() > 0)
|
||||
{
|
||||
os.writeKeyword("scalarFields") << scalarFields_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
if (vectorFields_.size() > 0)
|
||||
{
|
||||
os.writeKeyword("vectorFields") << vectorFields_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::explicitSource::read(const dictionary& dict)
|
||||
{
|
||||
if (basicSource::read(dict))
|
||||
{
|
||||
const dictionary& sourceDict = dict.subDict(name());
|
||||
const dictionary& subDictCoeffs = sourceDict.subDict(typeName + "Coeffs");
|
||||
setFieldData(subDictCoeffs.subDict("fieldData"));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<
|
||||
(
|
||||
Ostream& os,
|
||||
const explicitSource& source
|
||||
)
|
||||
{
|
||||
source.writeData(os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user