43 displacementInterpolationFvMotionSolver,
48 const word IOList<Tuple2<scalar, vector> >::typeName(
"scalarVectorTable");
56 Foam::displacementInterpolationFvMotionSolver::
57 displacementInterpolationFvMotionSolver
85 dynamicMeshCoeffs_.lookup(
"interpolationTables")
91 displacements_.setSize(fZones.
size());
95 const word& zoneName = faceZoneToTable[i][0];
96 label zoneI = fZones.findZoneID(zoneName);
102 "displacementInterpolationFvMotionSolver::"
103 "displacementInterpolationFvMotionSolver(const polyMesh&,"
105 ) <<
"Cannot find zone " << zoneName <<
endl
110 const word& tableName = faceZoneToTable[i][1];
127 times_[zoneI].setSize(table.
size());
128 displacements_[zoneI].setSize(table.
size());
132 times_[zoneI][j] = table[j].first();
133 displacements_[zoneI][j] = table[j].second();
143 for (
direction dir = 0; dir < vector::nComponents; dir++)
148 forAll(faceZoneToTable, i)
150 const word& zoneName = faceZoneToTable[i][0];
151 label zoneI = fZones.findZoneID(zoneName);
154 scalar minCoord = VGREAT;
155 scalar maxCoord = -VGREAT;
157 forAll(fz().meshPoints(), localI)
159 label pointI = fz().meshPoints()[localI];
160 const scalar coord = points0()[pointI][dir];
161 minCoord =
min(minCoord, coord);
162 maxCoord =
max(maxCoord, coord);
170 Pout<<
"direction " << dir <<
" : "
171 <<
"zone " << zoneName
172 <<
" ranges from coordinate " << zoneCoordinates[2*i]
173 <<
" to " << zoneCoordinates[2*i+1]
177 zoneCoordinates.sort();
180 zoneCoordinates[0] -= SMALL;
181 zoneCoordinates[zoneCoordinates.size()-1] += SMALL;
186 scalar minCoord =
gMin(meshCoords);
187 scalar maxCoord =
gMax(meshCoords);
191 Pout<<
"direction " << dir <<
" : "
192 <<
"mesh ranges from coordinate " << minCoord <<
" to "
200 labelList& rangeZone = rangeToZone_[dir];
205 rangeZone.
setSize(zoneCoordinates.size());
208 if (minCoord < zoneCoordinates[0])
210 label sz = rangeZone.
size();
211 rangeToCoord.setSize(sz+1);
213 rangeToCoord[rangeI] = minCoord-SMALL;
214 rangeZone[rangeI] = -1;
218 Pout<<
"direction " << dir <<
" : "
219 <<
"range " << rangeI <<
" at coordinate "
220 << rangeToCoord[rangeI] <<
" from min of mesh "
221 << rangeZone[rangeI] <<
endl;
225 forAll(zoneCoordinates, i)
227 rangeToCoord[rangeI] = zoneCoordinates[i];
228 rangeZone[rangeI] = zoneCoordinates.indices()[i]/2;
232 Pout<<
"direction " << dir <<
" : "
233 <<
"range " << rangeI <<
" at coordinate "
234 << rangeToCoord[rangeI]
235 <<
" from zone " << rangeZone[rangeI] <<
endl;
239 if (maxCoord > zoneCoordinates[zoneCoordinates.size()-1])
241 label sz = rangeToCoord.size();
242 rangeToCoord.setSize(sz+1);
244 rangeToCoord[sz] = maxCoord+SMALL;
249 Pout<<
"direction " << dir <<
" : "
250 <<
"range " << rangeI <<
" at coordinate "
251 << rangeToCoord[sz] <<
" from max of mesh "
252 << rangeZone[sz] <<
endl;
261 labelList nRangePoints(rangeToCoord.size(), 0);
263 forAll(meshCoords, pointI)
265 label rangeI =
findLower(rangeToCoord, meshCoords[pointI]);
267 if (rangeI == -1 || rangeI == rangeToCoord.size()-1)
271 "displacementInterpolationFvMotionSolver::"
272 "displacementInterpolationFvMotionSolver"
273 "(const polyMesh&, Istream&)"
274 ) <<
"Did not find point " << points0()[pointI]
275 <<
" coordinate " << meshCoords[pointI]
276 <<
" in ranges " << rangeToCoord
279 nRangePoints[rangeI]++;
284 for (label rangeI = 0; rangeI < rangeToCoord.size()-1; rangeI++)
287 Pout<<
"direction " << dir <<
" : "
288 <<
"range from " << rangeToCoord[rangeI]
289 <<
" to " << rangeToCoord[rangeI+1]
290 <<
" contains " << nRangePoints[rangeI]
291 <<
" points." <<
endl;
296 rangePoints.
setSize(nRangePoints.size());
297 rangeWeights.
setSize(nRangePoints.size());
298 forAll(rangePoints, rangeI)
300 rangePoints[rangeI].
setSize(nRangePoints[rangeI]);
301 rangeWeights[rangeI].
setSize(nRangePoints[rangeI]);
304 forAll(meshCoords, pointI)
306 label rangeI =
findLower(rangeToCoord, meshCoords[pointI]);
307 label&
nPoints = nRangePoints[rangeI];
308 rangePoints[rangeI][
nPoints] = pointI;
309 rangeWeights[rangeI][
nPoints] =
310 (meshCoords[pointI]-rangeToCoord[rangeI])
311 / (rangeToCoord[rangeI+1]-rangeToCoord[rangeI]);
334 "displacementInterpolationFvMotionSolver::curPoints() const"
335 ) <<
"The number of points in the mesh seems to have changed." <<
endl
336 <<
"In constant/polyMesh there are " << points0().size()
337 <<
" points; in the current mesh there are " <<
mesh().
nPoints()
348 if (times_[zoneI].size())
352 mesh().time().value(),
354 displacements_[zoneI]
360 Pout<<
"Zone displacements:" << zoneDisp <<
endl;
367 const labelList& rangeZone = rangeToZone_[dir];
371 for (label rangeI = 0; rangeI < rangeZone.
size()-1; rangeI++)
373 const labelList& rPoints = rangePoints[rangeI];
374 const scalarField& rWeights = rangeWeights[rangeI];
377 label minZoneI = rangeZone[rangeI];
380 scalar minDisp = (minZoneI == -1 ? 0.0 : zoneDisp[minZoneI][dir]);
381 label maxZoneI = rangeZone[rangeI+1];
384 scalar maxDisp = (maxZoneI == -1 ? 0.0 : zoneDisp[maxZoneI][dir]);
388 label pointI = rPoints[i];
389 scalar w = rWeights[i];
391 curPoints[pointI][dir] += (1.0-w)*minDisp+w*maxDisp;