mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: fieldValues FO updated follwing changes to functionObjectFile
This commit is contained in:
@ -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-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -43,11 +43,14 @@ void Foam::fieldValue::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
|
functionObjectFile::read(dict);
|
||||||
|
|
||||||
dict_ = dict;
|
dict_ = dict;
|
||||||
|
|
||||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||||
dict.lookup("fields") >> fields_;
|
dict.lookup("fields") >> fields_;
|
||||||
dict.lookup("valueOutput") >> valueOutput_;
|
dict.lookup("valueOutput") >> valueOutput_;
|
||||||
|
dict.readIfPresent("scaleFactor", scaleFactor_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +59,7 @@ void Foam::fieldValue::write()
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
functionObjectFile::write();
|
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||||
|
|
||||||
if (log_) Info<< type() << " " << name_ << " output:" << nl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,16 +75,15 @@ Foam::fieldValue::fieldValue
|
|||||||
const bool loadFromFiles
|
const bool loadFromFiles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
functionObjectFile(obr, name, valueType),
|
functionObjectFile(obr, name, valueType, dict),
|
||||||
name_(name),
|
|
||||||
obr_(obr),
|
obr_(obr),
|
||||||
dict_(dict),
|
dict_(dict),
|
||||||
active_(true),
|
active_(true),
|
||||||
log_(true),
|
log_(true),
|
||||||
sourceName_(word::null),
|
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
|
||||||
fields_(dict.lookup("fields")),
|
fields_(),
|
||||||
valueOutput_(dict.lookup("valueOutput")),
|
valueOutput_(false),
|
||||||
resultDict_(fileName("name"), dictionary::null)
|
scaleFactor_(1.0)
|
||||||
{
|
{
|
||||||
// Only active if obr is an fvMesh
|
// Only active if obr is an fvMesh
|
||||||
if (isA<fvMesh>(obr_))
|
if (isA<fvMesh>(obr_))
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / 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-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -28,7 +28,7 @@ Group
|
|||||||
grpFieldFunctionObjects
|
grpFieldFunctionObjects
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Base class for field value -based function objects.
|
Base class for field value-based function objects.
|
||||||
|
|
||||||
SourceFiles
|
SourceFiles
|
||||||
fieldValue.C
|
fieldValue.C
|
||||||
@ -96,6 +96,9 @@ protected:
|
|||||||
//- Results dictionary for external access of results
|
//- Results dictionary for external access of results
|
||||||
dictionary resultDict_;
|
dictionary resultDict_;
|
||||||
|
|
||||||
|
//- Scale factor - optional
|
||||||
|
scalar scaleFactor_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|||||||
@ -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) 2012-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -54,30 +54,9 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fieldValues::fieldValueDelta::fieldValueDelta
|
void Foam::fieldValues::fieldValueDelta::writeFileHeader(Ostream& os) const
|
||||||
(
|
|
||||||
const word& name,
|
|
||||||
const objectRegistry& obr,
|
|
||||||
const dictionary& dict,
|
|
||||||
const bool loadFromFiles
|
|
||||||
)
|
|
||||||
:
|
|
||||||
functionObjectFile(obr, name, typeName),
|
|
||||||
name_(name),
|
|
||||||
obr_(obr),
|
|
||||||
loadFromFiles_(loadFromFiles),
|
|
||||||
log_(true),
|
|
||||||
operation_(opSubtract),
|
|
||||||
source1Ptr_(NULL),
|
|
||||||
source2Ptr_(NULL)
|
|
||||||
{
|
|
||||||
read(dict);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
|
|
||||||
{
|
{
|
||||||
const wordList& fields1 = source1Ptr_->fields();
|
const wordList& fields1 = source1Ptr_->fields();
|
||||||
const wordList& fields2 = source2Ptr_->fields();
|
const wordList& fields2 = source2Ptr_->fields();
|
||||||
@ -92,8 +71,6 @@ void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ostream& os = file();
|
|
||||||
|
|
||||||
writeHeaderValue(os, "Source1", source1Ptr_->name());
|
writeHeaderValue(os, "Source1", source1Ptr_->name());
|
||||||
writeHeaderValue(os, "Source2", source2Ptr_->name());
|
writeHeaderValue(os, "Source2", source2Ptr_->name());
|
||||||
writeHeaderValue(os, "Operation", operationTypeNames_[operation_]);
|
writeHeaderValue(os, "Operation", operationTypeNames_[operation_]);
|
||||||
@ -108,6 +85,51 @@ void Foam::fieldValues::fieldValueDelta::writeFileHeader(const label i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fieldValues::fieldValueDelta::fieldValueDelta
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const objectRegistry& obr,
|
||||||
|
const dictionary& dict,
|
||||||
|
const bool loadFromFiles
|
||||||
|
)
|
||||||
|
:
|
||||||
|
functionObjectFile(obr, name, typeName, dict),
|
||||||
|
name_(name),
|
||||||
|
obr_(obr),
|
||||||
|
active_(true),
|
||||||
|
loadFromFiles_(loadFromFiles),
|
||||||
|
log_(true),
|
||||||
|
operation_(opSubtract),
|
||||||
|
source1Ptr_(NULL),
|
||||||
|
source2Ptr_(NULL)
|
||||||
|
{
|
||||||
|
// Check if the available mesh is an fvMesh otherise deactivate
|
||||||
|
if (!isA<fvMesh>(obr_))
|
||||||
|
{
|
||||||
|
active_ = false;
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"fieldMinMax::fieldMinMax"
|
||||||
|
"("
|
||||||
|
"const word&, "
|
||||||
|
"const objectRegistry&, "
|
||||||
|
"const dictionary&, "
|
||||||
|
"const bool"
|
||||||
|
")"
|
||||||
|
) << "No fvMesh available, deactivating " << name_
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active_)
|
||||||
|
{
|
||||||
|
read(dict);
|
||||||
|
writeFileHeader(file());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
|
Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
|
||||||
@ -118,69 +140,75 @@ Foam::fieldValues::fieldValueDelta::~fieldValueDelta()
|
|||||||
|
|
||||||
void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict)
|
void Foam::fieldValues::fieldValueDelta::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
log_ = dict.lookupOrDefault<Switch>("log", true);
|
if (active_)
|
||||||
source1Ptr_.reset
|
{
|
||||||
(
|
functionObjectFile::read(dict);
|
||||||
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"));
|
log_ = dict.lookupOrDefault<Switch>("log", true);
|
||||||
|
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()
|
void Foam::fieldValues::fieldValueDelta::write()
|
||||||
{
|
{
|
||||||
functionObjectFile::write();
|
if (active_)
|
||||||
|
|
||||||
source1Ptr_->write();
|
|
||||||
source2Ptr_->write();
|
|
||||||
|
|
||||||
if (Pstream::master())
|
|
||||||
{
|
{
|
||||||
file()<< obr_.time().value();
|
source1Ptr_->write();
|
||||||
}
|
source2Ptr_->write();
|
||||||
|
|
||||||
if (log_) Info<< type() << " " << name_ << " output:" << endl;
|
if (Pstream::master())
|
||||||
|
|
||||||
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;
|
file()<< obr_.time().value();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (log_) Info<< type() << " " << name_ << " output:" << endl;
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
processFields<scalar>(found);
|
||||||
|
processFields<vector>(found);
|
||||||
|
processFields<sphericalTensor>(found);
|
||||||
|
processFields<symmTensor>(found);
|
||||||
|
processFields<tensor>(found);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
Info<< endl;
|
file()<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
Info<< " none" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,6 +121,9 @@ private:
|
|||||||
//- Database this class is registered to
|
//- Database this class is registered to
|
||||||
const objectRegistry& obr_;
|
const objectRegistry& obr_;
|
||||||
|
|
||||||
|
//- On/off switch
|
||||||
|
bool active_;
|
||||||
|
|
||||||
//- Flag to indicate to load from files
|
//- Flag to indicate to load from files
|
||||||
bool loadFromFiles_;
|
bool loadFromFiles_;
|
||||||
|
|
||||||
@ -153,7 +156,7 @@ protected:
|
|||||||
// Functions to be over-ridden from IOoutputFilter class
|
// Functions to be over-ridden from IOoutputFilter class
|
||||||
|
|
||||||
//- Output file header information
|
//- Output file header information
|
||||||
virtual void writeFileHeader(const label i);
|
virtual void writeFileHeader(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user