ENH: basicSourtce - simplified setting of continuous operation
This commit is contained in:
parent
1d3aaec814
commit
2733a58ed6
@ -108,7 +108,6 @@ void Foam::basicSource::setSelection(const dictionary& dict)
|
||||
|
||||
void Foam::basicSource::setCellSet()
|
||||
{
|
||||
Info<< incrIndent << indent << "Source: " << name_ << endl;
|
||||
switch (selectionMode_)
|
||||
{
|
||||
case smPoints:
|
||||
@ -237,7 +236,7 @@ void Foam::basicSource::setCellSet()
|
||||
|
||||
Info<< indent << "- selected "
|
||||
<< 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),
|
||||
coeffs_(dict.subDict(modelType + "Coeffs")),
|
||||
active_(readBool(dict_.lookup("active"))),
|
||||
timeStart_(readScalar(dict_.lookup("timeStart"))),
|
||||
duration_(readScalar(dict_.lookup("duration"))),
|
||||
timeStart_(-1.0),
|
||||
duration_(0.0),
|
||||
selectionMode_
|
||||
(
|
||||
selectionModeTypeNames_.read(dict_.lookup("selectionMode"))
|
||||
@ -273,9 +272,24 @@ Foam::basicSource::basicSource
|
||||
fieldNames_(),
|
||||
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_);
|
||||
|
||||
setCellSet();
|
||||
|
||||
Info<< decrIndent;
|
||||
}
|
||||
|
||||
|
||||
@ -325,12 +339,7 @@ Foam::basicSource::~basicSource()
|
||||
|
||||
bool Foam::basicSource::isActive()
|
||||
{
|
||||
if
|
||||
(
|
||||
active_
|
||||
&& (mesh_.time().value() >= timeStart_)
|
||||
&& (mesh_.time().value() <= timeEnd())
|
||||
)
|
||||
if (active_ && inTimeLimits(mesh_.time().value()))
|
||||
{
|
||||
// Update the cell set if the mesh is changing
|
||||
if (mesh_.changing())
|
||||
|
@ -277,8 +277,8 @@ public:
|
||||
//- Return const access to the duration
|
||||
inline scalar duration() const;
|
||||
|
||||
//- Return const access to the time end
|
||||
inline scalar timeEnd() const;
|
||||
//- Return true if within time limits
|
||||
inline bool inTimeLimits(const scalar time) const;
|
||||
|
||||
//- Return const access to the cell selection mode
|
||||
inline const selectionModeType& selectionMode() const;
|
||||
|
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
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_))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user