Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2012-11-21 13:40:56 +00:00
21 changed files with 854 additions and 38 deletions

View File

@ -168,7 +168,7 @@ Foam::functionObjectFile::functionObjectFile
names_.insert(name);
filePtrs_.clear();
filePtrs_.setSize(names_.toc().size());
filePtrs_.setSize(1);
// cannot create files - need to access virtual function
}
@ -193,7 +193,7 @@ Foam::functionObjectFile::functionObjectFile
names_.insert(names);
filePtrs_.clear();
filePtrs_.setSize(names_.toc().size());
filePtrs_.setSize(names_.size());
// cannot create files - need to access virtual function
}

View File

@ -64,7 +64,7 @@ private:
const objectRegistry& obr_;
//- Prefix
const word& prefix_;
const word prefix_;
//- File names
wordHashSet names_;

View File

@ -39,7 +39,7 @@ Foam::MRFZoneList::MRFZoneList
{
reset(dict);
active();
active(true);
}
@ -51,7 +51,7 @@ Foam::MRFZoneList::~MRFZoneList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::MRFZoneList::active() const
bool Foam::MRFZoneList::active(const bool warn) const
{
bool a = false;
forAll(*this, i)
@ -59,7 +59,7 @@ bool Foam::MRFZoneList::active() const
a = a || this->operator[](i).active();
}
if (!a)
if (warn && this->size() && !a)
{
Info<< " No MRF zones active" << endl;
}

View File

@ -88,7 +88,7 @@ public:
// Member Functions
//- Return active status
bool active() const;
bool active(const bool warn = false) const;
//- Reset the source list
void reset(const dictionary& dict);

View File

@ -38,6 +38,8 @@ Foam::porosityModelList::porosityModelList
mesh_(mesh)
{
reset(dict);
active(true);
}
@ -49,7 +51,7 @@ Foam::porosityModelList::~porosityModelList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::porosityModelList::active() const
bool Foam::porosityModelList::active(const bool warn) const
{
bool a = false;
forAll(*this, i)
@ -57,7 +59,7 @@ bool Foam::porosityModelList::active() const
a = a || this->operator[](i).active();
}
if (!a)
if (warn && this->size() && !a)
{
Info<< "No porosity models active" << endl;
}

View File

@ -88,7 +88,7 @@ public:
// Member Functions
//- Return active status
bool active() const;
bool active(const bool active = false) const;
//- Reset the source list
void reset(const dictionary& dict);

View File

@ -10,6 +10,9 @@ fieldMinMax/fieldMinMax.C
fieldMinMax/fieldMinMaxFunctionObject.C
fieldValues/fieldValue/fieldValue.C
fieldValues/fieldValue/fieldValueNew.C
fieldValues/fieldValueDelta/fieldValueDelta.C
fieldValues/fieldValueDelta/fieldValueDeltaFunctionObject.C
fieldValues/faceSource/faceSource.C
fieldValues/faceSource/faceSourceFunctionObject.C
fieldValues/cellSource/cellSource.C

View File

@ -26,20 +26,14 @@ License
#include "cellSource.H"
#include "fvMesh.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::fieldValues::cellSource, 0);
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::fieldValues::cellSource::sourceType,
2
>::names[] =
const char* NamedEnum<fieldValues::cellSource::sourceType, 2>::names[] =
{
"cellZone",
"all"
@ -47,11 +41,7 @@ namespace Foam
template<>
const char* Foam::NamedEnum
<
Foam::fieldValues::cellSource::operationType,
9
>::names[] =
const char* NamedEnum<fieldValues::cellSource::operationType, 9>::names[] =
{
"none",
"sum",
@ -63,6 +53,12 @@ namespace Foam
"max",
"CoV"
};
namespace fieldValues
{
defineTypeNameAndDebug(cellSource, 0);
addToRunTimeSelectionTable(fieldValue, cellSource, dictionary);
}
}

View File

@ -177,6 +177,9 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
{
Type result = processValues(values, V, weightField);
// add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
if (valueOutput_)
{
IOField<Type>

View File

@ -32,19 +32,14 @@ License
#include "mergePoints.H"
#include "indirectPrimitivePatch.H"
#include "PatchTools.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::fieldValues::faceSource, 0);
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::fieldValues::faceSource::sourceType,
3
>::names[] =
const char* NamedEnum<fieldValues::faceSource::sourceType, 3>::names[] =
{
"faceZone",
"patch",
@ -53,11 +48,7 @@ namespace Foam
template<>
const char* Foam::NamedEnum
<
Foam::fieldValues::faceSource::operationType,
11
>::names[] =
const char* NamedEnum<fieldValues::faceSource::operationType, 11>::names[] =
{
"none",
"sum",
@ -72,6 +63,11 @@ namespace Foam
"areaNormalIntegrate"
};
namespace fieldValues
{
defineTypeNameAndDebug(faceSource, 0);
addToRunTimeSelectionTable(fieldValue, faceSource, dictionary);
}
}

View File

@ -291,6 +291,9 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
{
Type result = processValues(values, Sf, weightField);
// add to result dictionary, over-writing any previous entry
resultDict_.add(fieldName, result, true);
file()<< tab << result;
if (log_)

View File

@ -26,12 +26,14 @@ License
#include "fieldValue.H"
#include "fvMesh.H"
#include "Time.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(fieldValue, 0);
defineRunTimeSelectionTable(fieldValue, dictionary);
}
@ -92,7 +94,8 @@ Foam::fieldValue::fieldValue
log_(false),
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
fields_(dict.lookup("fields")),
valueOutput_(dict.lookup("valueOutput"))
valueOutput_(dict.lookup("valueOutput")),
resultDict_(fileName("name"), dictionary::null)
{
// Only active if obr is an fvMesh
if (isA<fvMesh>(obr_))

View File

@ -42,6 +42,8 @@ SourceFiles
#include "Switch.H"
#include "pointFieldFwd.H"
#include "OFstream.H"
#include "dictionary.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +51,6 @@ namespace Foam
{
// Forward declaration of classes
class dictionary;
class objectRegistry;
class fvMesh;
class mapPolyMesh;
@ -88,6 +89,9 @@ protected:
//- Output field values flag
Switch valueOutput_;
//- Results dictionary for external access of results
dictionary resultDict_;
// Functions to be over-ridden from IOoutputFilter class
@ -103,6 +107,21 @@ public:
//- Run-time type information
TypeName("fieldValue");
// Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
fieldValue,
dictionary,
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
),
(name, obr, dict, loadFromFiles)
);
//- Construct from components
fieldValue
@ -114,6 +133,15 @@ public:
const bool loadFromFiles = false
);
//- Return a reference to the selected fieldValue
static autoPtr<fieldValue> New
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles = false,
const bool output = true
);
//- Destructor
virtual ~fieldValue();
@ -147,6 +175,9 @@ public:
//- Helper function to return the reference to the mesh
inline const fvMesh& mesh() const;
//- Return access to the latest set of results
inline const dictionary& resultDict() const;
// Function object functions

View File

@ -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
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "fieldValue.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -75,4 +76,10 @@ inline const Foam::fvMesh& Foam::fieldValue::mesh() const
}
inline const Foam::dictionary& Foam::fieldValue::resultDict() const
{
return resultDict_;
}
// ************************************************************************* //

View File

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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/>.
\*---------------------------------------------------------------------------*/
#include "fieldValue.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::fieldValue> Foam::fieldValue::New
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles,
const bool output
)
{
const word modelType(dict.lookup("type"));
if (output)
{
Info<< "Selecting " << typeName << " " << modelType << endl;
}
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"fieldValue::New"
"("
"const word&, "
"const objectRegistry&, "
"const dictionary&, "
"const bool"
")"
) << "Unknown " << typeName << " type "
<< modelType << nl << nl
<< "Valid " << typeName << " types are:" << nl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<fieldValue>
(
cstrIter()
(
name,
obr,
dict,
loadFromFiles
)
);
}
// ************************************************************************* //

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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/>.
Typedef
Foam::IOfieldValueDelta
Description
Instance of the generic IOOutputFilter for fieldValueDelta.
\*---------------------------------------------------------------------------*/
#ifndef IOfieldValueDelta_H
#define IOfieldValueDelta_H
#include "fieldValueDelta.H"
#include "IOOutputFilter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef IOOutputFilter<fieldValueDelta> IOfieldValueDelta;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,213 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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/>.
\*---------------------------------------------------------------------------*/
#include "fieldValueDelta.H"
#include "ListOps.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(Foam::fieldValues::fieldValueDelta, 0);
template<>
const char*
NamedEnum<fieldValues::fieldValueDelta::operationType, 4>::names[] =
{
"add",
"subtract",
"min",
"max"
};
const Foam::NamedEnum<Foam::fieldValues::fieldValueDelta::operationType, 4>
Foam::fieldValues::fieldValueDelta::operationTypeNames_;
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValues::fieldValueDelta::updateMesh(const mapPolyMesh&)
{
// Do nothing
}
void Foam::fieldValues::fieldValueDelta::movePoints(const Field<point>&)
{
// Do nothing
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fieldValues::fieldValueDelta::fieldValueDelta
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
)
:
functionObjectFile(obr, name, typeName),
name_(name),
obr_(obr),
loadFromFiles_(loadFromFiles),
log_(false),
operation_(opSubtract),
source1Ptr_(NULL),
source2Ptr_(NULL)
{
read(dict);
}
void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
{
const wordList& fields1 = source1Ptr_->fields();
const wordList& fields2 = source2Ptr_->fields();
DynamicList<word> commonFields(fields1.size());
forAll(fields1, i)
{
label index = findIndex(fields2, fields1[i]);
if (index != -1)
{
commonFields.append(fields1[i]);
}
}
Ostream& os = file();
os << "# Source1 : " << source1Ptr_->name() << nl
<< "# Source2 : " << source2Ptr_->name() << nl
<< "# Operation : " << operationTypeNames_[operation_] << nl;
os << "# Time";
forAll(commonFields, i)
{
os << tab << commonFields[i];
}
os << endl;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict)
{
log_ = dict.lookupOrDefault<Switch>("log", false);
source1Ptr_.reset
(
fieldValue::New
(
name_ + ".source1",
obr_,
dict.subDict("source1"),
loadFromFiles_,
false
).ptr()
);
source2Ptr_.reset
(
fieldValue::New
(
name_ + ".source2",
obr_,
dict.subDict("source2"),
loadFromFiles_,
false
).ptr()
);
operation_ = operationTypeNames_.read(dict.lookup("operation"));
}
void Foam::fieldValues::fieldValueDelta::write()
{
functionObjectFile::write();
source1Ptr_->write();
source2Ptr_->write();
if (Pstream::master())
{
file()<< obr_.time().timeName();
}
if (log_)
{
Info<< type() << " output:" << endl;
}
bool found = false;
processFields<scalar>(found);
processFields<vector>(found);
processFields<sphericalTensor>(found);
processFields<symmTensor>(found);
processFields<tensor>(found);
if (Pstream::master())
{
file()<< endl;
}
if (log_)
{
if (!found)
{
Info<< " none" << endl;
}
else
{
Info<< endl;
}
}
}
void Foam::fieldValues::fieldValueDelta::execute()
{
// Do nothing
}
void Foam::fieldValues::fieldValueDelta::end()
{
// Do nothing
}
// ************************************************************************* //

View File

@ -0,0 +1,206 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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::fieldValues::fieldValueDelta
Group
grpFieldFunctionObjects
Description
This function object provides a differencing option between two 'field
value' function objects.
Example of function object specification:
\verbatim
fieldValueDelta1
{
type fieldValueDelta;
functionObjectLibs ("libfieldFunctionObjects.so");
fieldValue1
{
...
}
fieldValue2
{
...
}
}
\endverbatim
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: fieldValueDelta | yes |
\endtable
SeeAlso
Foam::fieldValue
SourceFiles
fieldValueDelta.C
\*---------------------------------------------------------------------------*/
#ifndef fieldValueDelta_H
#define fieldValueDelta_H
#include "functionObjectFile.H"
#include "fieldValue.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fieldValues
{
/*---------------------------------------------------------------------------*\
Class fieldValueDelta Declaration
\*---------------------------------------------------------------------------*/
class fieldValueDelta
:
public functionObjectFile
{
public:
//- Operation type enumeration
enum operationType
{
opAdd,
opSubtract,
opMin,
opMax
};
//- Operation type names
static const NamedEnum<operationType, 4> operationTypeNames_;
private:
// Private data
//- Name of this fieldValue object
word name_;
//- Database this class is registered to
const objectRegistry& obr_;
//- Flag to indicate to load from files
bool loadFromFiles_;
//- Switch to send output to Info as well as to file
Switch log_;
//- Operation to apply to values
operationType operation_;
//- Field value source object 1
autoPtr<fieldValue> source1Ptr_;
//- Field value source object 2
autoPtr<fieldValue> source2Ptr_;
// Private Member Functions
//- Templated function to process common fields
template<class Type>
void processFields(bool& found);
//- Templated function to apply the operation
template<class Type>
Type applyOperation(const Type& value1, const Type& value2) const;
protected:
// Functions to be over-ridden from IOoutputFilter class
//- Update mesh
virtual void updateMesh(const mapPolyMesh&);
//- Move points
virtual void movePoints(const Field<point>&);
//- Output file header information
virtual void writeFileHeader(const label i);
public:
//- Run-time type information
TypeName("fieldValueDelta");
//- Construct from components
fieldValueDelta
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles = false
);
//- Destructor
virtual ~fieldValueDelta();
// Public Member Functions
// Function object functions
//- Read from dictionary
virtual void read(const dictionary&);
//- Calculate and write
virtual void write();
//- Execute
virtual void execute();
//- Execute the at the final time-loop, currently does nothing
virtual void end();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fieldValues
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "fieldValueDeltaTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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/>.
\*---------------------------------------------------------------------------*/
#include "fieldValueDeltaFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug
(
fieldValueDeltaFunctionObject,
0
);
addToRunTimeSelectionTable
(
functionObject,
fieldValueDeltaFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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/>.
Typedef
Foam::fieldValueDeltaFunctionObject
Description
FunctionObject wrapper around fieldValueDelta to allow it to be
created via the functions entry within controlDict.
SourceFiles
fieldValueDeltaFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef fieldValueDeltaFunctionObject_H
#define fieldValueDeltaFunctionObject_H
#include "fieldValueDelta.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<fieldValues::fieldValueDelta>
fieldValueDeltaFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,123 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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/>.
\*---------------------------------------------------------------------------*/
#include "GeometricField.H"
#include "volMesh.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::fieldValues::fieldValueDelta::applyOperation
(
const Type& value1,
const Type& value2
) const
{
Type result = pTraits<Type>::zero;
switch (operation_)
{
case opAdd:
{
result = value1 + value2;
break;
}
case opSubtract:
{
result = value1 - value2;
break;
}
case opMin:
{
result = min(value1, value2);
break;
}
case opMax:
{
result = max(value1, value2);
break;
}
default:
{
FatalErrorIn
(
"Type Foam::fieldValues::fieldValueDelta::applyOperation"
"("
"const Type&, "
"const Type&"
") const"
)
<< "Unable to process operation "
<< operationTypeNames_[operation_]
<< abort(FatalError);
}
}
return result;
}
template<class Type>
void Foam::fieldValues::fieldValueDelta::processFields(bool& found)
{
typedef GeometricField<Type, fvPatchField, volMesh> vf;
const wordList& fields1 = source1Ptr_->fields();
const dictionary& results1 = source1Ptr_->resultDict();
const dictionary& results2 = source2Ptr_->resultDict();
Type r1(pTraits<Type>::zero);
Type r2(pTraits<Type>::zero);
forAll(fields1, i)
{
const word& fieldName = fields1[i];
if (obr_.foundObject<vf>(fieldName) && results2.found(fieldName))
{
results1.lookup(fieldName) >> r1;
results2.lookup(fieldName) >> r2;
Type result = applyOperation(r1, r2);
if (log_)
{
Info<< " " << operationTypeNames_[operation_]
<< "(" << fieldName << ") = " << result
<< endl;
}
if (Pstream::master())
{
file()<< tab << result;
}
found = true;
}
}
}
// ************************************************************************* //