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()();
66 const scalar projectLen =
mesh.bounds().mag();
72 projectVec = projectLen *
normalised(projectDir_);
77 const pointZone* zonePtr =
nullptr;
79 if (frozenPointsZone_.size() > 0)
83 zonePtr = &
pZones[frozenPointsZone_];
85 Pout<<
"surfaceDisplacementPointPatchVectorField : Fixing all " 86 << zonePtr->size() <<
" points in pointZone " << zonePtr->
name()
100 start[i] =
points0[meshPoints[i]] + displacement[i];
103 label nNotProjected = 0;
107 List<pointIndexHit> nearest;
119 const label meshPointi = meshPoints[i];
120 const point& pt =
mesh.points()[meshPointi];
122 if (zonePtr && (zonePtr->whichPoint(meshPointi) >= 0))
125 displacement[i] =
points0[meshPointi] - pt;
127 else if (nearest[i].hit())
139 Pout<<
" point:" << meshPointi
141 <<
" did not find any surface within " << projectLen
152 List<pointIndexHit> nearest;
170 projectVecs = projectLen*
patch().pointNormals();
179 offset[i] = start[i][wedgePlane_];
180 start[i][wedgePlane_] = 0;
181 projectVecs[i][wedgePlane_] = 0;
185 List<pointIndexHit> rightHit;
197 List<pointIndexHit> leftHit;
212 const label meshPointi = meshPoints[i];
213 const point& pt =
mesh.points()[meshPointi];
215 if (zonePtr && (zonePtr->whichPoint(meshPointi) >= 0))
218 displacement[i] =
points0[meshPointi] - pt;
220 else if (nearest[i].hit())
231 if (rightHit[i].hit())
238 start[i].distSqr(rightHit[i].
point())
239 < start[i].distSqr(leftHit[i].
point())
243 interPt = rightHit[i];
247 interPt = leftHit[i];
252 if (leftHit[i].hit())
254 interPt = leftHit[i];
263 interPt.point()[wedgePlane_] += offset[i];
265 displacement[i] = interPt.point() -
points0[meshPointi];
273 Pout<<
" point:" << meshPointi
275 <<
" did not find any intersection between" 276 <<
" ray from " << start[i]-projectVecs[i]
277 <<
" to " << start[i]+projectVecs[i] <<
endl;
284 reduce(nNotProjected, sumOp<label>());
286 if (nNotProjected > 0)
288 Info<<
"surfaceDisplacement :" 289 <<
" on patch " <<
patch().name()
290 <<
" did not project " << nNotProjected
291 <<
" out of " <<
returnReduce(meshPoints.size(), sumOp<label>())
292 <<
" points." <<
endl;
306 fixedValuePointPatchVectorField(
p, iF),
308 projectMode_(NEAREST),
322 fixedValuePointPatchVectorField(
p, iF,
dict),
324 surfacesDict_(
dict.subDict(
"geometry")),
325 projectMode_(projectModeNames_.
get(
"projectMode",
dict)),
328 (projectMode_ == FIXEDNORMAL)
332 wedgePlane_(
dict.getOrDefault(
"wedgePlane", -1)),
333 frozenPointsZone_(
dict.getOrDefault(
"frozenPointsZone",
word::null))
335 if (velocity_.x() < 0 || velocity_.y() < 0 || velocity_.z() < 0)
338 <<
"All components of velocity have to be positive : " 340 <<
"Set velocity components to a great value if no clipping" 355 fixedValuePointPatchVectorField(ppf,
p, iF, mapper),
356 velocity_(ppf.velocity_),
357 surfacesDict_(ppf.surfacesDict_),
358 projectMode_(ppf.projectMode_),
359 projectDir_(ppf.projectDir_),
360 wedgePlane_(ppf.wedgePlane_),
361 frozenPointsZone_(ppf.frozenPointsZone_)
371 fixedValuePointPatchVectorField(ppf),
372 velocity_(ppf.velocity_),
373 surfacesDict_(ppf.surfacesDict_),
374 projectMode_(ppf.projectMode_),
375 projectDir_(ppf.projectDir_),
376 wedgePlane_(ppf.wedgePlane_),
377 frozenPointsZone_(ppf.frozenPointsZone_)
388 fixedValuePointPatchVectorField(ppf, iF),
389 velocity_(ppf.velocity_),
390 surfacesDict_(ppf.surfacesDict_),
391 projectMode_(ppf.projectMode_),
392 projectDir_(ppf.projectDir_),
393 wedgePlane_(ppf.wedgePlane_),
394 frozenPointsZone_(ppf.frozenPointsZone_)
412 db().time().constant(),
424 return *surfacesPtr_;
435 const polyMesh&
mesh =
patch().boundaryMesh().mesh()();
437 const vectorField currentDisplacement(this->patchInternalField());
441 calcProjection(displacement);
445 vectorField offset(displacement-currentDisplacement);
450 const vector clipVelocity = velocity_*deltaT;
456 const scalar magD(
mag(d));
457 if (magD > ROOTVSMALL)
460 d *=
min(magD,
mag(clipVelocity));
465 fixedValuePointPatchVectorField::updateCoeffs();
474 os.
writeEntry(
"projectMode", projectModeNames_[projectMode_]);
498 fixedValuePointPatchVectorField,
499 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)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
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.
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) ...
virtual void write(Ostream &) const
Write.
Macros for easy insertion into run-time selection tables.
void reduce(T &value, [[maybe_unused]] BinaryOp bop, [[maybe_unused]] const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce)
#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...
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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.
IOporosityModelList pZones(mesh)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static constexpr const zero Zero
Global zero (0)