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().findIndex(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).referPatchIndex()
212 faceSign_.append(
labelList(fvp.size(), 1));
220 void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
222 const dictionary&
dict
229 dict.subDict(
"sampledSurfaceDict")
231 surfacePtr_().update();
232 nFaces_ =
returnReduce(surfacePtr_().faces().size(), sumOp<label>());
236 void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
248 if (facePatchId_[i] != -1)
251 globalFacesIs[i] += mesh_.boundaryMesh()[
patchi].start();
258 IndirectList<face>(mesh_.faces(), globalFacesIs),
272 nFaces += allFaces[proci].size();
273 nPoints += allPoints[proci].size();
276 faces.setSize(nFaces);
287 const face&
f = fcs[i];
288 face& newF = faces[nFaces++];
289 newF.setSize(
f.size());
308 const faceList& fcs = allFaces[proci];
311 const face&
f = fcs[i];
312 face& newF = faces[nFaces++];
313 newF.setSize(
f.size());
345 <<
" down to " << newPoints.size() <<
" points" <<
endl;
348 points.transfer(newPoints);
357 void Foam::functionObjects::fieldValues::surfaceFieldValue::
358 combineSurfaceGeometry
364 if (selectionType_ == selectionTypes::sampledSurface)
366 const sampledSurface&
s = surfacePtr_();
371 scalar mergeDim = 1
e-10*mesh_.bounds().mag();
380 SubList<face>(
s.faces(),
s.faces().size()),
398 Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea()
const
400 if (selectionType_ == selectionTypes::sampledSurface)
402 return gSum(surfacePtr_().magSf());
406 return gSum(filterField(mesh_.magSf()));
418 switch (selectionType_)
420 case selectionTypes::faceZone:
422 dict.lookupBackwardsCompatible({
"faceZone",
"name"})
427 case selectionTypes::patch:
429 dict.lookupBackwardsCompatible({
"patch",
"name"}) >> selectionName_;
433 case selectionTypes::sampledSurface:
435 sampledSurfaceFaces(
dict);
436 selectionName_ = surfacePtr_().name();
443 << selectionTypeNames[selectionType_]
444 <<
"(" << selectionName_ <<
"):" <<
nl
445 <<
" Unknown selection type. Valid selection types are:"
450 if (nFaces_ == 0 && (!mesh_.stitcher().stitches() || !mesh_.conformal()))
454 << selectionTypeNames[selectionType_]
455 <<
"(" << selectionName_ <<
"):" <<
nl
459 if (selectionType_ == selectionTypes::sampledSurface)
461 surfacePtr_().update();
464 totalArea_ = totalArea();
467 <<
" total faces = " << nFaces_
469 <<
" total area = " << totalArea_
472 if (
dict.readIfPresent(
"weightFields", weightFieldNames_))
474 Info<<
name() <<
" " << operationTypeNames_[operation_]
475 <<
" weight fields " << weightFieldNames_;
477 else if (
dict.found(
"weightField"))
479 weightFieldNames_.setSize(1);
480 dict.lookup(
"weightField") >> weightFieldNames_[0];
482 Info<<
name() <<
" " << operationTypeNames_[operation_]
483 <<
" weight field " << weightFieldNames_[0];
486 if (
dict.readIfPresent(
"scaleFactor", scaleFactor_))
488 Info<<
" scale factor = " << scaleFactor_ <<
nl;
495 const word surfaceFormat(
dict.lookup(
"surfaceFormat"));
497 surfaceWriterPtr_.reset
510 if (operation_ != operationType::none)
512 writeCommented(
file(),
"Selection type : ");
514 << selectionTypeNames[selectionType_] <<
" "
515 << selectionName_ <<
endl;
516 writeCommented(
file(),
"Faces : ");
518 writeCommented(
file(),
"Area : ");
521 writeCommented(
file(),
"Time");
530 <<
tab << operationTypeNames_[operation_]
531 <<
"(" << fields_[fieldi] <<
")";
553 return processValuesTypeType
577 case operationType::areaNormalAverage:
579 result =
gSum(weights*values & Sf)/
gSum(
mag(weights*Sf));
582 case operationType::areaNormalIntegrate:
584 result =
gSum(weights*values & Sf);
607 surfaceWriterPtr_(nullptr),
610 selectionTypeNames.
read
612 dict.lookupBackwardsCompatible({
"select",
"regionType"})
616 operation_(operationTypeNames_.read(
dict.lookup(
"operation"))),
619 writeArea_(
dict.lookupOrDefault(
"writeArea",
false)),
637 surfaceWriterPtr_(nullptr),
640 selectionTypeNames.
read
642 dict.lookupBackwardsCompatible({
"select",
"regionType"})
646 operation_(operationTypeNames_.read(
dict.lookup(
"operation"))),
649 writeArea_(
dict.lookupOrDefault(
"writeArea",
false)),
682 bool anyFields =
false;
685 #define validFieldType(fieldType, none) \
686 anyFields = anyFields || validField<fieldType>(fields_[i]);
688 #undef validFieldType
690 if (!anyFields && fields_.size() > 1)
692 cannotFindObjects(fields_);
696 if (anyFields && operation_ != operationType::none)
702 if (selectionType_ == selectionTypes::sampledSurface)
704 surfacePtr_().update();
708 if (anyFields && operation_ != operationType::none &&
Pstream::master())
716 totalArea_ = totalArea();
717 if (anyFields && operation_ != operationType::none &&
Pstream::master())
721 Log <<
" total area = " << totalArea_ <<
endl;
730 if (selectionType_ == selectionTypes::sampledSurface)
732 combineSurfaceGeometry(faces,
points);
736 combineMeshGeometry(faces,
points);
741 surfaceWriterPtr_->write
744 selectionTypeNames[selectionType_] + (
"_" + selectionName_),
754 selectionType_ == selectionTypes::sampledSurface
759 forAll(weightFieldNames_, i)
761 weights *= getFieldValues<scalar>(weightFieldNames_[i]);
765 selectionType_ == selectionTypes::sampledSurface
767 : (signs*filterField(mesh_.Sf()))()
773 const word& fieldName = fields_[i];
776 #define writeValuesFieldType(fieldType, none) \
777 ok = ok || writeValues<fieldType>(fieldName, signs, weights, Sf);
779 #undef writeValuesFieldType
783 cannotFindObject(fieldName);
788 if (anyFields && operation_ != operationType::none &&
Pstream::master())
817 if (&map.
mesh() == &mesh_)
829 if (&map.
mesh() == &mesh_)
841 if (&map.
mesh() == &mesh_)
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
wordList toc() const
Return the table of contents.
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.
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.
label findIndex(const word &key) const
Return the index of the given the key or -1 if not found.
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 faceZoneList & 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 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.
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")
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
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)
#define validFieldType(fieldType, none)