mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: function objects - enabled 'fields' entry to use patterns for some objects
This commit is contained in:
@ -39,6 +39,7 @@ Description
|
|||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
#include "uniformDimensionedFields.H"
|
#include "uniformDimensionedFields.H"
|
||||||
|
#include "fileFieldSelection.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -153,14 +154,14 @@ int main(int argc, char *argv[])
|
|||||||
#include "createNamedMesh.H"
|
#include "createNamedMesh.H"
|
||||||
|
|
||||||
// Initialize the set of selected fields from the command-line options
|
// Initialize the set of selected fields from the command-line options
|
||||||
HashSet<word> selectedFields;
|
functionObjects::fileFieldSelection fields(mesh);
|
||||||
if (args.optionFound("fields"))
|
if (args.optionFound("fields"))
|
||||||
{
|
{
|
||||||
args.optionLookup("fields")() >> selectedFields;
|
args.optionLookup("fields")() >> fields;
|
||||||
}
|
}
|
||||||
if (args.optionFound("field"))
|
if (args.optionFound("field"))
|
||||||
{
|
{
|
||||||
selectedFields.insert(args.optionLookup("field")());
|
fields.insert(args.optionLookup("field")());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Externally stored dictionary for functionObjectList
|
// Externally stored dictionary for functionObjectList
|
||||||
@ -170,7 +171,13 @@ int main(int argc, char *argv[])
|
|||||||
// Construct functionObjectList
|
// Construct functionObjectList
|
||||||
autoPtr<functionObjectList> functionsPtr
|
autoPtr<functionObjectList> functionsPtr
|
||||||
(
|
(
|
||||||
functionObjectList::New(args, runTime, functionsDict, selectedFields)
|
functionObjectList::New
|
||||||
|
(
|
||||||
|
args,
|
||||||
|
runTime,
|
||||||
|
functionsDict,
|
||||||
|
fields.selection()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
forAll(timeDirs, timei)
|
forAll(timeDirs, timei)
|
||||||
@ -179,6 +186,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Info<< "Time = " << runTime.timeName() << endl;
|
Info<< "Time = " << runTime.timeName() << endl;
|
||||||
|
|
||||||
|
fields.updateSelection();
|
||||||
|
|
||||||
if (mesh.readUpdate() != polyMesh::UNCHANGED)
|
if (mesh.readUpdate() != polyMesh::UNCHANGED)
|
||||||
{
|
{
|
||||||
// Update functionObjectList if mesh changes
|
// Update functionObjectList if mesh changes
|
||||||
@ -187,7 +196,7 @@ int main(int argc, char *argv[])
|
|||||||
args,
|
args,
|
||||||
runTime,
|
runTime,
|
||||||
functionsDict,
|
functionsDict,
|
||||||
selectedFields
|
fields.selection()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +209,7 @@ int main(int argc, char *argv[])
|
|||||||
args,
|
args,
|
||||||
runTime,
|
runTime,
|
||||||
mesh,
|
mesh,
|
||||||
selectedFields,
|
fields.selection(),
|
||||||
functionsPtr(),
|
functionsPtr(),
|
||||||
timei == timeDirs.size()-1
|
timei == timeDirs.size()-1
|
||||||
);
|
);
|
||||||
|
|||||||
@ -150,7 +150,8 @@ Foam::functionObjects::writeFile::writeFile
|
|||||||
fileName_("undefined"),
|
fileName_("undefined"),
|
||||||
filePtr_(),
|
filePtr_(),
|
||||||
writePrecision_(IOstream::defaultPrecision()),
|
writePrecision_(IOstream::defaultPrecision()),
|
||||||
writeToFile_(true)
|
writeToFile_(true),
|
||||||
|
writtenHeader_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -167,7 +168,8 @@ Foam::functionObjects::writeFile::writeFile
|
|||||||
fileName_(fileName),
|
fileName_(fileName),
|
||||||
filePtr_(),
|
filePtr_(),
|
||||||
writePrecision_(IOstream::defaultPrecision()),
|
writePrecision_(IOstream::defaultPrecision()),
|
||||||
writeToFile_(true)
|
writeToFile_(true),
|
||||||
|
writtenHeader_(false)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
|
|
||||||
@ -234,8 +236,13 @@ void Foam::functionObjects::writeFile::writeCommented
|
|||||||
const string& str
|
const string& str
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os << setw(1) << "#" << setw(1) << ' '
|
os << setw(1) << "#";
|
||||||
<< setf(ios_base::left) << setw(charWidth() - 2) << str.c_str();
|
|
||||||
|
if (str.size())
|
||||||
|
{
|
||||||
|
os << setw(1) << ' '
|
||||||
|
<< setf(ios_base::left) << setw(charWidth() - 2) << str.c_str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -255,8 +262,8 @@ void Foam::functionObjects::writeFile::writeHeader
|
|||||||
const string& str
|
const string& str
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os << setw(1) << "#" << setw(1) << ' '
|
writeCommented(os, str);
|
||||||
<< setf(ios_base::left) << setw(charWidth() - 2) << str.c_str() << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -267,4 +274,10 @@ void Foam::functionObjects::writeFile::writeTime(Ostream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::functionObjects::writeFile::writeBreak(Ostream& os) const
|
||||||
|
{
|
||||||
|
writeHeader(os, "===");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -79,6 +79,9 @@ protected:
|
|||||||
//- Flag to enable/disable writing to file
|
//- Flag to enable/disable writing to file
|
||||||
bool writeToFile_;
|
bool writeToFile_;
|
||||||
|
|
||||||
|
//- Flag to identify whether the header has been written
|
||||||
|
bool writtenHeader_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
@ -171,6 +174,9 @@ public:
|
|||||||
//- Write the current time to stream
|
//- Write the current time to stream
|
||||||
virtual void writeTime(Ostream& os) const;
|
virtual void writeTime(Ostream& os) const;
|
||||||
|
|
||||||
|
//- Write a break marker to the stream
|
||||||
|
virtual void writeBreak(Ostream& os) const;
|
||||||
|
|
||||||
//- Write a (commented) header property and value pair
|
//- Write a (commented) header property and value pair
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void writeHeaderValue
|
void writeHeaderValue
|
||||||
|
|||||||
@ -9,8 +9,7 @@ Foam::argList::addOption
|
|||||||
(
|
(
|
||||||
"fields",
|
"fields",
|
||||||
"list",
|
"list",
|
||||||
"Specify a list of fields to be processed, e.g. '(U T p)' - "
|
"Specify a list of fields to be processed, e.g. '(U T p)'"
|
||||||
"regular expressions not currently supported"
|
|
||||||
);
|
);
|
||||||
Foam::argList::addOption
|
Foam::argList::addOption
|
||||||
(
|
(
|
||||||
|
|||||||
@ -93,6 +93,10 @@ $(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C
|
|||||||
|
|
||||||
functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C
|
functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C
|
||||||
functionObjects/volRegion/volRegion.C
|
functionObjects/volRegion/volRegion.C
|
||||||
|
functionObjects/fieldSelection/fieldSelection.C
|
||||||
|
functionObjects/fieldSelection/fileFieldSelection.C
|
||||||
|
functionObjects/fieldSelection/volFieldSelection.C
|
||||||
|
functionObjects/fieldSelection/solverFieldSelection.C
|
||||||
|
|
||||||
fvPatchFields = fields/fvPatchFields
|
fvPatchFields = fields/fvPatchFields
|
||||||
$(fvPatchFields)/fvPatchField/fvPatchFields.C
|
$(fvPatchFields)/fvPatchField/fvPatchFields.C
|
||||||
|
|||||||
@ -0,0 +1,85 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "fieldSelection.H"
|
||||||
|
#include "objectRegistry.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::fieldSelection::fieldSelection
|
||||||
|
(
|
||||||
|
const objectRegistry& obr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
HashSet<wordRe>(),
|
||||||
|
obr_(obr),
|
||||||
|
selection_()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::fieldSelection::~fieldSelection()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldSelection::read(const dictionary& dict)
|
||||||
|
{
|
||||||
|
dict.lookup("fields") >> *this;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldSelection::containsPattern() const
|
||||||
|
{
|
||||||
|
for (const wordRe& fieldName : *this)
|
||||||
|
{
|
||||||
|
if (fieldName.isPattern())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::functionObjects::fieldSelection::clearSelection()
|
||||||
|
{
|
||||||
|
selection_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fieldSelection::updateSelection()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
139
src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H
Normal file
139
src/finiteVolume/functionObjects/fieldSelection/fieldSelection.H
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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::functionObjects::fieldSelection
|
||||||
|
|
||||||
|
Description
|
||||||
|
Helper class to manage field selections
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fieldSelection.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_fieldSelection_H
|
||||||
|
#define functionObjects_fieldSelection_H
|
||||||
|
|
||||||
|
#include "HashSet.H"
|
||||||
|
#include "wordRe.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class dictionary;
|
||||||
|
class objectRegistry;
|
||||||
|
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fieldSelection Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fieldSelection
|
||||||
|
:
|
||||||
|
public HashSet<wordRe>
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
fieldSelection(const fieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected member data
|
||||||
|
|
||||||
|
//- Reference to the database
|
||||||
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
|
//- Current field selection
|
||||||
|
wordHashSet selection_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Add registered objects of a given type
|
||||||
|
template<class Type>
|
||||||
|
void addRegistered(wordHashSet& set) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Construct from object registry
|
||||||
|
fieldSelection(const objectRegistry& obr);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~fieldSelection();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the current field selection
|
||||||
|
const wordHashSet& selection() const
|
||||||
|
{
|
||||||
|
return selection_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the current field selection
|
||||||
|
wordHashSet& selection()
|
||||||
|
{
|
||||||
|
return selection_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Read the fieldSelection data from dictionary
|
||||||
|
virtual bool read(const dictionary& dict);
|
||||||
|
|
||||||
|
//- Return whether the field names contain a pattern
|
||||||
|
virtual bool containsPattern() const;
|
||||||
|
|
||||||
|
//- Clear the current selection
|
||||||
|
virtual void clearSelection();
|
||||||
|
|
||||||
|
//- Update the selection using current contents of obr_
|
||||||
|
virtual bool updateSelection();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "fieldSelectionTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "DynamicList.H"
|
||||||
|
#include "objectRegistry.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::functionObjects::fieldSelection::addRegistered
|
||||||
|
(
|
||||||
|
wordHashSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
DynamicList<word> names;
|
||||||
|
for (const wordRe& name : *this)
|
||||||
|
{
|
||||||
|
names.append(obr_.names<Type>(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
set.insert(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,64 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "fileFieldSelection.H"
|
||||||
|
#include "objectRegistry.H"
|
||||||
|
#include "volMesh.H"
|
||||||
|
#include "fvPatchField.H"
|
||||||
|
#include "surfaceMesh.H"
|
||||||
|
#include "fvsPatchField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::fileFieldSelection::fileFieldSelection
|
||||||
|
(
|
||||||
|
const objectRegistry& obr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fieldSelection(obr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::fileFieldSelection::~fileFieldSelection()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::fileFieldSelection::updateSelection()
|
||||||
|
{
|
||||||
|
wordHashSet oldSet;
|
||||||
|
oldSet.swap(selection_);
|
||||||
|
|
||||||
|
addFileGeoFields<fvPatchField, volMesh>(selection_);
|
||||||
|
addFileGeoFields<fvsPatchField, surfaceMesh>(selection_);
|
||||||
|
|
||||||
|
return selection_ != oldSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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::functionObjects::fileFieldSelection
|
||||||
|
|
||||||
|
Description
|
||||||
|
Helper class to manage file-based field selections
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fieldSelection.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_fileFieldSelection_H
|
||||||
|
#define functionObjects_fileFieldSelection_H
|
||||||
|
|
||||||
|
#include "fieldSelection.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class IOobjectList;
|
||||||
|
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fileFieldSelection Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fileFieldSelection
|
||||||
|
:
|
||||||
|
public fieldSelection
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
fileFieldSelection(const fileFieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Add registered GeometricField types to selection
|
||||||
|
template<template<class> class PatchType, class MeshType>
|
||||||
|
void addFileGeoFields(wordHashSet& set) const;
|
||||||
|
|
||||||
|
//- Add objects of a given type
|
||||||
|
template<class Type>
|
||||||
|
void addFromFile
|
||||||
|
(
|
||||||
|
const IOobjectList& allFileObjects,
|
||||||
|
wordHashSet& set
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Construct from object registry
|
||||||
|
fileFieldSelection(const objectRegistry& obr);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~fileFieldSelection();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Update the selection
|
||||||
|
virtual bool updateSelection();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "fileFieldSelectionTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "IOobjectList.H"
|
||||||
|
#include "GeometricField.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "DynamicList.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
void Foam::functionObjects::fileFieldSelection::addFromFile
|
||||||
|
(
|
||||||
|
const IOobjectList& allFileObjects,
|
||||||
|
wordHashSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
DynamicList<word> names;
|
||||||
|
|
||||||
|
for (const wordRe& fieldName : *this)
|
||||||
|
{
|
||||||
|
names.append(allFileObjects.names(Type::typeName, fieldName));
|
||||||
|
}
|
||||||
|
|
||||||
|
set.insert(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<template<class> class PatchType, class MeshType>
|
||||||
|
void Foam::functionObjects::fileFieldSelection::addFileGeoFields
|
||||||
|
(
|
||||||
|
wordHashSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
|
||||||
|
|
||||||
|
const IOobjectList allObjects(mesh, mesh.time().timeName());
|
||||||
|
|
||||||
|
addFromFile<GeometricField<scalar, PatchType, MeshType>>(allObjects, set);
|
||||||
|
addFromFile<GeometricField<vector, PatchType, MeshType>>(allObjects, set);
|
||||||
|
addFromFile<GeometricField<sphericalTensor, PatchType, MeshType>>
|
||||||
|
(
|
||||||
|
allObjects,
|
||||||
|
set
|
||||||
|
);
|
||||||
|
addFromFile<GeometricField<symmTensor, PatchType, MeshType>>
|
||||||
|
(
|
||||||
|
allObjects,
|
||||||
|
set
|
||||||
|
);
|
||||||
|
addFromFile<GeometricField<tensor, PatchType, MeshType>>(allObjects, set);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "solverFieldSelection.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "volMesh.H"
|
||||||
|
#include "fvPatchField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::solverFieldSelection::solverFieldSelection
|
||||||
|
(
|
||||||
|
const objectRegistry& obr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
volFieldSelection(obr)
|
||||||
|
{
|
||||||
|
if (!isA<fvMesh>(obr))
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Registry must be of type " << fvMesh::typeName
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::solverFieldSelection::~solverFieldSelection()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::solverFieldSelection::updateSelection()
|
||||||
|
{
|
||||||
|
wordHashSet oldSet;
|
||||||
|
oldSet.swap(selection_);
|
||||||
|
|
||||||
|
wordHashSet volFields;
|
||||||
|
addRegisteredGeoFields<fvPatchField, volMesh>(volFields);
|
||||||
|
|
||||||
|
const fvMesh& mesh = static_cast<const fvMesh&>(obr_);
|
||||||
|
|
||||||
|
const Foam::dictionary& solverDict = mesh.solverPerformanceDict();
|
||||||
|
|
||||||
|
for (const word& fieldName : volFields)
|
||||||
|
{
|
||||||
|
if (solverDict.found(fieldName))
|
||||||
|
{
|
||||||
|
selection_.insert(fieldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selection_ != oldSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,89 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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::functionObjects::volFieldSelection
|
||||||
|
|
||||||
|
Description
|
||||||
|
Helper class to manage volume field selections
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
volFieldSelection.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_solverFieldSelection_H
|
||||||
|
#define functionObjects_solverFieldSelection_H
|
||||||
|
|
||||||
|
#include "volFieldSelection.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class solverFieldSelection Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class solverFieldSelection
|
||||||
|
:
|
||||||
|
public volFieldSelection
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
solverFieldSelection(const solverFieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Construct from object registry
|
||||||
|
solverFieldSelection(const objectRegistry& obr);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~solverFieldSelection();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Update the selection using current contents of obr_
|
||||||
|
virtual bool updateSelection();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,61 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "volFieldSelection.H"
|
||||||
|
#include "volMesh.H"
|
||||||
|
#include "fvPatchField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::volFieldSelection::volFieldSelection
|
||||||
|
(
|
||||||
|
const objectRegistry& obr
|
||||||
|
)
|
||||||
|
:
|
||||||
|
fieldSelection(obr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::functionObjects::volFieldSelection::~volFieldSelection()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::functionObjects::volFieldSelection::updateSelection()
|
||||||
|
{
|
||||||
|
wordHashSet oldSet;
|
||||||
|
|
||||||
|
oldSet.swap(selection_);
|
||||||
|
|
||||||
|
addRegisteredGeoFields<fvPatchField, volMesh>(selection_);
|
||||||
|
|
||||||
|
return selection_ != oldSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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::functionObjects::volFieldSelection
|
||||||
|
|
||||||
|
Description
|
||||||
|
Helper class to manage volume field selections
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
volFieldSelection.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef functionObjects_volFieldSelection_H
|
||||||
|
#define functionObjects_volFieldSelection_H
|
||||||
|
|
||||||
|
#include "fieldSelection.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
namespace functionObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class volFieldSelection Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class volFieldSelection
|
||||||
|
:
|
||||||
|
public fieldSelection
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
volFieldSelection(const volFieldSelection&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Add registered GeometricField types to selection
|
||||||
|
template<template<class> class PatchType, class MeshType>
|
||||||
|
void addRegisteredGeoFields(wordHashSet& set) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Construct from object registry
|
||||||
|
volFieldSelection(const objectRegistry& obr);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~volFieldSelection();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Update the selection using current contents of obr_
|
||||||
|
virtual bool updateSelection();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace functionObjects
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "volFieldSelectionTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ 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 "volFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<template<class> class PatchType, class MeshType>
|
||||||
|
void Foam::functionObjects::volFieldSelection::addRegisteredGeoFields
|
||||||
|
(
|
||||||
|
wordHashSet& set
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
addRegistered<GeometricField<scalar, PatchType, MeshType>>(set);
|
||||||
|
addRegistered<GeometricField<vector, PatchType, MeshType>>(set);
|
||||||
|
addRegistered<GeometricField<sphericalTensor, PatchType, MeshType>>(set);
|
||||||
|
addRegistered<GeometricField<symmTensor, PatchType, MeshType>>(set);
|
||||||
|
addRegistered<GeometricField<tensor, PatchType, MeshType>>(set);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -55,7 +55,7 @@ fieldCoordinateSystemTransform
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
fvMeshFunctionObject(name, runTime, dict),
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
fieldSet_(),
|
fieldSet_(mesh_),
|
||||||
coordSys_(mesh_, dict.subDict("coordinateSystem"))
|
coordSys_(mesh_, dict.subDict("coordinateSystem"))
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
@ -90,23 +90,27 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::read
|
|||||||
const dictionary& dict
|
const dictionary& dict
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
fvMeshFunctionObject::read(dict);
|
if (fvMeshFunctionObject::read(dict))
|
||||||
|
{
|
||||||
|
fieldSet_.read(dict);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
dict.lookup("fields") >> fieldSet_;
|
return false;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
||||||
{
|
{
|
||||||
forAll(fieldSet_, fieldi)
|
fieldSet_.updateSelection();
|
||||||
|
|
||||||
|
for (const word& fieldName : fieldSet_.selection())
|
||||||
{
|
{
|
||||||
transform<scalar>(fieldSet_[fieldi]);
|
transform<scalar>(fieldName);
|
||||||
transform<vector>(fieldSet_[fieldi]);
|
transform<vector>(fieldName);
|
||||||
transform<sphericalTensor>(fieldSet_[fieldi]);
|
transform<sphericalTensor>(fieldName);
|
||||||
transform<symmTensor>(fieldSet_[fieldi]);
|
transform<symmTensor>(fieldName);
|
||||||
transform<tensor>(fieldSet_[fieldi]);
|
transform<tensor>(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -115,9 +119,9 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
|||||||
|
|
||||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::write()
|
bool Foam::functionObjects::fieldCoordinateSystemTransform::write()
|
||||||
{
|
{
|
||||||
forAll(fieldSet_, fieldi)
|
forAllConstIters(fieldSet_, iter)
|
||||||
{
|
{
|
||||||
writeObject(transformFieldName(fieldSet_[fieldi]));
|
writeObject(transformFieldName(iter()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -83,6 +83,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "fvMeshFunctionObject.H"
|
#include "fvMeshFunctionObject.H"
|
||||||
#include "coordinateSystem.H"
|
#include "coordinateSystem.H"
|
||||||
|
#include "volFieldSelection.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ protected:
|
|||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Fields to transform
|
//- Fields to transform
|
||||||
wordList fieldSet_;
|
volFieldSelection fieldSet_;
|
||||||
|
|
||||||
//- Co-ordinate system to transform to
|
//- Co-ordinate system to transform to
|
||||||
coordinateSystem coordSys_;
|
coordinateSystem coordSys_;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -51,9 +51,22 @@ Foam::functionObjects::fieldMinMax::modeTypeNames_
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const
|
void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os)
|
||||||
{
|
{
|
||||||
writeHeader(os, "Field minima and maxima");
|
if (!fieldSet_.updateSelection())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writtenHeader_)
|
||||||
|
{
|
||||||
|
writeBreak(file());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeHeader(os, "Field minima and maxima");
|
||||||
|
}
|
||||||
|
|
||||||
writeCommented(os, "Time");
|
writeCommented(os, "Time");
|
||||||
|
|
||||||
if (location_)
|
if (location_)
|
||||||
@ -77,14 +90,17 @@ void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
forAll(fieldSet_, fieldi)
|
forAllConstIters(fieldSet_.selection(), iter)
|
||||||
{
|
{
|
||||||
writeTabbed(os, "min(" + fieldSet_[fieldi] + ')');
|
const word& fieldName = iter();
|
||||||
writeTabbed(os, "max(" + fieldSet_[fieldi] + ')');
|
writeTabbed(os, "min(" + fieldName + ')');
|
||||||
|
writeTabbed(os, "max(" + fieldName + ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
os << endl;
|
os << endl;
|
||||||
|
|
||||||
|
writtenHeader_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,10 +117,9 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
|
|||||||
writeFile(mesh_, name, typeName, dict),
|
writeFile(mesh_, name, typeName, dict),
|
||||||
location_(true),
|
location_(true),
|
||||||
mode_(mdMag),
|
mode_(mdMag),
|
||||||
fieldSet_()
|
fieldSet_(mesh_)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
writeFileHeader(file());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +139,8 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
|||||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||||
|
|
||||||
mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
|
mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
|
||||||
dict.lookup("fields") >> fieldSet_;
|
|
||||||
|
fieldSet_.read(dict);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -138,16 +154,18 @@ bool Foam::functionObjects::fieldMinMax::execute()
|
|||||||
|
|
||||||
bool Foam::functionObjects::fieldMinMax::write()
|
bool Foam::functionObjects::fieldMinMax::write()
|
||||||
{
|
{
|
||||||
|
writeFileHeader(file());
|
||||||
|
|
||||||
if (!location_) writeTime(file());
|
if (!location_) writeTime(file());
|
||||||
Log << type() << " " << name() << " write:" << nl;
|
Log << type() << " " << name() << " write:" << nl;
|
||||||
|
|
||||||
forAll(fieldSet_, fieldi)
|
for (const word& fieldName : fieldSet_.selection())
|
||||||
{
|
{
|
||||||
calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt);
|
calcMinMaxFields<scalar>(fieldName, mdCmpt);
|
||||||
calcMinMaxFields<vector>(fieldSet_[fieldi], mode_);
|
calcMinMaxFields<vector>(fieldName, mode_);
|
||||||
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_);
|
calcMinMaxFields<sphericalTensor>(fieldName, mode_);
|
||||||
calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_);
|
calcMinMaxFields<symmTensor>(fieldName, mode_);
|
||||||
calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_);
|
calcMinMaxFields<tensor>(fieldName, mode_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!location_) file()<< endl;
|
if (!location_) file()<< endl;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -82,6 +82,7 @@ SourceFiles
|
|||||||
#include "fvMeshFunctionObject.H"
|
#include "fvMeshFunctionObject.H"
|
||||||
#include "writeFile.H"
|
#include "writeFile.H"
|
||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
|
#include "volFieldSelection.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ protected:
|
|||||||
modeType mode_;
|
modeType mode_;
|
||||||
|
|
||||||
//- Fields to assess min/max
|
//- Fields to assess min/max
|
||||||
wordList fieldSet_;
|
volFieldSelection fieldSet_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
@ -147,7 +148,7 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
//- Output file header information
|
//- Output file header information
|
||||||
virtual void writeFileHeader(Ostream& os) const;
|
virtual void writeFileHeader(Ostream& os);
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- Disallow default bitwise copy construct
|
||||||
fieldMinMax(const fieldMinMax&) = delete;
|
fieldMinMax(const fieldMinMax&) = delete;
|
||||||
|
|||||||
@ -107,7 +107,7 @@ protected:
|
|||||||
|
|
||||||
// Read from dictionary
|
// Read from dictionary
|
||||||
|
|
||||||
//- Fields to process
|
//- Fields to process (input-name output-name)
|
||||||
List<Tuple2<word, word>> fieldSet_;
|
List<Tuple2<word, word>> fieldSet_;
|
||||||
|
|
||||||
//- Switch to send output to Info as well as to file
|
//- Switch to send output to Info as well as to file
|
||||||
|
|||||||
@ -860,7 +860,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
|
|||||||
forAll(selected, i)
|
forAll(selected, i)
|
||||||
{
|
{
|
||||||
const word& fldName = scalarNames[selected[i]];
|
const word& fldName = scalarNames[selected[i]];
|
||||||
Log << " Scalar field " << fldName << endl;
|
Log << " Scalar field " << fldName << endl;
|
||||||
|
|
||||||
const scalarField& fld = obr_.lookupObject
|
const scalarField& fld = obr_.lookupObject
|
||||||
<
|
<
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -46,15 +46,26 @@ namespace functionObjects
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) const
|
void Foam::functionObjects::residuals::writeFileHeader(Ostream& os)
|
||||||
{
|
{
|
||||||
writeHeader(os, "Residuals");
|
if (!fieldSet_.updateSelection())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writtenHeader_)
|
||||||
|
{
|
||||||
|
writeBreak(file());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writeHeader(os, "Residuals");
|
||||||
|
}
|
||||||
|
|
||||||
writeCommented(os, "Time");
|
writeCommented(os, "Time");
|
||||||
|
|
||||||
forAll(fieldSet_, fieldi)
|
for (const word& fieldName : fieldSet_.selection())
|
||||||
{
|
{
|
||||||
const word& fieldName = fieldSet_[fieldi];
|
|
||||||
|
|
||||||
writeFileHeader<scalar>(os, fieldName);
|
writeFileHeader<scalar>(os, fieldName);
|
||||||
writeFileHeader<vector>(os, fieldName);
|
writeFileHeader<vector>(os, fieldName);
|
||||||
writeFileHeader<sphericalTensor>(os, fieldName);
|
writeFileHeader<sphericalTensor>(os, fieldName);
|
||||||
@ -63,6 +74,8 @@ void Foam::functionObjects::residuals::writeFileHeader(Ostream& os) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
os << endl;
|
os << endl;
|
||||||
|
|
||||||
|
writtenHeader_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -77,10 +90,9 @@ Foam::functionObjects::residuals::residuals
|
|||||||
:
|
:
|
||||||
fvMeshFunctionObject(name, runTime, dict),
|
fvMeshFunctionObject(name, runTime, dict),
|
||||||
writeFile(obr_, name, typeName, dict),
|
writeFile(obr_, name, typeName, dict),
|
||||||
fieldSet_()
|
fieldSet_(mesh_)
|
||||||
{
|
{
|
||||||
read(dict);
|
read(dict);
|
||||||
writeFileHeader(file());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -94,13 +106,13 @@ Foam::functionObjects::residuals::~residuals()
|
|||||||
|
|
||||||
bool Foam::functionObjects::residuals::read(const dictionary& dict)
|
bool Foam::functionObjects::residuals::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
fvMeshFunctionObject::read(dict);
|
if (fvMeshFunctionObject::read(dict))
|
||||||
|
{
|
||||||
|
fieldSet_.read(dict);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
wordList allFields(dict.lookup("fields"));
|
return false;
|
||||||
wordHashSet uniqueFields(allFields);
|
|
||||||
fieldSet_ = uniqueFields.toc();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,12 +126,12 @@ bool Foam::functionObjects::residuals::write()
|
|||||||
{
|
{
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
writeFileHeader(file());
|
||||||
|
|
||||||
writeTime(file());
|
writeTime(file());
|
||||||
|
|
||||||
forAll(fieldSet_, fieldi)
|
for (const word& fieldName : fieldSet_.selection())
|
||||||
{
|
{
|
||||||
const word& fieldName = fieldSet_[fieldi];
|
|
||||||
|
|
||||||
writeResidual<scalar>(fieldName);
|
writeResidual<scalar>(fieldName);
|
||||||
writeResidual<vector>(fieldName);
|
writeResidual<vector>(fieldName);
|
||||||
writeResidual<sphericalTensor>(fieldName);
|
writeResidual<sphericalTensor>(fieldName);
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -62,6 +62,7 @@ SourceFiles
|
|||||||
|
|
||||||
#include "fvMeshFunctionObject.H"
|
#include "fvMeshFunctionObject.H"
|
||||||
#include "writeFile.H"
|
#include "writeFile.H"
|
||||||
|
#include "solverFieldSelection.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -84,13 +85,13 @@ protected:
|
|||||||
// Protected data
|
// Protected data
|
||||||
|
|
||||||
//- Fields to write residuals
|
//- Fields to write residuals
|
||||||
wordList fieldSet_;
|
solverFieldSelection fieldSet_;
|
||||||
|
|
||||||
|
|
||||||
// Protected Member Functions
|
// Protected Member Functions
|
||||||
|
|
||||||
//- Output file header information
|
//- Output file header information
|
||||||
void writeFileHeader(Ostream& os) const;
|
void writeFileHeader(Ostream& os);
|
||||||
|
|
||||||
//- Output file header information per primitive type value
|
//- Output file header information per primitive type value
|
||||||
template<class Type>
|
template<class Type>
|
||||||
|
|||||||
Reference in New Issue
Block a user