40 namespace functionObjects
55 Foam::fileName Foam::functionObjects::patchCutLayerAverage::outputPath()
const
67 Foam::functionObjects::patchCutLayerAverage::calcNonInterpolatingWeights
77 const polyPatch& pp = mesh_.boundaryMesh()[patchName_];
78 const faceList& faces = pp.localFaces();
84 DynamicList<weight> dynWeights(faces.size()*2);
88 const label facei = faceMinOrder[i];
90 const scalar a = faceAreas[facei] & faceNormals[facei];
93 while (faceMinXs[facei] > plotXs[layeri + 1]) layeri ++;
96 label layerj = layeri;
97 while (faceMaxXs[facei] > plotXs[layerj])
100 dynWeights.append({facei, layerj, a});
103 if (faceMinXs[facei] < plotXs[layerj])
105 dynWeights.last().value -=
120 ) & faceNormals[facei];
124 if (faceMaxXs[facei] > plotXs[layerj + 1])
126 dynWeights.last().value -=
141 ) & faceNormals[facei];
149 List<weight> weights;
150 weights.transfer(dynWeights);
158 layerWeightSums[weights[weighti].layeri] += weights[weighti].value;
166 weights[weighti].value /=
167 (layerWeightSums[weights[weighti].layeri] + vSmall);
176 Foam::functionObjects::patchCutLayerAverage::calcInterpolatingWeights
186 const polyPatch& pp = mesh_.boundaryMesh()[patchName_];
187 const faceList& faces = pp.localFaces();
198 DynamicList<weight> dynWeights(faces.size()*2);
202 const label facei = faceMinOrder[i];
204 const scalar a = faceAreas[facei] & faceNormals[facei];
207 while (faceMinXs[facei] > plotXs[layeri + 1]) layeri ++;
210 label layerj = layeri;
211 while (faceMaxXs[facei] > plotXs[
max(layerj - 1, 0)])
214 dynWeights.append({facei, layerj, 0});
217 if (layerj > 0 && faceMinXs[facei] < plotXs[layerj])
221 forAll(faces[facei], facePointi)
223 const label pointi = faces[facei][facePointi];
225 (pointXs[pointi] - plotXs[layerj - 1])
226 /(plotXs[layerj] - plotXs[layerj - 1]);
237 dynWeights.last().value += faceF*a;
240 if (faceMinXs[facei] < plotXs[layerj - 1])
242 dynWeights.last().value -=
259 ).second() & faceNormals[facei];
263 if (faceMaxXs[facei] > plotXs[layerj])
265 dynWeights.last().value -=
282 ).second() & faceNormals[facei];
287 if (layerj < nLayers_ - 1 && faceMaxXs[facei] > plotXs[layerj])
291 forAll(faces[facei], facePointi)
293 const label pointi = faces[facei][facePointi];
295 (plotXs[layerj + 1] - pointXs[pointi])
296 /(plotXs[layerj + 1] - plotXs[layerj]);
307 dynWeights.last().value += faceF*a;
310 if (faceMinXs[facei] < plotXs[layerj])
312 dynWeights.last().value -=
329 ).second() & faceNormals[facei];
333 if (faceMaxXs[facei] > plotXs[layerj + 1])
335 dynWeights.last().value -=
352 ).second() & faceNormals[facei];
361 List<weight> weights;
362 weights.transfer(dynWeights);
372 layerWeightSums[weights[weighti].layeri] += weights[weighti].value;
380 weights[weighti].value /=
381 (layerWeightSums[weights[weighti].layeri] + vSmall);
390 weights[weighti].layeri == 0
391 || weights[weighti].layeri == nLayers_ - 1
394 weights[weighti].value *= 2;
404 Foam::functionObjects::patchCutLayerAverage::calcWeights
416 ? calcInterpolatingWeights
425 : calcNonInterpolatingWeights
437 void Foam::functionObjects::patchCutLayerAverage::calcWeights()
439 const polyPatch& pp = mesh_.boundaryMesh()[patchName_];
440 const faceList& faces = pp.localFaces();
446 const label nPlot = interpolate_ ? nLayers_ : nLayers_ + 1;
449 tmp<scalarField> tpointXs =
458 : tmp<pointScalarField>
462 )().boundaryField()[pp.index()].patchInternalField();
470 forAll(faces[facei], facePointi)
472 const label pointi = faces[facei][facePointi];
473 faceMinXs[facei] =
min(faceMinXs[facei], pointXs[pointi]);
474 faceMaxXs[facei] =
max(faceMaxXs[facei], pointXs[pointi]);
492 #define DeclareTypeFieldValues(Type, nullArg) \
493 PtrList<Field<Type>> Type##FieldValues;
495 #undef DeclareTypeFieldValues
499 for (
label iteri = 0; iteri < nOptimiseIter_ + debug; ++ iteri)
502 const List<weight> weights =
514 applyWeights(weights, (1/pp.magFaceAreas())())
519 const label nFields0 = (2 + !interpolate_)*iteri;
520 const label nFields = (2 + !interpolate_)*(iteri + 1);
523 #define ResizeTypeFieldValues(Type, nullArg) \
524 Type##FieldValues.resize(nFields);
526 #undef ResizeTypeFieldValues
530 const SubField<scalar> distance0s(plotXs, nLayers_);
531 const SubField<scalar> distance1s(plotXs, nLayers_, 1);
534 scalarFieldValues.set(nFields0, (distance0s + distance1s)/2);
537 scalarFieldValues.set(nFields0 + 1, distance1s - distance0s);
542 scalarFieldValues.set(nFields0,
new scalarField(plotXs));
546 scalarFieldValues.set(nFields - 1,
new scalarField(layerCounts));
548 if (iteri == nOptimiseIter_)
break;
553 for (
label ploti = 0; ploti < nPlot - 1; ++ ploti)
555 plotSumCounts[ploti + 1] =
559 ? (layerCounts[ploti + 1] + layerCounts[ploti])/2
565 const scalar plotDeltaCount = plotSumCounts.last()/(nPlot - 1);
570 plotXs.first() =
xMin;
572 for (
label ploti0 = 0; ploti0 < nPlot - 1; ++ ploti0)
577 && plotSumCounts[ploti0 + 1] > ploti*plotDeltaCount
581 (ploti*plotDeltaCount - plotSumCounts[ploti0])
582 /(plotSumCounts[ploti0 + 1] - plotSumCounts[ploti0]);
584 plotXs[ploti] = (1 -
f)*plot0Xs[ploti0] +
f*plot0Xs[ploti0 + 1];
589 plotXs.last() =
xMax;
633 const SubField<scalar> distance0s(plotXs, nLayers_);
634 const SubField<scalar> distance1s(plotXs, nLayers_, 1);
635 layerDistances_.reset(((distance0s + distance1s)/2).ptr());
636 layerThicknesses_.reset((distance1s - distance0s).ptr());
640 layerPositions_.reset
642 applyWeights(weights_,
pointField(pp.faceCentres())).ptr()
647 const List<weight> weights =
671 layers.boundaryFieldRef()[pp.index()];
675 const weight& w = weights[weighti];
678 w.value/pp.magFaceAreas()[w.facei];
690 Foam::functionObjects::patchCutLayerAverage::applyWeights
700 tLayerValues.
ref()[weights[weighti].layeri] +=
701 weights[weighti].value*faceValues[weights[weighti].facei];
711 void Foam::functionObjects::patchCutLayerAverage::clear()
714 layerDistances_.clear();
715 layerThicknesses_.clear();
716 layerPositions_.clear();
745 patchName_ =
dict.lookup<
word>(
"patch");
747 const bool haveDirection =
dict.found(
"direction");
748 const bool haveDistance =
dict.found(
"distance");
749 if (haveDirection == haveDistance)
752 <<
"keywords direction and distance both "
753 << (haveDirection ?
"" :
"un") <<
"defined in "
754 <<
"dictionary " <<
dict.name()
757 else if (haveDirection)
762 else if (haveDistance)
765 distanceName_ =
dict.lookup<
word>(
"distance");
768 nLayers_ =
dict.lookup<
label>(
"nPoints");
770 interpolate_ =
dict.lookupOrDefault<
bool>(
"interpolate",
false);
786 nOptimiseIter_ =
dict.lookupOrDefault(
"nOptimiseIter", 2);
800 result.
append(distanceName_);
815 if (!weights_.valid())
822 const bool writeThickness =
850 cannotFindObject(fields_[fieldi]);
855 #define DeclareTypeFieldValues(Type, nullArg) \
856 PtrList<Field<Type>> Type##FieldValues(fieldNames.size());
858 #undef DeclareTypeFieldValues
861 scalarFieldValues.set(0,
new scalarField(layerThicknesses_));
865 #define CollapseTypeFields(Type, nullArg) \
866 if (mesh_.foundObject<VolField<Type>>(fieldNames[fieldi])) \
868 const VolField<Type>& field = \
869 mesh_.lookupObject<VolField<Type>>(fieldNames[fieldi]); \
871 Type##FieldValues.set \
874 applyWeights(weights_, field.boundaryField()[pp.index()]) \
878 #undef CollapseTypeFields
927 if (&map.
mesh() == &mesh_)
939 if (&map.
mesh() == &mesh_)
951 if (&map.
mesh() == &mesh_)
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
static volPointInterpolation & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Pre-declare SubField and related Field type.
SubField< vector > subField
Declare type of subField.
Generic GeometricField class.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void append(const T &)
Append an element at the end of the list.
void resize(const label)
Alias for setSize(const label)
void size(const label)
Override size to be inconsistent with allocated storage.
virtual Ostream & write(const char)=0
Write character.
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
fileName globalPath() const
Return the global path.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static bool master(const label communicator=0)
Am I the master process.
static const direction nComponents
Number of components in this vector space.
Holds list of sampling positions.
static const NamedEnum< axisType, 6 > axisTypeNames_
String representation of axis enums.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const word & name() const
Return const reference to name.
A class for handling file names.
Abstract base-class for Time/database functionObjects.
const Time & time_
Reference to time.
const word & name() const
Return the name of this functionObject.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
const fvMesh & mesh_
Reference to the fvMesh.
This function object writes graphs of patch face values, area-averaged in planes perpendicular to a g...
patchCutLayerAverage(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
virtual wordList fields() const
Return the list of fields required.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual ~patchCutLayerAverage()
Destructor.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion.
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Write the patchCutLayerAverage.
virtual bool read(const dictionary &)
Read the patchCutLayerAverage data.
static const word outputPrefix
Directory prefix.
const word & name() const
Return reference to name.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
const polyMesh & mesh() const
Return polyMesh.
Class containing mesh-to-mesh mapping information.
const polyMesh & mesh() const
Return polyMesh.
Mesh consisting of general polyhedral cells.
static word defaultRegion
Return the default region name.
A patch is a list of labels that address the faces in the global face list.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const polyMesh & mesh() const
Return polyMesh.
static autoPtr< setWriter > New(const word &writeType, const IOstream::streamFormat writeFormat=IOstream::ASCII, const IOstream::compressionType writeCompression=IOstream::UNCOMPRESSED)
Select given write options.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
tmp< PointField< Type > > interpolate(const VolField< Type > &) const
Interpolate volField using inverse distance weighting.
A class for handling words, derived from string.
static const word null
An empty word.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
static List< word > fieldNames
Tuple2< vector, std::tuple< AreaIntegralType< Types > ... > > faceCutAreaIntegral(const face &f, const vector &fArea, const std::tuple< Types ... > &fPsis, const List< labelPair > &fCuts, const pointField &ps, const std::tuple< const Field< Types > &... > &pPsis, const scalarField &pAlphas, const scalar isoAlpha, const bool below)
Compute the face-cut-area and face-cut-area-integral of the given properties.
vector faceCutArea(const face &f, const vector &fArea, const List< labelPair > &fCuts, const pointField &ps, const scalarField &pAlphas, const scalar isoAlpha, const bool below)
Compute the face-cut-area.
Tuple2< vector, std::tuple< Types ... > > faceAreaAverage(const FaceValues< point > &fPs, const point &fPAvg, const std::tuple< FaceValues< Types > ... > &fPsis, const std::tuple< Types ... > &fPsiAvgs)
Compute the face-area and face-area-averages of the given properties.
List< labelPair > faceCuts(const face &f, const scalarField &pAlphas, const scalar isoAlpha)
Return the cuts for a given face. This returns a list of pairs of.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< word > wordList
A List of words.
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet dimless
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
A List of scalars.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
VolField< tensor > volTensorField
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
PointField< scalar > pointScalarField
VolField< scalar > volScalarField
dimensionSet normalised(const dimensionSet &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< vector > vectorField
Specialisation of Field<T> for vector.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
Type gMin(const FieldField< Field, Type > &f)
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
quaternion normalise(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Type gMax(const FieldField< Field, Type > &f)
#define TypeFieldValuesParameter(Type, nullArg)
#define FoundTypeField(Type, nullArg)
#define DeclareTypeFieldValues(Type, nullArg)
#define CollapseTypeFields(Type, nullArg)
#define ResizeTypeFieldValues(Type, nullArg)