42 Foam::surfaceDisplacementPointPatchVectorField::projectModeNames_
44 { projectMode::NEAREST,
"nearest" },
45 { projectMode::POINTNORMAL,
"pointNormal" },
46 { projectMode::FIXEDNORMAL,
"fixedNormal" },
52 void Foam::surfaceDisplacementPointPatchVectorField::calcProjection
57 const polyMesh&
mesh =
patch().boundaryMesh().mesh()();
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<<
"surfaceDisplacementPointPatchVectorField : 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())
137 Pout<<
" point:" << meshPoints[i]
138 <<
" coord:" << localPoints[i]
139 <<
" did not find any surface within " << projectLen
150 List<pointIndexHit> nearest;
168 projectVecs = projectLen*
patch().pointNormals();
177 offset[i] = start[i][wedgePlane_];
178 start[i][wedgePlane_] = 0;
179 projectVecs[i][wedgePlane_] = 0;
183 List<pointIndexHit> rightHit;
195 List<pointIndexHit> leftHit;
210 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
213 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
215 else if (nearest[i].hit())
226 if (rightHit[i].hit())
233 start[i].distSqr(rightHit[i].
point())
234 < start[i].distSqr(leftHit[i].
point())
238 interPt = rightHit[i];
242 interPt = leftHit[i];
247 if (leftHit[i].hit())
249 interPt = leftHit[i];
258 interPt.point()[wedgePlane_] += offset[i];
260 displacement[i] = interPt.point() -
points0[meshPoints[i]];
268 Pout<<
" point:" << meshPoints[i]
269 <<
" coord:" << localPoints[i]
270 <<
" did not find any intersection between" 271 <<
" ray from " << start[i]-projectVecs[i]
272 <<
" to " << start[i]+projectVecs[i] <<
endl;
279 reduce(nNotProjected, sumOp<label>());
281 if (nNotProjected > 0)
283 Info<<
"surfaceDisplacement :" 284 <<
" on patch " <<
patch().name()
285 <<
" did not project " << nNotProjected
286 <<
" out of " <<
returnReduce(localPoints.size(), sumOp<label>())
287 <<
" points." <<
endl;
301 fixedValuePointPatchVectorField(
p, iF),
303 projectMode_(NEAREST),
317 fixedValuePointPatchVectorField(
p, iF,
dict),
319 surfacesDict_(
dict.subDict(
"geometry")),
320 projectMode_(projectModeNames_.
get(
"projectMode",
dict)),
322 wedgePlane_(
dict.getOrDefault(
"wedgePlane", -1)),
323 frozenPointsZone_(
dict.getOrDefault(
"frozenPointsZone",
word::null))
325 if (velocity_.x() < 0 || velocity_.y() < 0 || velocity_.z() < 0)
328 <<
"All components of velocity have to be positive : " 330 <<
"Set velocity components to a great value if no clipping" 345 fixedValuePointPatchVectorField(ppf,
p, iF, mapper),
346 velocity_(ppf.velocity_),
347 surfacesDict_(ppf.surfacesDict_),
348 projectMode_(ppf.projectMode_),
349 projectDir_(ppf.projectDir_),
350 wedgePlane_(ppf.wedgePlane_),
351 frozenPointsZone_(ppf.frozenPointsZone_)
361 fixedValuePointPatchVectorField(ppf),
362 velocity_(ppf.velocity_),
363 surfacesDict_(ppf.surfacesDict_),
364 projectMode_(ppf.projectMode_),
365 projectDir_(ppf.projectDir_),
366 wedgePlane_(ppf.wedgePlane_),
367 frozenPointsZone_(ppf.frozenPointsZone_)
378 fixedValuePointPatchVectorField(ppf, iF),
379 velocity_(ppf.velocity_),
380 surfacesDict_(ppf.surfacesDict_),
381 projectMode_(ppf.projectMode_),
382 projectDir_(ppf.projectDir_),
383 wedgePlane_(ppf.wedgePlane_),
384 frozenPointsZone_(ppf.frozenPointsZone_)
402 db().time().constant(),
414 return *surfacesPtr_;
425 const polyMesh&
mesh =
patch().boundaryMesh().mesh()();
427 vectorField currentDisplacement(this->patchInternalField());
431 calcProjection(displacement);
434 vectorField offset(displacement-currentDisplacement);
439 const vector clipVelocity = velocity_*deltaT;
449 d[cmpt] =
max(d[cmpt], -clipVelocity[cmpt]);
453 d[cmpt] =
min(d[cmpt], clipVelocity[cmpt]);
460 fixedValuePointPatchVectorField::updateCoeffs();
469 os.
writeEntry(
"projectMode", projectModeNames_[projectMode_]);
489 fixedValuePointPatchVectorField,
490 surfaceDisplacementPointPatchVectorField
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
scalar deltaTValue() const noexcept
Return time step value.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
constexpr char nl
The newline '\n' character (0x0a)
Foam::pointPatchFieldMapper.
Ostream & endl(Ostream &os)
Add newline and flush stream.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
surfaceDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) 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.
const Time & time() const
Return the top-level database.
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.
virtual void write(Ostream &) const
Write.
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...
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with the type pointZone.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Displacement fixed by projection onto triSurface. Use in a displacementMotionSolver as a bc on the po...
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)
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.
const searchableSurfaces & surfaces() const
Surface to follow. Demand loads surfaceNames.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const std::string patch
OpenFOAM patch number as a std::string.
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.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
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.
IOporosityModelList pZones(mesh)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static constexpr const zero Zero
Global zero (0)