42Foam::surfaceDisplacementPointPatchVectorField::projectModeNames_
44 { projectMode::NEAREST,
"nearest" },
45 { projectMode::POINTNORMAL,
"pointNormal" },
46 { projectMode::FIXEDNORMAL,
"fixedNormal" },
52void Foam::surfaceDisplacementPointPatchVectorField::calcProjection
54 vectorField& displacement
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"
341 <<
" necessary." << exit(FatalError);
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_)
424 return *surfacesPtr_;
435 const polyMesh&
mesh = patch().boundaryMesh().mesh()();
437 const vectorField currentDisplacement(this->patchInternalField());
441 calcProjection(displacement);
445 vectorField offset(displacement-currentDisplacement);
449 const scalar deltaT =
mesh.time().deltaTValue();
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();
472 os.writeEntry(
"velocity", velocity_);
473 os.writeEntry(
"geometry", surfacesDict_);
474 os.writeEntry(
"projectMode", projectModeNames_[projectMode_]);
481 os.writeEntryIfDifferent<label>(
"wedgePlane", -1, wedgePlane_);
482 os.writeEntryIfDifferent<
word>
498 fixedValuePointPatchVectorField,
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
static constexpr direction nComponents
Number of components in this vector space.
const Cmpt & x() const noexcept
Access to the vector x component.
const Cmpt & z() const noexcept
Access to the vector z component.
const Cmpt & y() const noexcept
Access to the vector y component.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Foam::pointPatchFieldMapper.
Basic pointPatch represents a set of points from the mesh.
Mesh consisting of general polyhedral cells.
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
void findAnyIntersection(const pointField &start, const pointField &end, labelList &surfaces, List< pointIndexHit > &) const
Find any intersection. Return hit point information and.
void findNearest(const pointField &, const scalarField &nearestDistSqr, labelList &surfaces, List< pointIndexHit > &) const
Find nearest. Return -1 (and a miss()) or surface and nearest.
Displacement fixed by projection onto triSurface. Use in a displacementMotionSolver as a bc on the po...
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
surfaceDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
const searchableSurfaces & surfaces() const
Surface to follow. Demand loads surfaceNames.
virtual void write(Ostream &) const
Write.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
static const word null
An empty word.
IOporosityModelList pZones(mesh)
OBJstream os(runTime.globalPath()/outputName)
Different types of constants.
const std::string patch
OpenFOAM patch number as a std::string.
ZoneMesh< pointZone, polyMesh > pointZoneMesh
A ZoneMesh with pointZone content on a polyMesh.
List< label > labelList
A List of labels.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
#define makePointPatchTypeField(PatchTypeField, typePatchTypeField)
Define a concrete pointPatchField type and add to run-time tables Example, (pointPatchScalarField,...
#define forAll(list, i)
Loop across all elements in list.
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, IOobject::NO_REGISTER)))