Classes | Public Member Functions | Static Public Member Functions | List of all members
motionSmootherAlgo Class Reference

Given a displacement moves the mesh by scaling the displacement back until there are no more mesh errors. More...

Inheritance diagram for motionSmootherAlgo:
Inheritance graph
[legend]

Public Member Functions

 ClassName ("motionSmootherAlgo")
 
 motionSmootherAlgo (polyMesh &, pointMesh &, indirectPrimitivePatch &pp, pointVectorField &displacement, pointScalarField &scale, pointField &oldPoints, const labelList &adaptPatchIDs, const dictionary &paramDict)
 Construct from mesh, patches to work on and smoothing parameters. More...
 
 ~motionSmootherAlgo ()
 Destructor. More...
 
const polyMeshmesh () const
 Reference to mesh. More...
 
const pointMeshpMesh () const
 Reference to pointMesh. More...
 
const indirectPrimitivePatchpatch () const
 Reference to patch. More...
 
const labelListadaptPatchIDs () const
 Patch labels that are being adapted. More...
 
const dictionaryparamDict () 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< pointFieldcurPoints () 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 &paramDict, 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 updateMesh ()
 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...
 
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...
 
static bool checkMesh (const bool report, const dictionary &dict, const polyMeshGeometry &, const labelList &checkFaces, labelHashSet &wrongFaces)
 Check part of mesh with mesh settings in dict. More...
 
static bool checkMesh (const bool report, const dictionary &dict, const polyMeshGeometry &, const labelList &checkFaces, const List< labelPair > &baffles, labelHashSet &wrongFaces)
 Check part of mesh including baffles with mesh settings in dict. More...
 

Detailed Description

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
  • Shared points (parallel): a processor can have points which are part of pp on another processor but have no pp itself (i.e. it has points and/or edges but no faces of pp). Hence we have to be careful when e.g. synchronising displacements that the value from the processor which has faces of pp get priority. This is currently handled in setDisplacement by resetting the internal displacement to zero before doing anything else. The combine operator used will give preference to non-zero values.
  • Various routines take baffles. These are sets of boundary faces that are treated as a single internal face. This is a hack used to apply movement to internal faces.
  • Mesh constraints are looked up from the supplied dictionary. (uses recursive lookup)
Source files

Definition at line 96 of file motionSmootherAlgo.H.

Constructor & Destructor Documentation

◆ motionSmootherAlgo()

motionSmootherAlgo ( polyMesh ,
pointMesh ,
indirectPrimitivePatch pp,
pointVectorField displacement,
pointScalarField scale,
pointField oldPoints,
const labelList adaptPatchIDs,
const dictionary paramDict 
)

Construct from mesh, patches to work on and smoothing parameters.

◆ ~motionSmootherAlgo()

Destructor.

Definition at line 377 of file motionSmootherAlgo.C.

Member Function Documentation

◆ ClassName()

ClassName ( "motionSmootherAlgo"  )

◆ mesh()

const Foam::polyMesh & mesh ( ) const

Reference to mesh.

Definition at line 383 of file motionSmootherAlgo.C.

Referenced by motionSmootherAlgo::setDisplacementPatchFields().

Here is the caller graph for this function:

◆ pMesh()

const Foam::pointMesh & pMesh ( ) const

Reference to pointMesh.

Definition at line 389 of file motionSmootherAlgo.C.

Referenced by snappySnapDriver::smoothDisplacement().

Here is the caller graph for this function:

◆ patch()

const Foam::indirectPrimitivePatch & patch ( ) const

Reference to patch.

Definition at line 395 of file motionSmootherAlgo.C.

Referenced by listPlusEqOp< T >::operator()(), and snappySnapDriver::smoothDisplacement().

Here is the caller graph for this function:

◆ adaptPatchIDs()

const Foam::labelList & adaptPatchIDs ( ) const

Patch labels that are being adapted.

Definition at line 401 of file motionSmootherAlgo.C.

◆ paramDict()

const Foam::dictionary & paramDict ( ) const

Definition at line 407 of file motionSmootherAlgo.C.

◆ correct()

void correct ( )

◆ setDisplacementPatchFields() [1/2]

static void setDisplacementPatchFields ( const labelList patchIDs,
pointVectorField pointDisplacement 
)
static

Set patch fields on patchIDs to be consistent with.

all other boundary conditions

◆ setDisplacementPatchFields() [2/2]

void setDisplacementPatchFields ( )

◆ setDisplacement() [1/2]

static void setDisplacement ( const labelList patchIDs,
const indirectPrimitivePatch pp,
pointField patchDisp,
pointVectorField displacement 
)
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.

Referenced by snappyLayerDriver::addLayers(), snappySnapDriver::doSnap(), snappySnapDriver::preSmoothPatch(), motionSmootherAlgo::setDisplacement(), and motionSmootherAlgo::setDisplacementPatchFields().

Here is the caller graph for this function:

◆ setDisplacement() [2/2]

void setDisplacement ( pointField patchDisp)

Definition at line 571 of file motionSmootherAlgo.C.

References motionSmootherAlgo::correctBoundaryConditions(), and motionSmootherAlgo::setDisplacement().

Here is the call graph for this function:

◆ correctBoundaryConditions()

void correctBoundaryConditions ( pointVectorField ) 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 UPstream::blocking, GeometricField< Type, PatchField, GeoMesh >::boundaryFieldRef(), forAll, HashTable< T, Key, Hash >::found(), DimensionedField< Type, GeoMesh >::mesh(), MeshObject< pointMesh, UpdateableMeshObject, pointConstraints >::New(), patchi, syncTools::syncPointList(), and VectorSpace< Vector< scalar >, scalar, 3 >::zero.

Referenced by motionSmootherAlgo::curPoints(), and motionSmootherAlgo::setDisplacement().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modifyMotionPoints()

void modifyMotionPoints ( pointField newPoints) const

◆ curPoints()

Foam::tmp< Foam::pointField > curPoints ( ) const

◆ setErrorReduction()

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 Foam::readScalar(), and motionSmootherAlgo::scaleMesh().

Referenced by motionSmootherAlgo::movePoints(), snappySnapDriver::preSmoothPatch(), and snappySnapDriver::scaleMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scaleMesh() [1/3]

bool scaleMesh ( labelList checkFaces,
const bool  smoothMesh = true,
const label  nAllow = 0 
)

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(), motionSmootherAlgo::scaleMesh(), snappySnapDriver::scaleMesh(), and motionSmootherAlgo::setErrorReduction().

Here is the caller graph for this function:

◆ scaleMesh() [2/3]

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.

References motionSmootherAlgo::scaleMesh().

Here is the call graph for this function:

◆ scaleMesh() [3/3]

bool scaleMesh ( labelList checkFaces,
const List< labelPair > &  baffles,
const dictionary paramDict,
const dictionary meshQualityDict,
const bool  smoothMesh = true,
const label  nAllow = 0 
)

◆ movePoints()

void movePoints ( )

Update for new mesh geometry.

Definition at line 696 of file motionSmootherAlgo.C.

References motionSmootherAlgo::setErrorReduction().

Referenced by motionSmootherAlgo::scaleMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateMesh()

void updateMesh ( )

Update for new mesh topology.

Definition at line 1036 of file motionSmootherAlgo.C.

References GeometricField< Type, PatchField, GeoMesh >::boundaryField(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, forAll, syncTools::getMasterEdges(), IOobject::name(), Foam::nl, patches, and patchi.

Here is the call graph for this function:

◆ checkMesh() [1/5]

bool checkMesh ( const bool  report,
const polyMesh mesh,
const dictionary dict,
labelHashSet wrongFaces 
)
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 415 of file motionSmootherAlgoCheck.C.

References Foam::identity(), and primitiveMesh::nFaces().

Referenced by edgeCollapser::checkBadFaces(), motionSmootherAlgo::checkMesh(), snappyLayerDriver::doLayers(), snappySnapDriver::doSnap(), and motionSmootherAlgo::scaleMesh().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkMesh() [2/5]

bool checkMesh ( const bool  report,
const polyMesh mesh,
const dictionary dict,
const labelList checkFaces,
labelHashSet wrongFaces 
)
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().

Here is the call graph for this function:

◆ checkMesh() [3/5]

bool checkMesh ( const bool  report,
const polyMesh mesh,
const dictionary dict,
const labelList checkFaces,
const List< labelPair > &  baffles,
labelHashSet wrongFaces 
)
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 primitiveMesh::cellCentres(), primitiveMesh::cellVolumes(), motionSmootherAlgo::checkMesh(), Foam::endl(), primitiveMesh::faceAreas(), primitiveMesh::faceCentres(), Foam::Info, dictionary::lookup(), polyMesh::points(), dictionary::readIfPresent(), readScalar, Foam::returnReduce(), Foam::setw(), and HashTable< T, Key, Hash >::size().

Here is the call graph for this function:

◆ checkMesh() [4/5]

bool checkMesh ( const bool  report,
const dictionary dict,
const polyMeshGeometry meshGeom,
const labelList checkFaces,
labelHashSet wrongFaces 
)
static

Check part 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 433 of file motionSmootherAlgoCheck.C.

References motionSmootherAlgo::checkMesh().

Here is the call graph for this function:

◆ checkMesh() [5/5]

bool checkMesh ( const bool  report,
const dictionary dict,
const polyMeshGeometry meshGeom,
const labelList checkFaces,
const List< labelPair > &  baffles,
labelHashSet wrongFaces 
)
static

Check part 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.

Note: cannot check the skewness without the points and don't want

to store them on polyMeshGeometry. if (maxIntSkew > 0 || maxBounSkew > 0) { meshGeom.checkFaceSkewness ( report, maxIntSkew, maxBounSkew, checkFaces, baffles, &wrongFaces );

label nNewWrongFaces = returnReduce(wrongFaces.size(),sumOp<label>());

Info<< " faces with skewness > " << setw(3) << maxIntSkew << " (internal) or " << setw(3) << maxBounSkew << " (boundary) : " << nNewWrongFaces-nWrongFaces << endl;

nWrongFaces = nNewWrongFaces; }

Definition at line 456 of file motionSmootherAlgoCheck.C.

References polyMeshGeometry::affectedCells(), polyMeshGeometry::checkCellDeterminant(), polyMeshGeometry::checkFaceAngles(), polyMeshGeometry::checkFaceArea(), polyMeshGeometry::checkFaceDotProduct(), polyMeshGeometry::checkFaceFlatness(), polyMeshGeometry::checkFacePyramids(), polyMeshGeometry::checkFaceTets(), polyMeshGeometry::checkFaceTwist(), polyMeshGeometry::checkFaceWeights(), polyMeshGeometry::checkTriangleTwist(), polyMeshGeometry::checkVolRatio(), Foam::endl(), Foam::Info, dictionary::lookup(), polyMeshGeometry::mesh(), polyMesh::points(), dictionary::readIfPresent(), readScalar, Foam::returnReduce(), Foam::setw(), and HashTable< T, Key, Hash >::size().

Here is the call graph for this function:

◆ smooth()

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 236 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ avg()

Foam::tmp<Foam::GeometricField<Type, Foam::pointPatchField, Foam::pointMesh> > avg ( const GeometricField< Type, pointPatchField, pointMesh > &  fld,
const scalarField edgeWeight 
) const

The documentation for this class was generated from the following files: