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

Simple 2D Domain for free-smooth testing. More...

#include <XYRectangle.hpp>

+ Inheritance diagram for MBMesquite::XYRectangle:
+ Collaboration diagram for MBMesquite::XYRectangle:

Classes

struct  VertexConstraint
 Single constraint on a vertex (reduces degrees of freedom by 1) More...

Public Types

enum  Plane { XY = 2, YZ = 0, ZX = 1 }

Public Member Functions

MESQUITE_EXPORT XYRectangle (double w, double h, double x=0, double y=0, double z=0, Plane plane=XY)
 Define rectangular domain.
MESQUITE_EXPORT void setup (MBMesquite::Mesh *mesh, MBMesquite::MsqError &err)
 Classify mesh vertices against domain.
MESQUITE_EXPORT void snap_to (MBMesquite::Mesh::VertexHandle entity_handle, MBMesquite::Vector3D &coordinate) const
MESQUITE_EXPORT void vertex_normal_at (MBMesquite::Mesh::VertexHandle entity_handle, MBMesquite::Vector3D &coordinate) const
MESQUITE_EXPORT void element_normal_at (MBMesquite::Mesh::ElementHandle entity_handle, MBMesquite::Vector3D &coordinate) const
MESQUITE_EXPORT void vertex_normal_at (const MBMesquite::Mesh::VertexHandle *handles, MBMesquite::Vector3D coordinates[], unsigned count, MBMesquite::MsqError &err) const
 evaluate surface normals
MESQUITE_EXPORT void closest_point (MBMesquite::Mesh::VertexHandle handle, const MBMesquite::Vector3D &position, MBMesquite::Vector3D &closest, MBMesquite::Vector3D &normal, MBMesquite::MsqError &err) const
 evaluate closest point and normal
MESQUITE_EXPORT void domain_DoF (const MBMesquite::Mesh::VertexHandle *handle_array, unsigned short *dof_array, size_t num_handles, MBMesquite::MsqError &err) const

Private Types

typedef std::multimap
< Mesh::VertexHandle,
VertexConstraint
constraint_t
 Map vertex handles to constraints.

Private Attributes

double minCoords [3]
double maxCoords [3]
 corner coords
const int normalDir
const int widthDir
const int heightDir
constraint_t mConstraints

Detailed Description

Simple 2D Domain for free-smooth testing.

Define a simple bounded rectangular domain in the XY-plane. Mesh vertices are classified as one of the following:

  • 0 DoF : On a corner of the rectangle
  • 1 DoF : On an edge of the rectangle
  • 2 DoF : In the interior of the rectangle

Definition at line 51 of file XYRectangle.hpp.


Member Typedef Documentation

Map vertex handles to constraints.

Definition at line 132 of file XYRectangle.hpp.


Member Enumeration Documentation

Enumerator:
XY 
YZ 
ZX 

Definition at line 54 of file XYRectangle.hpp.

    {
        XY = 2,
        YZ = 0,
        ZX = 1
    };

Constructor & Destructor Documentation

MBMesquite::XYRectangle::XYRectangle ( double  w,
double  h,
double  x = 0,
double  y = 0,
double  z = 0,
Plane  plane = XY 
)

Define rectangular domain.

Parameters:
wWidth of rectangle (X-range)
hHeight of rectangle (Y-range)
xMinimum X coordinate of rectangle
yMinimum Y coordinate of rectangle
zMinimum Z coordinate of rectangle
planeWhich plane (default is XY).

Create w x h rectangle with, if plane is XY: X range of [x, x+w] and Y range of [y, y+h].

Definition at line 40 of file XYRectangle.cpp.

References heightDir, maxCoords, minCoords, widthDir, and z.

    : normalDir( p ), widthDir( ( p + 1 ) % 3 ), heightDir( ( p + 2 ) % 3 )
{
    minCoords[0] = maxCoords[0] = x;
    minCoords[1] = maxCoords[1] = y;
    minCoords[2] = maxCoords[2] = z;
    maxCoords[widthDir] += w;
    maxCoords[heightDir] += h;
}

Member Function Documentation

evaluate closest point and normal

Given a position in space, return the closest position in the domain and the domain normal at that point.

Parameters:
entity_handleEvaluate the subset of the domain contianing this entity
positionInput position for which to evaluate
closestClosest position in the domain.
normalDomain normal at the location of 'closest'

Implements MBMesquite::MeshDomain.

Definition at line 132 of file XYRectangle.cpp.

References vertex_normal_at().

{
    normal = position;
    vertex_normal_at( vertex, normal );
    closest    = position;
    closest[2] = 0;
}
void MBMesquite::XYRectangle::domain_DoF ( const MBMesquite::Mesh::VertexHandle handle_array,
unsigned short *  dof_array,
size_t  num_handles,
MBMesquite::MsqError err 
) const

Definition at line 144 of file XYRectangle.cpp.

References mConstraints.

Referenced by main().

{
    for( unsigned i = 0; i < num_handles; ++i )
    {
        // everything is at least constrained to XY-plane
        dof_array[i] = 2;
        // each additional constraint reduces degrees of freedom
        constraint_t::const_iterator j = mConstraints.lower_bound( vertices[i] );
        for( ; j != mConstraints.end() && j->first == vertices[i]; ++j )
            --dof_array[i];
    }
}
void MBMesquite::XYRectangle::element_normal_at ( MBMesquite::Mesh::ElementHandle  entity_handle,
MBMesquite::Vector3D coordinate 
) const [virtual]

Implements MBMesquite::MeshDomain.

Definition at line 116 of file XYRectangle.cpp.

References normalDir, and MBMesquite::Vector3D::set().

{
    norm.set( 0, 0, 0 );
    norm[normalDir] = 1.0;
}

Classify mesh vertices against domain.

Figure out which input mesh vertices like on corners or edges of the domain. Will fail if any vertex is outside of the rectangle.

Definition at line 50 of file XYRectangle.cpp.

References MBMesquite::arrptr(), epsilon, MBMesquite::Mesh::get_all_vertices(), heightDir, MBMesquite::MsqError::INVALID_MESH, MBMesquite::MsqError::INVALID_STATE, maxCoords, mConstraints, minCoords, MSQ_ERRRTN, MSQ_SETERR, normalDir, MBMesquite::Mesh::vertices_get_coordinates(), and widthDir.

Referenced by main().

{
    const double epsilon = 1e-4;
    if( maxCoords[widthDir] - minCoords[widthDir] <= epsilon ||
        maxCoords[heightDir] - minCoords[heightDir] <= epsilon ||
        maxCoords[normalDir] - minCoords[normalDir] > epsilon )
    {
        MSQ_SETERR( err )( "Invalid rectangle dimensions", MsqError::INVALID_STATE );
        return;
    }

    mConstraints.clear();

    std::vector< Mesh::EntityHandle > vertices;
    mesh->get_all_vertices( vertices, err );MSQ_ERRRTN( err );
    if( vertices.empty() )
    {
        MSQ_SETERR( err )( "Empty mesh", MsqError::INVALID_MESH );
        return;
    }

    std::vector< MsqVertex > coords( vertices.size() );
    mesh->vertices_get_coordinates( arrptr( vertices ), arrptr( coords ), coords.size(), err );MSQ_ERRRTN( err );

    for( size_t i = 0; i < vertices.size(); ++i )
    {
        for( int d = 0; d < 3; ++d )
        {
            if( d == normalDir ) continue;
            if( minCoords[d] - coords[i][d] > epsilon || coords[i][d] - maxCoords[d] > epsilon )
            {
                MSQ_SETERR( err )
                ( MsqError::INVALID_MESH, "Invalid vertex coordinate: (%f,%f,%f)\n", coords[i][0], coords[i][1],
                  coords[i][2] );
                return;
            }
            else if( coords[i][d] - minCoords[d] < epsilon )
            {
                VertexConstraint c( d, minCoords[d] );
                mConstraints.insert( constraint_t::value_type( vertices[i], c ) );
            }
            else if( maxCoords[d] - coords[i][d] < epsilon )
            {
                VertexConstraint c( d, maxCoords[d] );
                mConstraints.insert( constraint_t::value_type( vertices[i], c ) );
            }
        }
    }
}
void MBMesquite::XYRectangle::snap_to ( MBMesquite::Mesh::VertexHandle  entity_handle,
MBMesquite::Vector3D coordinate 
) const [virtual]

Modifies "coordinate" so that it lies on the domain to which "entity_handle" is constrained. The handle determines the domain. The coordinate is the proposed new position on that domain.

Implements MBMesquite::MeshDomain.

Definition at line 100 of file XYRectangle.cpp.

References mConstraints, minCoords, and normalDir.

{
    // everything gets moved into the plane
    coordinate[normalDir] = minCoords[normalDir];
    // apply other constraints
    constraint_t::const_iterator i = mConstraints.lower_bound( vertex );
    for( ; i != mConstraints.end() && i->first == vertex; ++i )
        coordinate[i->second.axis] = i->second.coord;
}
void MBMesquite::XYRectangle::vertex_normal_at ( MBMesquite::Mesh::VertexHandle  entity_handle,
MBMesquite::Vector3D coordinate 
) const [virtual]

Returns the normal of the domain to which "entity_handle" is constrained. For non-planar surfaces, the normal is calculated at the point on the domain that is closest to the passed in value of "coordinate". If the domain does not have a normal, or the normal cannot be determined, "coordinate" is set to (0,0,0). Otherwise, "coordinate" is set to the domain's normal at the appropriate point. In summary, the handle determines the domain. The coordinate determines the point of interest on that domain.

User should see also PatchData::get_domain_normal_at_vertex and PatchData::get_domain_normal_at_element .

Implements MBMesquite::MeshDomain.

Definition at line 110 of file XYRectangle.cpp.

References normalDir, and MBMesquite::Vector3D::set().

Referenced by closest_point().

{
    norm.set( 0, 0, 0 );
    norm[normalDir] = 1.0;
}
void MBMesquite::XYRectangle::vertex_normal_at ( const MBMesquite::Mesh::VertexHandle handles,
MBMesquite::Vector3D  coordinates[],
unsigned  count,
MBMesquite::MsqError err 
) const [virtual]

evaluate surface normals

Returns normals for a domain.

Parameters:
handlesThe domain evaluated is the one in which this mesh entity is constrained.
coordinatesAs input, a list of positions at which to evaluate the domain. As output, the resulting domain normals.
countThe length of the coordinates array.

Implements MBMesquite::MeshDomain.

Definition at line 122 of file XYRectangle.cpp.

References normalDir.

{
    Vector3D norm( 0, 0, 0 );
    norm[normalDir] = 1.0;
    std::fill( normals, normals + count, norm );
}

Member Data Documentation

Definition at line 115 of file XYRectangle.hpp.

Referenced by setup(), and XYRectangle().

corner coords

Definition at line 114 of file XYRectangle.hpp.

Referenced by setup(), and XYRectangle().

Definition at line 133 of file XYRectangle.hpp.

Referenced by domain_DoF(), setup(), and snap_to().

Definition at line 114 of file XYRectangle.hpp.

Referenced by setup(), snap_to(), and XYRectangle().

Definition at line 115 of file XYRectangle.hpp.

Referenced by element_normal_at(), setup(), snap_to(), and vertex_normal_at().

const int MBMesquite::XYRectangle::widthDir [private]

Definition at line 115 of file XYRectangle.hpp.

Referenced by setup(), and XYRectangle().

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