55void 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];
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;
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")
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);
435bool 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_)
496 label celli = elementList_[i];
499 label newCelli = reverseMap[celli];
504 else if (newCelli < -1)
507 elems.
append(-newCelli - 2);
522 elementList_.transfer(elems);
530 for (
const label facei : faceList_)
534 label newFacei = reverseMap[facei];
539 else if (newFacei < -1)
542 elems.
append(-newFacei - 2);
557 faceList_.transfer(elems);
567 if (fixedLocations_ && &
mesh == &mesh_)
Istream and Ostream manipulators taking arguments.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
A HashTable similar to std::unordered_map.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
bool empty() const noexcept
True if the hash table is empty.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
List of IOobjects with searching and retrieving facilities.
HashTable< wordHashSet > classes() const
A summary hash of classes used and their associated object names.
static unsigned int defaultPrecision() noexcept
Return the default precision.
virtual const fileName & name() const
Read/write access to the name of the stream.
virtual bool read()
Re-read model coefficients if they have changed.
fileName globalPath() const
Return global path for the case.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual dimensionedScalar startTime() const
Return start time.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
void size(const label n)
Older name for setAddressableSize.
T & operator[](const label i)
Return element of UList.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
const Type & value() const
Return const reference to value.
int verbose() const noexcept
Output verbosity level.
Abstract base-class for Time/database function objects.
const word & name() const noexcept
Return the name of this functionObject.
static word outputPrefix
Directory prefix.
const fvMesh & mesh_
Reference to the fvMesh.
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
const labelList & reverseCellMap() const
Reverse cell map.
const labelList & reverseFaceMap() const
Reverse face map.
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
Mesh consisting of general polyhedral cells.
static const word & regionName(const word ®ion)
The mesh region name or word::null if polyMesh::defaultRegion.
label findCell(const point &p, const cellDecomposition=CELL_TETS) const
Find cell enclosing this location and return index.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const vectorField & faceCentres() const
const vectorField & cellCentres() const
const cellList & cells() const
Set of locations to sample.
bool includeOutOfBounds_
Include probes that were not found (default: true)
HashPtrTable< OFstream > probeFilePtrs_
Current open files (non-empty on master only)
virtual const wordRes & fieldNames() const noexcept
Return names of fields to probe.
labelList processor_
Processor holding the cell or face (-1 if point not found.
label prepare(unsigned request)
Classify field types, close/open file streams.
pointField oldPoints_
Original probes location (only used for patchProbes)
virtual void findElements(const fvMesh &mesh)
Find cells and faces containing probes.
labelList patchIDList_
Patch IDs on which the new probes are located (for patchProbes)
virtual bool execute()
Sample and store result if the sampleOnExecute is enabled.
virtual bool write()
Sample and write.
virtual bool read(const dictionary &)
Read the probes.
int myProcNo() const noexcept
Return processor number.
splitCell * master() const
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Omanip< int > setw(const int i)
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
#define doLocalCode(GeoField)