MOAB: Mesh Oriented datABase  (version 5.4.1)
MBMesquite::DeformingDomainWrapper Class Reference

Smooth mesh with deforming domain (deforming geometry) More...

#include <DeformingDomainWrapper.hpp>

+ Inheritance diagram for MBMesquite::DeformingDomainWrapper:
+ Collaboration diagram for MBMesquite::DeformingDomainWrapper:

Public Types

enum  MeshCharacteristic { SHAPE, SHAPE_SIZE, SHAPE_SIZE_ORIENT }
 Mesh characteristics to attempt to preserve. More...

Public Member Functions

MESQUITE_EXPORT DeformingDomainWrapper ()
virtual MESQUITE_EXPORT ~DeformingDomainWrapper ()
void set_initial_coord_tag (const std::string &tag_name)
 Specify tag used to get/set cached initial mesh vertex coordinates.
std::string get_initial_coord_tag () const
 Get tag used to store vertex coordinates of initial mesh.
MESQUITE_EXPORT void store_initial_mesh (Mesh *mesh, MsqError &err)
 Store the initial mesh before deformation as a reference.
void set_mesh_characteristic (MeshCharacteristic t)
 Specify which mesh characteristics to preserve.
MeshCharacteristic get_mesh_characteristic () const
bool is_culling_enabled () const
 Check if vertex culling will be used.
void enable_culling (bool yesno)
 Enable vertex culling.
void set_cpu_time_limit (double seconds)
 Specify timeout after which optimization will exit.
void clear_cpu_time_limit ()
 No timeout.
bool get_cpu_time_limit (double &seconds) const
 Get timeout after which optimization will exit.
MESQUITE_EXPORT void set_vertex_movement_limit_factor (double f)
 Specify factor by which to minimum distance a vertex must move in an iteration to avoid termination of the optimization.
double get_vertex_movement_limit_factor () const

Protected Member Functions

MESQUITE_EXPORT void run_wrapper (MeshDomainAssoc *mesh_and_domain, ParallelMesh *pmesh, Settings *settings, QualityAssessor *qa, MsqError &err)
MESQUITE_EXPORT void move_to_domain (Mesh *mesh, MeshDomain *geom, MsqError &err)

Private Attributes

MeshCharacteristic metricType
std::string initVertexCoords
 name of tag used to store coordinates of initial mesh
bool doCulling
double cpuTime
double movementFactor

Detailed Description

Smooth mesh with deforming domain (deforming geometry)

This wrapper stores the initial mesh on/in an undeformed domain and uses the characteristics of that mesh to guide the optimization of the mesh after deformation of the domain.

The caller must ensure that the wrapper has the initial mesh description. The simplest way to do this is to call store_initial_mesh prior to the deformation of the geometric domain.

Application using this wrapper should preform the following steps.

  1. Change any wrapper settings
  2. Call store_initial_mesh with a mesh object containing all vertices in the mesh
  3. If using DeformingCurveSmoother, call DeformingCurveSmoother::store_initial_mesh separately for each geometric curve in the mesh.
  4. Optionally export mesh to file if Mesh implementation can save tag data
  5. Deform domain
  6. Optionally restore mesh from file
  7. Move any vertices bound to geometric points/vertices to their new location
  8. If using DeformingCurveSmoother, call smooth_curve separately for each geometric curve
  9. If doing free smooth call run_instructions for entire mesh. Otherwise call run_instructions separately for each geometric surface and each volume.

This algorithm uses non-barrier metrics which makes it possible, if unlikely, that the result mesh will contain more/different inverted elements than the input mesh.

Mesquite does not do edge/curve smoothing. The caller may either set up a "free" smooth where vertices on geometric curves are smoothed as a part of teh surface or volume optimization or simply redistribute the vertices along the curves outside of mesquite. The DeformingCurveSmoother class is provided below to facilitate redistributing nodes on a curve such that fractional arc length is preserved for edges. However, this it is as a stand-alone utility that must be invoked independently for each curve.

Definition at line 81 of file DeformingDomainWrapper.hpp.


Member Enumeration Documentation

Mesh characteristics to attempt to preserve.

Enumerator:
SHAPE 

Attempt to preserve element shape (TShapeNB1 metric)

SHAPE_SIZE 

Attempt to preserve element shape and size (TShapeSize2DNB1 & TShapeSize3DNB1)

SHAPE_SIZE_ORIENT 

Attempt to preserve element shape, size, and orientation (TShapeSizeOrientNB1)

Definition at line 139 of file DeformingDomainWrapper.hpp.

    {
        SHAPE,             //!< Attempt to preserve element shape (TShapeNB1 metric)
        SHAPE_SIZE,        //!< Attempt to preserve element shape and size (TShapeSize2DNB1 &
                           //!< TShapeSize3DNB1)
        SHAPE_SIZE_ORIENT  //!< Attempt to preserve element shape, size, and orientation
                           //!< (TShapeSizeOrientNB1)
    };

Constructor & Destructor Documentation


Member Function Documentation

No timeout.

Definition at line 190 of file DeformingDomainWrapper.hpp.

References cpuTime.

    {
        cpuTime = 0.0;
    }

Enable vertex culling.

Culling will be enabled by default.

Definition at line 178 of file DeformingDomainWrapper.hpp.

References doCulling.

    {
        doCulling = yesno;
    }
bool MBMesquite::DeformingDomainWrapper::get_cpu_time_limit ( double &  seconds) const [inline]

Get timeout after which optimization will exit.

Returns:
false if no timeout specified, true otherwise

Definition at line 197 of file DeformingDomainWrapper.hpp.

References cpuTime.

    {
        seconds = cpuTime;
        return cpuTime > 0.0;
    }

Get tag used to store vertex coordinates of initial mesh.

Return the tag passed to set_initial_coord_tag or if store_initial_mesh has been called, the the tag created by store_initial_mesh .

Definition at line 117 of file DeformingDomainWrapper.hpp.

References initVertexCoords.

    {
        return initVertexCoords;
    }

Definition at line 215 of file DeformingDomainWrapper.hpp.

References movementFactor.

    {
        return movementFactor;
    }

Check if vertex culling will be used.

Definition at line 169 of file DeformingDomainWrapper.hpp.

References doCulling.

    {
        return doCulling;
    }
void MBMesquite::DeformingDomainWrapper::move_to_domain ( Mesh mesh,
MeshDomain geom,
MsqError err 
) [protected]

Definition at line 159 of file DeformingDomainWrapper.cpp.

References MBMesquite::Mesh::get_all_vertices(), MSQ_ERRRTN, MBMesquite::MeshDomain::snap_to(), MBMesquite::Mesh::vertex_set_coordinates(), and MBMesquite::Mesh::vertices_get_coordinates().

Referenced by run_wrapper().

{
    std::vector< Mesh::VertexHandle > verts;
    mesh->get_all_vertices( verts, err );MSQ_ERRRTN( err );

    MsqVertex coords;
    std::vector< Mesh::VertexHandle >::const_iterator i;
    for( i = verts.begin(); i != verts.end(); ++i )
    {
        mesh->vertices_get_coordinates( &*i, &coords, 1, err );MSQ_ERRRTN( err );
        geom->snap_to( *i, coords );
        mesh->vertex_set_coordinates( *i, coords, err );MSQ_ERRRTN( err );
    }
}
void MBMesquite::DeformingDomainWrapper::run_wrapper ( MeshDomainAssoc mesh_and_domain,
ParallelMesh pmesh,
Settings settings,
QualityAssessor quality_assessor,
MsqError err 
) [protected, virtual]

Function that each wrapper must implement

Implements MBMesquite::Wrapper.

Definition at line 91 of file DeformingDomainWrapper.cpp.

References MBMesquite::TerminationCriterion::add_absolute_vertex_movement_edge_length(), MBMesquite::TerminationCriterion::add_cpu_time(), MBMesquite::TerminationCriterion::add_iteration_limit(), MBMesquite::QualityAssessor::add_quality_assessment(), MBMesquite::InstructionQueue::add_quality_assessor(), cpuTime, MBMesquite::TerminationCriterion::cull_on_absolute_vertex_movement_edge_length(), MBMesquite::DEFAULT_INNER_ITERATIONS, doCulling, geom, MBMesquite::MeshDomainAssoc::get_domain(), MBMesquite::MeshDomainAssoc::get_mesh(), MBMesquite::inner(), MBMesquite::MsqError::INVALID_STATE, mesh, metricType, move_to_domain(), movementFactor, MSQ_ERRRTN, MSQ_SETERR, MBMesquite::outer(), MBMesquite::P, MBMesquite::InstructionQueue::run_common(), MBMesquite::QualityImprover::set_inner_termination_criterion(), MBMesquite::InstructionQueue::set_master_quality_improver(), MBMesquite::QualityImprover::set_outer_termination_criterion(), SHAPE, SHAPE_SIZE, SHAPE_SIZE_ORIENT, and MBMesquite::PatchSetUser::use_element_on_vertex_patch().

{
    if( movementFactor <= 0 )
    {
        MSQ_SETERR( err )
        ( MsqError::INVALID_STATE, "Optimization will not terminate with non-positive movement factor %f",
          movementFactor );
        return;
    }

    Mesh* mesh       = mesh_and_domain->get_mesh();
    MeshDomain* geom = mesh_and_domain->get_domain();

    // Move initial mesh to domain in case caller did not
    move_to_domain( mesh, geom, err );MSQ_ERRRTN( err );

    const double P = 1.0;
    TagVertexMesh init_mesh( err, mesh );MSQ_ERRRTN( err );
    ReferenceMesh ref_mesh( &init_mesh );
    RefMeshTargetCalculator W( &ref_mesh );

    TShapeNB1 mu_s;
    TShapeSize2DNB1 mu_2d_ss;
    TShapeSize3DNB1 mu_3d_ss;
    TMixed mu_ss( &mu_2d_ss, &mu_3d_ss );
    TShapeSizeOrientNB1 mu_sso;
    TMetric* mu = 0;
    switch( metricType )
    {
        case SHAPE:
            mu = &mu_s;
            break;
        case SHAPE_SIZE:
            mu = &mu_ss;
            break;
        case SHAPE_SIZE_ORIENT:
            mu = &mu_sso;
            break;
    }

    TQualityMetric sample_metric( &W, mu );
    ElementPMeanP elem_metric( P, &sample_metric );
    PMeanPTemplate obj_func( P, &elem_metric );

    TerminationCriterion inner, outer;
    SteepestDescent improver( &obj_func );
    improver.use_element_on_vertex_patch();  // Nash optimization
    inner.add_iteration_limit( DEFAULT_INNER_ITERATIONS );
    if( doCulling )
        inner.cull_on_absolute_vertex_movement_edge_length( movementFactor );
    else
        outer.add_absolute_vertex_movement_edge_length( movementFactor );
    if( cpuTime > 0.0 ) outer.add_cpu_time( cpuTime );
    improver.set_inner_termination_criterion( &inner );
    improver.set_outer_termination_criterion( &outer );

    qa->add_quality_assessment( &elem_metric );
    InstructionQueue q;
    q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
    q.set_master_quality_improver( &improver, err );MSQ_ERRRTN( err );
    q.add_quality_assessor( qa, err );MSQ_ERRRTN( err );
    q.run_common( mesh_and_domain, pmesh, settings, err );MSQ_ERRRTN( err );
}
void MBMesquite::DeformingDomainWrapper::set_cpu_time_limit ( double  seconds) [inline]

Specify timeout after which optimization will exit.

Definition at line 184 of file DeformingDomainWrapper.hpp.

References cpuTime.

    {
        cpuTime = seconds;
    }
void MBMesquite::DeformingDomainWrapper::set_initial_coord_tag ( const std::string &  tag_name) [inline]

Specify tag used to get/set cached initial mesh vertex coordinates.

This optimizer uses the initial mesh (prior to deformation of the domain) as a reference when smoothing the mesh on the deformed domain. The initial mesh is stored/accessed as alternate vertex coordinates stored in a Tag on the mesh. This function can be used to specify the tag used to store those initial coordinates. If the named tag already exists then it must have a type of DOUBLE and a size of three values.

If the application already has the initial coordinates stored in some tag, then calling this function with the tag handle is sufficient to to set up the optmizer. Otherwise store_initial_mesh can be called to copy the initial vertex coordinates into a tag. If both this function is called to set the tag handle and store_initial_mesh is called, then store_initial_mesh will copy the vertices into the specified tag. Otherwise store_initial_mesh, if called, will create a new tag.

Definition at line 106 of file DeformingDomainWrapper.hpp.

References initVertexCoords.

    {
        initVertexCoords = tag_name;
    }

Specify which mesh characteristics to preserve.

It typically works the best to preserve whichever quantities can be preserved. For example, if the overall area/volume of the domain didn't change much, attempt to preserve size. If the deformation of the domain doesn't require rotation of the elements relative to the global coordinate system, then preserve orientation.

The default is SHAPE.

Definition at line 158 of file DeformingDomainWrapper.hpp.

References metricType, and t.

    {
        metricType = t;
    }

Specify factor by which to minimum distance a vertex must move in an iteration to avoid termination of the optimization.

Value must be greater than zero, and should be less 1.0 The optimizer will calculated a representative edge length from the mesh. It will terminate the optimization when an iteration moves no vertex more than this factor times the characteristic edge length.

Definition at line 85 of file DeformingDomainWrapper.cpp.

References movementFactor.

Referenced by main().

{
    assert( f > 0.0 );
    movementFactor = f;
}

Store the initial mesh before deformation as a reference.

Store the initial mesh for use as a reference when smoothing mesh on deformed geometry.

Parameters:
meshThe mesh instance to be operated on. Initial mesh data is stored by copying vertex coordinates to This must be called prior to the optimization with the mesh in its undeformed state. This function need not be called if the application cal provide access to the coordinates of vertices of the initial mesh through the tag mechanism already. See set_initial_coord_tag

Definition at line 76 of file DeformingDomainWrapper.cpp.

References MBMesquite::InstructionQueue::add_tag_vertex_mesh(), MBMesquite::TagVertexMesh::get_tag_name(), initVertexCoords, MSQ_ERRRTN, and MBMesquite::IQInterface::run_instructions().

Referenced by main().

{
    TagVertexMesh tool( err, mesh, false, initVertexCoords );MSQ_ERRRTN( err );
    InstructionQueue q;
    q.add_tag_vertex_mesh( &tool, err );MSQ_ERRRTN( err );
    q.run_instructions( mesh, err );MSQ_ERRRTN( err );
    if( initVertexCoords.empty() ) initVertexCoords = tool.get_tag_name();
}

Member Data Documentation

name of tag used to store coordinates of initial mesh

Definition at line 233 of file DeformingDomainWrapper.hpp.

Referenced by get_initial_coord_tag(), set_initial_coord_tag(), and store_initial_mesh().

List of all members.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines