37template<
class GeoField>
39Foam::sampledSets::getOrLoadField(
const word& fieldName)
const
73void Foam::sampledSets::writeCoordSet
103void 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)
158 values[samplei] = pTraits<Type>::max;
162 values[samplei] = interpPtr().interpolate(
p, celli, facei);
170 const label celli =
s.cells()[samplei];
174 values[samplei] = pTraits<Type>::max;
184 globIdx.gatherInplace(values);
187 Type avgValue =
Zero;
193 avgValue =
sum(values);
194 sizeValue =
values.size();
195 limits = MinMax<Type>(values);
198 avgEnsemble += avgValue;
199 sizeEnsemble += sizeValue;
200 limitsEnsemble += limits;
204 avgValue /= sizeValue;
208 values = UIndirectList<Type>(values, globOrder)();
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);
282template<
class GeoField>
283void 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);
vtk::internalMeshWriter writer(topoMesh, topoCells, vtk::formatType::INLINE_ASCII, runTime.path()/"blockTopology")
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static unsigned int defaultPrecision() noexcept
Return the default precision.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all processes in communicator.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
static label worldComm
Default communicator (all processors)
Base class for writing coordSet(s) and tracks with fields.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
A class for handling file names.
const fvMesh & mesh_
Reference to the fvMesh.
const Time & time() const
Return the top-level database.
const Type * cfindObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
splitCell * master() const
A class for managing temporary objects.
void reset(tmp< T > &&other) noexcept
Clear existing and transfer ownership.
A class for handling words, derived from Foam::string.
word outputName("finiteArea-edges.obj")
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))
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
List< word > wordList
A List of words.
List< label > labelList
A List of labels.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
vector point
Point is a vector.
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
IOdictionary propsDict(dictIO)