41 namespace functionObjects
76 "sumDirectionBalance",
80 "weightedAreaAverage",
82 "weightedAreaIntegrate",
105 void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
107 label zoneId = mesh_.faceZones().findZoneID(regionName_);
113 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 114 <<
" Unknown face zone name: " << regionName_
115 <<
". Valid face zones are: " << mesh_.faceZones().names()
119 const faceZone& fZone = mesh_.faceZones()[zoneId];
127 label facei = fZone[i];
130 label facePatchId = -1;
131 if (mesh_.isInternalFace(facei))
138 facePatchId = mesh_.boundaryMesh().whichPatch(facei);
140 if (isA<coupledPolyPatch>(pp))
142 if (refCast<const coupledPolyPatch>(pp).owner())
151 else if (!isA<emptyPolyPatch>(pp))
153 faceId = facei - pp.
start();
166 faceSigns.append(-1);
172 faceIds.append(faceId);
173 facePatchIds.append(facePatchId);
177 faceId_.transfer(faceIds);
178 facePatchId_.transfer(facePatchIds);
179 faceSign_.transfer(faceSigns);
184 Pout<<
"Original face zone size = " << fZone.
size()
185 <<
", new size = " << faceId_.size() <<
endl;
190 void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
192 const label patchid = mesh_.boundaryMesh().findPatchID(regionName_);
198 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 199 <<
" Unknown patch name: " << regionName_
200 <<
". Valid patch names are: " 201 << mesh_.boundaryMesh().names() <<
nl 207 label nFaces = pp.size();
208 if (isA<emptyPolyPatch>(pp))
213 faceId_.setSize(nFaces);
214 facePatchId_.setSize(nFaces);
215 faceSign_.setSize(nFaces);
220 faceId_[facei] = facei;
221 facePatchId_[facei] = patchid;
222 faceSign_[facei] = 1;
227 void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
236 dict.
subDict(
"sampledSurfaceDict")
238 surfacePtr_().update();
243 void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
255 if (facePatchId_[i] != -1)
258 globalFacesIs[i] += mesh_.boundaryMesh()[
patchi].start();
279 nFaces += allFaces[proci].size();
280 nPoints += allPoints[proci].
size();
294 const face&
f = fcs[i];
295 face& newF = faces[nFaces++];
306 points[nPoints++] = pts[i];
315 const faceList& fcs = allFaces[proci];
318 const face&
f = fcs[i];
319 face& newF = faces[nFaces++];
330 points[nPoints++] = pts[i];
351 Pout<<
"Merged from " << points.
size()
352 <<
" down to " << newPoints.
size() <<
" points" <<
endl;
364 void Foam::functionObjects::fieldValues::surfaceFieldValue::
365 combineSurfaceGeometry
371 if (surfacePtr_.valid())
378 scalar mergeDim = 1
e-10*mesh_.bounds().mag();
405 Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea()
const 409 if (surfacePtr_.valid())
411 totalArea =
gSum(surfacePtr_().magSf());
415 totalArea =
gSum(filterField(mesh_.magSf(),
false));
429 dict.
lookup(
"name") >> regionName_;
433 case regionTypes::faceZone:
438 case regionTypes::patch:
443 case regionTypes::sampledSurface:
445 sampledSurfaceFaces(dict);
452 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 453 <<
nl <<
" Unknown region type. Valid region types are:" 462 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 466 if (surfacePtr_.valid())
468 surfacePtr_().update();
471 totalArea_ = totalArea();
474 <<
" total faces = " << nFaces_
476 <<
" total area = " << totalArea_
481 Info<<
" weight field = " << weightFieldName_ <<
nl;
483 if (regionType_ == regionTypes::sampledSurface)
486 <<
"Cannot use weightField for a sampledSurface" 491 if (dict.
found(
"orientedWeightField"))
493 if (weightFieldName_ ==
"none")
495 dict.
lookup(
"orientedWeightField") >> weightFieldName_;
496 Info<<
" weight field = " << weightFieldName_ <<
nl;
497 orientWeightField_ =
true;
502 <<
"Either weightField or orientedWeightField can be supplied, " 511 orientedFieldsStart_ = fields_.
size();
512 fields_.append(orientedFields);
517 Info<<
" scale factor = " << scaleFactor_ <<
nl;
524 const word surfaceFormat(dict.
lookup(
"surfaceFormat"));
526 surfaceWriterPtr_.reset
532 subOrEmptyDict(surfaceFormat)
544 if (operation_ != operationType::none)
546 writeCommented(
file(),
"Region type : ");
547 file() << regionTypeNames_[regionType_] <<
" " << regionName_ <<
endl;
548 writeCommented(
file(),
"Faces : ");
550 writeCommented(
file(),
"Area : ");
553 writeCommented(
file(),
"Time");
562 <<
tab << operationTypeNames_[operation_]
563 <<
"(" << fields_[fieldi] <<
")";
582 case operationType::sumDirection:
584 vector n(dict_.lookup(
"direction"));
587 case operationType::sumDirectionBalance:
589 vector n(dict_.lookup(
"direction"));
597 return processSameTypeValues(values, Sf, weightField);
614 case operationType::sumDirection:
616 vector n(dict_.lookup(
"direction"));
617 n /=
mag(
n) + rootVSmall;
622 case operationType::sumDirectionBalance:
624 vector n(dict_.lookup(
"direction"));
625 n /=
mag(
n) + rootVSmall;
630 case operationType::areaNormalAverage:
632 scalar result =
sum(values & Sf)/
sum(
mag(Sf));
633 return vector(result, 0.0, 0.0);
635 case operationType::areaNormalIntegrate:
637 scalar result =
sum(values & Sf);
638 return vector(result, 0.0, 0.0);
643 return processSameTypeValues(values, Sf, weightField);
659 surfaceWriterPtr_(
nullptr),
660 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
661 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
662 weightFieldName_(
"none"),
663 orientWeightField_(
false),
683 surfaceWriterPtr_(
nullptr),
684 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
685 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
686 weightFieldName_(
"none"),
687 orientWeightField_(
false),
722 if (operation_ != operationType::none)
727 if (surfacePtr_.valid())
729 surfacePtr_().update();
739 totalArea_ = totalArea();
744 Log <<
" total area = " << totalArea_ <<
endl;
748 if (surfaceWriterPtr_.valid())
753 if (surfacePtr_.valid())
755 combineSurfaceGeometry(faces, points);
759 combineMeshGeometry(faces, points);
764 surfaceWriterPtr_->write
767 regionTypeNames_[regionType_] + (
"_" + regionName_),
777 if (weightFieldName_ !=
"none")
780 getFieldValues<scalar>
789 combineFields(weightField);
794 const word& fieldName = fields_[i];
797 bool orient = i >= orientedFieldsStart_;
798 ok = ok || writeValues<scalar>(fieldName, weightField, orient);
799 ok = ok || writeValues<vector>(fieldName, weightField, orient);
801 || writeValues<sphericalTensor>(fieldName, weightField, orient);
802 ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
803 ok = ok || writeValues<tensor>(fieldName, weightField, orient);
808 <<
"Requested field " << fieldName
809 <<
" not found in database and not processed"
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual ~surfaceFieldValue()
Destructor.
surfaceFieldValue(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
void initialise(const dictionary &dict)
Initialise, e.g. face addressing.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A face is a list of labels corresponding to mesh vertices.
A list of keyword definitions, which are a keyword followed by any number of values (e...
addToRunTimeSelectionTable(functionObject, fieldValueDelta, dictionary)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
An abstract class for surfaces with sampling.
virtual bool write()
Calculate and write.
static const NamedEnum< operationType, 17 > operationTypeNames_
Operation type names.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
void size(const label)
Override size to be inconsistent with allocated storage.
const boolList & flipMap() const
Return face flip map.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool read(const dictionary &dict)
Read from dictionary.
static bool master(const label communicator=0)
Am I the master process.
regionTypes
region type enumeration
Vector< scalar > vector
A scalar version of the templated Vector.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
dimensionedScalar neg(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
virtual const faceList & faces() const =0
Faces of surface.
operationType
Operation type enumeration.
A list of faces which address into the list of points.
A List obtained as a section of another List.
bool read(const char *, int32_t &)
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Type gSum(const FieldField< Field, Type > &f)
A class for handling words, derived from string.
defineTypeNameAndDebug(fieldValueDelta, 0)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Type processValues(const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const
Apply the 'operation' to the values. Wrapper around.
static const label labelMax
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
dimensionedScalar pos0(const dimensionedScalar &ds)
word name(const complex &)
Return a string representation of a complex.
void setSize(const label)
Reset size of List.
static bool & parRun()
Is this a parallel run?
static label nProcs(const label communicator=0)
Number of processes in parallel run.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
virtual bool read(const dictionary &)
Read from dictionary.
virtual const pointField & points() const =0
Points of surface.
prefixOSstream Pout(cout, "Pout")
label start() const
Return start label of this patch in the polyMesh face list.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
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.
#define Log
Report write to Foam::Info if the local log switch is true.
dimensioned< scalar > mag(const dimensioned< Type > &)
Base class for field value -based function objects.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const doubleScalar e
Elementary charge.
A subset of mesh faces organised as a primitive patch.
static const NamedEnum< regionTypes, 3 > regionTypeNames_
region type names
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A List with indirect addressing.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
virtual void writeFileHeader(const label i)
Output file header information.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
virtual bool write()
Write.
label whichFace(const label l) const
Return label of face in patch from global face label.