43Foam::surfaceSlipDisplacementPointPatchVectorField::projectModeNames_
45 { projectMode::NEAREST,
"nearest" },
46 { projectMode::POINTNORMAL,
"pointNormal" },
47 { projectMode::FIXEDNORMAL,
"fixedNormal" },
53void Foam::surfaceSlipDisplacementPointPatchVectorField::calcProjection
55 vectorField& displacement
68 const scalar projectLen =
mesh.bounds().mag();
74 projectVec = projectLen *
normalised(projectDir_);
79 const pointZone* zonePtr =
mesh.pointZones().cfindZone(frozenPointsZone_);
83 Pout<<
"surfaceSlipDisplacementPointPatchVectorField : Fixing all "
84 << zonePtr->size() <<
" points in pointZone " << zonePtr->
name()
87 else if (!frozenPointsZone_.empty())
90 <<
"Cannot find frozen point zone: " << frozenPointsZone_ <<
nl
104 start[i] =
points0[meshPoints[i]] + displacement[i];
107 label nNotProjected = 0;
111 List<pointIndexHit> nearest;
123 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
126 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
128 else if (nearest[i].hit())
130 displacement[i] = nearest[i].point() -
points0[meshPoints[i]];
138 Pout<<
" point:" << meshPoints[i]
139 <<
" coord:" << localPoints[i]
140 <<
" did not find any surface within " << projectLen
151 List<pointIndexHit> nearest;
178 offset[i] = start[i][wedgePlane_];
179 start[i][wedgePlane_] = 0;
180 projectVecs[i][wedgePlane_] = 0;
184 List<pointIndexHit> rightHit;
196 List<pointIndexHit> leftHit;
211 if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
214 displacement[i] =
points0[meshPoints[i]] - localPoints[i];
216 else if (nearest[i].hit())
219 displacement[i] = nearest[i].point() -
points0[meshPoints[i]];
225 if (rightHit[i].hit())
232 start[i].distSqr(rightHit[i].
point())
233 < start[i].distSqr(leftHit[i].
point())
237 interPt = rightHit[i];
241 interPt = leftHit[i];
246 if (leftHit[i].hit())
248 interPt = leftHit[i];
257 interPt.point()[wedgePlane_] += offset[i];
259 displacement[i] = interPt.point() -
points0[meshPoints[i]];
267 Pout<<
" point:" << meshPoints[i]
268 <<
" coord:" << localPoints[i]
269 <<
" did not find any intersection between"
270 <<
" ray from " << start[i]-projectVecs[i]
271 <<
" to " << start[i]+projectVecs[i] <<
endl;
282 scalePtr_->value(this->db().time().timeOutputValue())
288 reduce(nNotProjected, sumOp<label>());
290 if (nNotProjected > 0)
292 Info<<
"surfaceSlipDisplacement :"
294 <<
" did not project " << nNotProjected
295 <<
" out of " <<
returnReduce(localPoints.size(), sumOp<label>())
296 <<
" points." <<
endl;
311 projectMode_(NEAREST),
326 surfacesDict_(
dict.subDict(
"geometry")),
327 projectMode_(projectModeNames_.get(
"projectMode",
dict)),
330 (projectMode_ == FIXEDNORMAL)
334 wedgePlane_(
dict.getOrDefault(
"wedgePlane", -1)),
335 frozenPointsZone_(
dict.getOrDefault(
"frozenPointsZone",
word::null)),
355 const surfaceSlipDisplacementPointPatchVectorField& ppf,
357 const DimensionedField<vector, pointMesh>& iF,
358 const pointPatchFieldMapper&
362 surfacesDict_(ppf.surfacesDict_),
363 projectMode_(ppf.projectMode_),
364 projectDir_(ppf.projectDir_),
365 wedgePlane_(ppf.wedgePlane_),
366 frozenPointsZone_(ppf.frozenPointsZone_),
371 scalePtr_ = ppf.scalePtr_.clone(fpp->patch());
379 const surfaceSlipDisplacementPointPatchVectorField& ppf,
380 const DimensionedField<vector, pointMesh>& iF
384 surfacesDict_(ppf.surfacesDict_),
385 projectMode_(ppf.projectMode_),
386 projectDir_(ppf.projectDir_),
387 wedgePlane_(ppf.wedgePlane_),
388 frozenPointsZone_(ppf.frozenPointsZone_),
393 scalePtr_ = ppf.scalePtr_.clone(fpp->patch());
424 return *surfacesPtr_;
435 vectorField displacement(this->patchInternalField());
438 calcProjection(displacement);
443 <<
" on patch " << patch().name()
444 <<
" of field " << this->internalField().name()
446 <<
" min:" <<
gMin(displacement)
448 <<
" average:" <<
gAverage(displacement)
456 setInInternalField(iF, displacement);
468 os.writeEntry(
"geometry", surfacesDict_);
469 os.writeEntry(
"projectMode", projectModeNames_[projectMode_]);
476 os.writeEntryIfDifferent<label>(
"wedgePlane", -1, wedgePlane_);
477 os.writeEntryIfDifferent<
word>
486 scalePtr_->writeData(
os);
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...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
@ 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 autoPtr< PatchFunction1< Type > > NewIfPresent(const polyPatch &pp, const word &entryName, const dictionary &dict, const bool faceValues=true)
An optional selector.
static constexpr direction nComponents
Number of components in this vector space.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const word & name() const noexcept
The patch name.
const pointMesh & mesh() const noexcept
Return the mesh reference.
const pointPatch & patch() const noexcept
Return the patch.
const objectRegistry & db() const
The associated objectRegistry.
bool updated() const noexcept
True if the boundary condition has already been updated.
Foam::pointPatchFieldMapper.
void patchInternalField(const UList< Type1 > &internalData, const labelUList &addressing, UList< Type1 > &pfld) const
void setInInternalField(Field< Type1 > &iF, const Field< Type1 > &pF, const labelUList &meshPoints) const
const Field< vector > & primitiveField() const noexcept
virtual void write(Ostream &os) const
Write.
virtual void updateCoeffs()
const DimensionedField< vector, pointMesh > & internalField() const noexcept
Basic pointPatch represents a set of points from the mesh.
virtual const labelList & meshPoints() const =0
Return mesh points.
virtual const vectorField & localPoints() const =0
Return pointField of points in patch.
const pointBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
virtual const vectorField & pointNormals() const =0
Return point unit normals.
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 follows a triSurface. Use in a displacementMotionSolver as a bc on the pointDisplacement...
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const searchableSurfaces & surfaces() const
Surface to follow. Demand loads surfaceNames.
surfaceSlipDisplacementPointPatchVectorField(const pointPatch &, const DimensionedField< vector, pointMesh > &)
Construct from patch and internal field.
A class for handling words, derived from Foam::string.
static const word null
An empty word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
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))
Different types of constants.
Namespace for handling debugging switches.
Type gAverage(const FieldField< Field, Type > &f, const label comm)
The global arithmetic average of a FieldField.
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).
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
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.
Type gMaxMagSqr(const UList< Type > &f, const label comm)
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
Field< vector > vectorField
Specialisation of Field<T> for vector.
pointPatchField< vector > pointPatchVectorField
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Type gMin(const FieldField< Field, Type > &f)
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#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)))