44 namespace functionObjects
93 Foam::labelList Foam::functionObjects::fieldValues::surfaceFieldValue::patchis
105 if (patchiis.empty())
108 <<
type() <<
' ' << this->
name() <<
": "
110 <<
"(" << patchNames[i] <<
"):" <<
nl
112 <<
". Valid patch names are: "
117 patchis.append(patchiis);
124 void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
126 const faceZone& zone = faceZonePtr_->zone();
129 mesh_.polyBFacePatches();
130 mesh_.polyBFacePatchFaces();
132 DynamicList<label> faceIds(zone.size());
133 DynamicList<label> facePatchIds(zone.size());
134 DynamicList<label> faceSigns(zone.size());
138 const label facei = zone[zoneFacei];
139 const label faceSign = zone.flipMap()[zoneFacei] ? -1 : 1;
141 if (mesh_.isInternalFace(facei))
143 faceIds.append(facei);
144 facePatchIds.append(-1);
145 faceSigns.append(faceSign);
149 const label bFacei = facei - mesh_.nInternalFaces();
152 const labelUList patchFaces = mesh_.polyBFacePatchFaces()[bFacei];
157 const fvPatch& fvp = mesh_.boundary()[
patches[i]];
160 isType<processorFvPatch>(fvp)
161 && refCast<const processorFvPatch>(fvp).neighbour()
167 faceIds.append(patchFaces[i]);
168 facePatchIds.append(
patches[i]);
169 faceSigns.append(faceSign);
174 faceId_.transfer(faceIds);
175 facePatchId_.transfer(facePatchIds);
176 faceSign_.transfer(faceSigns);
182 void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchesFaces()
184 const labelList patchis = this->patchis(patchNames_);
187 facePatchId_.clear();
193 const fvPatch& fvp = mesh_.boundary()[
patchi];
197 faceSign_.append(
labelList(fvp.size(), 1));
201 forAll(mesh_.boundary(), pcPatchj)
203 const fvPatch& pcFvp = mesh_.boundary()[pcPatchj];
207 isA<processorCyclicFvPatch>(pcFvp)
208 && refCast<const processorCyclicFvPatch>(pcFvp).referPatchIndex()
213 facePatchId_.append(
labelList(pcFvp.size(), pcPatchj));
214 faceSign_.append(
labelList(pcFvp.size(), 1));
224 Foam::functionObjects::fieldValues::surfaceFieldValue::setSampledSurfaceFaces()
226 surfacePtr_().update();
228 nFaces_ =
returnReduce(surfacePtr_().faces().size(), sumOp<label>());
232 void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
244 if (facePatchId_[i] != -1)
247 globalFacesIs[i] += mesh_.poly().boundary()[
patchi].start();
254 IndirectList<face>(mesh_.faces(), globalFacesIs),
268 nFaces += allFaces[proci].size();
269 nPoints += allPoints[proci].size();
272 faces.setSize(nFaces);
283 const face&
f = fcs[i];
284 face& newF = faces[nFaces++];
285 newF.setSize(
f.size());
304 const faceList& fcs = allFaces[proci];
307 const face&
f = fcs[i];
308 face& newF = faces[nFaces++];
309 newF.setSize(
f.size());
338 points.transfer(newPoints);
347 void Foam::functionObjects::fieldValues::surfaceFieldValue::
348 combineSurfaceGeometry
354 if (selectionType_ == selectionTypes::sampledSurface)
356 const sampledSurface&
s = surfacePtr_();
361 scalar mergeDim = 1
e-10*mesh_.bounds().mag();
370 SubList<face>(
s.faces(),
s.faces().size()),
388 Foam::functionObjects::fieldValues::surfaceFieldValue::area()
const
390 if (selectionType_ == selectionTypes::sampledSurface)
392 return gSum(surfacePtr_().magSf());
396 return gSum(filterField(mesh_.magSf()));
410 writeCommented(
file(),
"Selection");
413 << selectionTypeNames[selectionType_] <<
"("
414 << selectionName_.c_str() <<
")" <<
endl;
416 writeHeaderValue(
file(),
"Faces", nFaces_);
418 writeHeaderValue(
file(),
"Area", area_);
420 writeCommented(
file(),
"Time");
422 if (writeNFaces_)
file() <<
tab <<
"Faces";
423 if (writeArea_)
file() <<
tab <<
"Area";
428 <<
tab << operationTypeNames_[operation_]
429 <<
"(" << fields_[fieldi] <<
")";
451 return processValuesTypeType
475 case operationType::areaNormalAverage:
477 result =
gSum(weights*values & Sf)/
gSum(
mag(weights*Sf));
480 case operationType::areaNormalIntegrate:
482 result =
gSum(weights*values & Sf);
496 switch (selectionType_)
498 case selectionTypes::faceZone:
499 if (faceZonePtr_->zone().moveUpdate()) setFaceZoneFaces();
501 case selectionTypes::patch:
504 case selectionTypes::sampledSurface:
505 surfacePtr_->movePoints();
506 setSampledSurfaceFaces();
510 area_ = nFaces_ ?
area() : NaN;
516 switch (selectionType_)
518 case selectionTypes::faceZone:
519 if (!faceZonePtr_->zone().moveUpdate()) setFaceZoneFaces();
521 case selectionTypes::patch:
525 case selectionTypes::sampledSurface:
543 surfaceWriterPtr_(nullptr),
544 selectionType_(selectionTypeNames.select(
dict)),
545 selectionName_(
string::null),
550 writeNFaces_(
dict.lookupOrDefault(
"writeNumberOfFaces", false)),
551 writeArea_(
dict.lookupOrDefault(
"writeArea", false)),
552 faceZonePtr_(nullptr),
570 surfaceWriterPtr_(nullptr),
571 selectionType_(selectionTypeNames.select(
dict)),
572 selectionName_(
string::null),
577 writeNFaces_(
dict.lookupOrDefault(
"writeNumberOfFaces", false)),
578 writeArea_(
dict.lookupOrDefault(
"writeArea", false)),
579 faceZonePtr_(nullptr),
605 const word selection(selectionTypeNames[selectionType_]);
607 switch (selectionType_)
609 case selectionTypes::faceZone:
613 selectionName_ = faceZonePtr_->name();
617 case selectionTypes::patch:
625 ?
'"' + patchName +
'"'
634 const labelList patchis = this->patchis(patchNames_);
636 selectionName_.clear();
640 const fvPatch& fvp = mesh_.boundary()[patchis[i]];
641 selectionName_.append((i ?
" " :
"") + fvp.
name());
646 case selectionTypes::sampledSurface:
655 selectionTypeNames[selectionTypes::sampledSurface]
659 selectionName_ = surfacePtr_().name();
665 if (
dict.found(
"weightFields"))
667 dict.lookup(
"weightFields") >> weightFieldNames_;
669 else if (
dict.found(
"weightField"))
671 weightFieldNames_.setSize(1);
673 dict.lookup(
"weightField") >> weightFieldNames_[0];
678 const word surfaceFormat(
dict.lookup(
"surfaceFormat"));
680 surfaceWriterPtr_.reset
694 Info<<
indent <<
"operation = " << operationTypeNames_[operation_] <<
nl;
695 if (weightFieldNames_.size() == 1)
697 Info<<
indent <<
"weight field = " << weightFieldNames_[0] <<
nl;
699 if (weightFieldNames_.size() > 1)
702 forAll(weightFieldNames_, i)
Info<<
' ' << weightFieldNames_[i];
718 bool anyFields =
false;
721 #define validFieldType(fieldType, none) \
722 anyFields = anyFields || validField<fieldType>(fields_[i]);
724 #undef validFieldType
726 if (!anyFields && fields_.size() > 1)
728 cannotFindObjects(fields_);
738 if (selectionType_ == selectionTypes::sampledSurface)
740 surfacePtr_().update();
763 Log <<
" number of faces = " << nFaces_ <<
endl;
767 Log <<
" area = " << area_ <<
endl;
773 selectionType_ == selectionTypes::sampledSurface
778 forAll(weightFieldNames_, i)
780 weights *= getFieldValues<scalar>(weightFieldNames_[i]);
784 selectionType_ == selectionTypes::sampledSurface
786 : (signs*filterField(mesh_.Sf()))()
790 #define DeclareValues(fieldType, nullArg) \
791 PtrList<Field<fieldType>> fieldType##Values(fields_.size());
799 const word& fieldName = fields_[i];
802 #define writeValuesFieldType(fieldType, none) \
804 const bool typeOk = validField<fieldType>(fieldName); \
808 tmp<Field<fieldType>> values = \
809 getFieldValues<fieldType>(fieldName); \
811 writeValues<fieldType> \
822 fieldType##Values.set \
825 getFieldValues<fieldType>(fieldName).ptr() \
827 combineField(fieldType##Values[i]); \
834 #undef writeValuesFieldType
838 cannotFindObject(fieldName);
855 if (selectionType_ == selectionTypes::sampledSurface)
857 combineSurfaceGeometry(faces,
points);
861 combineMeshGeometry(faces,
points);
866 surfaceWriterPtr_->write
868 baseFileDir()/
name()/time_.name(),
869 word(selectionTypeNames[selectionType_])
873 ? selectionName_.replaceAll(
" ",
",").c_str()
874 : selectionName_.c_str()
901 if (selectionType_ == selectionTypes::faceZone)
903 faceZonePtr_->movePoints();
918 if (selectionType_ == selectionTypes::faceZone)
920 faceZonePtr_->topoChange(map);
935 if (selectionType_ == selectionTypes::faceZone)
937 faceZonePtr_->mapMesh(map);
952 if (selectionType_ == selectionTypes::faceZone)
954 faceZonePtr_->distribute(map);
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
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.
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Abstract base-class for Time/database functionObjects.
virtual const word & type() const =0
Runtime type information.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void movePoints(const polyMesh &mesh)
Update topology using the given map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
const word & name() const
Return the name of this functionObject.
virtual void topoChange(const polyTopoChangeMap &map)
Update topology using the given map.
Base class for field value -based function objects.
const dictionary & dict() const
Return the reference to the construction dictionary.
virtual bool read(const dictionary &dict)
Read from dictionary.
virtual bool write()
Write.
Surface, patch or faceZone selection class.
surfaceFieldValue(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
void changeMesh()
Update the surface following mesh change.
static const NamedEnum< selectionTypes, 4 > selectionTypeNames
Selection type names.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
void moveMesh()
Update the surface following mesh motion.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
static const NamedEnum< operationType, 15 > operationTypeNames_
Operation type names.
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.
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.
virtual bool write()
Calculate and write.
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 polyMesh & poly() const
Return reference to polyMesh.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
virtual const word & name() const
Return name.
faceZone selection or generation class
Registry of regIOobjects.
Motion of the mesh specified as a list of pointMeshMovers.
wordList names() const
Return the list of patch names.
labelList findIndices(const wordRe &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
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 polyBoundaryMesh & boundary() const
Return boundary mesh.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
A class for handling character strings derived from std::string.
static autoPtr< surfaceWriter > New(const word &writeType, const IOstream::streamFormat writeFormat, const IOstream::compressionType writeCompression)
Select given write options.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
A wordRe is a word, but can also have a regular expression for matching words.
static bool isPattern(const string &)
Test string for regular expression meta characters.
A class for handling words, derived from string.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::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)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
Omanip< int > setw(const int i)
FOR_ALL_FIELD_TYPES(makeDimensionedPointFieldFunctions)
vectorField pointField
pointField is a vectorField.
Type gSum(const UList< Type > &f, const label comm)
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)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
List< wordRe > wordReList
A List of wordRe (word or regular expression)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
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
label mergePoints(const Field< 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.
Ostream & indent(Ostream &os)
Indent stream.
wordList patchNames(nPatches)
#define ValuesParameter(fieldType, nullArg)
#define DeclareValues(fieldType, nullArg)
#define writeValuesFieldType(fieldType, none)
#define validFieldType(fieldType, none)