Go to the documentation of this file.
54 syncTools::syncPointPositions
59 point(GREAT,GREAT,GREAT)
64 if (
mag(syncedFld[i] -
fld[i]) > maxMag)
67 <<
"On point " << i <<
" point:" <<
fld[i]
68 <<
" synchronised point:" << syncedFld[i]
79 const scalar val =
fld[pointI];
81 if ((val > -GREAT) && (val < GREAT))
86 <<
"Problem : point:" << pointI <<
" value:" << val
102 const face&
f = mesh_.faces()[iter.key()];
119 const edgeList& edges = mesh_.edges();
126 wght[edgeI] = 1.0/(edges[edgeI].mag(
points)+SMALL);
151 label pointI = meshPoints[i];
152 if (isAffectedPoint.
get(pointI) == 1)
157 0.5*
fld[pointI] + 0.5*avgFld[pointI]
185 if (isAffectedPoint.
get(pointI) == 1 && isInternalPoint(pointI))
190 0.5*
fld[pointI] + 0.5*avgFld[pointI]
211 if (isInternalPoint(iter.key()))
213 fld[iter.key()] *= scale;
233 label pointI = meshPoints[i];
237 fld[pointI] *= scale;
253 if (isInternalPoint(iter.key()))
255 fld[iter.key()] =
max(0.0,
fld[iter.key()]-
f);
275 label pointI = meshPoints[i];
287 return isInternalPoint_.get(pointI) == 1;
293 const label nPointIter,
300 isAffectedPoint.
setSize(mesh_.nPoints());
303 faceSet nbrFaces(mesh_,
"checkFaces", wrongFaces);
310 for (
label i = 0; i < nPointIter; i++)
312 pointSet nbrPoints(mesh_,
"grownPoints", getPoints(nbrFaces.
toc()));
316 const labelList& pCells = mesh_.pointCells(iter.key());
320 const cell& cFaces = mesh_.cells()[pCells[pCellI]];
324 nbrFaces.
insert(cFaces[cFaceI]);
328 nbrFaces.
sync(mesh_);
330 if (i == nPointIter - 2)
334 const face&
f = mesh_.faces()[iter.key()];
337 isAffectedPoint.
set(
f[fp], 1);
343 affectedFaces = nbrFaces.
toc();
364 displacement_(displacement),
366 oldPoints_(oldPoints),
367 adaptPatchIDs_(adaptPatchIDs),
368 paramDict_(paramDict),
369 isInternalPoint_(mesh_.nPoints(), 1)
403 return adaptPatchIDs_;
415 oldPoints_ = mesh_.points();
435 label patchI = patchIDs[i];
447 const lduSchedule& patchSchedule = displacement.mesh().globalData().
450 forAll(patchSchedule, patchEvalI)
452 label patchI = patchSchedule[patchEvalI].patch;
454 if (!adaptPatchSet.
found(patchI))
456 if (patchSchedule[patchEvalI].init)
477 label patchI = patchIDs[i];
487 setDisplacementPatchFields(adaptPatchIDs_, displacement_);
515 isPatchPoint.
set(ppMeshPoints);
525 label pointI = cppMeshPoints[i];
526 if (isPatchPoint[pointI])
535 forAll(ppMeshPoints, patchPointI)
537 displacement[ppMeshPoints[patchPointI]] = patchDisp[patchPointI];
553 setDisplacementPatchFields(patchIDs, displacement);
560 forAll(ppMeshPoints, patchPointI)
562 const vector& newDisp = displacement[ppMeshPoints[patchPointI]];
564 if (
mag(newDisp-patchDisp[patchPointI]) > SMALL)
575 Pout<<
"Written " << nVerts <<
" points that are changed to file "
580 forAll(ppMeshPoints, patchPointI)
582 patchDisp[patchPointI] = displacement[ppMeshPoints[patchPointI]];
589 setDisplacement(adaptPatchIDs_, pp_, patchDisp, displacement_);
601 const lduSchedule& patchSchedule = mesh_.globalData().patchSchedule();
604 forAll(patchSchedule, patchEvalI)
606 label patchI = patchSchedule[patchEvalI].patch;
608 if (adaptPatchSet.
found(patchI))
610 if (patchSchedule[patchEvalI].init)
625 forAll(patchSchedule, patchEvalI)
627 label patchI = patchSchedule[patchEvalI].patch;
629 if (!adaptPatchSet.
found(patchI))
631 if (patchSchedule[patchEvalI].init)
666 Info<<
"Correcting 2-D mesh motion";
668 if (mesh_.globalData().parallel())
671 <<
"2D mesh-motion probably not correct in parallel" <<
endl;
676 const edgeList& edges = mesh_.edges();
683 const edge&
e = edges[neIndices[i]];
685 point& pStart = newPoints[
e.start()];
687 pStart += pn*(pn & (oldPoints[
e.start()] - pStart));
689 point& pEnd = newPoints[
e.end()];
691 pEnd += pn*(pn & (oldPoints[
e.end()] - pEnd));
701 Pout<<
"motionSmootherAlgo::modifyMotionPoints :"
702 <<
" testing sync of newPoints."
704 testSyncPositions(newPoints, 1
e-6*mesh_.bounds().mag());
713 mesh_.clearAdditionalGeom();
714 pp_.movePoints(mesh_.points());
720 const scalar errorReduction
723 scalar oldErrorReduction =
readScalar(paramDict_.lookup(
"errorReduction"));
725 paramDict_.remove(
"errorReduction");
726 paramDict_.add(
"errorReduction", errorReduction);
728 return oldErrorReduction;
735 const bool smoothMesh,
736 const label nAllowableErrors
754 const bool smoothMesh,
755 const label nAllowableErrors
781 actualPatchTypes[patchI] = pbm[patchI].type();
788 displacement_.boundaryField();
789 actualPatchFieldTypes.
setSize(pfld.size());
795 actualPatchFieldTypes[patchI] =
800 actualPatchFieldTypes[patchI] = pfld[patchI].type();
810 mesh_.time().timeName(),
816 scale_*displacement_,
817 actualPatchFieldTypes,
824 Pout<<
"scaleMesh : testing sync of totalDisplacement" <<
endl;
830 1
e-6*mesh_.bounds().mag()
837 modifyMotionPoints(tnewPoints());
849 const bool smoothMesh,
850 const label nAllowableErrors
853 if (!smoothMesh && adaptPatchIDs_.empty())
856 <<
"You specified both no movement on the internal mesh points"
857 <<
" (smoothMesh = false)" <<
nl
858 <<
"and no movement on the patch (adaptPatchIDs is empty)" <<
nl
859 <<
"Hence nothing to adapt."
868 Pout<<
"Entering scaleMesh : coupled patches:" <<
endl;
874 refCast<const coupledPolyPatch>(
patches[patchI]);
876 Pout<<
'\t' << patchI <<
'\t' << pp.
name()
879 <<
" forwardT:" << pp.
forwardT().size()
885 const scalar errorReduction =
887 const label nSmoothScale =
901 Info<<
"Moving mesh using displacement scaling :"
902 <<
" min:" <<
gMin(scale_.internalField())
903 <<
" max:" <<
gMax(scale_.internalField())
910 mesh_.movePoints(newPoints);
915 faceSet wrongFaces(mesh_,
"wrongFaces", mesh_.nFaces()/100+100);
916 checkMesh(
false, mesh_, meshQualityDict, checkFaces, baffles, wrongFaces);
925 wrongFaces.
sync(mesh_);
931 if (
mag(errorReduction) < SMALL)
936 label own = mesh_.faceOwner()[iter.key()];
937 const cell& ownFaces = mesh_.cells()[own];
941 newWrongFaces.
insert(ownFaces[cfI]);
944 if (iter.key() < mesh_.nInternalFaces())
946 label nei = mesh_.faceNeighbour()[iter.key()];
947 const cell& neiFaces = mesh_.cells()[nei];
951 newWrongFaces.
insert(neiFaces[cfI]);
956 wrongFaces.
sync(mesh_);
963 pointSet usedPoints(mesh_,
"usedPoints", getPoints(wrongFaces));
964 usedPoints.
sync(mesh_);
972 getAffectedFacesAndPoints
982 Pout<<
"Faces in error:" << wrongFaces.
size()
983 <<
" with points:" << usedPoints.
size()
987 if (adaptPatchIDs_.size())
990 scaleField(pp_.meshPoints(), usedPoints, errorReduction, scale_);
996 scaleField(usedPoints, errorReduction, scale_);
1000 scalarField eWeights(calcEdgeWeights(oldPoints_));
1002 for (
label i = 0; i < nSmoothScale; i++)
1004 if (adaptPatchIDs_.size())
1022 minSmooth(eWeights, isAffectedPoint, oldScale, scale_);
1038 Pout<<
"scale_ after smoothing :"
1054 forAll(adaptPatchIDs_, i)
1056 label patchI = adaptPatchIDs_[i];
1060 !isA<fixedValuePointPatchVectorField>
1062 displacement_.boundaryField()[patchI]
1067 <<
"Patch " <<
patches[patchI].name()
1068 <<
" has wrong boundary condition "
1069 << displacement_.boundaryField()[patchI].type()
1070 <<
" on field " << displacement_.name() <<
nl
1071 <<
"Only type allowed is "
1072 << fixedValuePointPatchVectorField::typeName
1081 const labelList& meshPoints = pp_.meshPoints();
1085 isInternalPoint_.unset(meshPoints[i]);
void constrainCorners(GeometricField< Type, pointPatchField, pointMesh > &pf) const
Apply patch-patch constraints only.
void evaluate()
Evaluate boundary conditions.
virtual const pointField & points() const
Return raw points.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
scalar setErrorReduction(const scalar)
Set the errorReduction (by how much to scale the displacement.
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
bool checkMesh(const polyMeshGen &mesh, const bool report)
Check mesh for correctness. Returns false for no error.
void modifyMotionPoints(pointField &newPoints) const
Apply optional point constraint (2d correction)
labelHashSet getPoints(const labelHashSet &) const
Get points used by given faces.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
void correctBoundaryConditions(pointVectorField &) const
Special correctBoundaryConditions which evaluates fixedValue.
List< Key > toc() const
Return the table of contents.
const vector & planeNormal() const
Return plane normal.
#define forAll(list, i)
Loop across all elements in list.
void transfer(HashTable< T, Key, Hash > &)
Transfer the contents of the argument table into this table.
A class for managing temporary objects.
void correct()
Take over existing mesh position.
void updateMesh()
Update for new mesh topology.
const indirectPrimitivePatch & patch() const
Reference to patch.
const labelList & adaptPatchIDs() const
Patch labels that are being adapted.
virtual const tensorField & forwardT() const
Return face transformation tensor.
void set(const PackedList< 1 > &)
Set specified bits.
static void checkFld(const pointScalarField &)
tmp< pointField > curPoints() const
Get the current points (oldPoints+scale*displacement)
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool scaleMesh(labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0)
Move mesh with given scale. Return true if mesh ok or has.
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
void setDisplacementPatchFields()
Set patch fields on displacement to be consistent with.
dimensioned< scalar > mag(const dimensioned< Type > &)
void subtractField(const labelHashSet &pointLabels, const scalar f, pointScalarField &) const
Lower on internal points.
Mesh consisting of general polyhedral cells.
static const pointConstraints & New(const pointMesh &mesh)
void setSize(const label, const unsigned int &val=0u)
Alias for resize()
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
const objectRegistry & db() const
Return the local objectRegistry.
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
virtual bool parallel() const
Are the cyclic planes parallel.
Class applies a two-dimensional correction to mesh motion point field.
virtual bool separated() const
Are the planes separated.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
~motionSmootherAlgo()
Destructor.
Pre-declare SubField and related Field type.
bool isInternalPoint(const label pointI) const
Helper function. Is point internal?
void testSyncPositions(const pointField &, const scalar maxMag) const
Test synchronisation of points.
InternalField & internalField()
Return internal field.
virtual void sync(const polyMesh &mesh)
Sync set across coupled patches. Adds coupled points to set.
const pointMesh & mesh() const
Return the mesh reference.
A list of keyword definitions, which are a keyword followed by any number of values (e....
label size() const
Return number of elements in table.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
bool found(const Key &) const
Return true if hashedEntry is found in table.
Mesh representing a set of points created from polyMesh.
errorManip< error > abort(error &err)
unsigned int get(const label) const
Get value at index I.
const double e
Elementary charge.
motionSmootherAlgo(const motionSmootherAlgo &)
Disallow default bitwise copy construct.
const dictionary & paramDict() const
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
void setSize(const label)
Reset size of List.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void getAffectedFacesAndPoints(const label nPointIter, const faceSet &wrongFaces, labelList &affectedFaces, PackedBoolList &isAffectedPoint) const
Given a set of faces that cause smoothing and a number of.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
prefixOSstream Pout(cout, "Pout")
U correctBoundaryConditions()
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
const polyMesh & mesh() const
Reference to mesh.
static void setDisplacement(const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement)
Set displacement field from displacement on patch points.
label size() const
Return the number of elements in the PtrList.
bool insert(const Key &key)
Insert a new entry.
To synchronise displacements. We want max displacement since.
label readLabel(Istream &is)
bool required() const
Is 2D correction required, i.e. is the mesh a wedge or slab.
void movePoints()
Update for new mesh geometry.
const pointMesh & pMesh() const
Reference to pointMesh.
A face is a list of labels corresponding to mesh vertices.
void constrain(GeometricField< Type, pointPatchField, pointMesh > &pf, const bool overrideValue=false) const
Apply boundary conditions (single-patch constraints) and.
const labelList & normalEdgeIndices() const
Return indices of normal edges.
const fileName & name() const
Return the name of the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
void correctPoints(pointField &p) const
Correct motion points.
Type gMin(const FieldField< Field, Type > &f)
void scaleField(const labelHashSet &pointLabels, const scalar scale, pointScalarField &) const
Scale certain (internal) points of a field.
const globalMeshData & globalData() const
Return parallel info.
vector point
Point is a vector.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Generic GeometricField class.
void minSmooth(const scalarField &edgeWeights, const PackedBoolList &isAffectedPoint, const pointScalarField &fld, pointScalarField &newFld) const
Explicit smoothing and min on all affected internal points.
fileName path() const
Return complete path.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const word & name() const
Return name.
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
labelList pointLabels(nPoints, -1)
tmp< scalarField > calcEdgeWeights(const pointField &) const
Calculate per-edge weight.
Type gMax(const FieldField< Field, Type > &f)
A list of faces which address into the list of points.