41 const NamedEnum<surfaceDisplacementPointPatchVectorField::projectMode, 3>
42 surfaceDisplacementPointPatchVectorField::projectModeNames_
52 void surfaceDisplacementPointPatchVectorField::calcProjection
58 const pointField& localPoints = patch().localPoints();
59 const labelList& meshPoints = patch().meshPoints();
74 projectVec = projectLen*
n;
79 const pointZone* zonePtr =
nullptr;
81 if (frozenPointsZone_.size() > 0)
85 zonePtr = &
pZones[frozenPointsZone_];
87 Pout<<
"surfaceDisplacementPointPatchVectorField : Fixing all "
88 << zonePtr->size() <<
" points in pointZone " << zonePtr->
name()
93 const motionSolver& motion =
94 refCast<const fvMeshMovers::motionSolver>
96 refCast<const fvMesh>(
mesh).mover()
101 refCast<const displacementMotionSolver>(motion).points0();
106 start[i] = points0[meshPoints[i]] + displacement[i];
109 label nNotProjected = 0;
113 List<pointIndexHit> nearest;
125 if (zonePtr && (zonePtr->localIndex(meshPoints[i]) >= 0))
128 displacement[i] = points0[meshPoints[i]] - localPoints[i];
130 else if (nearest[i].hit())
133 nearest[i].hitPoint()
134 - points0[meshPoints[i]];
142 Pout<<
" point:" << meshPoints[i]
143 <<
" coord:" << localPoints[i]
144 <<
" did not find any surface within " << projectLen
155 List<pointIndexHit> nearest;
173 projectVecs = projectLen*patch().pointNormals();
182 offset[i] = start[i][wedgePlane_];
183 start[i][wedgePlane_] = 0;
184 projectVecs[i][wedgePlane_] = 0;
188 List<pointIndexHit> rightHit;
200 List<pointIndexHit> leftHit;
215 if (zonePtr && (zonePtr->localIndex(meshPoints[i]) >= 0))
218 displacement[i] = points0[meshPoints[i]] - localPoints[i];
220 else if (nearest[i].hit())
224 nearest[i].hitPoint()
225 - points0[meshPoints[i]];
231 if (rightHit[i].hit())
233 if (leftHit[i].hit())
237 magSqr(rightHit[i].hitPoint()-start[i])
238 <
magSqr(leftHit[i].hitPoint()-start[i])
241 interPt = rightHit[i];
245 interPt = leftHit[i];
250 interPt = rightHit[i];
255 if (leftHit[i].hit())
257 interPt = leftHit[i];
266 interPt.rawPoint()[wedgePlane_] +=
offset[i];
268 displacement[i] = interPt.rawPoint()-points0[meshPoints[i]];
276 Pout<<
" point:" << meshPoints[i]
277 <<
" coord:" << localPoints[i]
278 <<
" did not find any intersection between"
279 <<
" ray from " << start[i]-projectVecs[i]
280 <<
" to " << start[i]+projectVecs[i] <<
endl;
287 reduce(nNotProjected, sumOp<label>());
289 if (nNotProjected > 0)
291 Info<<
"surfaceDisplacement :"
292 <<
" on patch " << patch().name()
293 <<
" did not project " << nNotProjected
294 <<
" out of " <<
returnReduce(localPoints.size(), sumOp<label>())
295 <<
" points." <<
endl;
310 fixedValuePointPatchVectorField(
p, iF,
dict),
312 surfacesDict_(
dict.subDict(
"geometry")),
313 projectMode_(projectModeNames_.
read(
dict.lookup(
"projectMode"))),
315 wedgePlane_(
dict.lookupOrDefault(
"wedgePlane", -1)),
316 frozenPointsZone_(
dict.lookupOrDefault(
"frozenPointsZone",
word::null))
318 if (velocity_.
x() < 0 || velocity_.
y() < 0 || velocity_.
z() < 0)
321 <<
"All components of velocity have to be positive : "
323 <<
"Set velocity components to a great value if no clipping"
338 fixedValuePointPatchVectorField(ppf,
p, iF, mapper),
339 velocity_(ppf.velocity_),
340 surfacesDict_(ppf.surfacesDict_),
341 projectMode_(ppf.projectMode_),
342 projectDir_(ppf.projectDir_),
343 wedgePlane_(ppf.wedgePlane_),
344 frozenPointsZone_(ppf.frozenPointsZone_)
355 fixedValuePointPatchVectorField(ppf, iF),
356 velocity_(ppf.velocity_),
357 surfacesDict_(ppf.surfacesDict_),
358 projectMode_(ppf.projectMode_),
359 projectDir_(ppf.projectDir_),
360 wedgePlane_(ppf.wedgePlane_),
361 frozenPointsZone_(ppf.frozenPointsZone_)
370 if (surfacesPtr_.empty())
379 db().time().constant(),
390 return surfacesPtr_();
403 vectorField currentDisplacement(this->patchInternalField());
407 calcProjection(displacement);
415 const vector clipVelocity = velocity_*deltaT;
425 d[cmpt] =
max(d[cmpt], -clipVelocity[cmpt]);
429 d[cmpt] =
min(d[cmpt], clipVelocity[cmpt]);
436 fixedValuePointPatchVectorField::updateCoeffs();
445 writeEntry(os,
"projectMode", projectModeNames_[projectMode_]);
446 writeEntry(os,
"projectDirection", projectDir_);
450 writeEntry(os,
"frozenPointsZone", frozenPointsZone_);
459 fixedValuePointPatchVectorField,
#define forAll(list, i)
Loop across all elements in list.
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...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual const fileName & name() const
Return the name of the stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
scalar deltaTValue() const
Return time step value.
static const direction nComponents
Number of components in this vector space.
const point & min() const
Minimum point defining the bounding box.
const point & max() const
Maximum point defining the bounding box.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Abstract base class for field mapping.
const Time & time() const
Return the top-level database.
Basic pointPatch represents a set of points from the mesh.
const polyMesh & mesh() const
Return the mesh reference.
Mesh consisting of general polyhedral cells.
const pointZoneList & pointZones() const
Return point zones.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const boundBox & bounds() const
Return mesh bounding box.
Container for searchableSurfaces.
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.
static const word & geometryDir()
Return the geometry directory name.
Displacement fixed by projection onto triSurface. Use in a displacementMotionSolver as a bc on the po...
const searchableSurfaceList & surfaces() const
Surface to follow. Demand loads surfaceNames.
virtual void write(Ostream &) const
Write.
surfaceDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from string.
static const word null
An empty word.
IOporosityModelList pZones(mesh)
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
makePointPatchTypeField(pointPatchVectorField, angularOscillatingDisplacementPointPatchVectorField)
bool read(const char *, int32_t &)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
PointIndexHit< point > pointIndexHit
Ostream & endl(Ostream &os)
Add newline and flush stream.
const dimensionSet dimless
vectorField pointField
pointField is a vectorField.
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Vector< scalar > vector
A scalar version of the templated Vector.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
Field< vector > vectorField
Specialisation of Field<T> for vector.
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
prefixOSstream Pout(cout, "Pout")
const dimensionSet dimVelocity
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void offset(label &lst, const label o)