forcesBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
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 "forcesBase.H"
27 #include "fvcGrad.H"
28 #include "porosityModel.H"
33 #include "fluidThermo.H"
34 #include "surfaceInterpolate.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace functionObjects
42 {
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 
51 (
52  const dictionary& dict
53 ) const
54 {
56 
57  const word forceType(dict.lookup("type"));
58 
59  // Name for file(fileID::mainFile=0)
60  names.append(forceType);
61 
62  if (dict.found("binData"))
63  {
64  const dictionary& binDict(dict.subDict("binData"));
65  const label nb = binDict.lookup<label>("nBin");
66  if (nb > 0)
67  {
68  // Name for file(fileID::binsFile=1)
69  names.append(forceType + "_bins");
70  }
71  }
72 
73  return names;
74 }
75 
76 
78 {
79  const word forceTypes
80  (
81  porosity_
82  ? "(pressure viscous porous)"
83  : "(pressure viscous)"
84  );
85 
86  switch (fileID(i))
87  {
88  case fileID::mainFile:
89  {
90  // force data
91 
92  writeHeader(file(i), "Forces");
93  writeCoRValueHeader(file(i));
94  writeCommented(file(i), "Time");
95 
96  writeCoRHeader(file(i));
97 
98  file(i)
99  << "forces" << forceTypes << tab
100  << "moments" << forceTypes;
101 
102  break;
103  }
104  case fileID::binsFile:
105  {
106  // bin data
107 
108  writeHeader(file(i), "Force bins");
109  writeHeaderValue(file(i), "bins", nBin_);
110  writeHeaderValue(file(i), "start", binMin_);
111  writeHeaderValue(file(i), "delta", binDx_);
112  writeHeaderValue(file(i), "direction", binDir_);
113 
114  vectorField binPoints(nBin_);
115  writeCommented(file(i), "x co-ords :");
116  forAll(binPoints, pointi)
117  {
118  binPoints[pointi] = (binMin_ + (pointi + 1)*binDx_)*binDir_;
119  file(i) << tab << binPoints[pointi].x();
120  }
121  file(i) << nl;
122 
123  writeCommented(file(i), "y co-ords :");
124  forAll(binPoints, pointi)
125  {
126  file(i) << tab << binPoints[pointi].y();
127  }
128  file(i) << nl;
129 
130  writeCommented(file(i), "z co-ords :");
131  forAll(binPoints, pointi)
132  {
133  file(i) << tab << binPoints[pointi].z();
134  }
135  file(i) << nl;
136 
137  writeCommented(file(i), "Time");
138 
139  for (label j = 0; j < nBin_; j++)
140  {
141  const word jn('(' + Foam::name(j) + ')');
142  const word f("forces" + jn + forceTypes);
143  const word m("moments" + jn + forceTypes);
144 
145  file(i)<< tab << f << tab << m;
146  }
147 
148  break;
149  }
150  default:
151  {
153  << "Unhandled file index: " << i
154  << abort(FatalError);
155  }
156  }
157 
158  file(i)<< endl;
159 }
160 
161 
163 {
164  if (initialised_)
165  {
166  return;
167  }
168 
169  if (directForceDensity_)
170  {
171  if (!obr_.foundObject<volVectorField>(fDName_))
172  {
174  << "Could not find " << fDName_ << " in database."
175  << exit(FatalError);
176  }
177  }
178  else
179  {
180  if
181  (
182  !obr_.foundObject<volVectorField>(UName_)
183  || !obr_.foundObject<volScalarField>(pName_)
184 
185  )
186  {
188  << "Could not find " << UName_ << ", " << pName_
189  << exit(FatalError);
190  }
191 
192  if
193  (
194  rhoName_ != "rhoInf"
195  && !obr_.foundObject<volScalarField>(rhoName_)
196  )
197  {
199  << "Could not find " << rhoName_
200  << exit(FatalError);
201  }
202  }
203 
204  initialised_ = true;
205 }
206 
207 
208 
209 
211 (
212  const volScalarField& p
213 ) const
214 {
215  if (p.dimensions() == dimPressure)
216  {
217  return 1.0;
218  }
219  else
220  {
221  if (rhoName_ != "rhoInf")
222  {
224  << "Dynamic pressure is expected but kinematic is provided."
225  << exit(FatalError);
226  }
227 
228  return rhoRef_;
229  }
230 }
231 
232 
234 {
235  if (phaseName_ == word::null)
236  {
237  return volScalarField::New
238  (
239  "alpha",
240  mesh_,
242  );
243  }
244  else
245  {
246  return obr_.lookupObject<volScalarField>
247  (
248  IOobject::groupName("alpha", phaseName_)
249  );
250  }
251 }
252 
253 
255 (
256  const label patchi
257 ) const
258 {
259  if (phaseName_ == word::null)
260  {
261  return tmp<scalarField>
262  (
263  new scalarField(mesh_.boundary()[patchi].size(), 1)
264  );
265  }
266  else
267  {
268  return obr_.lookupObject<volScalarField>
269  (
270  IOobject::groupName("alpha", phaseName_)
271  ).boundaryField()[patchi];
272  }
273 }
274 
275 
277 (
278  const vectorField& Md,
279  const vectorField& fN,
280  const vectorField& fT,
281  const vectorField& fP,
282  const vectorField& d
283 )
284 {
285  if (nBin_ == 1)
286  {
287  force_[0][0] += sum(fN);
288  force_[1][0] += sum(fT);
289  force_[2][0] += sum(fP);
290  moment_[0][0] += sum(Md^fN);
291  moment_[1][0] += sum(Md^fT);
292  moment_[2][0] += sum(Md^fP);
293  }
294  else
295  {
296  scalarField dd((d & binDir_) - binMin_);
297 
298  forAll(dd, i)
299  {
300  label bini = min(max(floor(dd[i]/binDx_), 0), force_[0].size() - 1);
301 
302  force_[0][bini] += fN[i];
303  force_[1][bini] += fT[i];
304  force_[2][bini] += fP[i];
305  moment_[0][bini] += Md[i]^fN[i];
306  moment_[1][bini] += Md[i]^fT[i];
307  moment_[2][bini] += Md[i]^fP[i];
308  }
309  }
310 }
311 
312 
314 {}
315 
316 
318 {
319  file << "CofR" << tab;
320 }
321 
322 
324 {
325  file << CofR();
326 }
327 
328 
330 {
331  Log << type() << " " << name() << " write:" << nl
332  << " sum of forces:" << nl
333  << " pressure : " << sum(force_[0]) << nl
334  << " viscous : " << sum(force_[1]) << nl
335  << " porous : " << sum(force_[2]) << nl
336  << " sum of moments:" << nl
337  << " pressure : " << sum(moment_[0]) << nl
338  << " viscous : " << sum(moment_[1]) << nl
339  << " porous : " << sum(moment_[2])
340  << endl;
341 
342  writeTime(file(fileID::mainFile));
343  writeCofR(file(fileID::mainFile));
344 
345  if (porosity_)
346  {
347  file(fileID::mainFile) << tab << setw(1) << '('
348  << sum(force_[0]) << setw(1) << ' '
349  << sum(force_[1]) << setw(1) << ' '
350  << sum(force_[2]) << setw(3) << ") ("
351  << sum(moment_[0]) << setw(1) << ' '
352  << sum(moment_[1]) << setw(1) << ' '
353  << sum(moment_[2]) << setw(1) << ')';
354  }
355  else
356  {
357  file(fileID::mainFile) << tab << setw(1) << '('
358  << sum(force_[0]) << setw(1) << ' '
359  << sum(force_[1]) << setw(3) << ") ("
360  << sum(moment_[0]) << setw(1) << ' '
361  << sum(moment_[1]) << setw(1) << ')';
362  }
363 
364  file(fileID::mainFile) << endl;
365 }
366 
367 
369 {
370  if (nBin_ == 1)
371  {
372  return;
373  }
374 
375  List<Field<vector>> f(force_);
376  List<Field<vector>> m(moment_);
377 
378  if (binCumulative_)
379  {
380  for (label i = 1; i < f[0].size(); i++)
381  {
382  f[0][i] += f[0][i-1];
383  f[1][i] += f[1][i-1];
384  f[2][i] += f[2][i-1];
385 
386  m[0][i] += m[0][i-1];
387  m[1][i] += m[1][i-1];
388  m[2][i] += m[2][i-1];
389  }
390  }
391 
392  writeTime(file(fileID::binsFile));
393 
394 
395  forAll(f[0], i)
396  {
397  if (porosity_)
398  {
399  file(fileID::binsFile)
400  << tab << setw(1) << '('
401  << f[0][i] << setw(1) << ' '
402  << f[1][i] << setw(1) << ' '
403  << f[2][i] << setw(3) << ") ("
404  << m[0][i] << setw(1) << ' '
405  << m[1][i] << setw(1) << ' '
406  << m[2][i] << setw(1) << ')';
407  }
408  else
409  {
410  file(fileID::binsFile)
411  << tab << setw(1) << '('
412  << f[0][i] << setw(1) << ' '
413  << f[1][i] << setw(3) << ") ("
414  << m[0][i] << setw(1) << ' '
415  << m[1][i] << setw(1) << ')';
416  }
417  }
418 
419  file(fileID::binsFile) << endl;
420 }
421 
422 
423 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
424 
426 (
427  const word& name,
428  const Time& runTime,
429  const dictionary& dict
430 )
431 :
432  fvMeshFunctionObject(name, runTime, dict),
433  logFiles(obr_, name),
434  force_(3),
435  moment_(3),
436  patchSet_(),
437  pName_(word::null),
438  UName_(word::null),
439  rhoName_(word::null),
440  phaseName_(word::null),
441  directForceDensity_(false),
442  fDName_(""),
443  rhoRef_(vGreat),
444  pRef_(0),
445  porosity_(false),
446  nBin_(1),
447  binDir_(Zero),
448  binDx_(0.0),
449  binMin_(great),
450  binPoints_(),
451  binCumulative_(true),
452  initialised_(false)
453 {
454  read(dict);
455 }
456 
457 
459 (
460  const word& name,
461  const objectRegistry& obr,
462  const dictionary& dict
463 )
464 :
466  logFiles(obr_, name),
467  force_(3),
468  moment_(3),
469  patchSet_(),
470  pName_(word::null),
471  UName_(word::null),
472  rhoName_(word::null),
473  phaseName_(word::null),
474  directForceDensity_(false),
475  fDName_(""),
476  rhoRef_(vGreat),
477  pRef_(0),
478  porosity_(false),
479  nBin_(1),
480  binDir_(Zero),
481  binDx_(0.0),
482  binMin_(great),
483  binPoints_(),
484  binCumulative_(true),
485  initialised_(false)
486 {
487  read(dict);
488 }
489 
490 
491 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
492 
494 {}
495 
496 
497 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
498 
500 {
502 
503  initialised_ = false;
504 
505  Log << type() << " " << name() << ":" << nl;
506 
507  directForceDensity_ = dict.lookupOrDefault("directForceDensity", false);
508 
509  const polyBoundaryMesh& pbm = mesh_.poly().boundary();
510 
511  patchSet_ = mesh_.poly().boundary().patchSet(dict);
512 
513  if (directForceDensity_)
514  {
515  // Optional entry for fDName
516  fDName_ = dict.lookupOrDefault<word>("fD", "fD");
517  }
518  else
519  {
520  // Optional phase entry
521  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
522 
523  // Optional U, p and rho entries
524  pName_ =
525  dict.lookupOrDefault<word>
526  (
527  "p",
528  IOobject::groupName("p", phaseName_)
529  );
530  UName_ =
531  dict.lookupOrDefault<word>
532  (
533  "U",
534  IOobject::groupName("U", phaseName_)
535  );
536  rhoName_ =
537  dict.lookupOrDefault<word>
538  (
539  "rho",
540  IOobject::groupName("rho", phaseName_)
541  );
542 
543  // Reference density needed for incompressible calculations
544  if (rhoName_ == "rhoInf")
545  {
546  dict.lookup("rhoInf") >> rhoRef_;
547  }
548 
549  // Reference pressure, 0 by default
550  pRef_ = dict.lookupOrDefault<scalar>("pRef", 0.0);
551  }
552 
553  dict.readIfPresent("porosity", porosity_);
554  if (porosity_)
555  {
556  Log << " Including porosity effects" << endl;
557  }
558  else
559  {
560  Log << " Not including porosity effects" << endl;
561  }
562 
563  if (dict.found("binData"))
564  {
565  const dictionary& binDict(dict.subDict("binData"));
566  binDict.lookup("nBin") >> nBin_;
567 
568  if (nBin_ < 0)
569  {
571  << "Number of bins (nBin) must be zero or greater"
572  << exit(FatalIOError);
573  }
574  else if ((nBin_ == 0) || (nBin_ == 1))
575  {
576  nBin_ = 1;
577  forAll(force_, i)
578  {
579  force_[i].setSize(1);
580  moment_[i].setSize(1);
581  }
582  }
583 
584  if (nBin_ > 1)
585  {
586  binDict.lookup("direction") >> binDir_;
587  binDir_ /= mag(binDir_);
588 
589  binMin_ = great;
590  scalar binMax = -great;
591  forAllConstIter(labelHashSet, patchSet_, iter)
592  {
593  const label patchi = iter.key();
594  const polyPatch& pp = pbm[patchi];
595  const scalarField d(pp.faceCentres() & binDir_);
596  binMin_ = min(min(d), binMin_);
597  binMax = max(max(d), binMax);
598  }
599  reduce(binMin_, minOp<scalar>());
600  reduce(binMax, maxOp<scalar>());
601 
602  // slightly boost binMax so that region of interest is fully
603  // within bounds
604  binMax = 1.0001*(binMax - binMin_) + binMin_;
605 
606  binDx_ = (binMax - binMin_)/scalar(nBin_);
607 
608  // create the bin points used for writing
609  binPoints_.setSize(nBin_);
610  forAll(binPoints_, i)
611  {
612  binPoints_[i] = (i + 0.5)*binDir_*binDx_;
613  }
614 
615  binDict.lookup("cumulative") >> binCumulative_;
616 
617  // allocate storage for forces and moments
618  forAll(force_, i)
619  {
620  force_[i].setSize(nBin_);
621  moment_[i].setSize(nBin_);
622  }
623  }
624  }
625 
626  if (nBin_ == 1)
627  {
628  // allocate storage for forces and moments
629  force_[0].setSize(1);
630  force_[1].setSize(1);
631  force_[2].setSize(1);
632  moment_[0].setSize(1);
633  moment_[1].setSize(1);
634  moment_[2].setSize(1);
635  }
636 
637  resetNames(createFileNames(dict));
638 
639  return true;
640 }
641 
644 {
646  typedef compressible::momentumTransportModel cmpModel;
647  typedef phaseIncompressible::momentumTransportModel phaseIcoModel;
648  typedef phaseCompressible::momentumTransportModel phaseCmpModel;
649 
651  const word phaseModelName =
652  phaseName_ == word::null
653  ? word::null
655 
656  if (obr_.foundObject<icoModel>(modelName))
657  {
659  obr_.lookupObject<icoModel>(modelName);
660 
661  return fvc::interpolate(alpha()*rho())*model.devSigma();
662  }
663  else if (obr_.foundObject<cmpModel>(modelName))
664  {
665  const cmpModel& model =
666  obr_.lookupObject<cmpModel>(modelName);
667 
668  return fvc::interpolate(alpha())*model.devTau();
669  }
670  else if (obr_.foundObject<phaseIcoModel>(phaseModelName))
671  {
672  const phaseIcoModel& model =
673  obr_.lookupObject<phaseIcoModel>(phaseModelName);
674 
675  return fvc::interpolate(rho())*model.devSigma();
676  }
677  else if (obr_.foundObject<phaseCmpModel>(phaseModelName))
678  {
679  const phaseCmpModel& model =
680  obr_.lookupObject<phaseCmpModel>(phaseModelName);
681 
682  return model.devTau();
683  }
684  else
685  {
687  << "No valid model for viscous stress calculation"
688  << exit(FatalError);
689 
690  return surfaceVectorField::null();
691  }
692 }
693 
694 
696 {
698  typedef compressible::momentumTransportModel cmpModel;
699  typedef phaseIncompressible::momentumTransportModel phaseIcoModel;
700  typedef phaseCompressible::momentumTransportModel phaseCmpModel;
701 
703  const word phaseModelName =
704  phaseName_ == word::null
705  ? word::null
707 
708  if (obr_.foundObject<icoModel>(modelName))
709  {
711  obr_.lookupObject<icoModel>(modelName);
712 
713  return rho()*model.nu();
714  }
715  else if (obr_.foundObject<cmpModel>(modelName))
716  {
717  const cmpModel& model =
718  obr_.lookupObject<cmpModel>(modelName);
719 
720  return model.rho()*model.nu();
721  }
722  else if (obr_.foundObject<phaseIcoModel>(phaseModelName))
723  {
724  const phaseIcoModel& model =
725  obr_.lookupObject<phaseIcoModel>(phaseModelName);
726 
727  return rho()*model.nu();
728  }
729  else if (obr_.foundObject<phaseCmpModel>(phaseModelName))
730  {
731  const phaseCmpModel& model =
732  obr_.lookupObject<phaseCmpModel>(phaseModelName);
733 
734  return model.rho()*model.nu();
735  }
736  else if (obr_.foundObject<dictionary>("physicalProperties"))
737  {
738  // Legacy support for icoFoam
739 
741  obr_.lookupObject<dictionary>("physicalProperties");
742 
743  const dimensionedScalar nu
744  (
745  "nu",
748  );
749 
750  return rho()*nu;
751  }
752  else
753  {
755  << "No valid model for dynamic viscosity calculation"
756  << exit(FatalError);
757 
758  return volScalarField::null();
759  }
760 }
761 
762 
764 {
765  if (rhoName_ == "rhoInf")
766  {
767  return volScalarField::New
768  (
769  "rho",
770  mesh_,
771  dimensionedScalar(dimDensity, rhoRef_)
772  );
773  }
774  else
775  {
776  return(obr_.lookupObject<volScalarField>(rhoName_));
777  }
778 }
779 
780 
782 {
783  initialise();
784 
785  force_[0] = Zero;
786  force_[1] = Zero;
787  force_[2] = Zero;
788 
789  moment_[0] = Zero;
790  moment_[1] = Zero;
791  moment_[2] = Zero;
792 
793  if (directForceDensity_)
794  {
795  const volVectorField& fD = obr_.lookupObject<volVectorField>(fDName_);
796 
797  const surfaceVectorField::Boundary& Sfb =
798  mesh_.Sf().boundaryField();
799 
800  forAllConstIter(labelHashSet, patchSet_, iter)
801  {
802  const label patchi = iter.key();
803 
804  const vectorField Md
805  (
806  mesh_.C().boundaryField()[patchi] - CofR
807  );
808 
809  const scalarField sA(mag(Sfb[patchi]));
810 
811  // Normal force = surfaceUnitNormal*(surfaceNormal & forceDensity)
812  const vectorField fN
813  (
814  Sfb[patchi]/sA
815  *(
816  Sfb[patchi] & fD.boundaryField()[patchi]
817  )
818  );
819 
820  // Tangential force (total force minus normal fN)
821  const vectorField fT(sA*fD.boundaryField()[patchi] - fN);
822 
823  //- Porous force
824  const vectorField fP(Md.size(), Zero);
825 
826  applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[patchi]);
827  }
828  }
829  else
830  {
831  const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
832 
833  const surfaceVectorField::Boundary& Sfb =
834  mesh_.Sf().boundaryField();
835 
836  const surfaceScalarField::Boundary& magSfb =
837  mesh_.magSf().boundaryField();
838 
839  tmp<surfaceVectorField> tdevTau = devTau();
840  const surfaceVectorField::Boundary& devTaub = tdevTau().boundaryField();
841 
842  // Scale pRef by density for incompressible simulations
843  const scalar pRef = pRef_/rho(p);
844 
845  forAllConstIter(labelHashSet, patchSet_, iter)
846  {
847  const label patchi = iter.key();
848 
849  const vectorField Md
850  (
851  mesh_.C().boundaryField()[patchi] - CofR
852  );
853 
854  const vectorField fN
855  (
856  alpha(patchi)
857  *rho(p)
858  *Sfb[patchi]
859  *(p.boundaryField()[patchi] - pRef)
860  );
861 
862  const vectorField fT(magSfb[patchi] * devTaub[patchi]);
863 
864  const vectorField fP(Md.size(), Zero);
865 
866  applyBins(Md, fN, fT, fP, mesh_.C().boundaryField()[patchi]);
867  }
868  }
869 
870  if (porosity_)
871  {
872  const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
873  const volScalarField rho(this->rho());
874  const volScalarField mu(this->mu());
875 
876  const HashTable<const porosityModel*> models =
877  obr_.lookupClass<porosityModel>();
878 
879  if (models.empty())
880  {
882  << "Porosity effects requested, but no porosity models found "
883  << "in the database"
884  << endl;
885  }
886 
888  {
889  const porosityModel& pm = *iter();
890 
891  const vectorField fPTot(pm.force(U, rho, mu));
892 
893  const cellZone& cZone = mesh_.cellZones()[pm.zoneName()];
894  const vectorField d(mesh_.C(), cZone);
895  const vectorField fP(fPTot, cZone);
896  const vectorField Md(d - CofR);
897 
898  const vectorField fDummy(Md.size(), Zero);
899 
900  applyBins(Md, fDummy, fDummy, fP, d);
901  }
902  }
903 
908 }
909 
910 
912 {
914 }
915 
916 
918 {
919  return sum(force_[0]) + sum(force_[1]) + sum(force_[2]);
920 }
921 
922 
924 {
925  return sum(moment_[0]) + sum(moment_[1]) + sum(moment_[2]);
926 }
927 
928 
930 {
931  return true;
932 }
933 
934 
936 {
937  calcForcesMoments(CofR());
938 
939  if (Pstream::master())
940  {
941  logFiles::write();
942 
943  writeForces();
944 
945  writeBins();
946 
947  Log << endl;
948  }
949 
950  return true;
951 }
952 
953 
954 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:492
Macros for easy insertion into run-time selection tables.
Generic GeometricBoundaryField class.
Generic GeometricField class.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
static const GeometricField< Type, GeoMesh, PrimitiveField > & null()
Return a null geometric field.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
An STL-conforming hash table.
Definition: HashTable.H:127
bool empty() const
Return true if the hash table is empty.
Definition: HashTableI.H:72
static word groupName(Name name, const word &group)
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
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.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:423
Named list of cell indices representing a sub-set of the mesh.
Definition: cellZone.H:61
Base class for single-phase compressible momentum transport models.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:669
Calculates the forces and moments by integrating the pressure and skin-friction forces over a given l...
Definition: forcesBase.H:64
virtual void calcForcesMoments()
Calculate the forces and moments.
Definition: forcesBase.C:911
tmp< volScalarField > alpha() const
Get the volume fraction field.
Definition: forcesBase.C:233
void initialise()
Initialise the fields.
Definition: forcesBase.C:162
virtual void writeCoRHeader(Ostream &file)
Write the time varying centre of rotation column header.
Definition: forcesBase.C:317
tmp< surfaceVectorField > devTau() const
Return the effective surface stress.
Definition: forcesBase.C:643
void applyBins(const vectorField &Md, const vectorField &fN, const vectorField &fT, const vectorField &fP, const vectorField &d)
Accumulate bin data.
Definition: forcesBase.C:277
tmp< volScalarField > mu() const
Dynamic viscosity field.
Definition: forcesBase.C:695
virtual vector forceEff() const
Return the total force.
Definition: forcesBase.C:917
forcesBase(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: forcesBase.C:426
virtual vector momentEff() const
Return the total moment.
Definition: forcesBase.C:923
virtual void writeCoRValueHeader(Ostream &file)
Write the constant centre of rotation value in the header.
Definition: forcesBase.C:313
void writeBins()
Helper function to write bin data.
Definition: forcesBase.C:368
virtual ~forcesBase()
Destructor.
Definition: forcesBase.C:493
virtual void writeFileHeader(const label i)
Output file header information.
Definition: forcesBase.C:77
void writeForces()
Helper function to write force data.
Definition: forcesBase.C:329
tmp< volScalarField > rho() const
Return rho if specified otherwise rhoRef.
Definition: forcesBase.C:763
fileID
Enumeration for ensuring the right file is accessed.
Definition: forcesBase.H:72
virtual bool execute()
Execute, currently does nothing.
Definition: forcesBase.C:929
virtual bool write()
Write the forces.
Definition: forcesBase.C:935
virtual void writeCofR(Ostream &file)
Write the time varying centre of rotation.
Definition: forcesBase.C:323
virtual bool read(const dictionary &)
Read the forces data.
Definition: forcesBase.C:499
wordList createFileNames(const dictionary &dict) const
Create file names for forces and bins.
Definition: forcesBase.C:51
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
const wordList & names() const
Return the list of log file names.
Definition: logFiles.C:107
virtual bool write()
Write function.
Definition: logFiles.C:173
virtual bool read(const dictionary &)
Read optional controls.
Base class for single-phase incompressible momentum transport models.
virtual tmp< surfaceVectorField > devSigma() const
Return the effective surface stress.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Registry of regIOobjects.
Templated abstract base class for multiphase compressible momentum transport models.
Templated abstract base class for multiphase incompressible momentum transport models.
A base class for physical properties.
Foam::polyBoundaryMesh.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the patch set corresponding to the given names.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
const vectorField::subField faceCentres() const
Return face centres.
Definition: polyPatch.C:227
Top level model for porosity models.
Definition: porosityModel.H:57
const word & zoneName() const
Return const access to the cell zone name.
virtual tmp< vectorField > force(const volVectorField &U, const volScalarField &rho, const volScalarField &mu) const
Return the force over the cell zone(s)
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
static const word null
An empty word.
Definition: word.H:78
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Calculate the gradient of the given field.
label patchi
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
#define WarningInFunction
Report a warning using Foam::Warning.
#define Log
Report write to Foam::Info if the local log switch is true.
const dimensionedScalar mu
Atomic mass unit.
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
void writeHeader(std::ostream &, const bool isBinary, const std::string &title)
Write header.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
const dimensionSet & dimless
Definition: dimensions.C:138
const dimensionSet & dimKinematicViscosity
Definition: dimensions.C:171
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
static const char tab
Definition: Ostream.H:296
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimDensity
Definition: dimensions.C:158
tmp< DimensionedField< scalar, GeoMesh, Field > > jn(const int n, const DimensionedField< scalar, GeoMesh, PrimitiveField > &dsf)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
const dimensionSet & dimPressure
Definition: dimensions.C:163
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
error FatalError
static const char nl
Definition: Ostream.H:297
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
labelList f(nPoints)
dictionary dict
volScalarField & p