fluxSummary.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fluxSummary.H"
27 #include "surfaceFields.H"
28 #include "dictionary.H"
29 #include "Time.H"
30 #include "syncTools.H"
31 #include "meshTools.H"
32 #include "PatchEdgeFaceWave.H"
33 #include "patchEdgeFaceRegion.H"
34 #include "globalIndex.H"
35 #include "OBJstream.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(fluxSummary, 0);
42 
43  template<>
44  const char* NamedEnum
45  <
47  3
48  >::names[] =
49  {
50  "faceZone",
51  "faceZoneAndDirection",
52  "cellZoneAndDirection"
53  };
54 }
55 
56 
59 
60 
61 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
62 
64 (
65  const word& faceZoneName,
66  DynamicList<word>& faceZoneNames,
67  DynamicList<List<label> >& faceID,
68  DynamicList<List<label> >& facePatchID,
69  DynamicList<List<scalar> >& faceSign
70 ) const
71 {
72  const fvMesh& mesh = refCast<const fvMesh>(obr_);
73 
74  label zoneI = mesh.faceZones().findZoneID(faceZoneName);
75 
76  if (zoneI == -1)
77  {
79  << "Unable to find faceZone " << faceZoneName
80  << ". Valid faceZones are: " << mesh.faceZones().names()
81  << exit(FatalError);
82  }
83 
84  faceZoneNames.append(faceZoneName);
85 
86  const faceZone& fZone = mesh.faceZones()[zoneI];
87 
88  DynamicList<label> faceIDs(fZone.size());
89  DynamicList<label> facePatchIDs(fZone.size());
90  DynamicList<scalar> faceSigns(fZone.size());
91 
92  forAll(fZone, i)
93  {
94  label faceI = fZone[i];
95 
96  label faceID = -1;
97  label facePatchID = -1;
98  if (mesh.isInternalFace(faceI))
99  {
100  faceID = faceI;
101  facePatchID = -1;
102  }
103  else
104  {
105  facePatchID = mesh.boundaryMesh().whichPatch(faceI);
106  const polyPatch& pp = mesh.boundaryMesh()[facePatchID];
107  if (isA<coupledPolyPatch>(pp))
108  {
109  if (refCast<const coupledPolyPatch>(pp).owner())
110  {
111  faceID = pp.whichFace(faceI);
112  }
113  else
114  {
115  faceID = -1;
116  }
117  }
118  else if (!isA<emptyPolyPatch>(pp))
119  {
120  faceID = faceI - pp.start();
121  }
122  else
123  {
124  faceID = -1;
125  facePatchID = -1;
126  }
127  }
128 
129  if (faceID >= 0)
130  {
131  // orientation set by faceZone flip map
132  if (fZone.flipMap()[faceI])
133  {
134  faceSigns.append(-1);
135  }
136  else
137  {
138  faceSigns.append(1);
139  }
140 
141  faceIDs.append(faceID);
142  facePatchIDs.append(facePatchID);
143  }
144  }
145 
146  faceID.append(faceIDs);
147  facePatchID.append(facePatchIDs);
148  faceSign.append(faceSigns);
149 }
150 
151 
153 (
154  const word& faceZoneName,
155  const vector& dir,
156  DynamicList<vector>& zoneRefDir,
157  DynamicList<word>& faceZoneNames,
158  DynamicList<List<label> >& faceID,
159  DynamicList<List<label> >& facePatchID,
160  DynamicList<List<scalar> >& faceSign
161 ) const
162 {
163  const fvMesh& mesh = refCast<const fvMesh>(obr_);
164 
165  vector refDir = dir/(mag(dir) + ROOTVSMALL);
166 
167  label zoneI = mesh.faceZones().findZoneID(faceZoneName);
168 
169  if (zoneI == -1)
170  {
172  << "Unable to find faceZone " << faceZoneName
173  << ". Valid faceZones are: " << mesh.faceZones().names()
174  << exit(FatalError);
175  }
176 
177  faceZoneNames.append(faceZoneName);
178  zoneRefDir.append(refDir);
179 
180  const faceZone& fZone = mesh.faceZones()[zoneI];
181 
182  DynamicList<label> faceIDs(fZone.size());
183  DynamicList<label> facePatchIDs(fZone.size());
184  DynamicList<scalar> faceSigns(fZone.size());
185 
186  const surfaceVectorField& Sf = mesh.Sf();
187  const surfaceScalarField& magSf = mesh.magSf();
188 
189  vector n = vector::zero;
190 
191  forAll(fZone, i)
192  {
193  label faceI = fZone[i];
194 
195  label faceID = -1;
196  label facePatchID = -1;
197  if (mesh.isInternalFace(faceI))
198  {
199  faceID = faceI;
200  facePatchID = -1;
201  }
202  else
203  {
204  facePatchID = mesh.boundaryMesh().whichPatch(faceI);
205  const polyPatch& pp = mesh.boundaryMesh()[facePatchID];
206  if (isA<coupledPolyPatch>(pp))
207  {
208  if (refCast<const coupledPolyPatch>(pp).owner())
209  {
210  faceID = pp.whichFace(faceI);
211  }
212  else
213  {
214  faceID = -1;
215  }
216  }
217  else if (!isA<emptyPolyPatch>(pp))
218  {
219  faceID = faceI - pp.start();
220  }
221  else
222  {
223  faceID = -1;
224  facePatchID = -1;
225  }
226  }
227 
228  if (faceID >= 0)
229  {
230  // orientation set by comparison with reference direction
231  if (facePatchID != -1)
232  {
233  n = Sf.boundaryField()[facePatchID][faceID]
234  /(magSf.boundaryField()[facePatchID][faceID] + ROOTVSMALL);
235  }
236  else
237  {
238  n = Sf[faceID]/(magSf[faceID] + ROOTVSMALL);
239  }
240 
241  if ((n & refDir) > tolerance_)
242  {
243  faceSigns.append(1);
244  }
245  else
246  {
247  faceSigns.append(-1);
248  }
249 
250  faceIDs.append(faceID);
251  facePatchIDs.append(facePatchID);
252  }
253  }
254 
255  faceID.append(faceIDs);
256  facePatchID.append(facePatchIDs);
257  faceSign.append(faceSigns);
258 }
259 
260 
262 (
263  const word& cellZoneName,
264  const vector& dir,
265  DynamicList<vector>& zoneRefDir,
266  DynamicList<word>& faceZoneNames,
267  DynamicList<List<label> >& faceID,
268  DynamicList<List<label> >& facePatchID,
269  DynamicList<List<scalar> >& faceSign
270 ) const
271 {
272  const fvMesh& mesh = refCast<const fvMesh>(obr_);
273 
274  vector refDir = dir/(mag(dir) + ROOTVSMALL);
275 
276  const label cellZoneI = mesh.cellZones().findZoneID(cellZoneName);
277 
278  if (cellZoneI == -1)
279  {
281  << "Unable to find cellZone " << cellZoneName
282  << ". Valid zones are: " << mesh.cellZones().names()
283  << exit(FatalError);
284  }
285 
286  const label nInternalFaces = mesh.nInternalFaces();
287  const polyBoundaryMesh& pbm = mesh.boundaryMesh();
288 
289  labelList cellAddr(mesh.nCells(), -1);
290  const labelList& cellIDs = mesh.cellZones()[cellZoneI];
291  UIndirectList<label>(cellAddr, cellIDs) = identity(cellIDs.size());
292  labelList nbrFaceCellAddr(mesh.nFaces() - nInternalFaces, -1);
293 
294  forAll(pbm, patchI)
295  {
296  const polyPatch& pp = pbm[patchI];
297 
298  if (pp.coupled())
299  {
300  forAll(pp, i)
301  {
302  label faceI = pp.start() + i;
303  label nbrFaceI = faceI - nInternalFaces;
304  label own = mesh.faceOwner()[faceI];
305  nbrFaceCellAddr[nbrFaceI] = cellAddr[own];
306  }
307  }
308  }
309 
310  // correct boundary values for parallel running
311  syncTools::swapBoundaryFaceList(mesh, nbrFaceCellAddr);
312 
313  // collect faces
314  DynamicList<label> faceIDs(floor(0.1*mesh.nFaces()));
315  DynamicList<label> facePatchIDs(faceIDs.size());
316  DynamicList<label> faceLocalPatchIDs(faceIDs.size());
317  DynamicList<scalar> faceSigns(faceIDs.size());
318 
319  // internal faces
320  for (label faceI = 0; faceI < nInternalFaces; faceI++)
321  {
322  const label own = cellAddr[mesh.faceOwner()[faceI]];
323  const label nbr = cellAddr[mesh.faceNeighbour()[faceI]];
324 
325  if (((own != -1) && (nbr == -1)) || ((own == -1) && (nbr != -1)))
326  {
327  vector n = mesh.faces()[faceI].normal(mesh.points());
328  n /= mag(n) + ROOTVSMALL;
329 
330  if ((n & refDir) > tolerance_)
331  {
332  faceIDs.append(faceI);
333  faceLocalPatchIDs.append(faceI);
334  facePatchIDs.append(-1);
335  faceSigns.append(1);
336  }
337  else if ((n & -refDir) > tolerance_)
338  {
339  faceIDs.append(faceI);
340  faceLocalPatchIDs.append(faceI);
341  facePatchIDs.append(-1);
342  faceSigns.append(-1);
343  }
344  }
345  }
346 
347  // loop of boundary faces
348  forAll(pbm, patchI)
349  {
350  const polyPatch& pp = pbm[patchI];
351 
352  forAll(pp, localFaceI)
353  {
354  const label faceI = pp.start() + localFaceI;
355  const label own = cellAddr[mesh.faceOwner()[faceI]];
356  const label nbr = nbrFaceCellAddr[faceI - nInternalFaces];
357 
358  if ((own != -1) && (nbr == -1))
359  {
360  vector n = mesh.faces()[faceI].normal(mesh.points());
361  n /= mag(n) + ROOTVSMALL;
362 
363  if ((n & refDir) > tolerance_)
364  {
365  faceIDs.append(faceI);
366  faceLocalPatchIDs.append(localFaceI);
367  facePatchIDs.append(patchI);
368  faceSigns.append(1);
369  }
370  else if ((n & -refDir) > tolerance_)
371  {
372  faceIDs.append(faceI);
373  faceLocalPatchIDs.append(localFaceI);
374  facePatchIDs.append(patchI);
375  faceSigns.append(-1);
376  }
377  }
378  }
379  }
380 
381  // convert into primitivePatch for convenience
383  (
384  IndirectList<face>(mesh.faces(), faceIDs),
385  mesh.points()
386  );
387 
388  if (debug)
389  {
390  OBJstream os(mesh.time().path()/"patch.obj");
391  faceList faces(patch);
392  os.write(faces, mesh.points(), false);
393  }
394 
395 
396  // data on all edges and faces
397  List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges());
398  List<patchEdgeFaceRegion> allFaceInfo(patch.size());
399 
400  bool search = true;
401 
402  if (debug)
403  {
404  Info<< "initialiseCellZoneAndDirection: "
405  << "Starting walk to split patch into faceZones"
406  << endl;
407  }
408 
409  globalIndex globalFaces(patch.size());
410 
411  label oldFaceID = 0;
412  label regionI = 0;
413  while (search)
414  {
415  DynamicList<label> changedEdges;
417 
418  label seedFaceI = labelMax;
419  for (; oldFaceID < patch.size(); oldFaceID++)
420  {
421  if (allFaceInfo[oldFaceID].region() == -1)
422  {
423  seedFaceI = globalFaces.toGlobal(oldFaceID);
424  break;
425  }
426  }
427  reduce(seedFaceI, minOp<label>());
428 
429  if (seedFaceI == labelMax)
430  {
431  break;
432  }
433 
434  if (globalFaces.isLocal(seedFaceI))
435  {
436  label localFaceI = globalFaces.toLocal(seedFaceI);
437  const labelList& fEdges = patch.faceEdges()[localFaceI];
438 
439  forAll(fEdges, i)
440  {
441  if (allEdgeInfo[fEdges[i]].region() != -1)
442  {
444  << "Problem in edge face wave: attempted to assign a "
445  << "value to an edge that has already been visited. "
446  << "Edge info: " << allEdgeInfo[fEdges[i]]
447  << endl;
448  }
449 
450  changedEdges.append(fEdges[i]);
451  changedInfo.append(regionI);
452  }
453  }
454 
455 
457  <
460  > calc
461  (
462  mesh,
463  patch,
464  changedEdges,
465  changedInfo,
466  allEdgeInfo,
467  allFaceInfo,
468  returnReduce(patch.nEdges(), sumOp<label>())
469  );
470 
471  if (debug)
472  {
473  label nCells = 0;
474  forAll(allFaceInfo, faceI)
475  {
476  if (allFaceInfo[faceI].region() == regionI)
477  {
478  nCells++;
479  }
480  }
481 
482  Info<< "*** region:" << regionI
483  << " found:" << returnReduce(nCells, sumOp<label>())
484  << " faces" << endl;
485  }
486 
487  regionI++;
488  }
489 
490  // collect the data per region
491  label nRegion = regionI;
492 
493  List<DynamicList<label> > regionFaceIDs(nRegion);
494  List<DynamicList<label> > regionFacePatchIDs(nRegion);
495  List<DynamicList<scalar> > regionFaceSigns(nRegion);
496 
497  forAll(allFaceInfo, faceI)
498  {
499  regionI = allFaceInfo[faceI].region();
500 
501  regionFaceIDs[regionI].append(faceLocalPatchIDs[faceI]);
502  regionFacePatchIDs[regionI].append(facePatchIDs[faceI]);
503  regionFaceSigns[regionI].append(faceSigns[faceI]);
504  }
505 
506  // transfer to persistent storage
507  forAll(regionFaceIDs, regionI)
508  {
509  const word zoneName = cellZoneName + ":faceZone" + Foam::name(regionI);
510  faceZoneNames.append(zoneName);
511  zoneRefDir.append(refDir);
512  faceID.append(regionFaceIDs[regionI]);
513  facePatchID.append(regionFacePatchIDs[regionI]);
514  faceSign.append(regionFaceSigns[regionI]);
515 
516  // write OBJ of faces to file
517  if (debug)
518  {
519  OBJstream os(mesh.time().path()/zoneName + ".obj");
520  faceList faces(mesh.faces(), regionFaceIDs[regionI]);
521  os.write(faces, mesh.points(), false);
522  }
523  }
524 
525  if (log_)
526  {
527  Info<< type() << " " << name_ << " output:" << nl
528  << " Created " << faceID.size()
529  << " separate face zones from cell zone " << cellZoneName << nl;
530 
531  forAll(faceZoneNames, i)
532  {
533  label nFaces = returnReduce(faceID[i].size(), sumOp<label>());
534  Info<< " " << faceZoneNames[i] << ": "
535  << nFaces << " faces" << nl;
536  }
537 
538  Info<< endl;
539  }
540 }
541 
542 
544 {
545  faceArea_.setSize(faceID_.size(), 0);
546 
547  const fvMesh& mesh = refCast<const fvMesh>(obr_);
548  const surfaceScalarField& magSf = mesh.magSf();
549 
550  forAll(faceID_, zoneI)
551  {
552  const labelList& faceIDs = faceID_[zoneI];
553  const labelList& facePatchIDs = facePatchID_[zoneI];
554 
555  scalar sumMagSf = 0;
556 
557  forAll(faceIDs, i)
558  {
559  label faceI = faceIDs[i];
560 
561  if (facePatchIDs[i] == -1)
562  {
563  sumMagSf += magSf[faceI];
564  }
565  else
566  {
567  label patchI = facePatchIDs[i];
568  sumMagSf += magSf.boundaryField()[patchI][faceI];
569  }
570  }
571 
572  faceArea_[zoneI] = returnReduce(sumMagSf, sumOp<scalar>());
573  }
574 }
575 
576 
577 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
578 
580 (
581  const word& name,
582  const objectRegistry& obr,
583  const dictionary& dict,
584  const bool loadFromFiles
585 )
586 :
587  functionObjectFile(obr, name),
588  name_(name),
589  obr_(obr),
590  active_(true),
591  log_(true),
592  mode_(mdFaceZone),
593  scaleFactor_(1),
594  phiName_("phi"),
595  faceZoneName_(),
596  refDir_(),
597  faceID_(),
598  facePatchID_(),
599  faceSign_(),
600  faceArea_(),
601  filePtrs_(),
602  tolerance_(0.8)
603 {
604  // Check if the available mesh is an fvMesh otherise deactivate
605  if (!isA<fvMesh>(obr_))
606  {
607  active_ = false;
609  << "No fvMesh available, deactivating " << name_
610  << endl;
611  }
612 
613  read(dict);
614 }
615 
616 
617 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
618 
620 {}
621 
622 
623 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
624 
626 {
627  if (!active_)
628  {
629  return;
630  }
631 
633 
634  log_ = dict.lookupOrDefault<Switch>("log", true);
635 
636  mode_ = modeTypeNames_.read(dict.lookup("mode"));
637  phiName_= dict.lookupOrDefault<word>("phiName", "phi");
638  dict.readIfPresent("scaleFactor", scaleFactor_);
639  dict.readIfPresent("tolerance", tolerance_);
640 
641  // initialise with capacity of 10 faceZones
642  DynamicList<vector> refDir(10);
643  DynamicList<word> faceZoneName(refDir.size());
644  DynamicList<List<label> > faceID(refDir.size());
645  DynamicList<List<label> > facePatchID(refDir.size());
646  DynamicList<List<scalar> > faceSign(refDir.size());
647 
648  switch (mode_)
649  {
650  case mdFaceZone:
651  {
652  List<word> zones(dict.lookup("faceZones"));
653 
654  forAll(zones, i)
655  {
656  initialiseFaceZone
657  (
658  zones[i],
659  faceZoneName,
660  faceID,
661  facePatchID,
662  faceSign
663  );
664  }
665  break;
666  }
667  case mdFaceZoneAndDirection:
668  {
670  zoneAndDirection(dict.lookup("faceZoneAndDirection"));
671 
672  forAll(zoneAndDirection, i)
673  {
674  initialiseFaceZoneAndDirection
675  (
676  zoneAndDirection[i].first(),
677  zoneAndDirection[i].second(),
678  refDir,
679  faceZoneName,
680  faceID,
681  facePatchID,
682  faceSign
683  );
684  }
685  break;
686  }
687  case mdCellZoneAndDirection:
688  {
690  zoneAndDirection(dict.lookup("cellZoneAndDirection"));
691 
692  forAll(zoneAndDirection, i)
693  {
694  initialiseCellZoneAndDirection
695  (
696  zoneAndDirection[i].first(),
697  zoneAndDirection[i].second(),
698  refDir,
699  faceZoneName,
700  faceID,
701  facePatchID,
702  faceSign
703  );
704  }
705  break;
706  }
707  default:
708  {
710  << "unhandled enumeration " << modeTypeNames_[mode_]
711  << abort(FatalIOError);
712  }
713  }
714 
715  faceZoneName_.transfer(faceZoneName);
716  refDir_.transfer(refDir);
717  faceID_.transfer(faceID);
718  facePatchID_.transfer(facePatchID);
719  faceSign_.transfer(faceSign);
720 
721  initialiseFaceArea();
722 
723  if (writeToFile())
724  {
725  filePtrs_.setSize(faceZoneName_.size());
726 
727  forAll(filePtrs_, fileI)
728  {
729  const word& fzName = faceZoneName_[fileI];
730  filePtrs_.set(fileI, createFile(fzName));
731  writeFileHeader
732  (
733  fzName,
734  faceArea_[fileI],
735  refDir_[fileI],
736  filePtrs_[fileI]
737  );
738  }
739  }
740 
741  // Provide some output
742  if (log_)
743  {
744  Info<< type() << " " << name_ << " output:" << nl;
745 
746  forAll(faceZoneName_, zoneI)
747  {
748  const word& zoneName = faceZoneName_[zoneI];
749  scalar zoneArea = faceArea_[zoneI];
750 
751  Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl;
752  }
753 
754  Info<< endl;
755  }
756 }
757 
758 
760 (
761  const word& fzName,
762  const scalar area,
763  const vector& refDir,
764  Ostream& os
765 ) const
766 {
767  writeHeader(os, "Flux summary");
768  writeHeaderValue(os, "Face zone", fzName);
769  writeHeaderValue(os, "Total area", area);
770 
771  switch (mode_)
772  {
773  case mdFaceZoneAndDirection:
774  case mdCellZoneAndDirection:
775  {
776  writeHeaderValue(os, "Reference direction", refDir);
777  break;
778  }
779  default:
780  {}
781  }
782 
783  writeHeaderValue(os, "Scale factor", scaleFactor_);
784 
785  writeCommented(os, "Time");
786  os << tab << "positive"
787  << tab << "negative"
788  << tab << "net"
789  << tab << "absolute"
790  << endl;
791 }
792 
793 
795 {
796  // Do nothing - only valid on write
797 }
798 
799 
801 {
802  // Do nothing - only valid on write
803 }
804 
805 
807 {
808  // Do nothing - only valid on write
809 }
810 
811 
813 {
814  if (!active_)
815  {
816  return;
817  }
818 
819  const surfaceScalarField& phi =
820  obr_.lookupObject<surfaceScalarField>(phiName_);
821 
822  word flowType = "";
823  if (phi.dimensions() == dimVolume/dimTime)
824  {
825  flowType = "volumetric";
826  }
827  else if (phi.dimensions() == dimMass/dimTime)
828  {
829  flowType = "mass";
830  }
831  else
832  {
834  << "Unsupported flux field " << phi.name() << " with dimensions "
835  << phi.dimensions() << ". Expected eithe mass flow or volumetric "
836  << "flow rate" << abort(FatalError);
837  }
838 
839  if (log_)
840  {
841  Info<< type() << " " << name_ << ' ' << flowType << " flux output:"
842  << nl;
843  }
844 
845  forAll(faceZoneName_, zoneI)
846  {
847  const labelList& faceID = faceID_[zoneI];
848  const labelList& facePatchID = facePatchID_[zoneI];
849  const scalarList& faceSign = faceSign_[zoneI];
850 
851  scalar phiPos = scalar(0);
852  scalar phiNeg = scalar(0);
853  scalar phif = scalar(0);
854 
855  forAll(faceID, i)
856  {
857  label faceI = faceID[i];
858  label patchI = facePatchID[i];
859 
860  if (patchI != -1)
861  {
862  phif = phi.boundaryField()[patchI][faceI];
863  }
864  else
865  {
866  phif = phi[faceI];
867  }
868 
869  phif *= faceSign[i];
870 
871  if (phif > 0)
872  {
873  phiPos += phif;
874  }
875  else
876  {
877  phiNeg += phif;
878  }
879  }
880 
881  reduce(phiPos, sumOp<scalar>());
882  reduce(phiNeg, sumOp<scalar>());
883 
884  phiPos *= scaleFactor_;
885  phiNeg *= scaleFactor_;
886 
887  scalar netFlux = phiPos + phiNeg;
888  scalar absoluteFlux = phiPos - phiNeg;
889 
890  if (log_)
891  {
892  Info<< " faceZone " << faceZoneName_[zoneI] << ':' << nl
893  << " positive : " << phiPos << nl
894  << " negative : " << phiNeg << nl
895  << " net : " << netFlux << nl
896  << " absolute : " << absoluteFlux
897  << nl << endl;
898  }
899 
900  if (writeToFile())
901  {
902  filePtrs_[zoneI]
903  << obr_.time().value() << token::TAB
904  << phiPos << token::TAB
905  << phiNeg << token::TAB
906  << netFlux << token::TAB
907  << absoluteFlux
908  << endl;
909  }
910  }
911 
912  if (log_) Info<< endl;
913 }
914 
915 
916 
917 // ************************************************************************* //
Foam::token::TAB
@ TAB
Definition: token.H:96
meshTools.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::OBJstream
OFstream which keeps track of vertices.
Definition: OBJstream.H:53
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::DynamicList< word >
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::OBJstream::write
virtual Ostream & write(const char)
Write character.
Definition: OBJstream.C:82
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
globalIndex.H
Foam::labelMax
static const label labelMax
Definition: label.H:62
Foam::PatchEdgeFaceWave
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
Definition: PatchEdgeFaceWave.H:69
Foam::PrimitivePatch::nEdges
label nEdges() const
Return number of edges in patch.
Definition: PrimitivePatchTemplate.H:299
Foam::minOp
Definition: ops.H:173
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:322
Foam::indirectPrimitivePatch
PrimitivePatch< face, IndirectList, const pointField & > indirectPrimitivePatch
Foam::indirectPrimitivePatch.
Definition: indirectPrimitivePatch.H:45
Foam::calc
void calc(const argList &args, const Time &runTime, const fvMesh &mesh)
Definition: Lambda2.C:38
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::fluxSummary::obr_
const objectRegistry & obr_
Reference to the database.
Definition: fluxSummary.H:166
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::functionObjectFile::read
void read(const dictionary &dict)
Read.
Definition: functionObjectFile.C:178
Foam::globalIndex::isLocal
bool isLocal(const label i) const
Is on local processor.
Definition: globalIndexI.H:95
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
surfaceFields.H
Foam::surfaceFields.
Foam::PrimitivePatch::faceEdges
const labelListList & faceEdges() const
Return face-edge addressing.
Definition: PrimitivePatchTemplate.C:312
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
syncTools.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
modeTypeNames_
const Foam::NamedEnum< Foam::scene::modeType, 2 > modeTypeNames_
Definition: scene.C:53
Foam::fluxSummary::initialiseFaceArea
void initialiseFaceArea()
Initialise the total area per derived faceZone.
Definition: fluxSummary.C:543
Foam::fluxSummary::execute
virtual void execute()
Execute, currently does nothing.
Definition: fluxSummary.C:794
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
PatchEdgeFaceWave.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::fluxSummary::facePatchID_
List< List< label > > facePatchID_
Face patch IDs.
Definition: fluxSummary.H:196
Foam::fluxSummary::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: fluxSummary.C:800
Foam::faceZone
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:64
Foam::fluxSummary::initialiseCellZoneAndDirection
void initialiseCellZoneAndDirection(const word &cellZoneName, const vector &refDir, DynamicList< vector > &dir, DynamicList< word > &faceZoneNames, DynamicList< List< label > > &faceID, DynamicList< List< label > > &facePatchID, DynamicList< List< scalar > > &faceSign) const
Initialise face set from cell zone and direction.
Definition: fluxSummary.C:262
Foam::List::append
void append(const T &)
Append an element at the end of the list.
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::IndirectList
A List with indirect addressing.
Definition: IndirectList.H:102
Foam::fluxSummary::initialiseFaceZone
void initialiseFaceZone(const word &faceZoneName, DynamicList< word > &faceZoneNames, DynamicList< List< label > > &faceID, DynamicList< List< label > > &facePatchID, DynamicList< List< scalar > > &faceSign) const
Initialise face set from face zone.
Definition: fluxSummary.C:64
Foam::fluxSummary::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: fluxSummary.C:625
Foam::identity
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fluxSummary::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fluxSummary.C:806
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fluxSummary::fluxSummary
fluxSummary(const fluxSummary &)
Disallow default bitwise copy construct.
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::fluxSummary::~fluxSummary
virtual ~fluxSummary()
Destructor.
Definition: fluxSummary.C:619
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::globalIndex
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::DynamicList::append
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::globalIndex::toLocal
label toLocal(const label i) const
From global to local on current processor.
Definition: globalIndexI.H:117
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::polyPatch::whichFace
label whichFace(const label l) const
Return label of face in patch from global face label.
Definition: polyPatch.H:389
Foam::sumOp
Definition: ops.H:162
Foam::tab
static const char tab
Definition: Ostream.H:259
Foam::fluxSummary::faceArea_
List< scalar > faceArea_
Sum of face areas.
Definition: fluxSummary.H:202
Foam::fluxSummary::writeFileHeader
virtual void writeFileHeader(const word &fzName, const scalar area, const vector &refDir, Ostream &os) const
Output file header information.
Definition: fluxSummary.C:760
Foam::Vector< scalar >
Foam::List< label >
Foam::patchEdgeFaceRegion
Transport of region for use in PatchEdgeFaceWave.
Definition: patchEdgeFaceRegion.H:59
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
dictionary.H
Foam::fluxSummary::write
virtual void write()
Write the fluxSummary.
Definition: fluxSummary.C:812
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:106
Foam::fluxSummary::faceID_
List< List< label > > faceID_
Face IDs.
Definition: fluxSummary.H:193
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fluxSummary::modeType
modeType
Face mode type.
Definition: fluxSummary.H:146
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::fluxSummary::modeTypeNames_
static const NamedEnum< modeType, 3 > modeTypeNames_
Mode type names.
Definition: fluxSummary.H:154
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
Foam::fluxSummary::initialiseFaceZoneAndDirection
void initialiseFaceZoneAndDirection(const word &faceZoneName, const vector &refDir, DynamicList< vector > &dir, DynamicList< word > &faceZoneNames, DynamicList< List< label > > &faceID, DynamicList< List< label > > &facePatchID, DynamicList< List< scalar > > &faceSign) const
Initialise face set from face zone and direction.
Definition: fluxSummary.C:153
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::faceZone::flipMap
const boolList & flipMap() const
Return face flip map.
Definition: faceZone.H:249
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
patchEdgeFaceRegion.H
fluxSummary.H
OBJstream.H
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::NamedEnum
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:52
Foam::globalIndex::toGlobal
label toGlobal(const label i) const
From local to global.
Definition: globalIndexI.H:82
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88