42 namespace functionObjects
76 "sumDirectionBalance",
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()
120 mesh_.polyBFacePatches();
121 mesh_.polyBFacePatchFaces();
131 const label facei = zone[zoneFacei];
132 const label faceSign = zone.
flipMap()[zoneFacei] ? -1 : 1;
134 if (mesh_.isInternalFace(facei))
137 facePatchIds.append(-1);
138 faceSigns.append(faceSign);
142 const label bFacei = facei - mesh_.nInternalFaces();
145 const labelUList patchFaces = mesh_.polyBFacePatchFaces()[bFacei];
150 const fvPatch& fvp = mesh_.boundary()[patches[i]];
153 isType<processorFvPatch>(fvp)
154 && refCast<const processorFvPatch>(fvp).neighbour()
160 faceIds.append(patchFaces[i]);
161 facePatchIds.append(patches[i]);
162 faceSigns.append(faceSign);
167 faceId_.transfer(faceIds);
168 facePatchId_.transfer(facePatchIds);
169 faceSign_.transfer(faceSigns);
175 void Foam::functionObjects::fieldValues::surfaceFieldValue::setPatchFaces()
177 const label patchId = mesh_.boundaryMesh().findPatchID(regionName_);
183 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 184 <<
" Unknown patch name: " << regionName_
185 <<
". Valid patch names are: " 186 << mesh_.boundaryMesh().names() <<
nl 204 isA<processorCyclicFvPatch>(fvp)
205 && refCast<const processorCyclicFvPatch>(fvp).referPatchID() == patchId
218 void Foam::functionObjects::fieldValues::surfaceFieldValue::sampledSurfaceFaces
227 dict.
subDict(
"sampledSurfaceDict")
229 surfacePtr_().update();
234 void Foam::functionObjects::fieldValues::surfaceFieldValue::combineMeshGeometry
246 if (facePatchId_[i] != -1)
249 globalFacesIs[i] += mesh_.boundaryMesh()[
patchi].start();
270 nFaces += allFaces[proci].size();
271 nPoints += allPoints[proci].
size();
285 const face&
f = fcs[i];
286 face& newF = faces[nFaces++];
297 points[nPoints++] = pts[i];
306 const faceList& fcs = allFaces[proci];
309 const face&
f = fcs[i];
310 face& newF = faces[nFaces++];
321 points[nPoints++] = pts[i];
342 Pout<<
"Merged from " << points.
size()
343 <<
" down to " << newPoints.
size() <<
" points" <<
endl;
355 void Foam::functionObjects::fieldValues::surfaceFieldValue::
356 combineSurfaceGeometry
362 if (regionType_ == regionTypes::sampledSurface)
369 scalar mergeDim = 1
e-10*mesh_.bounds().mag();
396 Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea()
const 398 if (regionType_ == regionTypes::sampledSurface)
400 return gSum(surfacePtr_().magSf());
404 return gSum(filterField(mesh_.magSf()));
418 case regionTypes::faceZone:
420 dict.
lookup(
"name") >> regionName_;
424 case regionTypes::patch:
426 dict.
lookup(
"name") >> regionName_;
430 case regionTypes::sampledSurface:
432 sampledSurfaceFaces(dict);
433 regionName_ = surfacePtr_().name();
440 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" 441 <<
nl <<
" Unknown region type. Valid region types are:" 446 if (nFaces_ == 0 && (!mesh_.stitcher().stitches() || !mesh_.conformal()))
450 << regionTypeNames_[regionType_] <<
"(" << regionName_ <<
"):" <<
nl 454 if (regionType_ == regionTypes::sampledSurface)
456 surfacePtr_().update();
459 totalArea_ = totalArea();
462 <<
" total faces = " << nFaces_
464 <<
" total area = " << totalArea_
469 Info<<
name() <<
" " << operationTypeNames_[operation_]
470 <<
" weight fields " << weightFieldNames_;
472 else if (dict.
found(
"weightField"))
474 weightFieldNames_.setSize(1);
475 dict.
lookup(
"weightField") >> weightFieldNames_[0];
477 Info<<
name() <<
" " << operationTypeNames_[operation_]
478 <<
" weight field " << weightFieldNames_[0];
483 Info<<
" scale factor = " << scaleFactor_ <<
nl;
490 const word surfaceFormat(dict.
lookup(
"surfaceFormat"));
492 surfaceWriterPtr_.reset
505 if (operation_ != operationType::none)
507 writeCommented(
file(),
"Region type : ");
508 file() << regionTypeNames_[regionType_] <<
" " << regionName_ <<
endl;
509 writeCommented(
file(),
"Faces : ");
511 writeCommented(
file(),
"Area : ");
514 writeCommented(
file(),
"Time");
523 <<
tab << operationTypeNames_[operation_]
524 <<
"(" << fields_[fieldi] <<
")";
543 case operationType::sumDirection:
545 const vector n(dict_.lookup(
"direction"));
546 result =
gSum(weights*
pos0(values*(Sf &
n))*
mag(values));
549 case operationType::sumDirectionBalance:
551 const vector n(dict_.lookup(
"direction"));
559 return processValuesTypeType
583 case operationType::areaNormalAverage:
585 result =
gSum(weights*values & Sf)/
gSum(
mag(weights*Sf));
588 case operationType::areaNormalIntegrate:
590 result =
gSum(weights*values & Sf);
612 case operationType::sumDirection:
616 result =
gSum(weights*
pos0(nv)*n*(nv));
619 case operationType::sumDirectionBalance:
623 result =
gSum(weights*
pos0(nv)*n*(nv));
629 return processValuesTypeType
653 surfaceWriterPtr_(
nullptr),
654 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
655 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
676 surfaceWriterPtr_(
nullptr),
677 regionType_(regionTypeNames_.read(dict.
lookup(
"regionType"))),
678 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
713 if (operation_ != operationType::none)
718 if (regionType_ == regionTypes::sampledSurface)
720 surfacePtr_().update();
730 totalArea_ = totalArea();
735 Log <<
" total area = " << totalArea_ <<
endl;
744 if (regionType_ == regionTypes::sampledSurface)
746 combineSurfaceGeometry(faces, points);
750 combineMeshGeometry(faces, points);
755 surfaceWriterPtr_->write
758 regionTypeNames_[regionType_] + (
"_" + regionName_),
768 regionType_ == regionTypes::sampledSurface
773 forAll(weightFieldNames_, i)
775 weights *= getFieldValues<scalar>(weightFieldNames_[i]);
779 regionType_ == regionTypes::sampledSurface
781 : (signs*filterField(mesh_.Sf()))()
787 const word& fieldName = fields_[i];
790 #define writeValuesFieldType(fieldType, none) \ 793 || writeValues<fieldType> \ 801 #undef writeValuesFieldType 806 <<
"Requested field " << fieldName
807 <<
" not found in database and not processed" 842 if (&map.
mesh() == &mesh_)
854 if (&map.
mesh() == &mesh_)
const fvPatchList & patches
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.
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.
virtual bool write()
Calculate and write.
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.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
static bool master(const label communicator=0)
Am I the master process.
regionTypes
region type enumeration
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Initialise the NamedEnum HashTable from the static list of names.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
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 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
A class for handling words, derived from string.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void append(const T &)
Append an element at the end of the list.
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.
List< label > labelList
A List of labels.
static autoPtr< surfaceWriter > New(const word &writeType, const IOstream::streamFormat writeFormat, const IOstream::compressionType writeCompression)
Select given write options.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const polyMesh & mesh() const
Return polyMesh.
virtual label size() const
Return size.
dimensionedScalar pos0(const dimensionedScalar &ds)
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
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.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
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")
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.
FOR_ALL_FIELD_TYPES(DefineFvWallInfoType)
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.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
static const NamedEnum< regionTypes, 3 > regionTypeNames_
region type names
Registry of regIOobjects.
Class containing mesh-to-mesh mapping information.
const polyMesh & mesh() const
Return polyMesh.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
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.