mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: basicSourtce - simplified setting of continuous operation
This commit is contained in:
@ -108,7 +108,6 @@ void Foam::basicSource::setSelection(const dictionary& dict)
|
|||||||
|
|
||||||
void Foam::basicSource::setCellSet()
|
void Foam::basicSource::setCellSet()
|
||||||
{
|
{
|
||||||
Info<< incrIndent << indent << "Source: " << name_ << endl;
|
|
||||||
switch (selectionMode_)
|
switch (selectionMode_)
|
||||||
{
|
{
|
||||||
case smPoints:
|
case smPoints:
|
||||||
@ -237,7 +236,7 @@ void Foam::basicSource::setCellSet()
|
|||||||
|
|
||||||
Info<< indent << "- selected "
|
Info<< indent << "- selected "
|
||||||
<< returnReduce(cells_.size(), sumOp<label>())
|
<< returnReduce(cells_.size(), sumOp<label>())
|
||||||
<< " cell(s) with volume " << V_ << nl << decrIndent << endl;
|
<< " cell(s) with volume " << V_ << nl << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,8 +256,8 @@ Foam::basicSource::basicSource
|
|||||||
dict_(dict),
|
dict_(dict),
|
||||||
coeffs_(dict.subDict(modelType + "Coeffs")),
|
coeffs_(dict.subDict(modelType + "Coeffs")),
|
||||||
active_(readBool(dict_.lookup("active"))),
|
active_(readBool(dict_.lookup("active"))),
|
||||||
timeStart_(readScalar(dict_.lookup("timeStart"))),
|
timeStart_(-1.0),
|
||||||
duration_(readScalar(dict_.lookup("duration"))),
|
duration_(0.0),
|
||||||
selectionMode_
|
selectionMode_
|
||||||
(
|
(
|
||||||
selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
|
selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
|
||||||
@ -273,9 +272,24 @@ Foam::basicSource::basicSource
|
|||||||
fieldNames_(),
|
fieldNames_(),
|
||||||
applied_()
|
applied_()
|
||||||
{
|
{
|
||||||
|
Info<< incrIndent << indent << "Source: " << name_ << endl;
|
||||||
|
|
||||||
|
if (dict_.readIfPresent("timeStart", timeStart_))
|
||||||
|
{
|
||||||
|
dict_.lookup("duration") >> duration_;
|
||||||
|
Info<< indent << "- applying source at time " << timeStart_
|
||||||
|
<< " for duration " << duration_ << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< indent<< "-applying source for all time" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
setSelection(dict_);
|
setSelection(dict_);
|
||||||
|
|
||||||
setCellSet();
|
setCellSet();
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -325,12 +339,7 @@ Foam::basicSource::~basicSource()
|
|||||||
|
|
||||||
bool Foam::basicSource::isActive()
|
bool Foam::basicSource::isActive()
|
||||||
{
|
{
|
||||||
if
|
if (active_ && inTimeLimits(mesh_.time().value()))
|
||||||
(
|
|
||||||
active_
|
|
||||||
&& (mesh_.time().value() >= timeStart_)
|
|
||||||
&& (mesh_.time().value() <= timeEnd())
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Update the cell set if the mesh is changing
|
// Update the cell set if the mesh is changing
|
||||||
if (mesh_.changing())
|
if (mesh_.changing())
|
||||||
|
|||||||
@ -277,8 +277,8 @@ public:
|
|||||||
//- Return const access to the duration
|
//- Return const access to the duration
|
||||||
inline scalar duration() const;
|
inline scalar duration() const;
|
||||||
|
|
||||||
//- Return const access to the time end
|
//- Return true if within time limits
|
||||||
inline scalar timeEnd() const;
|
inline bool inTimeLimits(const scalar time) const;
|
||||||
|
|
||||||
//- Return const access to the cell selection mode
|
//- Return const access to the cell selection mode
|
||||||
inline const selectionModeType& selectionMode() const;
|
inline const selectionModeType& selectionMode() const;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -63,9 +63,17 @@ inline Foam::scalar Foam::basicSource::duration() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::basicSource::timeEnd() const
|
inline bool Foam::basicSource::inTimeLimits(const scalar time) const
|
||||||
{
|
{
|
||||||
return timeStart_ + duration_;
|
return
|
||||||
|
(
|
||||||
|
(timeStart_ < 0)
|
||||||
|
||
|
||||||
|
(
|
||||||
|
(mesh_.time().value() >= timeStart_)
|
||||||
|
&& (mesh_.time().value() <= (timeStart_ + duration_))
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user