42 Foam::surfaceSlipDisplacementPointPatchVectorField::projectModeNames_
44 { projectMode::NEAREST,
"nearest" },
45 { projectMode::POINTNORMAL,
"pointNormal" },
46 { projectMode::FIXEDNORMAL,
"fixedNormal" },
52 void Foam::surfaceSlipDisplacementPointPatchVectorField::calcProjection
67 const scalar projectLen =
mesh.bounds().mag();
73 projectVec = projectLen *
normalised(projectDir_);
78 const pointZone* zonePtr =
nullptr;
80 if (frozenPointsZone_.size() > 0)
84 zonePtr = &
pZones[frozenPointsZone_];
86 Pout<<
"surfaceSlipDisplacementPointPatchVectorField : Fixing all " 87 << zonePtr->size() <<
" points in pointZone " << zonePtr->
name()
101 start[i] =
points0[meshPoints[i]] + displacement[i];
104 label nNotProjected = 0;
108 List<pointIndexHit> nearest;
120 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
123 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
125 else if (nearest[i].hit())
127 displacement[i] = nearest[i].point() -
points0[meshPoints[i]];
135 Pout<<
" point:" << meshPoints[i]
136 <<
" coord:" << localPoints[i]
137 <<
" did not find any surface within " << projectLen
148 List<pointIndexHit> nearest;
175 offset[i] = start[i][wedgePlane_];
176 start[i][wedgePlane_] = 0;
177 projectVecs[i][wedgePlane_] = 0;
181 List<pointIndexHit> rightHit;
193 List<pointIndexHit> leftHit;
208 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
211 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
213 else if (nearest[i].hit())
216 displacement[i] = nearest[i].point() -
points0[meshPoints[i]];
222 if (rightHit[i].hit())
229 start[i].distSqr(rightHit[i].
point())
230 < start[i].distSqr(leftHit[i].
point())
234 interPt = rightHit[i];
238 interPt = leftHit[i];
243 if (leftHit[i].hit())
245 interPt = leftHit[i];
254 interPt.point()[wedgePlane_] += offset[i];
256 displacement[i] = interPt.point() -
points0[meshPoints[i]];
264 Pout<<
" point:" << meshPoints[i]
265 <<
" coord:" << localPoints[i]
266 <<
" did not find any intersection between" 267 <<
" ray from " << start[i]-projectVecs[i]
268 <<
" to " << start[i]+projectVecs[i] <<
endl;
275 reduce(nNotProjected, sumOp<label>());
277 if (nNotProjected > 0)
279 Info<<
"surfaceSlipDisplacement :" 281 <<
" did not project " << nNotProjected
282 <<
" out of " <<
returnReduce(localPoints.size(), sumOp<label>())
283 <<
" points." <<
endl;
298 projectMode_(NEAREST),
313 surfacesDict_(
dict.subDict(
"geometry")),
314 projectMode_(projectModeNames_.
get(
"projectMode",
dict)),
316 wedgePlane_(
dict.getOrDefault(
"wedgePlane", -1)),
317 frozenPointsZone_(
dict.getOrDefault(
"frozenPointsZone",
word::null))
331 surfacesDict_(ppf.surfacesDict_),
332 projectMode_(ppf.projectMode_),
333 projectDir_(ppf.projectDir_),
334 wedgePlane_(ppf.wedgePlane_),
335 frozenPointsZone_(ppf.frozenPointsZone_)
346 surfacesDict_(ppf.surfacesDict_),
347 projectMode_(ppf.projectMode_),
348 projectDir_(ppf.projectDir_),
349 wedgePlane_(ppf.wedgePlane_),
350 frozenPointsZone_(ppf.frozenPointsZone_)
362 surfacesDict_(ppf.surfacesDict_),
363 projectMode_(ppf.projectMode_),
364 projectDir_(ppf.projectDir_),
365 wedgePlane_(ppf.wedgePlane_),
366 frozenPointsZone_(ppf.frozenPointsZone_)
384 db().time().constant(),
396 return *surfacesPtr_;
405 vectorField displacement(this->patchInternalField());
408 calcProjection(displacement);
414 setInInternalField(iF, displacement);
427 os.
writeEntry(
"projectMode", projectModeNames_[projectMode_]);
448 surfaceSlipDisplacementPointPatchVectorField
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
Displacement follows a triSurface. Use in a displacementMotionSolver as a bc on the pointDisplacement...
const pointPatch & patch() const noexcept
Return the patch.
commsTypes
Communications types.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Foam::pointPatchFieldMapper.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
virtual void write(Ostream &os) const
Write.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
::Foam::direction nComponents(const expressions::valueTypeCode) noexcept
The number of components associated with given valueTypeCode.
Ignore writing from objectRegistry::writeObject()
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
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.
const pointMesh & mesh() const noexcept
Return the mesh reference.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
vectorField pointField
pointField is a vectorField.
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static const word null
An empty word.
Container for searchableSurfaces. The collection is specified as a dictionary. For example...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Update the patch field.
virtual const word & name() const =0
Return name.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
pointPatchField< vector > pointPatchVectorField
virtual const vectorField & pointNormals() const =0
Return point unit normals.
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
virtual const vectorField & localPoints() const =0
Return pointField of points in patch.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
virtual void write(Ostream &) const
Write.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))
vector point
Point is a vector.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Basic pointPatch represents a set of points from the mesh.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
messageStream Info
Information stream (stdout output on master, null elsewhere)
makePointPatchTypeField(pointPatchVectorField, solidBodyMotionDisplacementPointPatchVectorField)
Field< vector > vectorField
Specialisation of Field<T> for vector.
List< label > labelList
A List of labels.
const searchableSurfaces & surfaces() const
Surface to follow. Demand loads surfaceNames.
Defines the attributes of an object for which implicit objectRegistry management is supported...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
surfaceSlipDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
virtual const labelList & meshPoints() const =0
Return mesh points.
IOporosityModelList pZones(mesh)
static constexpr const zero Zero
Global zero (0)