ENH: Added check to field sources to issue warning if source defined but not used

This commit is contained in:
andy
2011-11-02 13:11:21 +00:00
parent 3dcc83c444
commit 1f474b835b
5 changed files with 38 additions and 0 deletions

View File

@ -242,6 +242,9 @@ public:
//- Return const access to the source active flag
inline bool active() const;
//- Return const access to the applied flag
inline bool applied() const;
//- Return const access to the time start
inline scalar timeStart() const;

View File

@ -51,6 +51,12 @@ inline bool Foam::basicSource::active() const
}
inline bool Foam::basicSource::applied() const
{
return applied_;
}
inline Foam::scalar Foam::basicSource::timeStart() const
{
return timeStart_;

View File

@ -33,6 +33,24 @@ namespace Foam
defineTypeNameAndDebug(basicSourceList, 0);
}
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::basicSourceList::checkApplied() const
{
forAll(*this, i)
{
const basicSource& bs = this->operator[](i);
if (!bs.applied())
{
WarningIn("void Foam::basicSourceList::checkApplied() const")
<< "Source " << bs.name() << " defined, but not used" << endl;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::basicSourceList::basicSourceList

View File

@ -62,6 +62,9 @@ private:
// Private Member Functions
//- Check that all sources have been applied
void checkApplied() const;
//- Disallow default bitwise copy construct
basicSourceList(const basicSourceList&);

View File

@ -23,11 +23,19 @@ License
\*---------------------------------------------------------------------------*/
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::basicSourceList::apply(fvMatrix<Type>& eqn)
{
if (mesh_.time().timeIndex() == mesh_.time().startTimeIndex() + 1)
{
checkApplied();
}
const word& fieldName = eqn.psi().name();
forAll(*this, i)