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;
74 movingIDs_.setSize(nMovingPoints);
75 Info <<
"Total points on moving boundaries: " << nMovingPoints << endl;
76 const pointField& points =
mesh().points();
85 if (markedPoints[
i] == 1)
88 movingIDs_[nMovingPoints] =
i;
92 movingIDs_.setSize(nMovingPoints);
95 movingPoints_.setSize(nMovingPoints, vector::zero);
97 label nStaticPoints = 0;
98 forAll (staticPatches_, patchI)
102 mesh().boundaryMesh().findPatchID(staticPatches_[patchI]);
106 FatalErrorIn(
"void RBFMotionSolver::makeControlPoints()")
107 <<
"Patch " << staticPatches_[patchI] <<
" not found. "
108 <<
"valid patch names: " <<
mesh().boundaryMesh().names()
109 << abort(FatalError);
112 const labelList& mp =
mesh().boundaryMesh()[patchIndex].meshPoints();
115 markedPoints[mp[
i]] = -1;
119 Info <<
"Total points on static boundaries: " << nStaticPoints << endl;
120 staticIDs_.setSize(nStaticPoints);
126 if (markedPoints[
i] == -1)
128 staticIDs_[nStaticPoints] =
i;
132 staticIDs_.setSize(nStaticPoints);
135 controlIDs_.setSize(movingIDs_.size() + staticIDs_.size());
136 motion_.setSize(controlIDs_.size(), vector::zero);
137 label nControlPoints = 0;
138 forAll (movingPatches_, patchI)
142 mesh().boundaryMesh().findPatchID(movingPatches_[patchI]);
143 const labelList& mp =
mesh().boundaryMesh()[patchIndex].meshPoints();
147 label pickedPoint = 0;
148 pickedPoint < mp.size();
149 pickedPoint += coarseningRatio_
153 controlIDs_[nControlPoints] = mp[pickedPoint];
155 markedPoints[mp[pickedPoint]] = 2;
159 Info <<
"Selected " << nControlPoints
160 <<
" control points on moving boundaries" << endl;
162 if (includeStaticPatches_)
164 forAll (staticPatches_, patchI)
168 mesh().boundaryMesh().findPatchID(staticPatches_[patchI]);
169 const labelList& mp =
170 mesh().boundaryMesh()[patchIndex].meshPoints();
174 label pickedPoint = 0;
175 pickedPoint < mp.size();
176 pickedPoint += coarseningRatio_
180 controlIDs_[nControlPoints] = mp[pickedPoint];
182 markedPoints[mp[pickedPoint]] = 2;
186 Info <<
"Selected " << nControlPoints
187 <<
" total control points" << endl;
191 controlIDs_.setSize(nControlPoints);
193 controlPoints_.setSize(nControlPoints);
197 controlPoints_[
i] = points[controlIDs_[
i]];
200 internalIDs_.setSize(points.size());
201 internalPoints_.setSize(points.size());
203 label nInternalPoints = 0;
206 if (markedPoints[
i] == 0)
209 internalIDs_[nInternalPoints] =
i;
210 internalPoints_[nInternalPoints] = points[
i];
214 Info <<
"Number of internal points: " << nInternalPoints << endl;
216 internalIDs_.setSize(nInternalPoints);
217 internalPoints_.setSize(nInternalPoints);
221void Foam::RBFMotionSolver::setMovingPoints()
const
223 const pointField& points =
mesh().points();
227 movingPoints_[
i] = points[movingIDs_[
i]];
234Foam::RBFMotionSolver::RBFMotionSolver
236 const polyMesh&
mesh,
237 const IOdictionary& dict
240 displacementMotionSolver(
mesh, dict, typeName),
241 movingPatches_(lookup(
"movingPatches")),
242 staticPatches_(lookup(
"staticPatches")),
243 coarseningRatio_(readLabel(lookup(
"coarseningRatio"))),
244 includeStaticPatches_(lookup(
"includeStaticPatches")),
245 frozenInterpolation_(lookup(
"frozenInterpolation")),
256 subDict(
"interpolation"),
275 if (m.size() != movingIDs_.size())
279 "void RBFMotionSolver::setMotion(const vectorField& m)"
280 ) <<
"Incorrect size of motion points: m = " << m.size()
281 <<
" movingIDs = " << movingIDs_.size()
282 << abort(FatalError);
287 motion_ = vector::zero;
293 if (!frozenInterpolation_)
296 const pointField& points =
mesh().points();
299 controlPoints_[
i] = points[controlIDs_[
i]];
302 interpolation_.movePoints();
311 return movingPoints_;
314void Foam::RBFMotionSolver::movePoints(
const pointField&)
321 tmp<pointField> tcurPoints
323 new vectorField(
mesh().nPoints(), vector::zero)
326 pointField& curPoints =
const_cast<pointField&
>(tcurPoints());
332 curPoints[movingIDs_[
i]] = motion_[
i];
337 curPoints[staticIDs_[
i]] = vector::zero;
340 vectorField motionOfControl(controlIDs_.size());
344 motionOfControl[
i] = curPoints[controlIDs_[
i]];
347 vectorField interpolatedMotion =
348 interpolation_.interpolate(motionOfControl).ref();
352 curPoints[internalIDs_[
i]] = interpolatedMotion[
i];
355 curPoints +=
mesh().points();
356 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)