Go to the documentation of this file.
33 #include "indirectPrimitivePatch.H"
34 #include "PatchTools.H"
57 "sumDirectionBalance",
61 "weightedAreaAverage",
109 label faceI = fZone[i];
112 label facePatchId = -1;
113 if (
mesh().isInternalFace(faceI))
122 if (isA<coupledPolyPatch>(pp))
124 if (refCast<const coupledPolyPatch>(pp).owner())
133 else if (!isA<emptyPolyPatch>(pp))
155 facePatchIds.
append(facePatchId);
166 Pout<<
"Original face zone size = " << fZone.
size()
179 <<
type() <<
" " << name_ <<
": "
180 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):" <<
nl
181 <<
" Unknown patch name: " << sourceName_
182 <<
". Valid patch names are: "
183 <<
mesh().boundaryMesh().names() <<
nl
189 label nFaces = pp.size();
190 if (isA<emptyPolyPatch>(pp))
195 faceId_.setSize(nFaces);
196 facePatchId_.setSize(nFaces);
197 faceSign_.setSize(nFaces);
202 faceId_[faceI] = faceI;
204 faceSign_[faceI] = 1;
215 dict.subDict(
"sampledSurfaceDict")
217 surfacePtr_().update();
234 if (facePatchId_[i] != -1)
236 label patchI = facePatchId_[i];
237 globalFacesIs[i] +=
mesh().boundaryMesh()[patchI].start();
258 nFaces += allFaces[procI].
size();
273 const face&
f = fcs[i];
274 face& newF = faces[nFaces++];
294 const faceList& fcs = allFaces[procI];
297 const face&
f = fcs[i];
298 face& newF = faces[nFaces++];
331 <<
" down to " << newPoints.size() <<
" points" <<
endl;
334 points.transfer(newPoints);
349 if (surfacePtr_.valid())
356 scalar mergeDim = 1
e-10*
mesh().bounds().mag();
386 if (surfacePtr_.valid())
388 totalArea =
gSum(surfacePtr_().magSf());
392 totalArea =
gSum(filterField(
mesh().magSf(),
false));
415 case stSampledSurface:
417 sampledSurfaceFaces(
dict);
423 <<
type() <<
" " << name_ <<
": "
424 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):"
425 <<
nl <<
" Unknown source type. Valid source types are:"
433 <<
type() <<
" " << name_ <<
": "
434 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):" <<
nl
435 <<
" Source has no faces - deactivating" <<
endl;
441 if (surfacePtr_.valid())
443 surfacePtr_().update();
446 totalArea_ = totalArea();
449 <<
type() <<
" " << name_ <<
":" <<
nl
450 <<
" total faces = " << nFaces_ <<
nl
451 <<
" total area = " << totalArea_ <<
nl;
453 if (
dict.readIfPresent(
"weightField", weightFieldName_))
455 if (log_)
Info <<
" weight field = " << weightFieldName_ <<
nl;
457 if (source_ == stSampledSurface)
460 <<
"Cannot use weightField for a sampledSurface"
465 if (
dict.found(
"orientedWeightField"))
467 if (weightFieldName_ ==
"none")
469 dict.lookup(
"orientedWeightField") >> weightFieldName_;
470 if (log_)
Info <<
" weight field = " << weightFieldName_ <<
nl;
471 orientWeightField_ =
true;
476 <<
"Either weightField or orientedWeightField can be supplied, "
483 if (
dict.readIfPresent(
"orientedFields", orientedFields))
485 orientedFieldsStart_ = fields_.
size();
486 fields_.append(orientedFields);
493 const word surfaceFormat(
dict.lookup(
"surfaceFormat"));
495 surfaceWriterPtr_.reset
500 dict.subOrEmptyDict(
"formatOptions").
501 subOrEmptyDict(surfaceFormat)
510 writeHeaderValue(os,
"Source", sourceTypeNames_[source_]);
511 writeHeaderValue(os,
"Name", sourceName_);
512 writeHeaderValue(os,
"Faces", nFaces_);
513 writeHeaderValue(os,
"Total area", totalArea_);
514 writeHeaderValue(os,
"Scale factor", scaleFactor_);
516 writeCommented(os,
"Time");
524 os <<
tab << operationTypeNames_[operation_]
525 <<
"(" << fields_[i] <<
")";
544 vector n(dict_.lookup(
"direction"));
547 case opSumDirectionBalance:
549 vector n(dict_.lookup(
"direction"));
557 return processSameTypeValues(values, Sf, weightField);
575 vector n(dict_.lookup(
"direction"));
576 n /=
mag(
n) + ROOTVSMALL;
581 case opSumDirectionBalance:
583 vector n(dict_.lookup(
"direction"));
584 n /=
mag(
n) + ROOTVSMALL;
589 case opAreaNormalAverage:
592 return vector(result, 0.0, 0.0);
594 case opAreaNormalIntegrate:
596 scalar result =
gSum(values & Sf);
597 return vector(result, 0.0, 0.0);
602 return processSameTypeValues(values, Sf, weightField);
615 const bool loadFromFiles
619 surfaceWriterPtr_(NULL),
620 source_(sourceTypeNames_.read(
dict.lookup(
"source"))),
621 operation_(operationTypeNames_.read(
dict.lookup(
"operation"))),
622 weightFieldName_(
"none"),
623 orientWeightField_(
false),
625 writeArea_(
dict.lookupOrDefault(
"writeArea",
false)),
634 writeFileHeader(file());
665 if (surfacePtr_.valid())
667 surfacePtr_().update();
674 totalArea_ = totalArea();
675 file() <<
tab << totalArea_;
676 if (log_)
Info<<
" total area = " << totalArea_ <<
endl;
681 if (weightFieldName_ !=
"none")
684 setFieldValues<scalar>
695 const word& fieldName = fields_[i];
698 bool orient = i >= orientedFieldsStart_;
699 ok = ok || writeValues<scalar>(fieldName, weightField, orient);
700 ok = ok || writeValues<vector>(fieldName, weightField, orient);
702 writeValues<sphericalTensor>(fieldName, weightField, orient);
703 ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
704 ok = ok || writeValues<tensor>(fieldName, weightField, orient);
709 <<
"Requested field " << fieldName
710 <<
" not found in database and not processed"
virtual void write()
Calculate and write.
label nFaces_
Global number of faces.
A class for handling words, derived from string.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void setPatchFaces()
Set faces to evaluate based on a patch.
#define forAll(list, i)
Loop across all elements in list.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
bool read(const char *, int32_t &)
A List obtained as a section of another List.
static const label labelMax
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void sampledSurfaceFaces(const dictionary &)
Set faces according to sampledSurface.
static bool & parRun()
Is this a parallel run?
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
word sourceName_
Name of source object.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
labelList faceSign_
List of +1/-1 representing face flip map.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Type gSum(const FieldField< Field, Type > &f)
dimensioned< scalar > mag(const dimensioned< Type > &)
const labelList & faceId() const
Return the local list of face IDs.
const faceZoneMesh & faceZones() const
Return face zone mesh.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
Registry of regIOobjects.
virtual void read(const dictionary &dict)
Read from dictionary.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
Type processValues(const Field< Type > &values, const vectorField &Sf, const scalarField &weightField) const
Apply the 'operation' to the values. Wrapper around.
A subset of mesh faces organised as a primitive patch.
A patch is a list of labels that address the faces in the global face list.
void combineSurfaceGeometry(faceList &faces, pointField &points) const
Combine surface faces and points from multiple processors.
virtual void writeFileHeader(Ostream &os) const
Output file header information.
A List with indirect addressing.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
An abstract class for surfaces with sampling.
void initialise(const dictionary &dict)
Initialise, e.g. face addressing.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Macros for easy insertion into run-time selection tables.
label findZoneID(const word &zoneName) const
Find zone index given a name.
const double e
Elementary charge.
Vector< scalar > vector
A scalar version of the templated Vector.
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))
label start() const
Return start label of this patch in the polyMesh face list.
wordList names() const
Return a list of zone names.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual ~faceSource()
Destructor.
virtual void read(const dictionary &)
Read from dictionary.
void setSize(const label)
Reset size of List.
sourceType source_
Source type.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
label whichFace(const label l) const
Return label of face in patch from global face label.
prefixOSstream Pout(cout, "Pout")
Base class for field value-based function objects.
const word name_
Name of model.
static autoPtr< surfaceWriter > New(const word &writeType)
Return a reference to the selected surfaceWriter.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
static const NamedEnum< operationType, 15 > operationTypeNames_
Operation type names.
faceSource(const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false)
Construct from components.
A face is a list of labels corresponding to mesh vertices.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual void write()
Write to screen/file.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
addToRunTimeSelectionTable(fieldValue, cellSource, dictionary)
const fvMesh & mesh() const
Helper function to return the reference to the mesh.
const boolList & flipMap() const
Return face flip map.
labelList facePatchId_
Local list of patch ID per face.
dimensionedScalar neg(const dimensionedScalar &ds)
#define WarningInFunction
Report a warning using Foam::Warning.
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.
scalar totalArea() const
Calculate and return total area of the faceSource: sum(magSf)
void combineMeshGeometry(faceList &faces, pointField &points) const
Combine mesh faces and points from multiple processors.
word name(const complex &)
Return a string representation of a complex.
labelList faceId_
Local list of face IDs.
defineTypeNameAndDebug(cellSource, 0)
void setFaceZoneFaces()
Set faces to evaluate based on a face zone.
Initialise the NamedEnum HashTable from the static list of names.
A list of faces which address into the list of points.
static const NamedEnum< sourceType, 3 > sourceTypeNames_
Source type names.
dimensionedScalar pos(const dimensionedScalar &ds)