ENH: Multiple updates to function objects

Updated objects
- corrected Peclet number for compressible cases
- propagated log flag and resultName across objects

New function objects
- new fluxSummary:
  - calculates positive, negative, absolute and net flux across face
    zones
- new runTimeControl
  - abort the calculation when a user-defined metric is achieved.
    Available options include:
    - average value remains unchanged wrt a given threshold
    - equation initial residual exceeds a threshold - useful to abort
      diverging cases
    - equation max iterations exceeds a threshold - useful to abort
      diverging cases
    - min/max of a function object value
    - min time step exceeds a threshold - useful to abort diverging
      cases
- new valueAverage:
  - average singular values from other function objects, e.g. Cd, Cl and
    Cm from the forceCoeffs function object
This commit is contained in:
Andrew Heather
2015-11-25 17:19:06 +00:00
parent f4de5d17e4
commit 6838df9cd2
129 changed files with 9233 additions and 3546 deletions

View File

@ -0,0 +1,165 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "minMaxCondition.H"
#include "addToRunTimeSelectionTable.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<>
void Foam::minMaxCondition::setValue<Foam::scalar>
(
const word& valueType,
const word& fieldName,
scalar& value
) const
{
state_.getObjectResult(functionObjectName_, fieldName, value);
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(minMaxCondition, 0);
addToRunTimeSelectionTable(runTimeCondition, minMaxCondition, dictionary);
template<>
const char* NamedEnum<minMaxCondition::modeType, 2>::names[] =
{
"minimum",
"maximum"
};
}
const Foam::NamedEnum<Foam::minMaxCondition::modeType, 2>
Foam::minMaxCondition::modeTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::minMaxCondition::minMaxCondition
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
functionObjectState& state
)
:
runTimeCondition(name, obr, dict, state),
functionObjectName_(dict.lookup("functionObjectName")),
mode_(modeTypeNames_.read(dict.lookup("mode"))),
fieldNames_(dict.lookup("fields")),
value_(readScalar(dict.lookup("value")))
{}
// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::minMaxCondition::~minMaxCondition()
{}
// * * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * //
bool Foam::minMaxCondition::apply()
{
bool satisfied = true;
if (!active_)
{
return satisfied;
}
forAll(fieldNames_, fieldI)
{
const word& fieldName = fieldNames_[fieldI];
const word valueType =
state_.objectResultType(functionObjectName_, fieldName);
if (valueType == word::null)
{
WarningIn("bool Foam::minMaxCondition::apply()")
<< "Unable to find entry " << fieldName
<< " for function object " << functionObjectName_
<< ". Condition will not be applied."
<< endl;
continue;
}
scalar v = 0;
setValue<scalar>(valueType, fieldName, v);
setValue<vector>(valueType, fieldName, v);
setValue<sphericalTensor>(valueType, fieldName, v);
setValue<symmTensor>(valueType, fieldName, v);
setValue<tensor>(valueType, fieldName, v);
Switch ok = false;
switch (mode_)
{
case mdMin:
{
if (v < value_)
{
ok = true;
}
break;
}
case mdMax:
{
if (v > value_)
{
ok = true;
}
break;
}
}
if (log_)
{
Info<< " " << type() << ": " << modeTypeNames_[mode_] << " "
<< fieldName << ": value = " << v
<< ", threshold value = " << value_
<< ", satisfied = " << ok << endl;
}
satisfied = satisfied && ok;
}
return satisfied;
}
void Foam::minMaxCondition::write()
{
// do nothing
}
// ************************************************************************* //

View File

@ -0,0 +1,145 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ 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::minMaxCondition
Description
Minimum/maximum run time conditions. If the value type is not scalar,
the magnitude of the value is used in the evaluation.
SourceFiles
minMaxCondition.H
minMaxCondition.C
\*---------------------------------------------------------------------------*/
#ifndef minMaxCondition_H
#define minMaxCondition_H
#include "runTimeCondition.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class minMaxCondition Declaration
\*---------------------------------------------------------------------------*/
class minMaxCondition
:
public runTimeCondition
{
public:
// Public enumerations
// Mode type
enum modeType
{
mdMin,
mdMax
};
static const NamedEnum<modeType, 2> modeTypeNames_;
protected:
// Protected data
//- Name of function object to retrueve data from
word functionObjectName_;
//- Mode
modeType mode_;
//- Field names
const wordList fieldNames_;
//- Value to compare
const scalar value_;
//- Helper function to retrieve the value from the state dictionary
template<class Type>
void setValue
(
const word& valueType,
const word& fieldName,
scalar& value
) const;
public:
//- Runtime type information
TypeName("minMax");
//- Constructor
minMaxCondition
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
functionObjectState& state
);
//- Destructor
virtual ~minMaxCondition();
// Public Member Functions
//- Apply the condition
virtual bool apply();
//- Write
virtual void write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<>
void minMaxCondition::setValue<Foam::scalar>
(
const word& valueType,
const word& fieldName,
scalar& value
) const;
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "minMaxConditionTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
template<class Type>
void Foam::minMaxCondition::setValue
(
const word& valueType,
const word& fieldName,
scalar& value
) const
{
if (pTraits<Type>::typeName != valueType)
{
return;
}
Type v = state_.getObjectResult<Type>(functionObjectName_, fieldName);
value = mag(v);
}
// ************************************************************************* //