forces.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "forces.H"
30 #include "fvcGrad.H"
31 #include "porosityModel.H"
34 #include "cartesianCS.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace functionObjects
42 {
43  defineTypeNameAndDebug(forces, 0);
44  addToRunTimeSelectionTable(functionObject, forces, dictionary);
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
50 
52 (
53  const dictionary& dict,
54  const word& e3Name,
55  const word& e1Name
56 )
57 {
58  point origin(Zero);
59 
60  // With objectRegistry for access to indirect (global) coordinate systems
61  coordSysPtr_ = coordinateSystem::NewIfPresent(obr_, dict);
62 
63  if (coordSysPtr_)
64  {
65  // Report ...
66  }
67  else if (dict.readIfPresent("CofR", origin))
68  {
69  const vector e3
70  (
71  e3Name.empty() ? vector(0, 0, 1) : dict.get<vector>(e3Name)
72  );
73  const vector e1
74  (
75  e1Name.empty() ? vector(1, 0, 0) : dict.get<vector>(e1Name)
76  );
77 
78  coordSysPtr_.reset(new coordSystem::cartesian(origin, e3, e1));
79  }
80  else
81  {
82  // No 'coordinateSystem' or 'CofR'
83  // - enforce a cartesian system
84 
86  }
87 }
88 
89 
91 {
92  auto* forcePtr = mesh_.getObjectPtr<volVectorField>(scopedName("force"));
93 
94  if (!forcePtr)
95  {
96  forcePtr = new volVectorField
97  (
98  IOobject
99  (
100  scopedName("force"),
101  time_.timeName(),
102  mesh_,
105  ),
106  mesh_,
108  );
109 
110  mesh_.objectRegistry::store(forcePtr);
111  }
112 
113  return *forcePtr;
114 }
115 
116 
118 {
119  auto* momentPtr = mesh_.getObjectPtr<volVectorField>(scopedName("moment"));
120 
121  if (!momentPtr)
122  {
123  momentPtr = new volVectorField
124  (
125  IOobject
126  (
127  scopedName("moment"),
128  time_.timeName(),
129  mesh_,
132  ),
133  mesh_,
135  );
136 
137  mesh_.objectRegistry::store(momentPtr);
138  }
139 
140  return *momentPtr;
141 }
142 
143 
145 {
146  if (initialised_)
147  {
148  return;
149  }
150 
151  if (directForceDensity_)
152  {
153  if (!foundObject<volVectorField>(fDName_))
154  {
156  << "Could not find " << fDName_ << " in database"
157  << exit(FatalError);
158  }
159  }
160  else
161  {
162  if
163  (
164  !foundObject<volVectorField>(UName_)
165  || !foundObject<volScalarField>(pName_)
166  )
167  {
169  << "Could not find U: " << UName_
170  << " or p:" << pName_ << " in database"
171  << exit(FatalError);
172  }
173 
174  if (rhoName_ != "rhoInf" && !foundObject<volScalarField>(rhoName_))
175  {
177  << "Could not find rho:" << rhoName_ << " in database"
178  << exit(FatalError);
179  }
180  }
181 
182  initialised_ = true;
183 }
184 
185 
187 {
188  sumPatchForcesP_ = Zero;
189  sumPatchForcesV_ = Zero;
190  sumPatchMomentsP_ = Zero;
191  sumPatchMomentsV_ = Zero;
192 
193  sumInternalForces_ = Zero;
194  sumInternalMoments_ = Zero;
195 
196  auto& force = this->force();
197  auto& moment = this->moment();
198  force == dimensionedVector(force.dimensions(), Zero);
199  moment == dimensionedVector(moment.dimensions(), Zero);
200 }
201 
202 
205 {
206  typedef compressible::turbulenceModel cmpTurbModel;
207  typedef incompressible::turbulenceModel icoTurbModel;
208 
209  if (foundObject<cmpTurbModel>(cmpTurbModel::propertiesName))
210  {
211  const auto& turb =
212  lookupObject<cmpTurbModel>(cmpTurbModel::propertiesName);
213 
214  return turb.devRhoReff();
215  }
216  else if (foundObject<icoTurbModel>(icoTurbModel::propertiesName))
217  {
218  const auto& turb =
219  lookupObject<icoTurbModel>(icoTurbModel::propertiesName);
220 
221  return rho()*turb.devReff();
222  }
223  else if (foundObject<fluidThermo>(fluidThermo::dictName))
224  {
225  const auto& thermo = lookupObject<fluidThermo>(fluidThermo::dictName);
226 
227  const auto& U = lookupObject<volVectorField>(UName_);
228 
229  return -thermo.mu()*dev(twoSymm(fvc::grad(U)));
230  }
231  else if (foundObject<transportModel>("transportProperties"))
232  {
233  const auto& laminarT =
234  lookupObject<transportModel>("transportProperties");
235 
236  const auto& U = lookupObject<volVectorField>(UName_);
237 
238  return -rho()*laminarT.nu()*dev(twoSymm(fvc::grad(U)));
239  }
240  else if (foundObject<dictionary>("transportProperties"))
241  {
242  const auto& transportProperties =
243  lookupObject<dictionary>("transportProperties");
244 
246 
247  const auto& U = lookupObject<volVectorField>(UName_);
248 
249  return -rho()*nu*dev(twoSymm(fvc::grad(U)));
250  }
251  else
252  {
254  << "No valid model for viscous stress calculation"
256 
257  return volSymmTensorField::null();
258  }
259 }
260 
261 
263 {
264  if (foundObject<fluidThermo>(basicThermo::dictName))
265  {
266  const auto& thermo = lookupObject<fluidThermo>(basicThermo::dictName);
267 
268  return thermo.mu();
269  }
270  else if (foundObject<transportModel>("transportProperties"))
271  {
272  const auto& laminarT =
273  lookupObject<transportModel>("transportProperties");
274 
275  return rho()*laminarT.nu();
276  }
277  else if (foundObject<dictionary>("transportProperties"))
278  {
279  const auto& transportProperties =
280  lookupObject<dictionary>("transportProperties");
281 
283 
284  return rho()*nu;
285  }
286  else
287  {
289  << "No valid model for dynamic viscosity calculation"
291 
292  return volScalarField::null();
293  }
294 }
295 
296 
298 {
299  if (rhoName_ == "rhoInf")
300  {
302  (
303  IOobject
304  (
305  "rho",
306  mesh_.time().timeName(),
307  mesh_
308  ),
309  mesh_,
310  dimensionedScalar(dimDensity, rhoRef_)
311  );
312  }
313 
314  return (lookupObject<volScalarField>(rhoName_));
315 }
316 
317 
318 Foam::scalar Foam::functionObjects::forces::rho(const volScalarField& p) const
319 {
320  if (p.dimensions() == dimPressure)
321  {
322  return 1;
323  }
324 
325  if (rhoName_ != "rhoInf")
326  {
328  << "Dynamic pressure is expected but kinematic is provided."
329  << exit(FatalError);
330  }
331 
332  return rhoRef_;
333 }
334 
335 
337 (
338  const label patchi,
339  const vectorField& Md,
340  const vectorField& fP,
341  const vectorField& fV
342 )
343 {
344  sumPatchForcesP_ += sum(fP);
345  sumPatchForcesV_ += sum(fV);
346  force().boundaryFieldRef()[patchi] += fP + fV;
347 
348  const vectorField mP(Md^fP);
349  const vectorField mV(Md^fV);
350 
351  sumPatchMomentsP_ += sum(mP);
352  sumPatchMomentsV_ += sum(mV);
353  moment().boundaryFieldRef()[patchi] += mP + mV;
354 }
355 
356 
358 (
359  const labelList& cellIDs,
360  const vectorField& Md,
361  const vectorField& f
362 )
363 {
364  auto& force = this->force();
365  auto& moment = this->moment();
366 
367  forAll(cellIDs, i)
368  {
369  const label celli = cellIDs[i];
370 
371  sumInternalForces_ += f[i];
372  force[celli] += f[i];
373 
374  const vector m(Md[i]^f[i]);
375  sumInternalMoments_ += m;
376  moment[celli] = m;
377  }
378 }
379 
380 
382 {
383  if (!forceFilePtr_.valid())
384  {
385  forceFilePtr_ = newFileAtStartTime("force");
386  writeIntegratedDataFileHeader("Force", forceFilePtr_());
387  }
388 
389  if (!momentFilePtr_.valid())
390  {
391  momentFilePtr_ = newFileAtStartTime("moment");
392  writeIntegratedDataFileHeader("Moment", momentFilePtr_());
393  }
394 }
395 
396 
398 (
399  const word& header,
400  OFstream& os
401 ) const
402 {
403  const auto& coordSys = coordSysPtr_();
404  const auto vecDesc = [](const word& root)->string
405  {
406  return root + "_x " + root + "_y " + root + "_z";
407  };
408  writeHeader(os, header);
409  writeHeaderValue(os, "CofR", coordSys.origin());
410  writeHeader(os, "");
411  writeCommented(os, "Time");
412  writeTabbed(os, vecDesc("total"));
413  writeTabbed(os, vecDesc("pressure"));
414  writeTabbed(os, vecDesc("viscous"));
415 
416  if (porosity_)
417  {
418  writeTabbed(os, vecDesc("porous"));
419  }
420 
421  os << endl;
422 }
423 
424 
426 {
427  const auto& coordSys = coordSysPtr_();
428 
429  writeIntegratedDataFile
430  (
431  coordSys.localVector(sumPatchForcesP_),
432  coordSys.localVector(sumPatchForcesV_),
433  coordSys.localVector(sumInternalForces_),
434  forceFilePtr_()
435  );
436 
437  writeIntegratedDataFile
438  (
439  coordSys.localVector(sumPatchMomentsP_),
440  coordSys.localVector(sumPatchMomentsV_),
441  coordSys.localVector(sumInternalMoments_),
442  momentFilePtr_()
443  );
444 }
445 
446 
448 (
449  const vector& pres,
450  const vector& vis,
451  const vector& internal,
452  OFstream& os
453 ) const
454 {
455  writeCurrentTime(os);
456 
457  writeValue(os, pres + vis + internal);
458  writeValue(os, pres);
459  writeValue(os, vis);
460 
461  if (porosity_)
462  {
463  writeValue(os, internal);
464  }
465 
466  os << endl;
467 }
468 
469 
471 (
472  const string& descriptor,
473  const vector& pres,
474  const vector& vis,
475  const vector& internal
476 ) const
477 {
478  if (!log)
479  {
480  return;
481  }
482 
483  Log << " Sum of " << descriptor.c_str() << nl
484  << " Total : " << (pres + vis + internal) << nl
485  << " Pressure : " << pres << nl
486  << " Viscous : " << vis << nl;
487 
488  if (porosity_)
489  {
490  Log << " Porous : " << internal << nl;
491  }
492 }
493 
494 
495 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
496 
498 (
499  const word& name,
500  const Time& runTime,
501  const dictionary& dict,
502  bool readFields
503 )
504 :
505  fvMeshFunctionObject(name, runTime, dict),
506  writeFile(mesh_, name),
507  sumPatchForcesP_(Zero),
508  sumPatchForcesV_(Zero),
509  sumPatchMomentsP_(Zero),
510  sumPatchMomentsV_(Zero),
511  sumInternalForces_(Zero),
512  sumInternalMoments_(Zero),
513  forceFilePtr_(),
514  momentFilePtr_(),
515  coordSysPtr_(nullptr),
516  patchSet_(),
517  rhoRef_(VGREAT),
518  pRef_(0),
519  pName_("p"),
520  UName_("U"),
521  rhoName_("rho"),
522  fDName_("fD"),
523  directForceDensity_(false),
524  porosity_(false),
525  writeFields_(false),
526  initialised_(false)
527 {
528  if (readFields)
529  {
530  read(dict);
532  Log << endl;
533  }
534 }
535 
536 
538 (
539  const word& name,
540  const objectRegistry& obr,
541  const dictionary& dict,
542  bool readFields
543 )
544 :
545  fvMeshFunctionObject(name, obr, dict),
546  writeFile(mesh_, name),
547  sumPatchForcesP_(Zero),
548  sumPatchForcesV_(Zero),
549  sumPatchMomentsP_(Zero),
550  sumPatchMomentsV_(Zero),
551  sumInternalForces_(Zero),
552  sumInternalMoments_(Zero),
553  forceFilePtr_(),
554  momentFilePtr_(),
555  coordSysPtr_(nullptr),
556  patchSet_(),
557  rhoRef_(VGREAT),
558  pRef_(0),
559  pName_("p"),
560  UName_("U"),
561  rhoName_("rho"),
562  fDName_("fD"),
563  directForceDensity_(false),
564  porosity_(false),
565  writeFields_(false),
566  initialised_(false)
567 {
568  if (readFields)
569  {
570  read(dict);
572  Log << endl;
573  }
574 }
575 
576 
577 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
578 
580 {
582  {
583  return false;
584  }
585 
586  initialised_ = false;
587 
588  Info<< type() << " " << name() << ":" << endl;
589 
590  patchSet_ =
591  mesh_.boundaryMesh().patchSet
592  (
593  dict.get<wordRes>("patches")
594  );
595 
596  dict.readIfPresent("directForceDensity", directForceDensity_);
597  if (directForceDensity_)
598  {
599  // Optional name entry for fD
600  if (dict.readIfPresent<word>("fD", fDName_))
601  {
602  Info<< " fD: " << fDName_ << endl;
603  }
604  }
605  else
606  {
607  // Optional field name entries
608  if (dict.readIfPresent<word>("p", pName_))
609  {
610  Info<< " p: " << pName_ << endl;
611  }
612  if (dict.readIfPresent<word>("U", UName_))
613  {
614  Info<< " U: " << UName_ << endl;
615  }
616  if (dict.readIfPresent<word>("rho", rhoName_))
617  {
618  Info<< " rho: " << rhoName_ << endl;
619  }
620 
621  // Reference density needed for incompressible calculations
622  if (rhoName_ == "rhoInf")
623  {
624  rhoRef_ = dict.getCheck<scalar>("rhoInf", scalarMinMax::ge(SMALL));
625  Info<< " Freestream density (rhoInf) set to " << rhoRef_ << endl;
626  }
627 
628  // Reference pressure, 0 by default
629  if (dict.readIfPresent<scalar>("pRef", pRef_))
630  {
631  Info<< " Reference pressure (pRef) set to " << pRef_ << endl;
632  }
633  }
634 
635  dict.readIfPresent("porosity", porosity_);
636  if (porosity_)
637  {
638  Info<< " Including porosity effects" << endl;
639  }
640  else
641  {
642  Info<< " Not including porosity effects" << endl;
643  }
644 
645  writeFields_ = dict.getOrDefault("writeFields", false);
646  if (writeFields_)
647  {
648  Info<< " Fields will be written" << endl;
649  }
650 
651 
652  return true;
653 }
654 
655 
657 {
658  initialise();
659 
660  reset();
661 
662  const point& origin = coordSysPtr_->origin();
663 
664  if (directForceDensity_)
665  {
666  const auto& fD = lookupObject<volVectorField>(fDName_);
667 
668  const auto& Sfb = mesh_.Sf().boundaryField();
669 
670  for (const label patchi : patchSet_)
671  {
672  const vectorField& d = mesh_.C().boundaryField()[patchi];
673 
674  const vectorField Md(d - origin);
675 
676  const scalarField sA(mag(Sfb[patchi]));
677 
678  // Pressure force = surfaceUnitNormal*(surfaceNormal & forceDensity)
679  const vectorField fP
680  (
681  Sfb[patchi]/sA
682  *(
683  Sfb[patchi] & fD.boundaryField()[patchi]
684  )
685  );
686 
687  // Viscous force (total force minus pressure fP)
688  const vectorField fV(sA*fD.boundaryField()[patchi] - fP);
689 
690  addToPatchFields(patchi, Md, fP, fV);
691  }
692  }
693  else
694  {
695  const auto& p = lookupObject<volScalarField>(pName_);
696 
697  const auto& Sfb = mesh_.Sf().boundaryField();
698 
699  tmp<volSymmTensorField> tdevRhoReff = devRhoReff();
700  const auto& devRhoReffb = tdevRhoReff().boundaryField();
701 
702  // Scale pRef by density for incompressible simulations
703  const scalar rhoRef = rho(p);
704  const scalar pRef = pRef_/rhoRef;
705 
706  for (const label patchi : patchSet_)
707  {
708  const vectorField& d = mesh_.C().boundaryField()[patchi];
709 
710  const vectorField Md(d - origin);
711 
712  const vectorField fP
713  (
714  rhoRef*Sfb[patchi]*(p.boundaryField()[patchi] - pRef)
715  );
716 
717  const vectorField fV(Sfb[patchi] & devRhoReffb[patchi]);
718 
719  addToPatchFields(patchi, Md, fP, fV);
720  }
721  }
722 
723  if (porosity_)
724  {
725  const auto& U = lookupObject<volVectorField>(UName_);
726  const volScalarField rho(this->rho());
727  const volScalarField mu(this->mu());
728 
729  const auto models = obr_.lookupClass<porosityModel>();
730 
731  if (models.empty())
732  {
734  << "Porosity effects requested, "
735  << "but no porosity models found in the database"
736  << endl;
737  }
738 
739  forAllConstIters(models, iter)
740  {
741  // Non-const access required if mesh is changing
742  auto& pm = const_cast<porosityModel&>(*iter());
743 
744  const vectorField fPTot(pm.force(U, rho, mu));
745 
746  const labelList& cellZoneIDs = pm.cellZoneIDs();
747 
748  for (const label zonei : cellZoneIDs)
749  {
750  const cellZone& cZone = mesh_.cellZones()[zonei];
751 
752  const vectorField d(mesh_.C(), cZone);
753  const vectorField fP(fPTot, cZone);
754  const vectorField Md(d - origin);
755 
756  addToInternalField(cZone, Md, fP);
757  }
758  }
759  }
760 
761  reduce(sumPatchForcesP_, sumOp<vector>());
762  reduce(sumPatchForcesV_, sumOp<vector>());
763  reduce(sumPatchMomentsP_, sumOp<vector>());
764  reduce(sumPatchMomentsV_, sumOp<vector>());
765  reduce(sumInternalForces_, sumOp<vector>());
766  reduce(sumInternalMoments_, sumOp<vector>());
767 }
768 
771 {
772  return sumPatchForcesP_ + sumPatchForcesV_ + sumInternalForces_;
773 }
774 
777 {
778  return sumPatchMomentsP_ + sumPatchMomentsV_ + sumInternalMoments_;
779 }
780 
781 
783 {
784  calcForcesMoments();
785 
786  Log << type() << " " << name() << " write:" << nl;
787 
788  const auto& coordSys = coordSysPtr_();
789 
790  const auto localFp(coordSys.localVector(sumPatchForcesP_));
791  const auto localFv(coordSys.localVector(sumPatchForcesV_));
792  const auto localFi(coordSys.localVector(sumInternalForces_));
793 
794  logIntegratedData("forces", localFp, localFv, localFi);
795 
796  const auto localMp(coordSys.localVector(sumPatchMomentsP_));
797  const auto localMv(coordSys.localVector(sumPatchMomentsV_));
798  const auto localMi(coordSys.localVector(sumInternalMoments_));
799 
800  logIntegratedData("moments", localMp, localMv, localMi);
801 
802  setResult("pressureForce", localFp);
803  setResult("viscousForce", localFv);
804  setResult("internalForce", localFi);
805  setResult("pressureMoment", localMp);
806  setResult("viscousMoment", localMv);
807  setResult("internalMoment", localMi);
808 
809  return true;
810 }
811 
812 
814 {
815  if (writeToFile())
816  {
817  Log << " writing force and moment files." << endl;
818 
819  createIntegratedDataFiles();
820  writeIntegratedDataFiles();
821  }
822 
823  if (writeFields_)
824  {
825  Log << " writing force and moment fields." << endl;
826 
827  force().write();
828  moment().write();
829  }
830 
831  Log << endl;
832 
833  return true;
834 }
835 
836 
837 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
virtual vector momentEff() const
Return the total moment.
Definition: forces.C:769
word dictName() const
The local dictionary name (final part of scoped name)
Definition: dictionaryI.H:53
dictionary dict
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:47
defineTypeNameAndDebug(ObukhovLength, 0)
static void writeHeader(Ostream &os, const word &fieldName)
dimensionedScalar log(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
Output to file stream, using an OSstream.
Definition: OFstream.H:49
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
const dimensionSet dimViscosity
compressible::turbulenceModel & turb
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
volVectorField & force()
Return access to the force field.
Definition: forces.C:83
virtual vector forceEff() const
Return the total force.
Definition: forces.C:763
Ignore writing from objectRegistry::writeObject()
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:85
void addToPatchFields(const label patchi, const vectorField &Md, const vectorField &fP, const vectorField &fV)
Add patch contributions to force and moment fields.
Definition: forces.C:330
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
virtual bool read(const dictionary &dict)
Read the dictionary.
Definition: forces.C:572
void writeIntegratedDataFiles()
Write integrated data to files.
Definition: forces.C:418
Macros for easy insertion into run-time selection tables.
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void writeIntegratedDataFile(const vector &pres, const vector &vis, const vector &internal, OFstream &os) const
Write integrated data to a file.
Definition: forces.C:441
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
A Cartesian coordinate system.
Definition: cartesianCS.H:65
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:84
psiReactionThermo & thermo
Definition: createFields.H:28
Templated abstract base class for single-phase incompressible turbulence models.
virtual bool execute()
Execute the function object.
Definition: forces.C:775
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:752
virtual void calcForcesMoments()
Calculate forces and moments.
Definition: forces.C:649
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
Calculate the gradient of the given field.
A class for handling words, derived from Foam::string.
Definition: word.H:63
tmp< volScalarField > mu() const
Return dynamic viscosity field.
Definition: forces.C:255
static MinMax< scalar > ge(const scalar &minVal)
A semi-infinite range from minVal to the type max.
Definition: MinMaxI.H:24
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition: tmp.H:203
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
IOdictionary transportProperties(IOobject("transportProperties", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Vector< scalar > vector
Definition: vector.H:57
void addToInternalField(const labelList &cellIDs, const vectorField &Md, const vectorField &f)
Add cell contributions to force and moment fields, and include porosity effects.
Definition: forces.C:351
tmp< volScalarField > rho() const
Return rho if specified otherwise rhoRef.
Definition: forces.C:290
const dimensionSet & dimensions() const noexcept
Return const reference to dimensions.
const dimensionSet dimPressure
void createIntegratedDataFiles()
Create the integrated-data files.
Definition: forces.C:374
volVectorField & moment()
Return access to the moment field.
Definition: forces.C:110
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
const dimensionSet dimForce
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
tmp< volSymmTensorField > devRhoReff() const
Return the effective stress (viscous + turbulent)
Definition: forces.C:197
void reset()
Reset containers and fields.
Definition: forces.C:179
void initialise()
Initialise containers and fields.
Definition: forces.C:137
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
virtual bool read(const dictionary &dict)
Read.
Definition: writeFile.C:241
labelList f(nPoints)
void setCoordinateSystem(const dictionary &dict, const word &e3Name=word::null, const word &e1Name=word::null)
Set the co-ordinate system from dictionary and axes names.
Definition: forces.C:45
const dimensionSet dimDensity
static const GeometricField< symmTensor, fvPatchField, volMesh > & null()
Return a null geometric field.
const dimensionedScalar mu
Atomic mass unit.
autoPtr< coordinateSystem > coordSysPtr_
Coordinate system used when evaluating forces and moments.
Definition: forces.H:377
U
Definition: pEqn.H:72
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
forces(const word &name, const Time &runTime, const dictionary &dict, const bool readFields=true)
Construct from Time and dictionary.
Definition: forces.C:491
const objectRegistry & obr_
Reference to the region objectRegistry.
Nothing to be read.
#define Log
Definition: PDRblock.C:28
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool read(const dictionary &dict)
Read optional controls.
Field< vector > vectorField
Specialisation of Field<T> for vector.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type.
List< label > labelList
A List of labels.
Definition: List.H:62
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
void writeIntegratedDataFileHeader(const word &header, OFstream &os) const
Write header for an integrated-data file.
Definition: forces.C:391
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
void logIntegratedData(const string &descriptor, const vector &pres, const vector &vis, const vector &internal) const
Write integrated data to stream.
Definition: forces.C:464
labelList cellIDs
volScalarField & nu
virtual bool write()
Write to data files/fields and to streams.
Definition: forces.C:806
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157