27#include "addToRunTimeSelectionTable.H"
45void Foam::RBFMotionSolver::makeControlIDs()
49 labelList markedPoints(
mesh().nPoints(), 0);
51 label nMovingPoints = 0;
52 forAll (movingPatches_, patchI)
56 mesh().boundaryMesh().findPatchID(movingPatches_[patchI]);
60 FatalErrorIn(
"void RBFMotionSolver::makeControlIDs()")
61 <<
"Patch " << movingPatches_[patchI] <<
" not found. "
62 <<
"valid patch names: " <<
mesh().boundaryMesh().names()
66 const labelList& mp =
mesh().boundaryMesh()[patchIndex].meshPoints();
69 markedPoints[mp[
i]] = 1;
75 movingIDs_.setSize(nMovingPoints);
76 Info <<
"Total points on moving boundaries: " << nMovingPoints << endl;
77 const pointField& points =
mesh().points();
86 if (markedPoints[
i] == 1)
89 movingIDs_[nMovingPoints] =
i;
94 movingIDs_.setSize(nMovingPoints);
97 movingPoints_.setSize(nMovingPoints, vector::zero);
99 label nStaticPoints = 0;
100 forAll (staticPatches_, patchI)
104 mesh().boundaryMesh().findPatchID(staticPatches_[patchI]);
108 FatalErrorIn(
"void RBFMotionSolver::makeControlPoints()")
109 <<
"Patch " << staticPatches_[patchI] <<
" not found. "
110 <<
"valid patch names: " <<
mesh().boundaryMesh().names()
111 << abort(FatalError);
114 const labelList& mp =
mesh().boundaryMesh()[patchIndex].meshPoints();
117 markedPoints[mp[
i]] = -1;
122 Info <<
"Total points on static boundaries: " << nStaticPoints << endl;
123 staticIDs_.setSize(nStaticPoints);
129 if (markedPoints[
i] == -1)
131 staticIDs_[nStaticPoints] =
i;
136 staticIDs_.setSize(nStaticPoints);
139 controlIDs_.setSize(movingIDs_.size() + staticIDs_.size());
140 motion_.setSize(controlIDs_.size(), vector::zero);
141 label nControlPoints = 0;
142 forAll (movingPatches_, patchI)
146 mesh().boundaryMesh().findPatchID(movingPatches_[patchI]);
147 const labelList& mp =
mesh().boundaryMesh()[patchIndex].meshPoints();
151 label pickedPoint = 0;
152 pickedPoint < mp.size();
153 pickedPoint += coarseningRatio_
157 controlIDs_[nControlPoints] = mp[pickedPoint];
159 markedPoints[mp[pickedPoint]] = 2;
164 Info <<
"Selected " << nControlPoints
165 <<
" control points on moving boundaries" << endl;
167 if (includeStaticPatches_)
169 forAll (staticPatches_, patchI)
173 mesh().boundaryMesh().findPatchID(staticPatches_[patchI]);
174 const labelList& mp =
175 mesh().boundaryMesh()[patchIndex].meshPoints();
179 label pickedPoint = 0;
180 pickedPoint < mp.size();
181 pickedPoint += coarseningRatio_
185 controlIDs_[nControlPoints] = mp[pickedPoint];
187 markedPoints[mp[pickedPoint]] = 2;
192 Info <<
"Selected " << nControlPoints
193 <<
" total control points" << endl;
197 controlIDs_.setSize(nControlPoints);
199 controlPoints_.setSize(nControlPoints);
203 controlPoints_[
i] = points[controlIDs_[
i]];
207 internalIDs_.setSize(points.size());
208 internalPoints_.setSize(points.size());
210 label nInternalPoints = 0;
213 if (markedPoints[
i] == 0)
216 internalIDs_[nInternalPoints] =
i;
217 internalPoints_[nInternalPoints] = points[
i];
222 Info <<
"Number of internal points: " << nInternalPoints << endl;
224 internalIDs_.setSize(nInternalPoints);
225 internalPoints_.setSize(nInternalPoints);
229void Foam::RBFMotionSolver::setMovingPoints()
const
231 const pointField& points =
mesh().points();
235 movingPoints_[
i] = points[movingIDs_[
i]];
242Foam::RBFMotionSolver::RBFMotionSolver
244 const polyMesh&
mesh,
245 const IOdictionary& dict
248 displacementMotionSolver(
mesh, dict, typeName),
249 movingPatches_(lookup(
"movingPatches")),
250 staticPatches_(lookup(
"staticPatches")),
251 coarseningRatio_(readLabel(lookup(
"coarseningRatio"))),
252 includeStaticPatches_(lookup(
"includeStaticPatches")),
253 frozenInterpolation_(lookup(
"frozenInterpolation")),
264 subDict(
"interpolation"),
283 if (m.size() != movingIDs_.size())
287 "void RBFMotionSolver::setMotion(const vectorField& m)"
288 ) <<
"Incorrect size of motion points: m = " << m.size()
289 <<
" movingIDs = " << movingIDs_.size()
290 << abort(FatalError);
295 motion_ = vector::zero;
301 if (!frozenInterpolation_)
304 const pointField& points =
mesh().points();
307 controlPoints_[
i] = points[controlIDs_[
i]];
311 interpolation_.movePoints();
320 return movingPoints_;
323void Foam::RBFMotionSolver::movePoints(
const pointField&)
330 tmp<pointField> tcurPoints
332 new vectorField(
mesh().nPoints(), vector::zero)
335 pointField&
curPoints =
const_cast<pointField&
>(tcurPoints());
351 vectorField motionOfControl(controlIDs_.size());
359 vectorField interpolatedMotion =
360 interpolation_.interpolate(motionOfControl).ref();
364 curPoints[internalIDs_[
i]] = interpolatedMotion[
i];
369 twoDCorrectPoints(
const_cast<pointField&
>(tcurPoints()));
forAll(example_CG.gList, solutionI)
virtual void updateMesh(const mapPolyMesh &)
const vectorField & movingPoints() const
virtual ~RBFMotionSolver()
void setMotion(const vectorField &)
virtual tmp< pointField > curPoints() const
addToRunTimeSelectionTable(Filter, IntegralFilter, dictionary)
defineTypeNameAndDebug(Filter, 0)