37 template<
class GeoField>
39 Foam::sampledSets::getOrLoadField(
const word& fieldName)
const 73 void Foam::sampledSets::writeCoordSet
103 void Foam::sampledSets::performAction
105 const VolumeField<Type>&
fld,
109 const word& fieldName =
fld.name();
110 const scalar timeValue =
fld.time().timeOutputValue();
113 autoPtr<interpolation<Type>> interpPtr;
115 if (!samplePointScheme_.empty() && samplePointScheme_ !=
"cell")
121 OFstream* osptr =
nullptr;
123 if (writeAsProbes_ && (request & ACTION_WRITE))
125 osptr = createProbeFile(fieldName);
129 (*osptr) <<
setw(width) << timeValue;
134 Type avgEnsemble =
Zero;
135 label sizeEnsemble = 0;
136 MinMax<Type> limitsEnsemble;
140 const sampledSet&
s = (*this)[seti];
141 const globalIndex& globIdx = globalIndices_[seti];
142 const labelList& globOrder = gatheredSorting_[seti];
144 const word& setName =
s.name();
152 const label celli =
s.cells()[samplei];
153 const label facei =
s.faces()[samplei];
155 if (celli == -1 && facei == -1)
162 values[samplei] = interpPtr().interpolate(
p, celli, facei);
170 const label celli =
s.cells()[samplei];
184 globIdx.gatherInplace(
values);
187 Type avgValue =
Zero;
194 sizeValue =
values.size();
195 limits = MinMax<Type>(
values);
198 avgEnsemble += avgValue;
199 sizeEnsemble += sizeValue;
200 limitsEnsemble += limits;
204 avgValue /= sizeValue;
215 const word resultArg(
'(' + setName +
',' + fieldName +
')');
217 this->setResult(
"average" + resultArg, avgValue);
218 this->setResult(
"min" + resultArg, limits.min());
219 this->setResult(
"max" + resultArg, limits.max());
220 this->setResult(
"size" + resultArg, sizeValue);
224 Info<<
name() <<
' ' << setName <<
" : " << fieldName <<
nl 225 <<
" avg: " << avgValue <<
nl 226 <<
" min: " << limits.min() <<
nl 227 <<
" max: " << limits.max() <<
nl <<
nl;
230 if ((request & ACTION_WRITE) != 0)
236 for (
const Type& val :
values)
238 (*osptr) <<
' ' <<
setw(width) << val;
244 writeCoordSet<Type>(writers_[seti],
values, fieldName);
257 avgEnsemble /= sizeEnsemble;
272 const word resultArg(
'(' + fieldName +
')');
274 this->setResult(
"average" + resultArg, avgEnsemble);
275 this->setResult(
"min" + resultArg, limitsEnsemble.min());
276 this->setResult(
"max" + resultArg, limitsEnsemble.max());
277 this->setResult(
"size" + resultArg, sizeEnsemble);
282 template<
class GeoField>
283 void Foam::sampledSets::performAction
285 const IOobjectList& objects,
292 fieldNames = objects.sortedNames<GeoField>(fieldSelection_);
296 fieldNames = mesh_.thisDb().sortedNames<GeoField>(fieldSelection_);
299 for (
const word& fieldName : fieldNames)
301 tmp<GeoField> tfield = getOrLoadField<GeoField>(fieldName);
305 performAction<typename GeoField::value_type>(tfield(), request);
A class for handling file names.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
static autoPtr< interpolation< Type > > New(const word &interpolationType, const GeometricField< Type, fvPatchField, volMesh > &psi)
Return a reference to the specified interpolation scheme.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
static unsigned int defaultPrecision() noexcept
Return the default precision.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
Ignore writing from objectRegistry::writeObject()
const Time & time() const
Return the top-level database.
static label worldComm
Default world communicator (all processors). May differ from globalComm if local worlds are in use...
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
IOdictionary propsDict(dictIO)
#define forAll(list, i)
Loop across all elements in list.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
word outputName("finiteArea-edges.obj")
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Generic templated field type.
A class for handling words, derived from Foam::string.
Base class for writing coordSet(s) and tracks with fields.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all processes in communicator.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
List< word > wordList
A List of words.
vector point
Point is a vector.
static bool master(const label communicator=worldComm)
Am I the master rank.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Omanip< int > setw(const int i)
List< label > labelList
A List of labels.
A class for managing temporary objects.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Defines the attributes of an object for which implicit objectRegistry management is supported...
const fvMesh & mesh_
Reference to the fvMesh.
void reset(tmp< T > &&other) noexcept
Clear existing and transfer ownership.
static constexpr const zero Zero
Global zero (0)