mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: probes and patchProbes - added caching of results (#2358)
- min, max, average and sample size results now stored in functionObjectProperties similar to sampledSets, e.g. for field p - min(p) - max(p) - average(p) - size(p)
This commit is contained in:
committed by
Mark Olesen
parent
e806d18612
commit
e147ac52e9
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -49,12 +50,18 @@ void Foam::patchProbes::sampleAndWrite
|
|||||||
<< setw(w)
|
<< setw(w)
|
||||||
<< vField.time().timeOutputValue();
|
<< vField.time().timeOutputValue();
|
||||||
|
|
||||||
forAll(values, probei)
|
for (const auto& v : values)
|
||||||
{
|
{
|
||||||
probeStream << ' ' << setw(w) << values[probei];
|
probeStream << ' ' << setw(w) << v;
|
||||||
}
|
}
|
||||||
probeStream << endl;
|
probeStream << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word& fieldName = vField.name();
|
||||||
|
this->setResult("average(" + fieldName + ")", average(values));
|
||||||
|
this->setResult("min(" + fieldName + ")", min(values));
|
||||||
|
this->setResult("max(" + fieldName + ")", max(values));
|
||||||
|
this->setResult("size(" + fieldName + ")", values.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,12 +82,18 @@ void Foam::patchProbes::sampleAndWrite
|
|||||||
<< setw(w)
|
<< setw(w)
|
||||||
<< sField.time().timeOutputValue();
|
<< sField.time().timeOutputValue();
|
||||||
|
|
||||||
forAll(values, probei)
|
for (const auto& v : values)
|
||||||
{
|
{
|
||||||
probeStream << ' ' << setw(w) << values[probei];
|
probeStream << ' ' << setw(w) << v;
|
||||||
}
|
}
|
||||||
probeStream << endl;
|
probeStream << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word& fieldName = sField.name();
|
||||||
|
this->setResult("average(" + fieldName + ")", average(values));
|
||||||
|
this->setResult("min(" + fieldName + ")", min(values));
|
||||||
|
this->setResult("max(" + fieldName + ")", max(values));
|
||||||
|
this->setResult("size(" + fieldName + ")", values.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,17 +103,19 @@ void Foam::patchProbes::sampleAndWrite
|
|||||||
const fieldGroup<Type>& fields
|
const fieldGroup<Type>& fields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAll(fields, fieldi)
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
|
||||||
|
for (const auto& fieldName : fields)
|
||||||
{
|
{
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
GeometricField<Type, fvPatchField, volMesh>
|
VolFieldType
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fields[fieldi],
|
fieldName,
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
@ -113,23 +128,11 @@ void Foam::patchProbes::sampleAndWrite
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
|
objectRegistry::const_iterator iter = mesh_.find(fieldName);
|
||||||
|
|
||||||
if
|
if (iter.found() && iter()->type() == VolFieldType::typeName)
|
||||||
(
|
|
||||||
iter.found()
|
|
||||||
&& iter()->type()
|
|
||||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite(mesh_.lookupObject<VolFieldType>(fieldName));
|
||||||
(
|
|
||||||
mesh_.lookupObject
|
|
||||||
<GeometricField<Type, fvPatchField, volMesh>>
|
|
||||||
(
|
|
||||||
fields[fieldi]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,17 +145,19 @@ void Foam::patchProbes::sampleAndWriteSurfaceFields
|
|||||||
const fieldGroup<Type>& fields
|
const fieldGroup<Type>& fields
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAll(fields, fieldi)
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
|
|
||||||
|
for (const auto& fieldName : fields)
|
||||||
{
|
{
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
GeometricField<Type, fvsPatchField, surfaceMesh>
|
SurfaceFieldType
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fields[fieldi],
|
fieldName,
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
@ -165,23 +170,11 @@ void Foam::patchProbes::sampleAndWriteSurfaceFields
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
|
objectRegistry::const_iterator iter = mesh_.find(fieldName);
|
||||||
|
|
||||||
if
|
if (iter.found() && iter()->type() == SurfaceFieldType::typeName)
|
||||||
(
|
|
||||||
iter.found()
|
|
||||||
&& iter()->type()
|
|
||||||
== GeometricField<Type, fvsPatchField, surfaceMesh>::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite(mesh_.lookupObject<SurfaceFieldType>(fieldName));
|
||||||
(
|
|
||||||
mesh_.lookupObject
|
|
||||||
<GeometricField<Type, fvsPatchField, surfaceMesh>>
|
|
||||||
(
|
|
||||||
fields[fieldi]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,12 +192,8 @@ Foam::patchProbes::sample
|
|||||||
{
|
{
|
||||||
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
||||||
|
|
||||||
tmp<Field<Type>> tValues
|
auto tValues = tmp<Field<Type>>::New(Field<Type>(this->size(), unsetVal));
|
||||||
(
|
auto& values = tValues.ref();
|
||||||
new Field<Type>(this->size(), unsetVal)
|
|
||||||
);
|
|
||||||
|
|
||||||
Field<Type>& values = tValues.ref();
|
|
||||||
|
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
@ -250,12 +239,8 @@ Foam::patchProbes::sample
|
|||||||
{
|
{
|
||||||
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
||||||
|
|
||||||
tmp<Field<Type>> tValues
|
auto tValues = tmp<Field<Type>>::New(Field<Type>(this->size(), unsetVal));
|
||||||
(
|
auto& values = tValues.ref();
|
||||||
new Field<Type>(this->size(), unsetVal)
|
|
||||||
);
|
|
||||||
|
|
||||||
Field<Type>& values = tValues.ref();
|
|
||||||
|
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017 OpenCFD Ltd.
|
Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -90,6 +90,12 @@ void Foam::probes::sampleAndWrite
|
|||||||
}
|
}
|
||||||
os << endl;
|
os << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word& fieldName = vField.name();
|
||||||
|
this->setResult("average(" + fieldName + ")", average(values));
|
||||||
|
this->setResult("min(" + fieldName + ")", min(values));
|
||||||
|
this->setResult("max(" + fieldName + ")", max(values));
|
||||||
|
this->setResult("size(" + fieldName + ")", values.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,23 +123,31 @@ void Foam::probes::sampleAndWrite
|
|||||||
}
|
}
|
||||||
os << endl;
|
os << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const word& fieldName = sField.name();
|
||||||
|
this->setResult("average(" + fieldName + ")", average(values));
|
||||||
|
this->setResult("min(" + fieldName + ")", min(values));
|
||||||
|
this->setResult("max(" + fieldName + ")", max(values));
|
||||||
|
this->setResult("size(" + fieldName + ")", values.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
|
void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
|
||||||
{
|
{
|
||||||
forAll(fields, fieldi)
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
|
|
||||||
|
for (const auto& fieldName : fields)
|
||||||
{
|
{
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
GeometricField<Type, fvPatchField, volMesh>
|
VolFieldType
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fields[fieldi],
|
fieldName,
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
@ -146,23 +160,11 @@ void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
|
objectRegistry::const_iterator iter = mesh_.find(fieldName);
|
||||||
|
|
||||||
if
|
if (iter.found() && iter()->type() == VolFieldType::typeName)
|
||||||
(
|
|
||||||
iter.found()
|
|
||||||
&& iter()->type()
|
|
||||||
== GeometricField<Type, fvPatchField, volMesh>::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite(mesh_.lookupObject<VolFieldType>(fieldName));
|
||||||
(
|
|
||||||
mesh_.lookupObject
|
|
||||||
<GeometricField<Type, fvPatchField, volMesh>>
|
|
||||||
(
|
|
||||||
fields[fieldi]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -172,17 +174,19 @@ void Foam::probes::sampleAndWrite(const fieldGroup<Type>& fields)
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
|
void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
|
||||||
{
|
{
|
||||||
forAll(fields, fieldi)
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
|
|
||||||
|
for (const auto& fieldName : fields)
|
||||||
{
|
{
|
||||||
if (loadFromFiles_)
|
if (loadFromFiles_)
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite
|
||||||
(
|
(
|
||||||
GeometricField<Type, fvsPatchField, surfaceMesh>
|
SurfaceFieldType
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
fields[fieldi],
|
fieldName,
|
||||||
mesh_.time().timeName(),
|
mesh_.time().timeName(),
|
||||||
mesh_,
|
mesh_,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
@ -195,23 +199,11 @@ void Foam::probes::sampleAndWriteSurfaceFields(const fieldGroup<Type>& fields)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
objectRegistry::const_iterator iter = mesh_.find(fields[fieldi]);
|
objectRegistry::const_iterator iter = mesh_.find(fieldName);
|
||||||
|
|
||||||
if
|
if (iter.found() && iter()->type() == SurfaceFieldType::typeName)
|
||||||
(
|
|
||||||
iter.found()
|
|
||||||
&& iter()->type()
|
|
||||||
== GeometricField<Type, fvsPatchField, surfaceMesh>::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
sampleAndWrite
|
sampleAndWrite(mesh_.lookupObject<SurfaceFieldType>(fieldName));
|
||||||
(
|
|
||||||
mesh_.lookupObject
|
|
||||||
<GeometricField<Type, fvsPatchField, surfaceMesh>>
|
|
||||||
(
|
|
||||||
fields[fieldi]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,12 +220,8 @@ Foam::probes::sample
|
|||||||
{
|
{
|
||||||
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
||||||
|
|
||||||
tmp<Field<Type>> tValues
|
auto tValues = tmp<Field<Type>>::New(Field<Type>(this->size(), unsetVal));
|
||||||
(
|
auto& values = tValues.ref();
|
||||||
new Field<Type>(this->size(), unsetVal)
|
|
||||||
);
|
|
||||||
|
|
||||||
Field<Type>& values = tValues.ref();
|
|
||||||
|
|
||||||
if (fixedLocations_)
|
if (fixedLocations_)
|
||||||
{
|
{
|
||||||
@ -298,12 +286,8 @@ Foam::probes::sample
|
|||||||
{
|
{
|
||||||
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
const Type unsetVal(-VGREAT*pTraits<Type>::one);
|
||||||
|
|
||||||
tmp<Field<Type>> tValues
|
auto tValues = tmp<Field<Type>>::New(Field<Type>(this->size(), unsetVal));
|
||||||
(
|
auto& values = tValues.ref();
|
||||||
new Field<Type>(this->size(), unsetVal)
|
|
||||||
);
|
|
||||||
|
|
||||||
Field<Type>& values = tValues.ref();
|
|
||||||
|
|
||||||
forAll(*this, probei)
|
forAll(*this, probei)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user