MOAB: Mesh Oriented datABase
(version 5.4.1)
|
Simple 2D Domain for free-smooth testing. More...
#include <XYRectangle.hpp>
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 |
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:
Definition at line 51 of file XYRectangle.hpp.
typedef std::multimap< Mesh::VertexHandle, VertexConstraint > MBMesquite::XYRectangle::constraint_t [private] |
Map vertex handles to constraints.
Definition at line 132 of file XYRectangle.hpp.
MBMesquite::XYRectangle::XYRectangle | ( | double | w, |
double | h, | ||
double | x = 0 , |
||
double | y = 0 , |
||
double | z = 0 , |
||
Plane | plane = XY |
||
) |
Define rectangular domain.
w | Width of rectangle (X-range) |
h | Height of rectangle (Y-range) |
x | Minimum X coordinate of rectangle |
y | Minimum Y coordinate of rectangle |
z | Minimum Z coordinate of rectangle |
plane | Which 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.
void MBMesquite::XYRectangle::closest_point | ( | MBMesquite::Mesh::VertexHandle | handle, |
const MBMesquite::Vector3D & | position, | ||
MBMesquite::Vector3D & | closest, | ||
MBMesquite::Vector3D & | normal, | ||
MBMesquite::MsqError & | err | ||
) | const [virtual] |
evaluate closest point and normal
Given a position in space, return the closest position in the domain and the domain normal at that point.
entity_handle | Evaluate the subset of the domain contianing this entity |
position | Input position for which to evaluate |
closest | Closest position in the domain. |
normal | Domain 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; }
void MBMesquite::XYRectangle::setup | ( | MBMesquite::Mesh * | mesh, |
MBMesquite::MsqError & | err | ||
) |
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.
handles | The domain evaluated is the one in which this mesh entity is constrained. |
coordinates | As input, a list of positions at which to evaluate the domain. As output, the resulting domain normals. |
count | The 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 ); }
const int MBMesquite::XYRectangle::heightDir [private] |
Definition at line 115 of file XYRectangle.hpp.
Referenced by setup(), and XYRectangle().
double MBMesquite::XYRectangle::maxCoords[3] [private] |
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().
double MBMesquite::XYRectangle::minCoords[3] [private] |
Definition at line 114 of file XYRectangle.hpp.
Referenced by setup(), snap_to(), and XYRectangle().
const int MBMesquite::XYRectangle::normalDir [private] |
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().