37template<
class GeoField>
39Foam::sampledSets::getOrLoadField(
const word& fieldName)
const
50 mesh_.time().timeName(),
61 tfield.
cref(
mesh_.cfindObject<GeoField>(fieldName));
69void Foam::sampledSets::writeCoordSet
99void Foam::sampledSets::performAction
105 const word& fieldName =
fld.name();
106 const scalar timeValue =
fld.time().timeOutputValue();
111 if (!samplePointScheme_.empty() && samplePointScheme_ !=
"cell")
119 if (writeAsProbes_ && (request & ACTION_WRITE))
121 osptr = createProbeFile(fieldName);
125 (*osptr) <<
setw(width) << timeValue;
130 Type avgEnsemble =
Zero;
131 label sizeEnsemble = 0;
138 const labelList& globOrder = gatheredSorting_[seti];
140 const word& setName =
s.name();
148 const label celli =
s.cells()[samplei];
149 const label facei =
s.faces()[samplei];
151 if (celli == -1 && facei == -1)
158 values[samplei] = interpPtr().interpolate(
p, celli, facei);
166 const label celli =
s.cells()[samplei];
180 globIdx.gatherInplace(values);
183 Type avgValue =
Zero;
189 avgValue =
sum(values);
190 sizeValue =
values.size();
194 avgEnsemble += avgValue;
195 sizeEnsemble += sizeValue;
200 avgValue /= sizeValue;
211 const word resultArg(
'(' + setName +
',' + fieldName +
')');
213 this->setResult(
"average" + resultArg, avgValue);
214 this->setResult(
"min" + resultArg,
limits.min());
215 this->setResult(
"max" + resultArg,
limits.max());
216 this->setResult(
"size" + resultArg, sizeValue);
220 Info<<
name() <<
' ' << setName <<
" : " << fieldName <<
nl
221 <<
" avg: " << avgValue <<
nl
226 if ((request & ACTION_WRITE) != 0)
232 for (
const Type& val : values)
234 (*osptr) <<
' ' <<
setw(width) << val;
240 writeCoordSet<Type>(writers_[seti], values, fieldName);
253 avgEnsemble /= sizeEnsemble;
268 const word resultArg(
'(' + fieldName +
')');
270 this->setResult(
"average" + resultArg, avgEnsemble);
271 this->setResult(
"min" + resultArg, limitsEnsemble.min());
272 this->setResult(
"max" + resultArg, limitsEnsemble.max());
273 this->setResult(
"size" + resultArg, sizeEnsemble);
278template<
class GeoField>
279void Foam::sampledSets::performAction
288 fieldNames = objects.sortedNames<GeoField>(fieldSelection_);
292 fieldNames = mesh_.thisDb().sortedNames<GeoField>(fieldSelection_);
295 for (
const word& fieldName : fieldNames)
301 performAction<typename GeoField::value_type>(tfield(), request);
IOdictionary propsDict(dictIO)
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static unsigned int defaultPrecision() noexcept
Return the default precision.
A min/max value pair with additional methods. In addition to conveniently storing values,...
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel.
A List with indirect addressing. Like IndirectList but does not store addressing.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
@ broadcast
broadcast [MPI]
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Base class for writing coordSet(s) and tracks with fields.
A class for handling file names.
const fvMesh & mesh_
Reference to the fvMesh.
Calculates a non-overlapping list of offsets based on an input size (eg, number of cells) from differ...
static autoPtr< interpolation< Type > > New(const word &interpolationType, const GeometricField< Type, fvPatchField, volMesh > &psi)
Return a reference to the specified interpolation scheme.
A traits class, which is primarily used for primitives and vector-space.
Holds list of sampling points which is filled at construction time. Various implementations of this b...
A class for managing temporary objects.
T & emplace(Args &&... args)
Reset with emplace construction. Return reference to the new content.
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
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
List of word.
GeometricField< Type, fvPatchField, volMesh > VolumeField
A volume field for a given type.
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
vector point
Point is a vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.