mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added new function object to calculate deltas between 2 faceSources
This commit is contained in:
@ -14,6 +14,8 @@ fieldValues/faceSource/faceSource.C
|
||||
fieldValues/faceSource/faceSourceFunctionObject.C
|
||||
fieldValues/cellSource/cellSource.C
|
||||
fieldValues/cellSource/cellSourceFunctionObject.C
|
||||
fieldValues/faceSourceDelta/faceSourceDelta.C
|
||||
fieldValues/faceSourceDelta/faceSourceDeltaFunctionObject.C
|
||||
|
||||
nearWallFields/nearWallFields.C
|
||||
nearWallFields/nearWallFieldsFunctionObject.C
|
||||
|
||||
@ -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::IOfaceSourceDelta
|
||||
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for faceSourceDelta.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOfaceSourceDelta_H
|
||||
#define IOfaceSourceDelta_H
|
||||
|
||||
#include "faceSourceDelta.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<faceSourceDelta> IOfaceSourceDelta;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,176 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "faceSourceDelta.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::fieldValues::faceSourceDelta, 0);
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldValues::faceSourceDelta::updateMesh(const mapPolyMesh&)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSourceDelta::movePoints(const Field<point>&)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldValues::faceSourceDelta::faceSourceDelta
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObjectFile(obr, name, typeName),
|
||||
obr_(obr),
|
||||
log_(false),
|
||||
faceSource1_
|
||||
(
|
||||
name + ".faceSource1",
|
||||
obr,
|
||||
dict.subDict("faceSource1"),
|
||||
loadFromFiles
|
||||
),
|
||||
faceSource2_
|
||||
(
|
||||
name + ".faceSource2",
|
||||
obr,
|
||||
dict.subDict("faceSource2"),
|
||||
loadFromFiles
|
||||
)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSourceDelta::writeFileHeader(const label i)
|
||||
{
|
||||
const wordList& fields1 = faceSource1_.fields();
|
||||
const wordList& fields2 = faceSource2_.fields();
|
||||
|
||||
DynamicList<word> commonFields(fields1.size());
|
||||
forAll(fields1, i)
|
||||
{
|
||||
label index = findIndex(fields2, fields1[i]);
|
||||
if (index != -1)
|
||||
{
|
||||
commonFields.append(fields1[i]);
|
||||
}
|
||||
}
|
||||
|
||||
file() << "# Time";
|
||||
|
||||
forAll(commonFields, i)
|
||||
{
|
||||
file()<< tab << commonFields[i];
|
||||
}
|
||||
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fieldValues::faceSourceDelta::~faceSourceDelta()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldValues::faceSourceDelta::read(const dictionary& dict)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
faceSource1_.read(dict.subDict("faceSource1"));
|
||||
faceSource2_.read(dict.subDict("faceSource2"));
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSourceDelta::write()
|
||||
{
|
||||
functionObjectFile::write();
|
||||
|
||||
faceSource1_.write();
|
||||
faceSource2_.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::faceSourceDelta::execute()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::fieldValues::faceSourceDelta::end()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::faceSourceDelta
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
This function object provides a differencing option between two 'face
|
||||
source' function objects.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
faceSourceDelta1
|
||||
{
|
||||
type faceSourceDelta;
|
||||
functionObjectLibs ("libfieldFunctionObjects.so");
|
||||
faceSource1
|
||||
{
|
||||
...
|
||||
}
|
||||
faceSource2
|
||||
{
|
||||
...
|
||||
}
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: faceSourceDelta | yes |
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::faceSource
|
||||
|
||||
SourceFiles
|
||||
faceSourceDelta.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faceSourceDelta_H
|
||||
#define faceSourceDelta_H
|
||||
|
||||
#include "functionObjectFile.H"
|
||||
#include "faceSource.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace fieldValues
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faceSourceDelta Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faceSourceDelta
|
||||
:
|
||||
public functionObjectFile
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Database this class is registered to
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Face source 1
|
||||
faceSource faceSource1_;
|
||||
|
||||
//- Face source 2
|
||||
faceSource faceSource2_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Templated function to process common fields
|
||||
template<class Type>
|
||||
void processFields(bool& found);
|
||||
|
||||
|
||||
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("faceSourceDelta");
|
||||
|
||||
|
||||
//- Construct from components
|
||||
faceSourceDelta
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faceSourceDelta();
|
||||
|
||||
|
||||
// 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 "faceSourceDeltaTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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 "faceSourceDeltaFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug
|
||||
(
|
||||
faceSourceDeltaFunctionObject,
|
||||
0
|
||||
);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
faceSourceDeltaFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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::faceSourceDeltaFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around faceSourceDelta to allow it to be
|
||||
created via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
faceSourceDeltaFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faceSourceDeltaFunctionObject_H
|
||||
#define faceSourceDeltaFunctionObject_H
|
||||
|
||||
#include "faceSourceDelta.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<fieldValues::faceSourceDelta>
|
||||
faceSourceDeltaFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::fieldValues::faceSourceDelta::processFields(bool& found)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vf;
|
||||
|
||||
const wordList& fields1 = faceSource1_.fields();
|
||||
|
||||
const dictionary& results1 = faceSource1_.resultDict();
|
||||
const dictionary& results2 = faceSource2_.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;
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " field: " << fieldName << ", delta: " << r2 - r1
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
file()<< tab << r2 - r1;
|
||||
}
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user