55 void Foam::probes::createProbeFiles(
const wordList& fieldNames)
59 bool needsNewFiles =
false;
73 <<
"Probing locations: " << *
this <<
nl 111 os <<
"# Probe " << probei <<
' ' <<
operator[](probei);
115 os <<
" # Not Found";
126 patchi < bm.nNonProcessor()
130 os <<
" at patch " << bm[patchi].name();
132 os <<
" with a distance of " 134 <<
" m to the original point " 149 os <<
' ' <<
setw(width) << probei;
174 const point& location = (*this)[probei];
178 elementList_[probei] = celli;
184 scalar minDistance = GREAT;
185 label minFaceID = -1;
188 label facei = cellFaces[i];
190 if (
mag(dist) < minDistance)
192 minDistance =
mag(dist);
196 faceList_[probei] = minFaceID;
200 faceList_[probei] = -1;
203 if (
debug && (elementList_[probei] != -1 || faceList_[probei] != -1))
205 Pout<<
"probes : found point " << location
206 <<
" in cell " << elementList_[probei]
207 <<
" and face " << faceList_[probei] <<
endl;
213 forAll(elementList_, probei)
215 const point& location = operator[](probei);
216 label celli = elementList_[probei];
217 label facei = faceList_[probei];
222 reduce(celli, maxOp<label>());
223 reduce(facei, maxOp<label>());
224 reduce(processor_[probei], maxOp<label>());
231 <<
"Did not find location " << location
232 <<
" in any cell. Skipping location." <<
endl;
235 else if (facei == -1)
240 <<
"Did not find location " << location
241 <<
" in any face. Skipping location." <<
endl;
247 if (elementList_[probei] != -1 && elementList_[probei] != celli)
250 <<
"Location " << location
251 <<
" seems to be on multiple domains:" 252 <<
" cell " << elementList_[probei]
254 <<
" and cell " << celli <<
" on some other domain." 256 <<
"This might happen if the probe location is on" 257 <<
" a processor patch. Change the location slightly" 258 <<
" to prevent this." <<
endl;
261 if (faceList_[probei] != -1 && faceList_[probei] != facei)
264 <<
"Location " << location
265 <<
" seems to be on multiple domains:" 266 <<
" cell " << faceList_[probei]
268 <<
" and face " << facei <<
" on some other domain." 270 <<
"This might happen if the probe location is on" 271 <<
" a processor patch. Change the location slightly" 272 <<
" to prevent this." <<
endl;
282 HashTable<wordHashSet> selected =
285 ? IOobjectList(mesh_, mesh_.time().timeName()).classes(fieldSelection_)
286 : mesh_.classes(fieldSelection_)
294 #define doLocalCode(InputType, Target) \ 297 const auto iter = selected.cfind(InputType::typeName); \ 301 Target.append(iter.val().sortedToc()); \ 302 nFields += Target.size(); \ 326 currentFields.insert(scalarFields_);
327 currentFields.insert(vectorFields_);
328 currentFields.insert(sphericalTensorFields_);
329 currentFields.insert(symmTensorFields_);
330 currentFields.insert(tensorFields_);
332 currentFields.insert(surfaceScalarFields_);
333 currentFields.insert(surfaceVectorFields_);
334 currentFields.insert(surfaceSphericalTensorFields_);
335 currentFields.insert(surfaceSymmTensorFields_);
336 currentFields.insert(surfaceTensorFields_);
339 <<
"Probing fields: " << currentFields <<
nl 340 <<
"Probing locations: " << *
this <<
nl 346 if (!currentFields.erase(iter.key()))
348 DebugInfo<<
"close probe stream: " << iter()->name() <<
endl;
350 probeFilePtrs_.remove(iter);
354 if ((request & ACTION_WRITE) && !currentFields.empty())
356 createProbeFiles(currentFields.sortedToc());
371 const bool loadFromFiles,
377 loadFromFiles_(loadFromFiles),
378 fixedLocations_(true),
379 includeOutOfBounds_(true),
383 samplePointScheme_(
"cell")
404 dict.
readEntry(
"probeLocations", static_cast<pointField&>(*
this));
415 if (!fixedLocations_ && samplePointScheme_ !=
"cell")
418 <<
"Only cell interpolation can be applied when " 419 <<
"not using fixedLocations. InterpolationScheme " 420 <<
"entry will be ignored" 429 prepare(ACTION_NONE);
435 bool Foam::probes::performAction(
unsigned request)
439 performAction(scalarFields_, request);
440 performAction(vectorFields_, request);
441 performAction(sphericalTensorFields_, request);
442 performAction(symmTensorFields_, request);
443 performAction(tensorFields_, request);
445 performAction(surfaceScalarFields_, request);
446 performAction(surfaceVectorFields_, request);
447 performAction(surfaceSphericalTensorFields_, request);
448 performAction(surfaceSymmTensorFields_, request);
449 performAction(surfaceTensorFields_, request);
459 return performAction(ACTION_ALL & ~ACTION_WRITE);
468 return performAction(ACTION_ALL);
476 if (&mpm.
mesh() != &mesh_)
491 DynamicList<label> elems(elementList_.size());
496 label celli = elementList_[i];
499 label newCelli = reverseMap[celli];
504 else if (newCelli < -1)
507 elems.append(-newCelli - 2);
512 elems.append(newCelli);
522 elementList_.transfer(elems);
527 DynamicList<label> elems(faceList_.size());
530 for (
const label facei : faceList_)
534 label newFacei = reverseMap[facei];
539 else if (newFacei < -1)
542 elems.
append(-newFacei - 2);
547 elems.append(newFacei);
557 faceList_.transfer(elems);
567 if (fixedLocations_ && &
mesh == &mesh_)
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
const Type & value() const noexcept
Return const reference to value.
void size(const label n)
Older name for setAddressableSize.
virtual bool write()
Sample and write.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
pointField oldPoints_
Original probes location (only used for patchProbes)
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
void append(const T &val)
Append an element at the end of the list.
virtual bool execute()
Sample and store result if the sampleOnExecute is enabled.
GeometricField< tensor, fvPatchField, volMesh > volTensorField
virtual const wordRes & fieldNames() const noexcept
Return names of fields to probe.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
#define doLocalCode(InputType, Target)
virtual dimensionedScalar startTime() const
Return start time.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
GeometricField< sphericalTensor, fvsPatchField, surfaceMesh > surfaceSphericalTensorField
Ostream & endl(Ostream &os)
Add newline and flush stream.
static unsigned int defaultPrecision() noexcept
Return the default precision.
labelList processor_
Processor holding the cell or face (-1 if point not found.
const cellList & cells() const
static int myProcNo(const label communicator=worldComm)
Rank of this process in the communicator (starting from masterNo()). Can be negative if the process i...
const Time & time() const
Return the top-level database.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
GeometricField< sphericalTensor, fvPatchField, volMesh > volSphericalTensorField
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Macros for easy insertion into run-time selection tables.
const word & name() const noexcept
Return the name of this functionObject.
#define forAll(list, i)
Loop across all elements in list.
label prepare(unsigned request)
Classify field types, close/open file streams.
T & operator[](const label i)
Return element of UList.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
GeometricField< symmTensor, fvsPatchField, surfaceMesh > surfaceSymmTensorField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
#define forAllIters(container, iter)
Iterate across all elements in the container object.
HashSet< word, Hash< word > > wordHashSet
A HashSet of words, uses string hasher.
const vectorField & cellCentres() const
#define DebugInfo
Report an information message using Foam::Info.
Istream and Ostream manipulators taking arguments.
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
label size() const noexcept
The number of elements in the List.
bool includeOutOfBounds_
Include probes that were not found (default: true)
const labelList & reverseCellMap() const
Reverse cell map.
int debug
Static debugging option.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
HashPtrTable< OFstream > probeFilePtrs_
Current open files (non-empty on master only)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
const vectorField & faceCentres() const
List< word > wordList
List of word.
vector point
Point is a vector.
bool verbose(const bool on) noexcept
Enable/disable verbose output.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual void findElements(const fvMesh &mesh)
Find cells and faces containing probes.
const polyMesh & mesh() const
Return polyMesh.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static word outputPrefix
Directory prefix.
virtual bool read(const dictionary &)
Read the probes.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
Omanip< int > setw(const int i)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type.
List< label > labelList
A List of labels.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
labelList patchIDList_
Patch IDs on which the new probes are located (for patchProbes)
const fvMesh & mesh_
Reference to the fvMesh.
static const word & regionName(const word ®ion)
The mesh region name or word::null if polyMesh::defaultRegion.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
const labelList & reverseFaceMap() const
Reverse face map.
fileName globalPath() const
Return global path for the case.