multiSolidBodyMotionSolver.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) 2018 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 
31 #include "transformField.H"
32 #include "cellZoneMesh.H"
33 #include "boolList.H"
34 #include "syncTools.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(multiSolidBodyMotionSolver, 0);
42  (
43  motionSolver,
44  multiSolidBodyMotionSolver,
45  dictionary
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 Foam::multiSolidBodyMotionSolver::multiSolidBodyMotionSolver
53 (
54  const polyMesh& mesh,
55  const IOdictionary& dict
56 )
57 :
58  points0MotionSolver(mesh, dict, typeName)
59 {
60  zoneIDs_.setSize(coeffDict().size());
61  SBMFs_.setSize(coeffDict().size());
62  pointIDs_.setSize(coeffDict().size());
63  label zonei = 0;
64 
65  for (const entry& dEntry : coeffDict())
66  {
67  if (dEntry.isDict())
68  {
69  const word& zoneName = dEntry.keyword();
70  const dictionary& subDict = dEntry.dict();
71 
72  zoneIDs_[zonei] = mesh.cellZones().findZoneID(zoneName);
73 
74  if (zoneIDs_[zonei] == -1)
75  {
76  FatalIOErrorInFunction(coeffDict())
77  << "Cannot find cellZone named " << zoneName
78  << ". Valid zones are "
79  << flatOutput(mesh.cellZones().names())
80  << exit(FatalIOError);
81  }
82 
83  SBMFs_.set
84  (
85  zonei,
86  solidBodyMotionFunction::New(subDict, mesh.time())
87  );
88 
89  // Collect points of cell zone.
90  const cellZone& cz = mesh.cellZones()[zoneIDs_[zonei]];
91 
92  boolList movePts(mesh.nPoints(), false);
93 
94  forAll(cz, i)
95  {
96  label celli = cz[i];
97  const cell& c = mesh.cells()[celli];
98  forAll(c, j)
99  {
100  const face& f = mesh.faces()[c[j]];
101  forAll(f, k)
102  {
103  label pointi = f[k];
104  movePts[pointi] = true;
105  }
106  }
107  }
108 
109  syncTools::syncPointList(mesh, movePts, orEqOp<bool>(), false);
110 
111  DynamicList<label> ptIDs(mesh.nPoints());
112  forAll(movePts, i)
113  {
114  if (movePts[i])
115  {
116  ptIDs.append(i);
117  }
118  }
119 
120  pointIDs_[zonei].transfer(ptIDs);
121 
122  Info<< "Applying solid body motion " << SBMFs_[zonei].type()
123  << " to "
124  << returnReduce(pointIDs_[zonei].size(), sumOp<label>())
125  << " points of cellZone " << zoneName << endl;
126 
127  zonei++;
128  }
129  }
130  zoneIDs_.setSize(zonei);
131  SBMFs_.setSize(zonei);
132  pointIDs_.setSize(zonei);
133 }
134 
135 
136 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
137 
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
145 {
146  tmp<pointField> ttransformedPts(new pointField(mesh().points()));
147  pointField& transformedPts = ttransformedPts.ref();
148 
149  forAll(zoneIDs_, i)
150  {
151  const labelList& zonePoints = pointIDs_[i];
152 
153  UIndirectList<point>(transformedPts, zonePoints) = transformPoints
154  (
155  SBMFs_[i].transformation(),
156  pointField(points0_, zonePoints)
157  );
158  }
159 
160  return ttransformedPts;
161 }
162 
163 
164 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::points0MotionSolver
Virtual base class for displacement motion solvers, where the point motion is relative to a set of fi...
Definition: points0MotionSolver.H:57
boolList.H
cellZoneMesh.H
Foam::cellZoneMesh.
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
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::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::DynamicList< label >
Foam::orEqOp
Definition: ops.H:86
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
transformField.H
Spatial transformation functions for primitive fields.
Foam::sumOp
Definition: ops.H:213
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::cellZone
A subset of mesh cells.
Definition: cellZone.H:62
multiSolidBodyMotionSolver.H
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::transformPoints
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
Definition: transformField.C:73
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::flatOutput
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:216
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
f
labelList f(nPoints)
Foam::List< bool >
Foam::multiSolidBodyMotionSolver::curPoints
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Definition: multiSolidBodyMotionSolver.C:144
Foam::multiSolidBodyMotionSolver::~multiSolidBodyMotionSolver
~multiSolidBodyMotionSolver()
Destructor.
Definition: multiSolidBodyMotionSolver.C:138
points
const pointField & points
Definition: gmvOutputHeader.H:1
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::UIndirectList
A List with indirect addressing.
Definition: faMatrix.H:60
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::cell
A cell is defined as a list of faces with extra functionality.
Definition: cell.H:54