55 void Foam::probes::createProbeFiles(
const wordList& fieldNames)
59 bool needsNewFiles =
false;
73 <<
"Probing locations: " << *
this <<
nl 108 os.setf(std::ios_base::left);
112 os <<
"# Probe " << probei <<
' ' <<
operator[](probei);
116 os <<
" # Not Found";
127 patchi < bm.nNonProcessor()
131 os <<
" at patch " << bm[patchi].name();
133 os <<
" with a distance of " 135 <<
" m to the original point " 143 os <<
setw(width) <<
"# Time";
149 os <<
' ' <<
setw(width) << probei;
171 const point& location = (*this)[probei];
175 elementList_[probei] = celli;
181 scalar minDistance = GREAT;
182 label minFaceID = -1;
185 label facei = cellFaces[i];
187 if (
mag(dist) < minDistance)
189 minDistance =
mag(dist);
193 faceList_[probei] = minFaceID;
197 faceList_[probei] = -1;
200 if (
debug && (elementList_[probei] != -1 || faceList_[probei] != -1))
202 Pout<<
"probes : found point " << location
203 <<
" in cell " << elementList_[probei]
204 <<
" and face " << faceList_[probei] <<
endl;
210 forAll(elementList_, probei)
212 const point& location = operator[](probei);
213 label celli = elementList_[probei];
214 label facei = faceList_[probei];
219 reduce(celli, maxOp<label>());
220 reduce(facei, maxOp<label>());
221 reduce(processor_[probei], maxOp<label>());
228 <<
"Did not find location " << location
229 <<
" in any cell. Skipping location." <<
endl;
232 else if (facei == -1)
237 <<
"Did not find location " << location
238 <<
" in any face. Skipping location." <<
endl;
244 if (elementList_[probei] != -1 && elementList_[probei] != celli)
247 <<
"Location " << location
248 <<
" seems to be on multiple domains:" 249 <<
" cell " << elementList_[probei]
251 <<
" and cell " << celli <<
" on some other domain." 253 <<
"This might happen if the probe location is on" 254 <<
" a processor patch. Change the location slightly" 255 <<
" to prevent this." <<
endl;
258 if (faceList_[probei] != -1 && faceList_[probei] != facei)
261 <<
"Location " << location
262 <<
" seems to be on multiple domains:" 263 <<
" cell " << faceList_[probei]
265 <<
" and face " << facei <<
" on some other domain." 267 <<
"This might happen if the probe location is on" 268 <<
" a processor patch. Change the location slightly" 269 <<
" to prevent this." <<
endl;
279 HashTable<wordHashSet> selected =
282 ? IOobjectList(mesh_, mesh_.time().timeName()).classes(fieldSelection_)
283 : mesh_.classes(fieldSelection_)
291 #define doLocalCode(InputType, Target) \ 294 const auto iter = selected.cfind(InputType::typeName); \ 298 Target.append(iter.val().sortedToc()); \ 299 nFields += Target.size(); \ 323 currentFields.insert(scalarFields_);
324 currentFields.insert(vectorFields_);
325 currentFields.insert(sphericalTensorFields_);
326 currentFields.insert(symmTensorFields_);
327 currentFields.insert(tensorFields_);
329 currentFields.insert(surfaceScalarFields_);
330 currentFields.insert(surfaceVectorFields_);
331 currentFields.insert(surfaceSphericalTensorFields_);
332 currentFields.insert(surfaceSymmTensorFields_);
333 currentFields.insert(surfaceTensorFields_);
336 <<
"Probing fields: " << currentFields <<
nl 337 <<
"Probing locations: " << *
this <<
nl 343 if (!currentFields.erase(iter.key()))
345 DebugInfo<<
"close probe stream: " << iter()->name() <<
endl;
347 probeFilePtrs_.remove(iter);
351 if ((request & ACTION_WRITE) && !currentFields.empty())
353 createProbeFiles(currentFields.sortedToc());
368 const bool loadFromFiles,
374 loadFromFiles_(loadFromFiles),
375 fixedLocations_(true),
376 includeOutOfBounds_(true),
380 samplePointScheme_(
"cell")
401 dict.
readEntry(
"probeLocations", static_cast<pointField&>(*
this));
412 if (!fixedLocations_ && samplePointScheme_ !=
"cell")
415 <<
"Only cell interpolation can be applied when " 416 <<
"not using fixedLocations. InterpolationScheme " 417 <<
"entry will be ignored" 426 prepare(ACTION_NONE);
432 bool Foam::probes::performAction(
unsigned request)
436 performAction(scalarFields_, request);
437 performAction(vectorFields_, request);
438 performAction(sphericalTensorFields_, request);
439 performAction(symmTensorFields_, request);
440 performAction(tensorFields_, request);
442 performAction(surfaceScalarFields_, request);
443 performAction(surfaceVectorFields_, request);
444 performAction(surfaceSphericalTensorFields_, request);
445 performAction(surfaceSymmTensorFields_, request);
446 performAction(surfaceTensorFields_, request);
456 return performAction(ACTION_ALL & ~ACTION_WRITE);
465 return performAction(ACTION_ALL);
473 if (&mpm.
mesh() != &mesh_)
488 DynamicList<label> elems(elementList_.size());
493 label celli = elementList_[i];
496 label newCelli = reverseMap[celli];
501 else if (newCelli < -1)
504 elems.append(-newCelli - 2);
509 elems.append(newCelli);
519 elementList_.transfer(elems);
524 DynamicList<label> elems(faceList_.size());
527 for (
const label facei : faceList_)
531 label newFacei = reverseMap[facei];
536 else if (newFacei < -1)
539 elems.
append(-newFacei - 2);
544 elems.append(newFacei);
554 faceList_.transfer(elems);
564 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.
const polyMesh & mesh() const noexcept
Return polyMesh.
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.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
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 expressions::valueTypeCode::INVALID.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
fileName globalPath() const
Return global path for the case = rootPath/globalCaseName. Same as TimePaths::globalPath() ...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
const labelList & reverseCellMap() const noexcept
Reverse cell map.
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 a time name for the given scalar time value formatted with the given precision.
label size() const noexcept
The number of elements in the container.
bool includeOutOfBounds_
Include probes that were not found (default: true)
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)
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.
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.
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...
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.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)