mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature-function-object-field-input' into 'develop'
Feature function object field input See merge request Development/OpenFOAM-plus!167
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -55,7 +55,7 @@ fieldCoordinateSystemTransform
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
fieldSet_(),
|
||||
fieldSet_(mesh_),
|
||||
coordSys_(mesh_, dict.subDict("coordinateSystem"))
|
||||
{
|
||||
read(dict);
|
||||
@ -90,23 +90,27 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::read
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
fvMeshFunctionObject::read(dict);
|
||||
if (fvMeshFunctionObject::read(dict))
|
||||
{
|
||||
fieldSet_.read(dict);
|
||||
return true;
|
||||
}
|
||||
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
fieldSet_.updateSelection();
|
||||
|
||||
for (const word& fieldName : fieldSet_.selection())
|
||||
{
|
||||
transform<scalar>(fieldSet_[fieldi]);
|
||||
transform<vector>(fieldSet_[fieldi]);
|
||||
transform<sphericalTensor>(fieldSet_[fieldi]);
|
||||
transform<symmTensor>(fieldSet_[fieldi]);
|
||||
transform<tensor>(fieldSet_[fieldi]);
|
||||
transform<scalar>(fieldName);
|
||||
transform<vector>(fieldName);
|
||||
transform<sphericalTensor>(fieldName);
|
||||
transform<symmTensor>(fieldName);
|
||||
transform<tensor>(fieldName);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -115,9 +119,9 @@ bool Foam::functionObjects::fieldCoordinateSystemTransform::execute()
|
||||
|
||||
bool Foam::functionObjects::fieldCoordinateSystemTransform::write()
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
forAllConstIters(fieldSet_, iter)
|
||||
{
|
||||
writeObject(transformFieldName(fieldSet_[fieldi]));
|
||||
writeObject(transformFieldName(iter()));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -83,6 +83,7 @@ SourceFiles
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "volFieldSelection.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -104,7 +105,7 @@ protected:
|
||||
// Protected data
|
||||
|
||||
//- Fields to transform
|
||||
wordList fieldSet_;
|
||||
volFieldSelection fieldSet_;
|
||||
|
||||
//- Co-ordinate system to transform to
|
||||
coordinateSystem coordSys_;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / 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
|
||||
This file is part of OpenFOAM.
|
||||
@ -51,9 +51,22 @@ Foam::functionObjects::fieldMinMax::modeTypeNames_
|
||||
|
||||
// * * * * * * * * * * * * 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");
|
||||
|
||||
if (location_)
|
||||
@ -77,14 +90,17 @@ void Foam::functionObjects::fieldMinMax::writeFileHeader(Ostream& os) const
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(fieldSet_, fieldi)
|
||||
forAllConstIters(fieldSet_.selection(), iter)
|
||||
{
|
||||
writeTabbed(os, "min(" + fieldSet_[fieldi] + ')');
|
||||
writeTabbed(os, "max(" + fieldSet_[fieldi] + ')');
|
||||
const word& fieldName = iter();
|
||||
writeTabbed(os, "min(" + fieldName + ')');
|
||||
writeTabbed(os, "max(" + fieldName + ')');
|
||||
}
|
||||
}
|
||||
|
||||
os << endl;
|
||||
|
||||
writtenHeader_ = true;
|
||||
}
|
||||
|
||||
|
||||
@ -101,10 +117,9 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
|
||||
writeFile(mesh_, name, typeName, dict),
|
||||
location_(true),
|
||||
mode_(mdMag),
|
||||
fieldSet_()
|
||||
fieldSet_(mesh_)
|
||||
{
|
||||
read(dict);
|
||||
writeFileHeader(file());
|
||||
}
|
||||
|
||||
|
||||
@ -124,7 +139,8 @@ bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
|
||||
location_ = dict.lookupOrDefault<Switch>("location", true);
|
||||
|
||||
mode_ = modeTypeNames_.lookupOrDefault("mode", dict, modeType::mdMag);
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
fieldSet_.read(dict);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -138,16 +154,18 @@ bool Foam::functionObjects::fieldMinMax::execute()
|
||||
|
||||
bool Foam::functionObjects::fieldMinMax::write()
|
||||
{
|
||||
writeFileHeader(file());
|
||||
|
||||
if (!location_) writeTime(file());
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
forAll(fieldSet_, fieldi)
|
||||
for (const word& fieldName : fieldSet_.selection())
|
||||
{
|
||||
calcMinMaxFields<scalar>(fieldSet_[fieldi], mdCmpt);
|
||||
calcMinMaxFields<vector>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<sphericalTensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<symmTensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<tensor>(fieldSet_[fieldi], mode_);
|
||||
calcMinMaxFields<scalar>(fieldName, mdCmpt);
|
||||
calcMinMaxFields<vector>(fieldName, mode_);
|
||||
calcMinMaxFields<sphericalTensor>(fieldName, mode_);
|
||||
calcMinMaxFields<symmTensor>(fieldName, mode_);
|
||||
calcMinMaxFields<tensor>(fieldName, mode_);
|
||||
}
|
||||
|
||||
if (!location_) file()<< endl;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / 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
|
||||
This file is part of OpenFOAM.
|
||||
@ -82,6 +82,7 @@ SourceFiles
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "vector.H"
|
||||
#include "volFieldSelection.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -124,7 +125,7 @@ protected:
|
||||
modeType mode_;
|
||||
|
||||
//- Fields to assess min/max
|
||||
wordList fieldSet_;
|
||||
volFieldSelection fieldSet_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
@ -147,7 +148,7 @@ protected:
|
||||
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os) const;
|
||||
virtual void writeFileHeader(Ostream& os);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
fieldMinMax(const fieldMinMax&) = delete;
|
||||
|
||||
@ -107,7 +107,7 @@ protected:
|
||||
|
||||
// Read from dictionary
|
||||
|
||||
//- Fields to process
|
||||
//- Fields to process (input-name output-name)
|
||||
List<Tuple2<word, word>> fieldSet_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
|
||||
@ -860,7 +860,7 @@ bool Foam::functionObjects::regionSizeDistribution::write()
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = scalarNames[selected[i]];
|
||||
Log << " Scalar field " << fldName << endl;
|
||||
Log << " Scalar field " << fldName << endl;
|
||||
|
||||
const scalarField& fld = obr_.lookupObject
|
||||
<
|
||||
|
||||
Reference in New Issue
Block a user