46 displacementInterpolationMotionSolver,
52 displacementMotionSolver,
53 displacementInterpolationMotionSolver,
58 const word GlobalIOList<Tuple2<scalar, vector>>::typeName
67 void Foam::displacementInterpolationMotionSolver::calcInterpolation()
72 List<Pair<word>> faceZoneToTable
80 displacements_.
setSize(fZones.size());
84 const word& zoneName = faceZoneToTable[i][0];
85 label zoneI = fZones.findZoneID(zoneName);
90 <<
"Cannot find zone " << zoneName <<
endl 91 <<
"Valid zones are " << fZones.names()
95 const word& tableName = faceZoneToTable[i][1];
97 GlobalIOList<Tuple2<scalar, vector>> table
112 times_[zoneI].
setSize(table.size());
113 displacements_[zoneI].
setSize(table.size());
117 times_[zoneI][j] = table[j].
first();
118 displacements_[zoneI][j] = table[j].second();
131 SortableList<scalar> zoneCoordinates(2*faceZoneToTable.size());
133 forAll(faceZoneToTable, i)
135 const word& zoneName = faceZoneToTable[i][0];
136 const faceZone& fz = fZones[zoneName];
138 scalar minCoord = VGREAT;
139 scalar maxCoord = -VGREAT;
141 forAll(fz().meshPoints(), localI)
143 label pointi = fz().meshPoints()[localI];
144 const scalar coord =
points0()[pointi][dir];
145 minCoord =
min(minCoord, coord);
146 maxCoord =
max(maxCoord, coord);
149 zoneCoordinates[2*i] =
returnReduce(minCoord, minOp<scalar>());
150 zoneCoordinates[2*i+1] =
returnReduce(maxCoord, maxOp<scalar>());
154 Pout<<
"direction " << dir <<
" : " 155 <<
"zone " << zoneName
156 <<
" ranges from coordinate " << zoneCoordinates[2*i]
157 <<
" to " << zoneCoordinates[2*i+1]
161 zoneCoordinates.sort();
164 zoneCoordinates[0] -= SMALL;
165 zoneCoordinates.last() += SMALL;
170 scalar minCoord =
gMin(meshCoords);
171 scalar maxCoord =
gMax(meshCoords);
175 Pout<<
"direction " << dir <<
" : " 176 <<
"mesh ranges from coordinate " << minCoord <<
" to " 184 labelList& rangeZone = rangeToZone_[dir];
186 List<scalarField>& rangeWeights = rangeToWeights_[dir];
189 rangeZone.
setSize(zoneCoordinates.size());
192 if (minCoord < zoneCoordinates[0])
194 label sz = rangeZone.size();
195 rangeToCoord.setSize(sz+1);
196 rangeZone.setSize(sz+1);
197 rangeToCoord[rangeI] = minCoord-SMALL;
198 rangeZone[rangeI] = -1;
202 Pout<<
"direction " << dir <<
" : " 203 <<
"range " << rangeI <<
" at coordinate " 204 << rangeToCoord[rangeI] <<
" from min of mesh " 205 << rangeZone[rangeI] <<
endl;
209 forAll(zoneCoordinates, i)
211 rangeToCoord[rangeI] = zoneCoordinates[i];
212 rangeZone[rangeI] = zoneCoordinates.indices()[i]/2;
216 Pout<<
"direction " << dir <<
" : " 217 <<
"range " << rangeI <<
" at coordinate " 218 << rangeToCoord[rangeI]
219 <<
" from zone " << rangeZone[rangeI] <<
endl;
223 if (maxCoord > zoneCoordinates.last())
225 label sz = rangeToCoord.size();
226 rangeToCoord.setSize(sz+1);
227 rangeZone.setSize(sz+1);
228 rangeToCoord[sz] = maxCoord+SMALL;
233 Pout<<
"direction " << dir <<
" : " 234 <<
"range " << rangeI <<
" at coordinate " 235 << rangeToCoord[sz] <<
" from max of mesh " 236 << rangeZone[sz] <<
endl;
247 forAll(meshCoords, pointi)
249 label rangeI =
findLower(rangeToCoord, meshCoords[pointi]);
251 if (rangeI == -1 || rangeI == rangeToCoord.size()-1)
254 <<
"Did not find point " <<
points0()[pointi]
255 <<
" coordinate " << meshCoords[pointi]
256 <<
" in ranges " << rangeToCoord
259 nRangePoints[rangeI]++;
264 for (label rangeI = 0; rangeI < rangeToCoord.size()-1; rangeI++)
267 Pout<<
"direction " << dir <<
" : " 268 <<
"range from " << rangeToCoord[rangeI]
269 <<
" to " << rangeToCoord[rangeI+1]
270 <<
" contains " << nRangePoints[rangeI]
271 <<
" points." <<
endl;
276 rangePoints.setSize(nRangePoints.size());
277 rangeWeights.setSize(nRangePoints.size());
278 forAll(rangePoints, rangeI)
280 rangePoints[rangeI].setSize(nRangePoints[rangeI]);
281 rangeWeights[rangeI].setSize(nRangePoints[rangeI]);
284 forAll(meshCoords, pointi)
286 label rangeI =
findLower(rangeToCoord, meshCoords[pointi]);
287 label&
nPoints = nRangePoints[rangeI];
288 rangePoints[rangeI][
nPoints] = pointi;
289 rangeWeights[rangeI][
nPoints] =
290 (meshCoords[pointi]-rangeToCoord[rangeI])
291 / (rangeToCoord[rangeI+1]-rangeToCoord[rangeI]);
300 Foam::displacementInterpolationMotionSolver::
301 displacementInterpolationMotionSolver
313 Foam::displacementInterpolationMotionSolver::
314 displacementInterpolationMotionSolver
336 <<
"The number of points in the mesh seems to have changed." <<
endl 337 <<
"In constant/polyMesh there are " <<
points0().
size()
338 <<
" points; in the current mesh there are " <<
mesh().
nPoints()
343 auto& curPoints = tcurPoints.ref();
349 if (times_[zoneI].size())
353 mesh().time().value(),
355 displacements_[zoneI]
361 Pout<<
"Zone displacements:" << zoneDisp <<
endl;
368 const labelList& rangeZone = rangeToZone_[dir];
370 const List<scalarField>& rangeWeights = rangeToWeights_[dir];
372 for (label rangeI = 0; rangeI < rangeZone.size()-1; rangeI++)
374 const labelList& rPoints = rangePoints[rangeI];
375 const scalarField& rWeights = rangeWeights[rangeI];
378 label minZoneI = rangeZone[rangeI];
381 scalar minDisp = (minZoneI == -1 ? 0.0 : zoneDisp[minZoneI][dir]);
382 label maxZoneI = rangeZone[rangeI+1];
385 scalar maxDisp = (maxZoneI == -1 ? 0.0 : zoneDisp[maxZoneI][dir]);
389 label pointi = rPoints[i];
390 scalar w = rWeights[i];
392 curPoints[pointi][dir] += (1.0-w)*minDisp+w*maxDisp;
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream. ...
void size(const label n)
Older name for setAddressableSize.
Virtual base class for displacement motion solver.
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with the type faceZone.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value...
errorManipArg< error, int > exit(error &err, const int errNo=1)
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Type gMin(const FieldField< Field, Type > &f)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
T & first()
Access first element of the list, position [0].
Ostream & endl(Ostream &os)
Add newline and flush stream.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Ignore writing from objectRegistry::writeObject()
const dictionary & coeffDict() const
Const access to the coefficients dictionary.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
Macros for easy insertion into run-time selection tables.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
void setSize(const label n)
Alias for resize()
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Interpolates y values from one curve to another with a different x distribution.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Field< Type > interpolateXY(const scalarField &xNew, const scalarField &xOld, const Field< Type > &yOld)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
const Time & time() const noexcept
Return Time associated with the objectRegistry.
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Field< vector > vectorField
Specialisation of Field<T> for vector.
pointField & points0() noexcept
Return reference to the reference ('0') pointField.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
const polyMesh & mesh() const
Return reference to mesh.
A class for managing temporary objects.
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
A primitive field of type <T> with automated input and output.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)