57 "sumDirectionBalance",
61 "weightedAreaAverage",
87 void Foam::fieldValues::faceSource::setFaceZoneFaces()
89 label zoneId =
mesh().faceZones().findZoneID(sourceName_);
93 FatalErrorIn(
"faceSource::faceSource::setFaceZoneFaces()")
94 <<
type() <<
" " << name_ <<
": " 95 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):" <<
nl 96 <<
" Unknown face zone name: " << sourceName_
97 <<
". Valid face zones are: " <<
mesh().faceZones().names()
109 label faceI = fZone[i];
112 label facePatchId = -1;
113 if (
mesh().isInternalFace(faceI))
120 facePatchId =
mesh().boundaryMesh().whichPatch(faceI);
122 if (isA<coupledPolyPatch>(pp))
124 if (refCast<const coupledPolyPatch>(pp).owner())
133 else if (!isA<emptyPolyPatch>(pp))
135 faceId = faceI - pp.
start();
148 faceSigns.append(-1);
154 faceIds.append(faceId);
155 facePatchIds.append(facePatchId);
159 faceId_.transfer(faceIds);
160 facePatchId_.transfer(facePatchIds);
161 faceSign_.transfer(faceSigns);
166 Pout<<
"Original face zone size = " << fZone.
size()
167 <<
", new size = " << faceId_.size() <<
endl;
172 void Foam::fieldValues::faceSource::setPatchFaces()
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;
209 void Foam::fieldValues::faceSource::sampledSurfaceFaces(
const dictionary& dict)
215 dict.
subDict(
"sampledSurfaceDict")
217 surfacePtr_().update();
222 void Foam::fieldValues::faceSource::combineMeshGeometry
234 if (facePatchId_[i] != -1)
236 label patchI = facePatchId_[i];
237 globalFacesIs[i] +=
mesh().boundaryMesh()[patchI].start();
258 nFaces += allFaces[procI].
size();
259 nPoints += allPoints[procI].
size();
273 const face&
f = fcs[i];
274 face& newF = faces[nFaces++];
285 points[nPoints++] = pts[i];
294 const faceList& fcs = allFaces[procI];
297 const face&
f = fcs[i];
298 face& newF = faces[nFaces++];
309 points[nPoints++] = pts[i];
330 Pout<<
"Merged from " << points.
size()
331 <<
" down to " << newPoints.
size() <<
" points" <<
endl;
343 void Foam::fieldValues::faceSource::combineSurfaceGeometry
349 if (surfacePtr_.valid())
356 scalar mergeDim = 1
e-10*
mesh().bounds().mag();
382 Foam::scalar Foam::fieldValues::faceSource::totalArea()
const 386 if (surfacePtr_.valid())
388 totalArea =
gSum(surfacePtr_().magSf());
392 totalArea =
gSum(filterField(
mesh().magSf(),
false));
403 dict.
lookup(
"sourceName") >> sourceName_;
417 case stSampledSurface:
419 sampledSurfaceFaces(dict);
425 <<
type() <<
" " << name_ <<
": " 426 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):" 427 <<
nl <<
" Unknown source type. Valid source types are:" 436 "Foam::fieldValues::faceSource::initialise(const dictionary&)" 438 <<
type() <<
" " << name_ <<
": " 439 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):" <<
nl 440 <<
" Source has no faces - deactivating" <<
endl;
446 if (surfacePtr_.valid())
448 surfacePtr_().update();
451 totalArea_ = totalArea();
454 <<
" total faces = " << nFaces_
456 <<
" total area = " << totalArea_
461 Info<<
" weight field = " << weightFieldName_ <<
nl;
463 if (source_ == stSampledSurface)
467 "void Foam::fieldValues::faceSource::initialise" 473 <<
"Cannot use weightField for a sampledSurface" 478 if (dict.
found(
"orientedWeightField"))
480 if (weightFieldName_ ==
"none")
482 dict.
lookup(
"orientedWeightField") >> weightFieldName_;
483 Info<<
" weight field = " << weightFieldName_ <<
nl;
484 orientWeightField_ =
true;
490 "void Foam::fieldValues::faceSource::initialise" 496 <<
"Either weightField or orientedWeightField can be supplied, " 505 orientedFieldsStart_ = fields_.
size();
506 fields_.append(orientedFields);
511 Info<<
" scale factor = " << scaleFactor_ <<
nl;
518 const word surfaceFormat(dict.
lookup(
"surfaceFormat"));
520 surfaceWriterPtr_.reset
526 subOrEmptyDict(surfaceFormat)
535 writeCommented(file(),
"Source : ");
536 file() << sourceTypeNames_[source_] <<
" " << sourceName_ <<
endl;
537 writeCommented(file(),
"Faces : ");
538 file() << nFaces_ <<
endl;
539 writeCommented(file(),
"Area : ");
540 file() << totalArea_ <<
endl;
542 writeCommented(file(),
"Time");
545 file() <<
tab <<
"Area";
551 <<
tab << operationTypeNames_[operation_]
552 <<
"(" << fields_[i] <<
")";
571 vector n(dict_.lookup(
"direction"));
574 case opSumDirectionBalance:
576 vector n(dict_.lookup(
"direction"));
584 return processSameTypeValues(values, Sf, weightField);
602 vector n(dict_.lookup(
"direction"));
603 n /=
mag(
n) + ROOTVSMALL;
608 case opSumDirectionBalance:
610 vector n(dict_.lookup(
"direction"));
611 n /=
mag(
n) + ROOTVSMALL;
616 case opAreaNormalAverage:
618 scalar result =
sum(values & Sf)/
sum(
mag(Sf));
619 return vector(result, 0.0, 0.0);
621 case opAreaNormalIntegrate:
623 scalar result =
sum(values & Sf);
624 return vector(result, 0.0, 0.0);
629 return processSameTypeValues(values, Sf, weightField);
642 const bool loadFromFiles
645 fieldValue(name, obr, dict, typeName, loadFromFiles),
646 surfaceWriterPtr_(NULL),
647 source_(sourceTypeNames_.read(dict.
lookup(
"source"))),
648 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
649 weightFieldName_(
"none"),
650 orientWeightField_(
false),
688 if (surfacePtr_.valid())
690 surfacePtr_().update();
695 file() << obr_.time().value();
700 totalArea_ = totalArea();
703 file() <<
tab << totalArea_;
705 if (log_)
Info<<
" total area = " << totalArea_ <<
endl;
710 if (weightFieldName_ !=
"none")
713 getFieldValues<scalar>
722 combineFields(weightField);
727 const word& fieldName = fields_[i];
730 bool orient = i >= orientedFieldsStart_;
731 ok = ok || writeValues<scalar>(fieldName, weightField, orient);
732 ok = ok || writeValues<vector>(fieldName, weightField, orient);
734 || writeValues<sphericalTensor>(fieldName, weightField, orient);
735 ok = ok || writeValues<symmTensor>(fieldName, weightField, orient);
736 ok = ok || writeValues<tensor>(fieldName, weightField, orient);
740 WarningIn(
"void Foam::fieldValues::faceSource::write()")
741 <<
"Requested field " << fieldName
742 <<
" not found in database and not processed" static bool & parRun()
Is this a parallel run?
A List with indirect addressing.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
const pointField & points
const boolList & flipMap() const
Return face flip map.
static const NamedEnum< sourceType, 3 > sourceTypeNames_
Source type names.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensionedScalar neg(const dimensionedScalar &ds)
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 ))
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
dimensioned< scalar > mag(const dimensioned< Type > &)
static const NamedEnum< operationType, 15 > operationTypeNames_
Operation type names.
An abstract class for surfaces with sampling.
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
A subset of mesh faces organised as a primitive patch.
A class for handling words, derived from string.
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 ~faceSource()
Destructor.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Base class for field value -based function objects.
A list of keyword definitions, which are a keyword followed by any number of values (e...
virtual void write()
Write to screen/file.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
void initialise(const dictionary &dict)
Initialise, e.g. face addressing.
virtual void read(const dictionary &dict)
Read from dictionary.
A patch is a list of labels that address the faces in the global face list.
Type gSum(const FieldField< Field, Type > &f)
virtual void writeFileHeader(const label i)
Output file header information.
A face is a list of labels corresponding to mesh vertices.
static void gatherAndMerge(const scalar mergeDist, const PrimitivePatch< Face, FaceList, PointField, PointType > &p, Field< PointType > &mergedPoints, List< Face > &mergedFaces, labelList &pointMergeMap)
Gather points and faces onto master and merge into single patch.
const Field< PointType > & localPoints() const
Return pointField of points in patch.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
const double e
Elementary charge.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
faceSource(const word &name, const objectRegistry &obr, const dictionary &dict, const bool loadFromFiles=false)
Construct from components.
Macros for easy insertion into run-time selection tables.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Initialise the NamedEnum HashTable from the static list of names.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
A list of faces which address into the list of points.
addToRunTimeSelectionTable(fieldValue, cellSource, dictionary)
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
virtual void read(const dictionary &)
Read from dictionary.
label start() const
Return start label of this patch in the polyMesh face list.
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.
static autoPtr< sampledSurface > New(const word &name, const polyMesh &, const dictionary &)
Return a reference to the selected surface.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Registry of regIOobjects.
defineTypeNameAndDebug(cellSource, 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.
Vector< scalar > vector
A scalar version of the templated Vector.
static bool master(const label communicator=0)
Am I the master process.
bool read(const char *, int32_t &)
virtual const pointField & points() const =0
Points of surface.
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
A List obtained as a section of another List.
virtual const faceList & faces() const =0
Faces of surface.
dimensionedScalar pos(const dimensionedScalar &ds)
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
virtual void write()
Calculate and write.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
label whichFace(const label l) const
Return label of face in patch from global face label.
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.
prefixOSstream Pout(cout,"Pout")
static const label labelMax