Given a displacement moves the mesh by scaling the displacement back until there are no more mesh errors. More...
Public Member Functions | |
ClassName ("motionSmootherAlgo") | |
motionSmootherAlgo (polyMesh &, pointMesh &, indirectPrimitivePatch &pp, pointVectorField &displacement, pointScalarField &scale, pointField &oldPoints, const labelList &adaptPatchIDs, const dictionary ¶mDict) | |
Construct from mesh, patches to work on and smoothing parameters. More... | |
motionSmootherAlgo (const motionSmootherAlgo &)=delete | |
Disallow default bitwise copy construction. More... | |
~motionSmootherAlgo () | |
Destructor. More... | |
const polyMesh & | mesh () const |
Reference to mesh. More... | |
const pointMesh & | pMesh () const |
Reference to pointMesh. More... | |
const indirectPrimitivePatch & | patch () const |
Reference to patch. More... | |
const labelList & | adaptPatchIDs () const |
Patch labels that are being adapted. More... | |
const dictionary & | paramDict () const |
void | correct () |
Take over existing mesh position. More... | |
void | setDisplacementPatchFields () |
Set patch fields on displacement to be consistent with. More... | |
void | setDisplacement (pointField &patchDisp) |
void | correctBoundaryConditions (pointVectorField &) const |
Special correctBoundaryConditions which evaluates fixedValue. More... | |
void | modifyMotionPoints (pointField &newPoints) const |
Apply optional point constraint (2d correction) More... | |
tmp< pointField > | curPoints () const |
Get the current points (oldPoints+scale*displacement) More... | |
scalar | setErrorReduction (const scalar) |
Set the errorReduction (by how much to scale the displacement. More... | |
bool | scaleMesh (labelList &checkFaces, const bool smoothMesh=true, const label nAllow=0) |
Move mesh with given scale. Return true if mesh ok or has. More... | |
bool | scaleMesh (labelList &checkFaces, const List< labelPair > &baffles, const bool smoothMesh=true, const label nAllow=0) |
Move mesh (with baffles) with given scale. More... | |
bool | scaleMesh (labelList &checkFaces, const List< labelPair > &baffles, const dictionary ¶mDict, const dictionary &meshQualityDict, const bool smoothMesh=true, const label nAllow=0) |
Move mesh with externally provided mesh constraints. More... | |
void | movePoints () |
Update for new mesh geometry. More... | |
void | topoChange () |
Update for new mesh topology. More... | |
template<class Type > | |
void | smooth (const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight, GeometricField< Type, pointPatchField, pointMesh > &newFld) const |
Fully explicit smoothing of fields (not positions) More... | |
void | operator= (const motionSmootherAlgo &)=delete |
Disallow default bitwise assignment. More... | |
template<class Type > | |
Foam::tmp< Foam::GeometricField< Type, Foam::pointPatchField, Foam::pointMesh > > | avg (const GeometricField< Type, pointPatchField, pointMesh > &fld, const scalarField &edgeWeight) const |
Static Public Member Functions | |
static void | setDisplacementPatchFields (const labelList &patchIDs, pointVectorField &pointDisplacement) |
Set patch fields on patchIDs to be consistent with. More... | |
static void | setDisplacement (const labelList &patchIDs, const indirectPrimitivePatch &pp, pointField &patchDisp, pointVectorField &displacement) |
Set displacement field from displacement on patch points. More... | |
static bool | checkMesh (const bool report, const polyMesh &mesh, const dictionary &dict, labelHashSet &wrongFaces) |
Check mesh with mesh settings in dict. Collects incorrect faces. More... | |
static bool | checkMesh (const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, labelHashSet &wrongFaces) |
Check (subset of mesh) with mesh settings in dict. More... | |
static bool | checkMesh (const bool report, const polyMesh &mesh, const dictionary &dict, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces) |
Check (subset of mesh including baffles) with mesh settings. More... | |
Given a displacement moves the mesh by scaling the displacement back until there are no more mesh errors.
Holds displacement field (read upon construction since need boundary conditions) and scaling factor and optional patch number on which to scale back displacement.
E.g.
// Construct iterative mesh mover. motionSmoother meshMover(mesh, labelList(1, patchi)); // Set desired displacement: meshMover.displacement() = .. for (label iter = 0; iter < maxIter; iter++) { if (meshMover.scaleMesh(true)) { Info<< "Successfully moved mesh" << endl; return true; } }
Note:
Definition at line 95 of file motionSmootherAlgo.H.
motionSmootherAlgo | ( | polyMesh & | mesh, |
pointMesh & | pMesh, | ||
indirectPrimitivePatch & | pp, | ||
pointVectorField & | displacement, | ||
pointScalarField & | scale, | ||
pointField & | oldPoints, | ||
const labelList & | adaptPatchIDs, | ||
const dictionary & | paramDict | ||
) |
Construct from mesh, patches to work on and smoothing parameters.
Definition at line 350 of file motionSmootherAlgo.C.
|
delete |
Disallow default bitwise copy construction.
~motionSmootherAlgo | ( | ) |
Destructor.
Definition at line 377 of file motionSmootherAlgo.C.
ClassName | ( | "motionSmootherAlgo" | ) |
const Foam::polyMesh & mesh | ( | ) | const |
Reference to mesh.
Definition at line 383 of file motionSmootherAlgo.C.
const Foam::pointMesh & pMesh | ( | ) | const |
Reference to pointMesh.
Definition at line 389 of file motionSmootherAlgo.C.
Referenced by snappySnapDriver::smoothDisplacement().
const Foam::indirectPrimitivePatch & patch | ( | ) | const |
Reference to patch.
Definition at line 395 of file motionSmootherAlgo.C.
Referenced by listPlusEqOp< T >::operator()(), and snappySnapDriver::smoothDisplacement().
const Foam::labelList & adaptPatchIDs | ( | ) | const |
Patch labels that are being adapted.
Definition at line 401 of file motionSmootherAlgo.C.
const Foam::dictionary & paramDict | ( | ) | const |
Definition at line 407 of file motionSmootherAlgo.C.
void correct | ( | ) |
Take over existing mesh position.
Definition at line 413 of file motionSmootherAlgo.C.
References motionSmootherAlgo::setDisplacementPatchFields().
Referenced by snappySnapDriver::doSnap(), and snappySnapDriver::preSmoothPatch().
|
static |
Set patch fields on patchIDs to be consistent with.
all other boundary conditions
Definition at line 426 of file motionSmootherAlgo.C.
References GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), GeometricBoundaryField< Type, PatchField, GeoMesh >::evaluate(), forAll, HashTable< T, Key, Hash >::found(), DimensionedField< Type, GeoMesh >::mesh(), MeshObject< pointMesh, UpdateableMeshObject, pointConstraints >::New(), patchi, and UPstream::scheduled.
void setDisplacementPatchFields | ( | ) |
Set patch fields on displacement to be consistent with.
internal values.
Definition at line 488 of file motionSmootherAlgo.C.
References motionSmootherAlgo::setDisplacement().
Referenced by motionSmootherAlgo::correct().
|
static |
Set displacement field from displacement on patch points.
Modify provided displacement to be consistent with actual boundary conditions on displacement. Note: resets the displacement to be 0 on coupled patches beforehand to make sure shared points partially on pp (on some processors) and partially not (on other processors) get the value from pp.
Definition at line 495 of file motionSmootherAlgo.C.
References globalMeshData::coupledPatch(), IOobject::db(), Foam::endl(), forAll, polyMesh::globalData(), Foam::mag(), DimensionedField< Type, GeoMesh >::mesh(), PrimitivePatch< FaceList, PointField >::meshPoints(), OSstream::name(), objectRegistry::path(), polyMesh::points(), Foam::Pout, syncTools::syncPointList(), Foam::meshTools::writeOBJ(), and VectorSpace< Vector< scalar >, scalar, 3 >::zero.
Referenced by snappyLayerDriver::addLayers(), snappySnapDriver::doSnap(), snappySnapDriver::preSmoothPatch(), and motionSmootherAlgo::setDisplacementPatchFields().
void setDisplacement | ( | pointField & | patchDisp | ) |
Definition at line 571 of file motionSmootherAlgo.C.
References motionSmootherAlgo::correctBoundaryConditions().
void correctBoundaryConditions | ( | pointVectorField & | displacement | ) | const |
Special correctBoundaryConditions which evaluates fixedValue.
patches first so they get overwritten with any constraint bc's.
Definition at line 579 of file motionSmootherAlgo.C.
References GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), GeometricBoundaryField< Type, PatchField, GeoMesh >::evaluate(), forAll, HashTable< T, Key, Hash >::found(), DimensionedField< Type, GeoMesh >::mesh(), MeshObject< pointMesh, UpdateableMeshObject, pointConstraints >::New(), patchi, UPstream::scheduled, syncTools::syncPointList(), and VectorSpace< Vector< scalar >, scalar, 3 >::zero.
Referenced by motionSmootherAlgo::setDisplacement().
void modifyMotionPoints | ( | pointField & | newPoints | ) | const |
Apply optional point constraint (2d correction)
Definition at line 646 of file motionSmootherAlgo.C.
References twoDPointCorrector::correctPoints(), Foam::e, edge::end(), Foam::endl(), forAll, Foam::Info, MeshObject< polyMesh, UpdateableMeshObject, twoDPointCorrector >::New(), twoDPointCorrector::normalEdgeIndices(), twoDPointCorrector::planeNormal(), Foam::Pout, twoDPointCorrector::required(), edge::start(), and WarningInFunction.
Foam::tmp< Foam::pointField > curPoints | ( | ) | const |
Get the current points (oldPoints+scale*displacement)
Definition at line 757 of file motionSmootherAlgo.C.
References pointMesh::boundary(), correctBoundaryConditions(), Foam::e, Foam::endl(), forAll, Foam::isA(), pointBoundaryMesh::mesh(), IOobject::NO_READ, IOobject::NO_WRITE, patchi, Foam::Pout, GeometricField< Type, PatchField, GeoMesh >::primitiveField(), motionSmootherAlgo::scaleMesh(), List< T >::setSize(), UPtrList< T >::size(), and VectorSpace< Vector< scalar >, scalar, 3 >::zero.
Foam::scalar setErrorReduction | ( | const scalar | errorReduction | ) |
Set the errorReduction (by how much to scale the displacement.
at error locations) parameter. Returns the old value. Set to 0 (so revert to old mesh) grows out one cell layer from error faces.
Definition at line 706 of file motionSmootherAlgo.C.
References motionSmootherAlgo::scaleMesh().
Referenced by motionSmootherAlgo::movePoints(), snappySnapDriver::preSmoothPatch(), and snappySnapDriver::scaleMesh().
Move mesh with given scale. Return true if mesh ok or has.
less than nAllow errors, false otherwise and locally update scale. Smoothmesh=false means only patch points get moved. Parallel ok (as long as displacement field is consistent across patches)
Definition at line 720 of file motionSmootherAlgo.C.
Referenced by motionSmootherAlgo::curPoints(), snappySnapDriver::preSmoothPatch(), snappySnapDriver::scaleMesh(), and motionSmootherAlgo::setErrorReduction().
bool scaleMesh | ( | labelList & | checkFaces, |
const List< labelPair > & | baffles, | ||
const bool | smoothMesh = true , |
||
const label | nAllow = 0 |
||
) |
Move mesh (with baffles) with given scale.
Definition at line 738 of file motionSmootherAlgo.C.
bool scaleMesh | ( | labelList & | checkFaces, |
const List< labelPair > & | baffles, | ||
const dictionary & | paramDict, | ||
const dictionary & | meshQualityDict, | ||
const bool | smoothMesh = true , |
||
const label | nAllow = 0 |
||
) |
Move mesh with externally provided mesh constraints.
Definition at line 831 of file motionSmootherAlgo.C.
References Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, forAll, forAllConstIter, Foam::gMax(), Foam::gMin(), Foam::Info, HashSet< Key, Hash >::insert(), dictionary::lookup(), Foam::mag(), patchIdentifier::name(), Foam::nl, patches, patchi, Foam::Pout, Foam::returnReduce(), HashTable< T, Key, Hash >::size(), pointSet::sync(), syncTools::syncPointList(), coupledPolyPatch::transform(), and VectorSpace< Vector< scalar >, scalar, 3 >::zero.
void movePoints | ( | ) |
Update for new mesh geometry.
Definition at line 696 of file motionSmootherAlgo.C.
References motionSmootherAlgo::setErrorReduction().
void topoChange | ( | ) |
Update for new mesh topology.
Definition at line 1035 of file motionSmootherAlgo.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, forAll, syncTools::getMasterEdges(), Foam::nl, patches, and patchi.
|
static |
Check mesh with mesh settings in dict. Collects incorrect faces.
in set. Returns true if one or more faces in error. Parallel ok.
Definition at line 360 of file motionSmootherAlgoCheck.C.
References Foam::identity(), and primitiveMesh::nFaces().
Referenced by edgeCollapser::checkBadFaces(), motionSmootherAlgo::checkMesh(), snappyLayerDriver::doLayers(), and snappySnapDriver::doSnap().
|
static |
Check (subset of mesh) with mesh settings in dict.
Collects incorrect faces in set. Returns true if one or more faces in error. Parallel ok.
Definition at line 33 of file motionSmootherAlgoCheck.C.
References motionSmootherAlgo::checkMesh().
|
static |
Check (subset of mesh including baffles) with mesh settings.
in dict. Collects incorrect faces in set. Returns true if one or more faces in error. Parallel ok.
Definition at line 54 of file motionSmootherAlgoCheck.C.
References polyMesh::bounds(), primitiveMesh::cellCentres(), primitiveMesh::cellVolumes(), Foam::polyMeshCheck::checkCellDeterminant(), Foam::polyMeshCheck::checkFaceAngles(), Foam::polyMeshCheck::checkFaceDotProduct(), Foam::polyMeshCheck::checkFaceFlatness(), Foam::polyMeshCheck::checkFacePyramids(), Foam::polyMeshCheck::checkFaceSkewness(), Foam::polyMeshCheck::checkFaceTets(), Foam::polyMeshCheck::checkFaceTwist(), Foam::polyMeshCheck::checkFaceWeights(), motionSmootherAlgo::checkMesh(), Foam::polyMeshCheck::checkVolRatio(), Foam::endl(), primitiveMesh::faceAreas(), primitiveMesh::faceCentres(), Foam::Info, dictionary::lookup(), boundBox::minDim(), polyMesh::points(), Foam::pow3(), dictionary::readIfPresent(), Foam::returnReduce(), Foam::setw(), and HashTable< T, Key, Hash >::size().
void smooth | ( | const GeometricField< Type, pointPatchField, pointMesh > & | fld, |
const scalarField & | edgeWeight, | ||
GeometricField< Type, pointPatchField, pointMesh > & | newFld | ||
) | const |
Fully explicit smoothing of fields (not positions)
of internal points with varying diffusivity.
Definition at line 228 of file motionSmootherAlgoTemplates.C.
References Foam::abort(), constrain(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::mag(), DimensionedField< Type, GeoMesh >::mesh(), MeshObject< pointMesh, UpdateableMeshObject, pointConstraints >::New(), Foam::Pout, and syncTools::syncPointList().
Referenced by motionSmootherAlgo::avg(), and snappySnapDriver::smoothDisplacement().
|
delete |
Disallow default bitwise assignment.
Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> > avg | ( | const GeometricField< Type, pointPatchField, pointMesh > & | fld, |
const scalarField & | edgeWeight | ||
) | const |
Definition at line 139 of file motionSmootherAlgoTemplates.C.
References constrain(), DimensionedField< Type, GeoMesh >::dimensions(), Foam::e, primitiveMesh::edges(), forAll, PackedList< nBits >::get(), Foam::mag(), DimensionedField< Type, GeoMesh >::mesh(), IOobject::name(), MeshObject< pointMesh, UpdateableMeshObject, pointConstraints >::New(), primitiveMesh::nPoints(), GeometricField< Type, PatchField, GeoMesh >::ref(), motionSmootherAlgo::smooth(), syncTools::syncPointList(), and Foam::Zero.