35bool Foam::functionObjects::columnAverage::columnAverageField
40 typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
46 const fieldType&
fld = *fldPtr;
48 const word resultName(averageName(fieldName));
50 auto* resPtr =
obr_.getObjectPtr<fieldType>(resultName);
54 resPtr =
new fieldType
59 fld.mesh().time().timeName(),
69 fieldType& res = *resPtr;
71 const meshStructure& ms = meshAddressing(
fld.mesh());
72 if (globalFaces_().empty())
77 const labelList& cellToPatchFace = ms.cellToPatchFaceAddressing();
80 Field<Type> regionField(globalFaces_().totalSize(),
Zero);
83 forAll(cellToPatchFace, celli)
85 const label regioni = cellToPatchFace[celli];
86 regionField[regioni] +=
fld[celli];
87 regionCount[regioni]++;
94 forAll(regionField, regioni)
96 regionField[regioni] /= regionCount[regioni];
100 forAll(cellToPatchFace, celli)
102 const label regioni = cellToPatchFace[celli];
103 res[celli] = regionField[regioni];
105 res.correctBoundaryConditions();
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
@ REGISTER
Request registration (bool: true).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
static void listReduce(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce list elements (list must be equal size on all ranks), applying bop to each list element.
const ObjectType * cfindObject(const word &fieldName) const
Return const pointer to the object (eg, a field) in the (sub) objectRegistry.
const objectRegistry & obr_
Reference to the region objectRegistry.
bool store()
Register object with its registry and transfer ownership to the registry.
List< label > labelList
A List of labels.
static constexpr const zero Zero
Global zero (0).
#define forAll(list, i)
Loop across all elements in list.