lumpedPointMovement.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) 2016-2018 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "lumpedPointMovement.H"
29 #include "lumpedPointIOMovement.H"
30 #include "demandDrivenData.H"
32 #include "Fstream.H"
33 #include "volFields.H"
34 #include "surfaceFields.H"
35 #include "PtrMap.H"
36 #include "faceZoneMesh.H"
37 #include "PstreamReduceOps.H"
38 
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 const Foam::Enum
43 <
45 >
47 ({
48  { outputFormatType::PLAIN, "plain" },
49  { outputFormatType::DICTIONARY, "dictionary" },
50 });
51 
52 
53 const Foam::Enum
54 <
56 >
58 ({
59  { scalingType::LENGTH, "length" },
60  { scalingType::FORCE, "force" },
61  { scalingType::MOMENT, "moment" },
62 });
63 
64 
65 const Foam::word
66 Foam::lumpedPointMovement::canonicalName("lumpedPointMovement");
67 
68 
69 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
75 //- Space-separated vector value (ASCII)
76 static inline Ostream& putPlain(Ostream& os, const vector& val)
77 {
78  os << val.x() << ' ' << val.y() << ' ' << val.z();
79  return os;
80 }
81 
82 
84 //- Space-separated vector value (ASCII)
85 static inline Ostream& putTime(Ostream& os, const Time& t)
86 {
87  os <<"Time index=" << t.timeIndex()
88  << " value=" << t.timeOutputValue();
89 
90  return os;
91 }
92 
93 
95 //- Write list content with size, bracket, content, bracket one-per-line.
96 // This makes for consistent for parsing, regardless of the list length.
97 template <class T>
98 static void writeList(Ostream& os, const string& header, const UList<T>& list)
99 {
100  const label len = list.size();
101 
102  // Header string
103  os << header.c_str() << nl;
104 
105  // Write size and start delimiter
106  os << len << nl << token::BEGIN_LIST << nl;
107 
108  // Write contents
109  for (label i=0; i < len; ++i)
110  {
111  os << list[i] << nl;
112  }
113 
114  // Write end delimiter
115  os << token::END_LIST << token::END_STATEMENT << nl << nl;
116 }
118 
119 } // End namespace Foam
120 
121 
122 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
123 
124 void Foam::lumpedPointMovement::calcThresholds() const
125 {
126  thresholdPtr_ = new scalarField(locations_);
127 
128  scalarField& thresh = *thresholdPtr_;
129 
130  for (label i=1; i < thresh.size(); ++i)
131  {
132  thresh[i-1] =
133  (
134  locations_[i-1]
135  + (division_ * (locations_[i] - locations_[i-1]))
136  );
137  }
138 }
139 
140 
141 Foam::label Foam::lumpedPointMovement::threshold(scalar pos) const
142 {
143  const scalarField& thresh = this->thresholds();
144  const label n = thresh.size();
145 
146  // Clamp above and below
147  //
148  // ? may need special treatment to clamp values below the first threshold ?
149  // ? special treatment when 'axis' is negative ?
150 
151  for (label i=0; i < n; ++i)
152  {
153  if (pos < thresh[i])
154  {
155  return i;
156  }
157  }
158 
159  // everything above goes into the last zone too
160  return n-1;
161 }
162 
163 
164 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
165 
167 :
168  axis_(0,0,1),
169  locations_(),
170  division_(0),
171  relax_(1),
172  interpolationScheme_(linearInterpolationWeights::typeName),
173  ownerId_(-1),
174  boundBox_(),
175  centre_(),
176  autoCentre_(true),
177  forcesDict_(),
178  coupler_(),
179  inputName_("positions.in"),
180  outputName_("forces.out"),
181  logName_("movement.log"),
182  inputFormat_(lumpedPointState::inputFormatType::DICTIONARY),
183  outputFormat_(outputFormatType::DICTIONARY),
184  scaleInput_(-1.0),
185  scaleOutput_(-1.0),
186  state0_(),
187  state_(),
188  thresholdPtr_(0),
189  interpolatorPtr_()
190 {}
191 
192 
194 (
195  const dictionary& dict,
196  label ownerId
197 )
198 :
199  axis_(0,0,1),
200  locations_(),
201  division_(0),
202  relax_(1),
203  interpolationScheme_
204  (
206  (
207  "interpolationScheme",
208  linearInterpolationWeights::typeName
209  )
210  ),
211  ownerId_(ownerId),
212  boundBox_(),
213  centre_(),
214  autoCentre_(true),
215  forcesDict_(),
216  coupler_(),
217  inputName_("positions.in"),
218  outputName_("forces.out"),
219  logName_("movement.log"),
220  scaleInput_(-1.0),
221  scaleOutput_(-1.0),
222  state0_(),
223  state_(),
224  thresholdPtr_(0),
225  interpolatorPtr_()
226 {
227  readDict(dict);
228 }
229 
230 
231 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
232 
234 {
235  deleteDemandDrivenData(thresholdPtr_);
236 }
237 
238 
239 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
240 
242 {
243  // assume the worst
244  deleteDemandDrivenData(thresholdPtr_);
245 
246  dict.readEntry("axis", axis_);
247 
248  division_ = 0;
249  if (dict.readIfPresent("division", division_))
250  {
251  if (division_ < 0)
252  {
253  division_ = 0;
254  }
255  else if (division_ > 1)
256  {
257  division_ = 1;
258  }
259  }
260 
261  dict.readIfPresent("relax", relax_);
262 
263  dict.readEntry("locations", locations_);
264 
265  if (dict.readIfPresent("interpolationScheme", interpolationScheme_))
266  {
267  interpolatorPtr_.clear();
268  }
269 
270  autoCentre_ = !dict.readIfPresent("centre", centre_);
271 
272  // Initial state from initial locations, with zero rotation
273  tmp<vectorField> pts = locations_ * axis_;
274  state0_ = lumpedPointState(pts);
275  state_ = state0_;
276 
277  forcesDict_.merge(dict.subOrEmptyDict("forces"));
278 
279  const dictionary& commDict = dict.subDict("communication");
280  coupler_.readDict(commDict);
281 
282  // TODO: calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1);
283 
284  commDict.readEntry("inputName", inputName_);
285  commDict.readEntry("outputName", outputName_);
286  commDict.readIfPresent("logName", logName_);
287 
288  inputFormat_ =
289  lumpedPointState::formatNames.get("inputFormat", commDict);
290 
291  outputFormat_ =
292  lumpedPointMovement::formatNames.get("outputFormat", commDict);
293 
294  scaleInput_ = -1;
295  scaleOutput_ = -1;
296 
297  const dictionary* scaleDict = nullptr;
298 
299  if ((scaleDict = commDict.findDict("scaleInput")))
300  {
301  for (int i=0; i < scaleInput_.size(); ++i)
302  {
303  const word& key = scalingNames[scalingType(i)];
304 
305  if
306  (
307  scaleDict->readIfPresent(key, scaleInput_[i])
308  && scaleInput_[i] > 0
309  )
310  {
311  Info<<"Using input " << key << " multiplier: "
312  << scaleInput_[i] << nl;
313  }
314  }
315  }
316 
317  if ((scaleDict = commDict.findDict("scaleOutput")))
318  {
319  for (int i=0; i < scaleOutput_.size(); ++i)
320  {
321  const word& key = scalingNames[scalingType(i)];
322 
323  if
324  (
325  scaleDict->readIfPresent(key, scaleOutput_[i])
326  && scaleOutput_[i] > 0
327  )
328  {
329  Info<<"Using output " << key << " multiplier: "
330  << scaleOutput_[i] << nl;
331  }
332  }
333  }
334 }
335 
336 
338 (
339  const polyMesh& mesh,
340  const labelUList& patchIds,
341  const pointField& points0
342 )
343 {
344  boundBox_ = boundBox::invertedBox;
345 
347  for (const label patchId : patchIds)
348  {
349  boundBox_.add(points0, patches[patchId].meshPoints());
350  }
351 
352  boundBox_.reduce();
353 
354  if (autoCentre_)
355  {
356  centre_ = boundBox_.centre();
357  centre_ -= (centre_ & axis_) * axis_;
359  {
360  Pout<<"autoCentre on " << centre_
361  << " boundBox: " << boundBox_ << endl;
362  }
363  }
364  else
365  {
366  // User-specified centre
368  {
369  Pout<<"centre on " << centre_
370  << " boundBox: " << boundBox_ << endl;
371  }
372  }
373 }
374 
375 
377 (
378  const polyMesh& mesh,
379  const labelUList& patchIds,
380  const pointField& points0
381 )
382 {
383  setBoundBox(mesh, patchIds, points0);
384 
385  faceZones_.clear();
386 
387  // Local storage location (boundary faces only)
388  const label firstFace = mesh.nInternalFaces();
389  labelList faceToZoneID(mesh.nFaces() - firstFace, -1);
390 
391  // Number of faces per zone
392  labelList nFaces(thresholds().size(), Zero);
393 
395 
396  for (const label patchId : patchIds)
397  {
398  const polyPatch& pp = patches[patchId];
399 
400  // Classify faces into respective zones according to their centres
401  label meshFaceI = pp.start();
402 
403  forAll(pp, i)
404  {
405  const face& f = mesh.faces()[meshFaceI];
406  label zoneId = this->threshold(f.centre(points0));
407 
408  // localize storage location
409  faceToZoneID[meshFaceI - firstFace] = zoneId;
410  ++nFaces[zoneId];
411 
412  ++meshFaceI;
413  }
414  }
415 
417  {
418  Pout<<"faces per zone:" << nFaces << endl;
419  }
420 
421  faceZones_.setSize(nFaces.size());
422 
423  label nZonedFaces = 0;
424  forAll(nFaces, zonei)
425  {
426  label n = nFaces[zonei];
427  labelList& addr = faceZones_[zonei];
428  addr.setSize(n);
429 
430  n = 0;
431  forAll(faceToZoneID, faceI)
432  {
433  if (faceToZoneID[faceI] == zonei)
434  {
435  // from local storage to global mesh face
436  label meshFaceI = faceI + firstFace;
437 
438  addr[n] = meshFaceI;
439  ++n;
440  }
441  }
442 
443  addr.setSize(n);
444  nZonedFaces += n;
445 
447  {
448  Pout<< "Created faceZone[" << zonei << "] "
449  << returnReduce(n, sumOp<label>()) << " faces, "
450  << thresholds()[zonei] << " threshold" << nl;
451  }
452  }
453 }
454 
455 
457 (
458  const polyMesh& pmesh,
459  List<vector>& forces,
460  List<vector>& moments
461 ) const
462 {
463  forces.setSize(faceZones_.size());
464  moments.setSize(faceZones_.size());
465 
466  if (faceZones_.empty())
467  {
469  << "Attempted to calculate forces without setMapping()"
470  << nl << endl;
471 
472  forces.setSize(thresholds().size(), Zero);
473  moments.setSize(thresholds().size(), Zero);
474  return false;
475  }
476 
477  // Initialize with zero
478  forces = Zero;
479  moments = Zero;
480 
481  // The mass centres
482  const pointField& lumpedCentres = state().points();
483 
484  const polyBoundaryMesh& patches = pmesh.boundaryMesh();
485 
486  const word pName(forcesDict_.lookupOrDefault<word>("p", "p"));
487  scalar pRef = forcesDict_.lookupOrDefault<scalar>("pRef", 0.0);
488  scalar rhoRef = forcesDict_.lookupOrDefault<scalar>("rhoRef", 1.0);
489 
490 
491  // Calculated force per patch - cache
492  PtrMap<vectorField> forceOnPatches;
493 
494  const volScalarField* pPtr = pmesh.findObject<volScalarField>(pName);
495 
496  // fvMesh and has pressure field
497  if (isA<fvMesh>(pmesh) && pPtr)
498  {
499  const fvMesh& mesh = dynamicCast<const fvMesh>(pmesh);
500  const volScalarField& p = *pPtr;
501 
502  // face centres (on patches)
503  const surfaceVectorField::Boundary& patchCf =
504  mesh.Cf().boundaryField();
505 
506  // face areas (on patches)
507  const surfaceVectorField::Boundary& patchSf =
508  mesh.Sf().boundaryField();
509 
510  // Pressure (on patches)
511  const volScalarField::Boundary& patchPress =
512  p.boundaryField();
513 
514  // rhoRef if the pressure field is dynamic, i.e. p/rho otherwise 1
515  rhoRef = (p.dimensions() == dimPressure ? 1.0 : rhoRef);
516 
517  // Scale pRef by density for incompressible simulations
518  pRef /= rhoRef;
519 
520  forAll(faceZones_, zonei)
521  {
522  const labelList& zn = faceZones_[zonei];
523 
524  forAll(zn, localFaceI)
525  {
526  const label meshFaceI = zn[localFaceI];
527 
528  // locate which patch this face is on,
529  // and its offset within the patch
530  const label patchI = patches.whichPatch(meshFaceI);
531  if (patchI == -1)
532  {
533  // Should not happen - could also warn
534  continue;
535  }
536 
537  const label patchFaceI = meshFaceI - patches[patchI].start();
538 
539  if (!forceOnPatches.found(patchI))
540  {
541  // Patch faces are +ve outwards,
542  // so the forces (exerted by fluid on solid)
543  // already have the correct sign
544  forceOnPatches.set
545  (
546  patchI,
547  (
548  rhoRef
549  * patchSf[patchI] * (patchPress[patchI] - pRef)
550  ).ptr()
551  );
552  }
553 
554  const vectorField& forceOnPatch = *forceOnPatches[patchI];
555 
556  // Force from the patch-face into sum
557  forces[zonei] += forceOnPatch[patchFaceI];
558 
559  // effective torque arm:
560  // - translated into the lumped-points coordinate system
561  // prior to determining the distance
562  const vector lever =
563  (
564  patchCf[patchI][patchFaceI] - centre_
565  - lumpedCentres[zonei]
566  );
567 
568  // Moment from the patch-face into sum
569  moments[zonei] += lever ^ forceOnPatch[patchFaceI];
570  }
571  }
572  }
573  else
574  {
575  Info<<"no pressure" << endl;
576  }
577 
580 
583 
584  return true;
585 }
586 
587 
588 // \cond fileScope
589 template<class T>
590 static inline T interpolatedValue
591 (
592  const Foam::UList<T> input,
593  const Foam::labelUList& indices,
594  const Foam::scalarField& weights
595 )
596 {
597  T result = weights[0] * input[indices[0]];
598  for (Foam::label i=1; i < indices.size(); ++i)
599  {
600  result += weights[i] * input[indices[i]];
601  }
602 
603  return result;
604 }
605 // \endcond
606 
607 
610 (
611  const pointField& points0,
612  const labelList& pointLabels
613 ) const
614 {
615  return displacePoints(state(), points0, pointLabels);
616 }
617 
618 
621 (
622  const lumpedPointState& state,
623  const pointField& points0,
624  const labelList& pointLabels
625 ) const
626 {
627  // storage for the interpolation indices/weights
628  labelList indices;
629  scalarField weights;
630  const interpolationWeights& interp = interpolator();
631 
632  // The mass centres
633  const pointField& lumpedCentres = state.points();
634 
635  // local-to-global transformation tensor
636  const tensorField& localToGlobal = state.rotations();
637 
638  // could also verify the sizes (state vs original)
639 
640  tmp<pointField> tdisp(new pointField(pointLabels.size()));
641  pointField& disp = tdisp.ref();
642 
643  forAll(pointLabels, ptI)
644  {
645  const point& p0 = points0[pointLabels[ptI]];
646 
647  // Interpolation factor based on the axis component
648  // of the original point (location)
649  scalar where = p0 & axis_;
650 
651  interp.valueWeights(where, indices, weights);
652 
653  vector origin = interpolatedValue(lumpedCentres, indices, weights);
654  tensor rotTensor = interpolatedValue(localToGlobal, indices, weights);
655 
656  if (indices.size() == 1)
657  {
658  // out-of-bounds, use corresponding end-point
659  where = locations_[indices[0]];
660  }
661 
662  // local point:
663  // - translated into the lumped-points coordinate system
664  // - relative to the interpolation (where) location
665  const vector local = (p0 - (where * axis_)) - centre_;
666 
667  // local-to-global rotation and translation
668  // - translate back out of the lumped-points coordinate system
669  //
670  // -> subtract p0 to return displacements
671  disp[ptI] = (rotTensor & local) + origin + centre_ - p0;
672  }
673 
674  return tdisp;
675 }
676 
677 
679 {
680  os.writeEntry("axis", axis_);
681  os.writeEntry("locations", locations_);
682  os.writeEntry("division", division_);
683  // os.writeEntry("interpolationScheme", interpolationScheme_);
684 }
685 
686 
688 {
689  lumpedPointState prev = state_;
690 
691  bool status = state_.readData
692  (
693  inputFormat_,
694  coupler().resolveFile(inputName_)
695  );
696 
697  state_.scalePoints(scaleInput_[scalingType::LENGTH]);
698 
699  state_.relax(relax_, prev);
700 
701  return status;
702 }
703 
704 
706 (
707  Ostream& os,
708  const UList<vector>& forces,
709  const UList<vector>& moments,
710  const outputFormatType fmt,
711  const Time* timeinfo
712 ) const
713 {
714  const bool writeMoments = (moments.size() == forces.size());
715 
716  if (fmt == outputFormatType::PLAIN)
717  {
718  os <<"########" << nl;
719  if (timeinfo)
720  {
721  os <<"# ";
722  putTime(os, *timeinfo) << nl;
723  }
724  os <<"# size=" << this->size() << nl
725  <<"# columns (points) (forces)";
726 
727  if (writeMoments)
728  {
729  os << " (moments)";
730  }
731 
732  os << nl;
733 
734  bool report = false;
735  scalar scaleLength = scaleOutput_[scalingType::LENGTH];
736  scalar scaleForce = scaleOutput_[scalingType::FORCE];
737  scalar scaleMoment = scaleOutput_[scalingType::MOMENT];
738 
739  if (scaleLength > 0)
740  {
741  report = true;
742  }
743  else
744  {
745  scaleLength = 1.0;
746  }
747 
748  if (scaleForce > 0)
749  {
750  report = true;
751  }
752  else
753  {
754  scaleForce = 1.0;
755  }
756 
757  if (writeMoments)
758  {
759  if (scaleMoment > 0)
760  {
761  report = true;
762  }
763  else
764  {
765  scaleMoment = 1.0;
766  }
767  }
768 
769  if (report)
770  {
771  os <<"# scaling points=" << scaleLength
772  <<" forces=" << scaleForce;
773 
774  if (writeMoments)
775  {
776  os <<" moments=" << scaleMoment;
777  }
778 
779  os << nl;
780  }
781 
782  os <<"########" << nl;
783 
784  forAll(locations_, i)
785  {
786  const vector pos = scaleLength * (locations_[i] * axis_);
787 
788  putPlain(os, pos) << ' ';
789 
790  if (i < forces.size())
791  {
792  const vector val(scaleForce * forces[i]);
793  putPlain(os, val);
794  }
795  else
796  {
797  putPlain(os, vector::zero);
798  }
799 
800  if (writeMoments)
801  {
802  os << ' ';
803  if (i < moments.size())
804  {
805  const vector val(scaleMoment * moments[i]);
806  putPlain(os, val);
807  }
808  else
809  {
810  putPlain(os, vector::zero);
811  }
812  }
813 
814  os << nl;
815  }
816  }
817  else
818  {
819  // Make it easier for external programs to parse
820  // - exclude the usual OpenFOAM 'FoamFile' header
821  // - ensure lists have consistent format
822 
823  os <<"////////" << nl;
824  if (timeinfo)
825  {
826  os <<"// ";
827  putTime(os, *timeinfo) << nl;
828  }
829  os << nl;
830 
831  writeList(os, "points", (locations_*axis_)());
832  writeList(os, "forces", forces);
833 
834  if (writeMoments)
835  {
836  writeList(os, "moments", moments);
837  }
838  }
839 
840  return true;
841 }
842 
843 
845 (
846  const UList<vector>& forces,
847  const UList<vector>& moments,
848  const Time* timeinfo
849 ) const
850 {
851  if (!Pstream::master())
852  {
853  return false;
854  }
855 
856  // Regular output
857  {
858  const fileName output(coupler().resolveFile(outputName_));
859  OFstream os(output, IOstream::ASCII);
860 
861  writeData(os, forces, moments, outputFormat_, timeinfo);
862  }
863 
864  // Log output
865  {
866  const fileName output(coupler().resolveFile(logName_));
867 
868  OFstream os
869  (
870  output,
874  true // append mode
875  );
876 
877  writeData(os, forces, moments, outputFormatType::PLAIN, timeinfo);
878  }
879 
880  return true;
881 }
882 
883 
886 {
887  if (!interpolatorPtr_.valid())
888  {
889  interpolatorPtr_ = interpolationWeights::New
890  (
891  interpolationScheme_,
892  locations_
893  );
894  }
895 
896  return *interpolatorPtr_;
897 }
898 
899 
900 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOstreamOption::UNCOMPRESSED
compression = false
Definition: IOstreamOption.H:73
Foam::dictionary::findDict
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
Definition: dictionary.C:503
volFields.H
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::dimPressure
const dimensionSet dimPressure
Foam::Tensor< scalar >
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::lumpedPointMovement::writeDict
void writeDict(Ostream &os) const
Write axis, locations, division as a dictionary.
Definition: lumpedPointMovement.C:678
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:51
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::lumpedPointMovement::forcesAndMoments
bool forcesAndMoments(const polyMesh &pmesh, List< vector > &forces, List< vector > &moments) const
The forces and moments acting on each pressure-zone.
Definition: lumpedPointMovement.C:457
Foam::lumpedPointMovement::scalingNames
static const Enum< scalingType > scalingNames
Names for the scaling types.
Definition: lumpedPointMovement.H:285
Foam::lumpedPointMovement::readDict
void readDict(const dictionary &dict)
Update settings from dictionary.
Definition: lumpedPointMovement.C:241
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::primitiveMesh::nInternalFaces
label nInternalFaces() const
Number of internal faces.
Definition: primitiveMeshI.H:78
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::primitiveMesh::nFaces
label nFaces() const
Number of mesh faces.
Definition: primitiveMeshI.H:90
Foam::boundBox::invertedBox
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
Definition: boundBox.H:86
Foam::IOstreamOption::currentVersion
static const versionNumber currentVersion
The current version number.
Definition: IOstreamOption.H:193
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::lumpedPointState::points
const pointField & points() const
The points corresponding to mass centres.
Definition: lumpedPointStateI.H:46
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
surfaceFields.H
Foam::surfaceFields.
Foam::lumpedPointMovement::scalingType
scalingType
Output format types.
Definition: lumpedPointMovement.H:272
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.H:1241
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::Enum::get
EnumType get(const word &enumName) const
The enumeration corresponding to the given name.
Definition: Enum.C:86
Foam::polyBoundaryMesh::start
label start() const
The start label of the boundary faces in the polyMesh face list.
Definition: polyBoundaryMesh.C:638
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
linearInterpolationWeights.H
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:42
Foam::lumpedPointState
The state of lumped points corresponds to positions and rotations.
Definition: lumpedPointState.H:111
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
patchIds
labelList patchIds
Definition: convertProcessorPatches.H:67
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:62
Foam::Field< vector >
Foam::lumpedPointState::formatNames
static const Enum< inputFormatType > formatNames
Names for the input format types.
Definition: lumpedPointState.H:125
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::lumpedPointMovement::setMapping
void setMapping(const polyMesh &mesh, const labelUList &patchIds, const pointField &points0)
Define the pressure-zones mapping for faces in the specified.
Definition: lumpedPointMovement.C:377
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:523
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:314
Foam::polyBoundaryMesh::whichPatch
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Definition: polyBoundaryMesh.C:805
Foam::vtk::writeList
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
Definition: foamVtkOutput.C:112
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:116
Foam::lumpedPointState::readData
bool readData(Istream &is)
Read input as dictionary content.
Definition: lumpedPointState.C:256
Foam::lumpedPointMovement::displacePoints
tmp< pointField > displacePoints(const pointField &points0, const labelList &pointLabels) const
Displace points according to the current state.
Definition: lumpedPointMovement.C:610
Foam::lumpedPointMovement::writeData
bool writeData(Ostream &os, const UList< vector > &forces, const UList< vector > &moments, const outputFormatType fmt=outputFormatType::PLAIN, const Time *timeinfo=nullptr) const
Write points, forces, moments. Only call from the master process.
Definition: lumpedPointMovement.C:706
PtrMap.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::writeData
static void writeData(Ostream &os, const Type &val)
Definition: rawSurfaceWriterImpl.C:39
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::lumpedPointMovement::canonicalName
static const word canonicalName
The canonical name ("lumpedPointMovement") for the dictionary.
Definition: lumpedPointMovement.H:378
Foam::interpolationWeights
Abstract base class for interpolating in 1D.
Definition: interpolationWeights.H:58
Foam::lumpedPointMovement::formatNames
static const Enum< outputFormatType > formatNames
Names for the output format types.
Definition: lumpedPointMovement.H:282
Foam::linearInterpolationWeights
Definition: linearInterpolationWeights.H:50
Foam::lumpedPointMovement::readState
bool readState()
Read state from file, applying relaxation as requested.
Definition: lumpedPointMovement.C:687
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
faceZoneMesh.H
Foam::faceZoneMesh.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::lumpedPointMovement::setBoundBox
void setBoundBox(const polyMesh &mesh, const labelUList &patchIds, const pointField &points0)
Define the bounding-box required to enclose the specified patches.
Definition: lumpedPointMovement.C:338
Foam::vector
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:51
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:311
PstreamReduceOps.H
Inter-processor communication reduction functions.
lumpedPointIOMovement.H
Foam::dictionary::subOrEmptyDict
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Definition: dictionary.C:603
Foam::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:99
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:438
Foam::Pstream::listCombineGather
static void listCombineGather(const List< commsStruct > &comms, List< T > &Value, const CombineOp &cop, const int tag, const label comm)
Definition: combineGatherScatter.C:290
Foam::lumpedPointMovement::interpolator
const interpolationWeights & interpolator() const
Interpolation weights.
Definition: lumpedPointMovement.C:885
points0
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
Foam::IOstreamOption::ASCII
"ascii"
Definition: IOstreamOption.H:66
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
Foam::objectRegistry::findObject
const Type * findObject(const word &name, const bool recursive=false) const
Return const pointer to the object of the given Type.
Definition: objectRegistryTemplates.C:401
Foam::interpolationWeights::New
static autoPtr< interpolationWeights > New(const word &type, const scalarField &samples)
Return a reference to the selected interpolationWeights.
Definition: interpolationWeights.C:53
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Fstream.H
Input/output from file streams.
Foam::lumpedPointMovement::outputFormatType
outputFormatType
Output format types.
Definition: lumpedPointMovement.H:265
Foam::interpolationWeights::valueWeights
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const =0
Calculate weights and indices to calculate t from samples.
f
labelList f(nPoints)
Foam::Vector< scalar >
Foam::List< label >
Foam::lumpedPointMovement::lumpedPointMovement
lumpedPointMovement()
Construct null.
Definition: lumpedPointMovement.C:166
Foam::UList< label >
Foam::lumpedPointState::rotations
const tensorField & rotations() const
The local-to-global transformation for each point.
Definition: lumpedPointStateI.H:58
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:118
Foam::UList::size
void size(const label n) noexcept
Override size to be inconsistent with allocated storage.
Definition: UListI.H:360
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::zero
static const Vector< scalar > zero
Definition: VectorSpace.H:115
Foam::lumpedPointMovement::~lumpedPointMovement
virtual ~lumpedPointMovement()
Destructor.
Definition: lumpedPointMovement.C:233
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:74
patchId
label patchId(-1)
Foam::plusEqOp
Definition: ops.H:72
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
p0
const volScalarField & p0
Definition: EEqn.H:36
Foam::Pstream::listCombineScatter
static void listCombineScatter(const List< commsStruct > &comms, List< T > &Value, const int tag, const label comm)
Scatter data. Reverse of combineGather.
Definition: combineGatherScatter.C:432
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:117
Foam::fvMesh::Cf
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
Definition: fvMeshGeometry.C:369
lumpedPointMovement.H
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
pointLabels
labelList pointLabels(nPoints, -1)
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::PtrMap
A HashTable of pointers to objects of type <T> with a label key.
Definition: HashTableFwd.H:47
Foam::pos
dimensionedScalar pos(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:177
Foam::fvMesh::Sf
const surfaceVectorField & Sf() const
Return cell face area vectors.
Definition: fvMeshGeometry.C:336