39 namespace functionObjects
73 "sumDirectionBalance",
102 void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
104 label zoneId = mesh_.faceZones().findZoneID(regionName_);
110 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 111 <<
" Unknown face zone name: " << regionName_
112 <<
". Valid face zones are: " << mesh_.faceZones().names()
116 const faceZone& fZone = mesh_.faceZones()[zoneId];
124 label facei = fZone[i];
127 label facePatchId = -1;
128 if (mesh_.isInternalFace(facei))
135 facePatchId = mesh_.boundaryMesh().whichPatch(facei);
137 if (isA<coupledPolyPatch>(pp))
139 if (refCast<const coupledPolyPatch>(pp).owner())
148 else if (!isA<emptyPolyPatch>(pp))
150 faceId = facei - pp.
start();
163 faceSigns.append(-1);
169 faceIds.append(faceId);
170 facePatchIds.append(facePatchId);
174 faceId_.transfer(faceIds);
175 facePatchId_.transfer(facePatchIds);
176 faceSign_.transfer(faceSigns);
181 Pout<<
"Original face zone size = " << fZone.
size()
182 <<
", new size = " << faceId_.size() <<
endl;
187 void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
189 const label patchid = mesh_.boundaryMesh().findPatchID(regionName_);
195 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 196 <<
" Unknown patch name: " << regionName_
197 <<
". Valid patch names are: " 198 << mesh_.boundaryMesh().names() <<
nl 204 label nFaces = pp.size();
205 if (isA<emptyPolyPatch>(pp))
210 faceId_.setSize(nFaces);
211 facePatchId_.setSize(nFaces);
212 faceSign_.setSize(nFaces);
217 faceId_[facei] = facei;
218 facePatchId_[facei] = patchid;
219 faceSign_[facei] = 1;
224 void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
233 dict.
subDict(
"sampledSurfaceDict")
235 surfacePtr_().update();
240 void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
252 if (facePatchId_[i] != -1)
255 globalFacesIs[i] += mesh_.boundaryMesh()[
patchi].start();
276 nFaces += allFaces[proci].size();
277 nPoints += allPoints[proci].
size();
291 const face&
f = fcs[i];
292 face& newF = faces[nFaces++];
303 points[nPoints++] = pts[i];
312 const faceList& fcs = allFaces[proci];
315 const face&
f = fcs[i];
316 face& newF = faces[nFaces++];
327 points[nPoints++] = pts[i];
348 Pout<<
"Merged from " << points.
size()
349 <<
" down to " << newPoints.
size() <<
" points" <<
endl;
361 void Foam::functionObjects::fieldValues::surfaceFieldValue::
362 combineSurfaceGeometry
368 if (regionType_ == regionTypes::sampledSurface)
375 scalar mergeDim = 1
e-10*mesh_.bounds().mag();
402 Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea()
const 404 if (regionType_ == regionTypes::sampledSurface)
406 return gSum(surfacePtr_().magSf());
410 return gSum(filterField(mesh_.magSf()));
424 case regionTypes::faceZone:
426 dict.
lookup(
"name") >> regionName_;
430 case regionTypes::patch:
432 dict.
lookup(
"name") >> regionName_;
436 case regionTypes::sampledSurface:
438 sampledSurfaceFaces(dict);
439 regionName_ = surfacePtr_().name();
446 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 447 <<
nl <<
" Unknown region type. Valid region types are:" 456 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 460 if (regionType_ == regionTypes::sampledSurface)
462 surfacePtr_().update();
465 totalArea_ = totalArea();
468 <<
" total faces = " << nFaces_
470 <<
" total area = " << totalArea_
475 Info<<
name() <<
" " << operationTypeNames_[operation_]
476 <<
" weight fields " << weightFieldNames_;
478 else if (dict.
found(
"weightField"))
480 weightFieldNames_.setSize(1);
481 dict.
lookup(
"weightField") >> weightFieldNames_[0];
483 Info<<
name() <<
" " << operationTypeNames_[operation_]
484 <<
" weight field " << weightFieldNames_[0];
489 Info<<
" scale factor = " << scaleFactor_ <<
nl;
496 const word surfaceFormat(dict.
lookup(
"surfaceFormat"));
498 surfaceWriterPtr_.reset
511 if (operation_ != operationType::none)
513 writeCommented(
file(),
"Region type : ");
514 file() << regionTypeNames_[regionType_] <<
" " << regionName_ <<
endl;
515 writeCommented(
file(),
"Faces : ");
517 writeCommented(
file(),
"Area : ");
520 writeCommented(
file(),
"Time");
529 <<
tab << operationTypeNames_[operation_]
530 <<
"(" << fields_[fieldi] <<
")";
549 case operationType::sumDirection:
551 const vector n(dict_.lookup(
"direction"));
552 result =
gSum(weights*
pos0(values*(Sf &
n))*
mag(values));
555 case operationType::sumDirectionBalance:
557 const vector n(dict_.lookup(
"direction"));
565 return processValuesTypeType
589 case operationType::areaNormalAverage:
591 result =
gSum(weights*values & Sf)/
gSum(
mag(weights*Sf));
594 case operationType::areaNormalIntegrate:
596 result =
gSum(weights*values & Sf);
618 case operationType::sumDirection:
622 result =
gSum(weights*
pos0(nv)*n*(nv));
625 case operationType::sumDirectionBalance:
629 result =
gSum(weights*
pos0(nv)*n*(nv));
635 return processValuesTypeType
658 surfaceWriterPtr_(
nullptr),
659 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
660 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
680 surfaceWriterPtr_(
nullptr),
681 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
682 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
717 if (operation_ != operationType::none)
722 if (regionType_ == regionTypes::sampledSurface)
724 surfacePtr_().update();
734 totalArea_ = totalArea();
739 Log <<
" total area = " << totalArea_ <<
endl;
748 if (regionType_ == regionTypes::sampledSurface)
750 combineSurfaceGeometry(faces, points);
754 combineMeshGeometry(faces, points);
759 surfaceWriterPtr_->write
762 regionTypeNames_[regionType_] + (
"_" + regionName_),
772 regionType_ == regionTypes::sampledSurface
777 forAll(weightFieldNames_, i)
779 weights *= getFieldValues<scalar>(weightFieldNames_[i]);
783 regionType_ == regionTypes::sampledSurface
785 : (signs*filterField(mesh_.Sf()))()
791 const word& fieldName = fields_[i];
794 #define writeValuesFieldType(fieldType, none) \ 797 || writeValues<fieldType> \ 805 #undef writeValuesFieldType 810 <<
"Requested field " << fieldName
811 <<
" 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.
static const NamedEnum< operationType, 16 > operationTypeNames_
Operation type names.
static autoPtr< surfaceWriter > New(const word &writeType, const IOstream::streamFormat writeFormat)
Return a reference to the selected surfaceWriter.
virtual bool write()
Calculate and write.
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
#define FOR_ALL_FIELD_TYPES(Macro,...)
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.
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.
#define writeValuesFieldType(fieldType, none)
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)
Form normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
A class for handling words, derived from string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
defineTypeNameAndDebug(fieldValueDelta, 0)
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
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.
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.
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.
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.