43 namespace functionObjects
104 void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
125 DynamicList<label> faceIds(zone.size());
126 DynamicList<label> facePatchIds(zone.size());
127 DynamicList<label> faceSigns(zone.size());
131 const label facei = zone[zoneFacei];
137 facePatchIds.append(-1);
153 isType<processorFvPatch>(fvp)
154 && refCast<const processorFvPatch>(fvp).neighbour()
160 faceIds.
append(patchFaces[i]);
161 facePatchIds.append(
patches[i]);
175 void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
177 const label patchId = mesh_.boundaryMesh().findPatchID(selectionName_);
183 << selectionTypeNames[selectionType_]
184 <<
"(" << selectionName_ <<
"):" <<
nl
185 <<
" Unknown patch name: " << selectionName_
186 <<
". Valid patch names are: "
187 << mesh_.boundaryMesh().names() <<
nl
191 const fvPatch& fvp = mesh_.boundary()[
patchId];
201 const fvPatch& fvp = mesh_.boundary()[
patchi];
205 isA<processorCyclicFvPatch>(fvp)
206 && refCast<const processorCyclicFvPatch>(fvp).referPatchID() ==
patchId
211 faceSign_.append(
labelList(fvp.size(), 1));
219 void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
221 const dictionary&
dict
228 dict.subDict(
"sampledSurfaceDict")
230 surfacePtr_().update();
231 nFaces_ =
returnReduce(surfacePtr_().faces().size(), sumOp<label>());
235 void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
247 if (facePatchId_[i] != -1)
250 globalFacesIs[i] += mesh_.boundaryMesh()[
patchi].start();
257 IndirectList<face>(mesh_.faces(), globalFacesIs),
271 nFaces += allFaces[proci].size();
272 nPoints += allPoints[proci].size();
275 faces.setSize(nFaces);
286 const face&
f = fcs[i];
287 face& newF = faces[nFaces++];
288 newF.setSize(
f.size());
307 const faceList& fcs = allFaces[proci];
310 const face&
f = fcs[i];
311 face& newF = faces[nFaces++];
312 newF.setSize(
f.size());
344 <<
" down to " << newPoints.size() <<
" points" <<
endl;
347 points.transfer(newPoints);
356 void Foam::functionObjects::fieldValues::surfaceFieldValue::
357 combineSurfaceGeometry
363 if (selectionType_ == selectionTypes::sampledSurface)
365 const sampledSurface&
s = surfacePtr_();
370 scalar mergeDim = 1
e-10*mesh_.bounds().mag();
379 SubList<face>(
s.faces(),
s.faces().size()),
397 Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea()
const
399 if (selectionType_ == selectionTypes::sampledSurface)
401 return gSum(surfacePtr_().magSf());
405 return gSum(filterField(mesh_.magSf()));
417 switch (selectionType_)
419 case selectionTypes::faceZone:
421 dict.lookupBackwardsCompatible({
"faceZone",
"name"})
426 case selectionTypes::patch:
428 dict.lookupBackwardsCompatible({
"patch",
"name"}) >> selectionName_;
432 case selectionTypes::sampledSurface:
434 sampledSurfaceFaces(
dict);
435 selectionName_ = surfacePtr_().name();
442 << selectionTypeNames[selectionType_]
443 <<
"(" << selectionName_ <<
"):" <<
nl
444 <<
" Unknown selection type. Valid selection types are:"
449 if (nFaces_ == 0 && (!mesh_.stitcher().stitches() || !mesh_.conformal()))
453 << selectionTypeNames[selectionType_]
454 <<
"(" << selectionName_ <<
"):" <<
nl
458 if (selectionType_ == selectionTypes::sampledSurface)
460 surfacePtr_().update();
463 totalArea_ = totalArea();
466 <<
" total faces = " << nFaces_
468 <<
" total area = " << totalArea_
471 if (
dict.readIfPresent(
"weightFields", weightFieldNames_))
473 Info<<
name() <<
" " << operationTypeNames_[operation_]
474 <<
" weight fields " << weightFieldNames_;
476 else if (
dict.found(
"weightField"))
478 weightFieldNames_.setSize(1);
479 dict.lookup(
"weightField") >> weightFieldNames_[0];
481 Info<<
name() <<
" " << operationTypeNames_[operation_]
482 <<
" weight field " << weightFieldNames_[0];
485 if (
dict.readIfPresent(
"scaleFactor", scaleFactor_))
487 Info<<
" scale factor = " << scaleFactor_ <<
nl;
494 const word surfaceFormat(
dict.lookup(
"surfaceFormat"));
496 surfaceWriterPtr_.reset
509 if (operation_ != operationType::none)
511 writeCommented(
file(),
"Selection type : ");
513 << selectionTypeNames[selectionType_] <<
" "
514 << selectionName_ <<
endl;
515 writeCommented(
file(),
"Faces : ");
517 writeCommented(
file(),
"Area : ");
520 writeCommented(
file(),
"Time");
529 <<
tab << operationTypeNames_[operation_]
530 <<
"(" << fields_[fieldi] <<
")";
552 return processValuesTypeType
576 case operationType::areaNormalAverage:
578 result =
gSum(weights*values & Sf)/
gSum(
mag(weights*Sf));
581 case operationType::areaNormalIntegrate:
583 result =
gSum(weights*values & Sf);
606 surfaceWriterPtr_(nullptr),
609 selectionTypeNames.
read
611 dict.lookupBackwardsCompatible({
"select",
"regionType"})
615 operation_(operationTypeNames_.read(
dict.lookup(
"operation"))),
618 writeArea_(
dict.lookupOrDefault(
"writeArea",
false)),
636 surfaceWriterPtr_(nullptr),
639 selectionTypeNames.
read
641 dict.lookupBackwardsCompatible({
"select",
"regionType"})
645 operation_(operationTypeNames_.read(
dict.lookup(
"operation"))),
648 writeArea_(
dict.lookupOrDefault(
"writeArea",
false)),
680 if (operation_ != operationType::none)
685 if (selectionType_ == selectionTypes::sampledSurface)
687 surfacePtr_().update();
697 totalArea_ = totalArea();
702 Log <<
" total area = " << totalArea_ <<
endl;
711 if (selectionType_ == selectionTypes::sampledSurface)
713 combineSurfaceGeometry(faces,
points);
717 combineMeshGeometry(faces,
points);
722 surfaceWriterPtr_->write
725 selectionTypeNames[selectionType_] + (
"_" + selectionName_),
735 selectionType_ == selectionTypes::sampledSurface
740 forAll(weightFieldNames_, i)
742 weights *= getFieldValues<scalar>(weightFieldNames_[i]);
746 selectionType_ == selectionTypes::sampledSurface
748 : (signs*filterField(mesh_.Sf()))()
754 const word& fieldName = fields_[i];
757 #define writeValuesFieldType(fieldType, none) \
760 || writeValues<fieldType> \
768 #undef writeValuesFieldType
773 <<
"Requested field " << fieldName
774 <<
" not found in database and not processed"
809 if (&map.
mesh() == &mesh_)
821 if (&map.
mesh() == &mesh_)
833 if (&map.
mesh() == &mesh_)
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
label findZoneID(const word &zoneName) const
Find zone index given a name.
wordList names() const
Return a list of zone names.
Initialise the NamedEnum HashTable from the static list of names.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
void append(T *)
Append an element at the end of the list.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=0)
Am I the master process.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Abstract base-class for Time/database functionObjects.
virtual const word & type() const =0
Runtime type information.
const word & name() const
Return the name of this functionObject.
Base class for field value -based function objects.
virtual bool read(const dictionary &dict)
Read from dictionary.
virtual bool write()
Write.
Surface (face) region selection class.
surfaceFieldValue(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
const labelList & faceSign() const
Return the list of +1/-1 representing face flip map.
label nFaces_
Global number of faces.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
void initialise(const dictionary &dict)
Initialise, e.g. face addressing.
static const NamedEnum< operationType, 14 > operationTypeNames_
Operation type names.
word selectionName_
Name of face selection (patch, faceZone, etc.)
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
selectionTypes selectionType_
Selection type.
virtual void writeFileHeader(const label i)
Output file header information.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
static const NamedEnum< selectionTypes, 3 > selectionTypeNames
Selection type names.
bool processValues(const Field< Type > &values, const scalarField &signs, const scalarField &weights, const vectorField &Sf, ResultType &result) const
Apply the operation to the values, and return true if successful.
labelList faceId_
Local list of face IDs.
labelList facePatchId_
Local list of patch ID per face.
virtual bool write()
Calculate and write.
labelList faceSign_
List of +1/-1 representing face flip map.
virtual ~surfaceFieldValue()
Destructor.
virtual bool read(const dictionary &)
Read from dictionary.
selectionTypes
Selection type enumeration.
operationType
Operation type enumeration.
const fvMesh & mesh_
Reference to the fvMesh.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const UCompactListList< label > & polyBFacePatches() const
Return poly-bFace-patch addressing.
const UCompactListList< label > & polyBFacePatchFaces() const
Return poly-bFace-patch-face addressing.
Registry of regIOobjects.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
const polyMesh & mesh() const
Return polyMesh.
Class containing mesh-to-mesh mapping information.
const polyMesh & mesh() const
Return polyMesh.
Mesh consisting of general polyhedral cells.
const meshFaceZones & faceZones() const
Return face zones.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
label nInternalFaces() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
static autoPtr< surfaceWriter > New(const word &writeType, const IOstream::streamFormat writeFormat, const IOstream::compressionType writeCompression)
Select given write options.
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
#define WarningInFunction
Report a warning using Foam::Warning.
#define Log
Report write to Foam::Info if the local log switch is true.
defineTypeNameAndDebug(fieldValueDelta, 0)
addToRunTimeSelectionTable(functionObject, fieldValueDelta, dictionary)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gSum(const FieldField< Field, Type > &f)
bool read(const char *, int32_t &)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
vectorField pointField
pointField is a vectorField.
FOR_ALL_FIELD_TYPES(DefineContiguousFvWallLocationDataType)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
Addressing for a faceList slice.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
dimensioned< scalar > mag(const dimensioned< Type > &)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
prefixOSstream Pout(cout, "Pout")
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
PrimitivePatch< IndirectList< face >, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
UList< label > labelUList
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
#define writeValuesFieldType(fieldType, none)