43 Foam::surfaceSlipDisplacementPointPatchVectorField::projectModeNames_
45 { projectMode::NEAREST,
"nearest" },
46 { projectMode::POINTNORMAL,
"pointNormal" },
47 { projectMode::FIXEDNORMAL,
"fixedNormal" },
53 void Foam::surfaceSlipDisplacementPointPatchVectorField::calcProjection
68 const scalar projectLen =
mesh.bounds().mag();
74 projectVec = projectLen *
normalised(projectDir_);
79 const pointZone* zonePtr =
nullptr;
81 if (frozenPointsZone_.size() > 0)
85 zonePtr = &
pZones[frozenPointsZone_];
87 Pout<<
"surfaceSlipDisplacementPointPatchVectorField : Fixing all " 88 << zonePtr->size() <<
" points in pointZone " << zonePtr->
name()
102 start[i] =
points0[meshPoints[i]] + displacement[i];
105 label nNotProjected = 0;
109 List<pointIndexHit> nearest;
121 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
124 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
126 else if (nearest[i].hit())
128 displacement[i] = nearest[i].point() -
points0[meshPoints[i]];
136 Pout<<
" point:" << meshPoints[i]
137 <<
" coord:" << localPoints[i]
138 <<
" did not find any surface within " << projectLen
149 List<pointIndexHit> nearest;
176 offset[i] = start[i][wedgePlane_];
177 start[i][wedgePlane_] = 0;
178 projectVecs[i][wedgePlane_] = 0;
182 List<pointIndexHit> rightHit;
194 List<pointIndexHit> leftHit;
209 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
212 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
214 else if (nearest[i].hit())
217 displacement[i] = nearest[i].point() -
points0[meshPoints[i]];
223 if (rightHit[i].hit())
230 start[i].distSqr(rightHit[i].
point())
231 < start[i].distSqr(leftHit[i].
point())
235 interPt = rightHit[i];
239 interPt = leftHit[i];
244 if (leftHit[i].hit())
246 interPt = leftHit[i];
255 interPt.point()[wedgePlane_] += offset[i];
257 displacement[i] = interPt.point() -
points0[meshPoints[i]];
265 Pout<<
" point:" << meshPoints[i]
266 <<
" coord:" << localPoints[i]
267 <<
" did not find any intersection between" 268 <<
" ray from " << start[i]-projectVecs[i]
269 <<
" to " << start[i]+projectVecs[i] <<
endl;
280 scalePtr_->value(this->db().time().timeOutputValue())
286 reduce(nNotProjected, sumOp<label>());
288 if (nNotProjected > 0)
290 Info<<
"surfaceSlipDisplacement :" 292 <<
" did not project " << nNotProjected
293 <<
" out of " <<
returnReduce(localPoints.size(), sumOp<label>())
294 <<
" points." <<
endl;
309 projectMode_(NEAREST),
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)),
357 surfacesDict_(ppf.surfacesDict_),
358 projectMode_(ppf.projectMode_),
359 projectDir_(ppf.projectDir_),
360 wedgePlane_(ppf.wedgePlane_),
361 frozenPointsZone_(ppf.frozenPointsZone_),
373 surfacesDict_(ppf.surfacesDict_),
374 projectMode_(ppf.projectMode_),
375 projectDir_(ppf.projectDir_),
376 wedgePlane_(ppf.wedgePlane_),
377 frozenPointsZone_(ppf.frozenPointsZone_),
396 surfacesDict_(ppf.surfacesDict_),
397 projectMode_(ppf.projectMode_),
398 projectDir_(ppf.projectDir_),
399 wedgePlane_(ppf.wedgePlane_),
400 frozenPointsZone_(ppf.frozenPointsZone_),
425 db().time().constant(),
437 return *surfacesPtr_;
448 vectorField displacement(this->patchInternalField());
451 calcProjection(displacement);
456 <<
" on patch " <<
patch().name()
457 <<
" of field " << this->internalField().name()
459 <<
" min:" <<
gMin(displacement)
461 <<
" average:" <<
gAverage(displacement)
466 Field<vector>& iF =
const_cast<Field<vector>&
>(this->primitiveField());
469 setInInternalField(iF, displacement);
482 os.
writeEntry(
"projectMode", projectModeNames_[projectMode_]);
499 scalePtr_->writeData(
os);
512 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.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Type gMin(const FieldField< Field, Type > &f)
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)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
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) ...
const pointMesh & mesh() const noexcept
Return the mesh reference.
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)
A pointPatch based on a polyPatch.
#define forAll(list, i)
Loop across all elements in list.
Type gMaxMagSqr(const UList< Type > &f, const label comm)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
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.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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.
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
const word & name() const noexcept
The patch name.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
int debug
Static debugging option.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
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 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...
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.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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.
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)