41 namespace functionObjects
75 "sumDirectionBalance",
79 "weightedAreaAverage",
103 void Foam::functionObjects::fieldValues::surfaceRegion::setFaceZoneFaces()
105 label zoneId =
mesh().faceZones().findZoneID(regionName_);
111 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 112 <<
" Unknown face zone name: " << regionName_
113 <<
". Valid face zones are: " <<
mesh().faceZones().names()
125 label facei = fZone[i];
128 label facePatchId = -1;
129 if (
mesh().isInternalFace(facei))
136 facePatchId =
mesh().boundaryMesh().whichPatch(facei);
138 if (isA<coupledPolyPatch>(pp))
140 if (refCast<const coupledPolyPatch>(pp).owner())
149 else if (!isA<emptyPolyPatch>(pp))
151 faceId = facei - pp.
start();
164 faceSigns.append(-1);
170 faceIds.append(faceId);
171 facePatchIds.append(facePatchId);
175 faceId_.transfer(faceIds);
176 facePatchId_.transfer(facePatchIds);
177 faceSign_.transfer(faceSigns);
182 Pout<<
"Original face zone size = " << fZone.
size()
183 <<
", new size = " << faceId_.size() <<
endl;
188 void Foam::functionObjects::fieldValues::surfaceRegion::setPatchFaces()
190 const label patchid =
mesh().boundaryMesh().findPatchID(regionName_);
196 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 197 <<
" Unknown patch name: " << regionName_
198 <<
". Valid patch names are: " 199 <<
mesh().boundaryMesh().names() <<
nl 205 label nFaces = pp.size();
206 if (isA<emptyPolyPatch>(pp))
211 faceId_.setSize(nFaces);
212 facePatchId_.setSize(nFaces);
213 faceSign_.setSize(nFaces);
218 faceId_[facei] = facei;
219 facePatchId_[facei] = patchid;
220 faceSign_[facei] = 1;
225 void Foam::functionObjects::fieldValues::surfaceRegion::sampledSurfaceFaces
234 dict.
subDict(
"sampledSurfaceDict")
236 surfacePtr_().update();
241 void Foam::functionObjects::fieldValues::surfaceRegion::combineMeshGeometry
253 if (facePatchId_[i] != -1)
256 globalFacesIs[i] +=
mesh().boundaryMesh()[
patchi].start();
277 nFaces += allFaces[proci].
size();
278 nPoints += allPoints[proci].
size();
292 const face&
f = fcs[i];
293 face& newF = faces[nFaces++];
304 points[nPoints++] = pts[i];
313 const faceList& fcs = allFaces[proci];
316 const face&
f = fcs[i];
317 face& newF = faces[nFaces++];
328 points[nPoints++] = pts[i];
349 Pout<<
"Merged from " << points.
size()
350 <<
" down to " << newPoints.
size() <<
" points" <<
endl;
362 void Foam::functionObjects::fieldValues::surfaceRegion::combineSurfaceGeometry
368 if (surfacePtr_.valid())
375 scalar mergeDim = 1
e-10*
mesh().bounds().mag();
402 Foam::functionObjects::fieldValues::surfaceRegion::totalArea()
const 406 if (surfacePtr_.valid())
408 totalArea =
gSum(surfacePtr_().magSf());
412 totalArea =
gSum(filterField(
mesh().magSf(),
false));
426 dict.
lookup(
"name") >> regionName_;
440 case stSampledSurface:
442 sampledSurfaceFaces(dict);
449 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 450 <<
nl <<
" Unknown region type. Valid region types are:" 459 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 463 if (surfacePtr_.valid())
465 surfacePtr_().update();
468 totalArea_ = totalArea();
471 <<
" total faces = " << nFaces_
473 <<
" total area = " << totalArea_
478 Info<<
" weight field = " << weightFieldName_ <<
nl;
480 if (regionType_ == stSampledSurface)
483 <<
"Cannot use weightField for a sampledSurface" 488 if (dict.
found(
"orientedWeightField"))
490 if (weightFieldName_ ==
"none")
492 dict.
lookup(
"orientedWeightField") >> weightFieldName_;
493 Info<<
" weight field = " << weightFieldName_ <<
nl;
494 orientWeightField_ =
true;
499 <<
"Either weightField or orientedWeightField can be supplied, " 508 orientedFieldsStart_ = fields_.
size();
509 fields_.append(orientedFields);
514 Info<<
" scale factor = " << scaleFactor_ <<
nl;
521 const word surfaceFormat(dict.
lookup(
"surfaceFormat"));
523 surfaceWriterPtr_.reset
529 subOrEmptyDict(surfaceFormat)
541 writeCommented(file(),
"Region type : ");
542 file() << regionTypeNames_[regionType_] <<
" " << regionName_ <<
endl;
543 writeCommented(file(),
"Faces : ");
544 file() << nFaces_ <<
endl;
545 writeCommented(file(),
"Area : ");
546 file() << totalArea_ <<
endl;
548 writeCommented(file(),
"Time");
551 file() <<
tab <<
"Area";
557 <<
tab << operationTypeNames_[operation_]
558 <<
"(" << fields_[i] <<
")";
577 vector n(dict_.lookup(
"direction"));
580 case opSumDirectionBalance:
582 vector n(dict_.lookup(
"direction"));
590 return processSameTypeValues(values, Sf, weightField);
608 vector n(dict_.lookup(
"direction"));
609 n /=
mag(
n) + ROOTVSMALL;
614 case opSumDirectionBalance:
616 vector n(dict_.lookup(
"direction"));
617 n /=
mag(
n) + ROOTVSMALL;
622 case opAreaNormalAverage:
624 scalar result =
sum(values & Sf)/
sum(
mag(Sf));
625 return vector(result, 0.0, 0.0);
627 case opAreaNormalIntegrate:
629 scalar result =
sum(values & Sf);
630 return vector(result, 0.0, 0.0);
635 return processSameTypeValues(values, Sf, weightField);
651 surfaceWriterPtr_(NULL),
652 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
653 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
654 weightFieldName_(
"none"),
655 orientWeightField_(
false),
664 if (!isA<fvMesh>(obr_))
681 surfaceWriterPtr_(NULL),
682 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
683 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
684 weightFieldName_(
"none"),
685 orientWeightField_(
false),
694 if (!isA<fvMesh>(obr_))
728 if (surfacePtr_.valid())
730 surfacePtr_().update();
740 totalArea_ = totalArea();
743 file() <<
tab << totalArea_;
745 Log <<
" total area = " << totalArea_ <<
endl;
750 if (weightFieldName_ !=
"none")
753 getFieldValues<scalar>
762 combineFields(weightField);
767 const word& fieldName = fields_[i];
770 bool orient = i >= orientedFieldsStart_;
771 ok = ok || writeValues<scalar>(fieldName, weightField, orient);
772 ok = ok || writeValues<vector>(fieldName, weightField, orient);
774 || writeValues<sphericalTensor>(fieldName, weightField, orient);
775 ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
776 ok = ok || writeValues<tensor>(fieldName, weightField, orient);
781 <<
"Requested field " << fieldName
782 <<
" not found in database and not processed"
#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 bool write()
Calculate and write.
label whichFace(const label l) const
Return label of face in patch from global face label.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const boolList & flipMap() const
Return face flip map.
A face is a list of labels corresponding to mesh vertices.
const double e
Elementary charge.
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.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
void size(const label)
Override size to be inconsistent with allocated storage.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
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.
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)
static const NamedEnum< operationType, 15 > operationTypeNames_
Operation type names.
Macros for easy insertion into run-time selection tables.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void initialise(const dictionary &dict)
Initialise, e.g. face addressing.
virtual const faceList & faces() const =0
Faces of surface.
virtual ~surfaceRegion()
Destructor.
dimensionedScalar pos(const dimensionedScalar &ds)
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))
surfaceRegion(const word &name, const Time &runTime, const dictionary &dict)
Construct from name, Time and dictionary.
Type gSum(const FieldField< Field, Type > &f)
label start() const
Return start label of this patch in the polyMesh face list.
A class for handling words, derived from string.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
defineTypeNameAndDebug(fieldValueDelta, 0)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
static const label labelMax
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
static const NamedEnum< regionTypes, 3 > regionTypeNames_
region type names
Type processValues(const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const
Apply the 'operation' to the values. Wrapper around.
prefixOSstream Pout(cout,"Pout")
operationType
Operation type enumeration.
word name(const complex &)
Return a string representation of a complex.
virtual bool read(const dictionary &)
Read from dictionary.
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.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
virtual const pointField & points() const =0
Points of surface.
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 > &)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A subset of mesh faces organised as a primitive patch.
virtual void writeFileHeader(const label i)
Output file header information.
Registry of regIOobjects.
A patch is a list of labels that address the faces in the global face list.
regionTypes
region type enumeration
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
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.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
virtual bool write()
Write to screen/file.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.