43 const char* NamedEnum<fieldValues::faceSource::sourceType, 3>::
44 names[] = {
"faceZone",
"patch",
"sampledSurface"};
46 const NamedEnum<fieldValues::faceSource::sourceType, 3>
50 const char* NamedEnum<fieldValues::faceSource::operationType, 7>::
53 "none",
"sum",
"areaAverage",
54 "areaIntegrate",
"weightedAverage",
"min",
"max"
57 const NamedEnum<fieldValues::faceSource::operationType, 7>
65 void Foam::fieldValues::faceSource::setFaceZoneFaces()
71 FatalErrorIn(
"faceSource::faceSource::setFaceZoneFaces()")
88 label faceI = fZone[i];
91 label facePatchId = -1;
92 if (
mesh().isInternalFace(faceI))
101 if (isA<processorPolyPatch>(pp))
103 if (refCast<const processorPolyPatch>(pp).owner())
105 faceId = pp.whichFace(faceI);
112 else if (isA<cyclicPolyPatch>(pp))
114 label patchFaceI = faceI - pp.start();
115 if (patchFaceI < pp.size()/2)
124 else if (!isA<emptyPolyPatch>(pp))
126 faceId = faceI - pp.start();
137 if (fZone.flipMap()[i])
158 Pout<<
"Original face zone size = " << fZone.size()
159 <<
", new size = " << count <<
endl;
164 void Foam::fieldValues::faceSource::setPatchFaces()
166 label patchId =
mesh().boundaryMesh().findPatchID(sourceName_);
171 <<
type() <<
" " << name_ <<
": "
172 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):" <<
nl
173 <<
" Unknown patch name: " << sourceName_
174 <<
". Valid patch names are: "
175 <<
mesh().boundaryMesh().names() <<
nl
179 const polyPatch& pp =
mesh().boundaryMesh()[patchId];
181 label nFaces = pp.size();
182 if (isA<cyclicPolyPatch>(pp))
186 else if (isA<emptyPolyPatch>(pp))
191 faceId_.setSize(nFaces);
192 facePatchId_.setSize(nFaces);
193 faceSign_.setSize(nFaces);
198 faceId_[faceI] = faceI;
199 facePatchId_[faceI] = patchId;
200 faceSign_[faceI] = 1;
205 void Foam::fieldValues::faceSource::sampledSurfaceFaces(
const dictionary& dict)
211 dict.subDict(
"sampledSurfaceDict")
213 surfacePtr_().update();
214 nFaces_ =
returnReduce(surfacePtr_().faces().size(), sumOp<label>());
234 case stSampledSurface:
236 sampledSurfaceFaces(dict);
242 <<
type() <<
" " << name_ <<
": "
243 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):"
244 <<
nl <<
" Unknown source type. Valid source types are:"
251 if (surfacePtr_.valid())
253 surfacePtr_().update();
254 totalArea =
gSum(surfacePtr_().magSf());
258 totalArea =
gSum(filterField(
mesh().magSf(),
false));
262 <<
" total faces = " << nFaces_
264 <<
" total area = " << totalArea
267 if (operation_ == opWeightedAverage)
269 dict.
lookup(
"weightField") >> weightFieldName_;
272 obr().foundObject<volScalarField>(weightFieldName_)
273 || obr().foundObject<surfaceScalarField>(weightFieldName_)
276 Info<<
" weight field = " << weightFieldName_;
281 <<
type() <<
" " << name_ <<
": "
282 << sourceTypeNames_[source_] <<
"(" << sourceName_ <<
"):"
283 << nl <<
" Weight field " << weightFieldName_
295 if (outputFilePtr_.valid())
298 <<
"# Source : " << sourceTypeNames_[source_] <<
" "
299 << sourceName_ <<
nl <<
"# Faces : " << nFaces_ <<
nl
300 <<
"# Time" <<
tab <<
"sum(magSf)";
305 << tab << operationTypeNames_[operation_]
306 <<
"(" << fields_[i] <<
")";
309 outputFilePtr_() <<
endl;
321 const bool loadFromFiles
325 source_(sourceTypeNames_.read(dict.
lookup(
"source"))),
326 operation_(operationTypeNames_.read(dict.
lookup(
"operation"))),
327 weightFieldName_(
"undefinedWeightedFieldName"),
364 if (surfacePtr_.valid())
366 surfacePtr_().update();
367 totalArea =
gSum(surfacePtr_().magSf());
371 totalArea =
gSum(filterField(
mesh().magSf(),
false));
376 outputFilePtr_() << obr_.time().value() <<
tab << totalArea;
381 writeValues<scalar>(fields_[i]);
382 writeValues<vector>(fields_[i]);
383 writeValues<sphericalTensor>(fields_[i]);
384 writeValues<symmTensor>(fields_[i]);
385 writeValues<tensor>(fields_[i]);
390 outputFilePtr_()<<
endl;