Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MsqMeshEntity Class Reference

MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh. More...

#include <MsqMeshEntity.hpp>

Public Member Functions

 MsqMeshEntity ()
 
EntityTopology get_element_type () const
 Returns element type. More...
 
msq_stdc::size_t vertex_count () const
 Returns the number of vertices in this element, based on its element type. More...
 
msq_stdc::size_t node_count () const
 Return number of nodes in element (number of corner vertices + number of higher-order nodes). More...
 
void get_vertex_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 gets the vertices of the mesh entity More...
 
void append_vertex_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 
void get_node_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 gets the vertices of the mesh entity More...
 
void append_node_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 
const msq_stdc::size_t * get_vertex_index_array () const
 Very efficient retrieval of vertices indexes (corresponding to the PatchData vertex array). More...
 
msq_stdc::size_t * get_vertex_index_array ()
 
void set_element_type (EntityTopology type)
 Sets element data. More...
 
void set_connectivity (msq_stdc::size_t *indices, size_t num_vertices)
 Set connectivity data (vertex array) for element. More...
 
msq_stdc::size_t get_vertex_index (msq_stdc::size_t vertex_in_element) const
 
void compute_weighted_jacobian (PatchData &pd, Vector3D &sample_point, Vector3D jacobian_vectors[], short &num_jacobian_vectors, MsqError &err)
 
void get_sample_points (QualityMetric::ElementEvaluationMode mode, msq_std::vector< Vector3D > &coords, MsqError &err)
 Returns a list of sample points given an evaluationmode. More...
 
void get_centroid (Vector3D &centroid, const PatchData &pd, MsqError &err) const
 Returns the centroid of the element. More...
 
void get_connected_vertices (msq_stdc::size_t vertex_index, msq_std::vector< msq_stdc::size_t > &vert_indices, MsqError &err)
 Fills a vector<size_t> with vertices connected to the given vertex through the edges of this MsqMeshEntity. More...
 
double compute_unsigned_area (PatchData &pd, MsqError &err)
 Computes the area of the element. More...
 
double compute_unsigned_volume (PatchData &pd, MsqError &err)
 Computes the volume of the element. More...
 
double compute_signed_area (PatchData &pd, MsqError &err)
 Computes the signed area of the element. More...
 
double compute_signed_volume (PatchData &pd, MsqError &err)
 Computes the signed volume of the element. More...
 
void compute_corner_normals (Vector3D normals[], PatchData &pd, MsqError &err)
 Uses a MeshDomain call-back function to compute the normal at the corner. More...
 
void compute_corner_matrices (PatchData &pd, Matrix3D A[], int num_m3d, MsqError &err)
 Compute matrices which column are the vectors issued from a corner. More...
 
 MsqMeshEntity ()
 
EntityTopology get_element_type () const
 Returns element type. More...
 
msq_stdc::size_t vertex_count () const
 Returns the number of vertices in this element, based on its element type. More...
 
msq_stdc::size_t node_count () const
 Return number of nodes in element (number of corner vertices + number of higher-order nodes). More...
 
void get_vertex_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 gets the vertices of the mesh entity More...
 
void append_vertex_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 
void get_node_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 gets the vertices of the mesh entity More...
 
void append_node_indices (msq_std::vector< msq_stdc::size_t > &vertex_list) const
 
const msq_stdc::size_t * get_vertex_index_array () const
 Very efficient retrieval of vertices indexes (corresponding to the PatchData vertex array). More...
 
msq_stdc::size_t * get_vertex_index_array ()
 
void set_element_type (EntityTopology type)
 Sets element data. More...
 
void set_connectivity (msq_stdc::size_t *indices, size_t num_vertices)
 Set connectivity data (vertex array) for element. More...
 
msq_stdc::size_t get_vertex_index (msq_stdc::size_t vertex_in_element) const
 
void compute_weighted_jacobian (PatchData &pd, Vector3D &sample_point, Vector3D jacobian_vectors[], short &num_jacobian_vectors, MsqError &err)
 
void get_sample_points (QualityMetric::ElementEvaluationMode mode, msq_std::vector< Vector3D > &coords, MsqError &err)
 Returns a list of sample points given an evaluationmode. More...
 
void get_centroid (Vector3D &centroid, const PatchData &pd, MsqError &err) const
 Returns the centroid of the element. More...
 
void get_connected_vertices (msq_stdc::size_t vertex_index, msq_std::vector< msq_stdc::size_t > &vert_indices, MsqError &err)
 Fills a vector<size_t> with vertices connected to the given vertex through the edges of this MsqMeshEntity. More...
 
double compute_unsigned_area (PatchData &pd, MsqError &err)
 Computes the area of the element. More...
 
double compute_unsigned_volume (PatchData &pd, MsqError &err)
 Computes the volume of the element. More...
 
double compute_signed_area (PatchData &pd, MsqError &err)
 Computes the signed area of the element. More...
 
double compute_signed_volume (PatchData &pd, MsqError &err)
 Computes the signed volume of the element. More...
 
void compute_corner_normals (Vector3D normals[], PatchData &pd, MsqError &err)
 Uses a MeshDomain call-back function to compute the normal at the corner. More...
 
void compute_corner_matrices (PatchData &pd, Matrix3D A[], int num_m3d, MsqError &err)
 Compute matrices which column are the vectors issued from a corner. More...
 

Static Private Member Functions

static void get_linear_quad_jac (Vector3D *sp, Vector3D &coord0, Vector3D &coord1, Vector3D &coord2, Vector3D &coord3, Vector3D *jac)
 
static void get_linear_quad_jac (Vector3D *sp, Vector3D &coord0, Vector3D &coord1, Vector3D &coord2, Vector3D &coord3, Vector3D *jac)
 

Private Attributes

EntityTopology mType
 
size_t * vertexIndices
 Pointer to connectivity array. More...
 
size_t numVertexIndices
 

Friends

msq_stdio::ostream & operator<< (msq_stdio::ostream &stream, const MsqMeshEntity &entity)
 
msq_stdio::ostream & operator<< (msq_stdio::ostream &stream, const MsqMeshEntity &entity)
 

Detailed Description

MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh.

Definition at line 69 of file includeLinks/MsqMeshEntity.hpp.

Constructor & Destructor Documentation

MsqMeshEntity ( )
inline
MsqMeshEntity ( )
inline

Definition at line 73 of file src/Mesh/MsqMeshEntity.hpp.

Member Function Documentation

void append_node_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const
void append_node_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const
void append_vertex_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const
void append_vertex_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const
void compute_corner_matrices ( PatchData pd,
Matrix3D  A[],
int  num_m3d,
MsqError err 
)

Compute matrices which column are the vectors issued from a corner.

Stores those corner matrices in the mTag data member.

Parameters
pdThe PatchData the element belongs to. It contains the vertices coords.
c_m3dAn array of Matrix3D objects. There should be one matrix per element corner (4 for a tet, 8 for an hex). Each column of the matrix will contain a vector corresponding to a corner edge.
num_m3dThe number of matrices in the c_m3d array. The function will check this number corresponds to the number of corner in the element. If not, an error is set.

Definition at line 731 of file Mesh/MsqMeshEntity.cpp.

References MsqMeshEntity::compute_corner_normals(), MsqMeshEntity::get_element_type(), PatchData::get_vertex_array(), Mesquite::HEXAHEDRON, MsqError::INVALID_ARG, Mesquite::MSQ_3RT_2_OVER_6RT_3, MSQ_ERRRTN, MSQ_SETERR, MsqError::NOT_IMPLEMENTED, Mesquite::QUADRILATERAL, Matrix3D::set_column(), Mesquite::TETRAHEDRON, Mesquite::TRIANGLE, and MsqMeshEntity::vertexIndices.

Referenced by TargetCalculator::compute_guide_matrices(), TargetCalculator::compute_reference_corner_matrices(), and DistanceFromTarget::compute_T_matrices().

732 {
733  MsqVertex* vertices = pd.get_vertex_array(err); MSQ_ERRRTN(err);
734  const size_t* v_i = &vertexIndices[0];
735 
736  // If 2D element, we will get the surface normal
737  Vector3D normals[4], vec1, vec2, vec3, vec4;
738 
739 
740  switch(get_element_type()){
741 
742  case TRIANGLE:
743  if (num_m3d != 3) {
744  MSQ_SETERR(err)("num_m3d incompatible with element type.", MsqError::INVALID_ARG);
745  return;
746  }
747 
748  compute_corner_normals( normals, pd, err ); MSQ_ERRRTN(err);
749 
750  vec1 = vertices[v_i[1]]-vertices[v_i[0]];
751  vec2 = vertices[v_i[2]]-vertices[v_i[0]];
752  vec3 = vertices[v_i[2]]-vertices[v_i[1]];
753 
754  A[0].set_column(0, vec1);
755  A[0].set_column(1, vec2);
756  A[0].set_column(2, normals[0]*MSQ_3RT_2_OVER_6RT_3);
757 
758  A[1].set_column(0, vec3);
759  A[1].set_column(1, -vec1);
760  A[1].set_column(2, normals[1]*MSQ_3RT_2_OVER_6RT_3);
761 
762  A[2].set_column(0, -vec2);
763  A[2].set_column(1, -vec3);
764  A[2].set_column(2, normals[2]*MSQ_3RT_2_OVER_6RT_3);
765 
766  break;
767 
768  case QUADRILATERAL:
769  if (num_m3d != 4) {
770  MSQ_SETERR(err)("num_m3d incompatible with element type.", MsqError::INVALID_ARG);
771  return;
772  }
773  vec1 = vertices[v_i[1]]-vertices[v_i[0]];
774  vec2 = vertices[v_i[3]]-vertices[v_i[0]];
775  vec3 = vertices[v_i[2]]-vertices[v_i[1]];
776  vec4 = vertices[v_i[3]]-vertices[v_i[2]];
777 
778  compute_corner_normals( normals, pd, err ); MSQ_ERRRTN(err);
779 
780  A[0].set_column(0, vec1);
781  A[0].set_column(1, vec2);
782  A[0].set_column(2, normals[0]);
783 
784  A[1].set_column(0, vec3);
785  A[1].set_column(1, -vec1);
786  A[1].set_column(2, normals[1]);
787 
788  A[2].set_column(0, vec4);
789  A[2].set_column(1, -vec3);
790  A[2].set_column(2, normals[2]);
791 
792  A[3].set_column(0, -vec2);
793  A[3].set_column(1, -vec4);
794  A[3].set_column(2, normals[3]);
795 
796  break;
797 
798  case TETRAHEDRON:
799  if (num_m3d != 4) {
800  MSQ_SETERR(err)("num_m3d incompatible with element type.", MsqError::INVALID_ARG);
801  return;
802  }
803  A[0].set_column(0, vertices[v_i[1]]-vertices[v_i[0]]);
804  A[0].set_column(1, vertices[v_i[2]]-vertices[v_i[0]]);
805  A[0].set_column(2, vertices[v_i[3]]-vertices[v_i[0]]);
806 
807  A[1].set_column(0, vertices[v_i[0]]-vertices[v_i[1]]);
808  A[1].set_column(1, vertices[v_i[3]]-vertices[v_i[1]]);
809  A[1].set_column(2, vertices[v_i[2]]-vertices[v_i[1]]);
810 
811  A[2].set_column(0, vertices[v_i[3]]-vertices[v_i[2]]);
812  A[2].set_column(1, vertices[v_i[0]]-vertices[v_i[2]]);
813  A[2].set_column(2, vertices[v_i[1]]-vertices[v_i[2]]);
814 
815  A[3].set_column(0, vertices[v_i[2]]-vertices[v_i[3]]);
816  A[3].set_column(1, vertices[v_i[1]]-vertices[v_i[3]]);
817  A[3].set_column(2, vertices[v_i[0]]-vertices[v_i[3]]);
818 
819  break;
820 
821  /*
822  case PYRAMID:
823  //We compute the pyramid's "condition number" by averaging
824  //the 4 tet's condition numbers, where the tets are created
825  //by removing one of the four base vertices from the pyramid.
826  //transform to origina v_i[0]
827  temp_vec[3]=vertices[v_i[1]]-vertices[v_i[0]];
828  temp_vec[4]=vertices[v_i[3]]-vertices[v_i[0]];
829  temp_vec[5]=vertices[v_i[4]]-vertices[v_i[0]];
830  //find AW_inverse
831  temp_vec[0]=temp_vec[3];
832  temp_vec[1]=temp_vec[4]-temp_vec[3];
833  temp_vec[2]=MSQ_SQRT_TWO*(temp_vec[5]-(temp_vec[4]/2.0));
834  return_flag=condition_number_3d(temp_vec,pd,met_vals[0],err);
835  if(!return_flag)
836  return return_flag;
837  //transform to origina v_i[1]
838  temp_vec[3]=vertices[v_i[2]]-vertices[v_i[1]];
839  temp_vec[4]=vertices[v_i[3]]-vertices[v_i[1]];
840  temp_vec[5]=vertices[v_i[4]]-vertices[v_i[1]];
841  //find AW_inverse
842  temp_vec[0]=temp_vec[3]-temp_vec[4];
843  temp_vec[1]=temp_vec[3];
844  temp_vec[2]=MSQ_SQRT_TWO*(temp_vec[5]-(temp_vec[4]/2.0));
845  return_flag=condition_number_3d(temp_vec,pd,met_vals[1],err);
846  if(!return_flag)
847  return return_flag;
848  //transform to origina v_i[1]
849  temp_vec[3]=vertices[v_i[3]]-vertices[v_i[2]];
850  temp_vec[4]=vertices[v_i[0]]-vertices[v_i[2]];
851  temp_vec[5]=vertices[v_i[4]]-vertices[v_i[2]];
852  //find AW_inverse
853  temp_vec[0]=-temp_vec[3];
854  temp_vec[1]=temp_vec[3]-temp_vec[4];
855  temp_vec[2]=MSQ_SQRT_TWO*(temp_vec[5]-(temp_vec[4]/2.0));
856  return_flag=condition_number_3d(temp_vec,pd,met_vals[2],err);
857  if(!return_flag)
858  return return_flag;
859  //transform to origina v_i[1]
860  temp_vec[3]=vertices[v_i[0]]-vertices[v_i[3]];
861  temp_vec[4]=vertices[v_i[1]]-vertices[v_i[3]];
862  temp_vec[5]=vertices[v_i[4]]-vertices[v_i[3]];
863  //find AW_inverse
864  temp_vec[0]=temp_vec[4]-temp_vec[3];
865  temp_vec[1]=-temp_vec[3];
866  temp_vec[2]=MSQ_SQRT_TWO*(temp_vec[5]-(temp_vec[4]/2.0));
867  return_flag=condition_number_3d(temp_vec,pd,met_vals[3],err);
868  fval=average_metrics(met_vals, 4, err);
869  if(!return_flag)
870  return return_flag;
871  break;
872  */
873 
874  case HEXAHEDRON:
875  if (num_m3d != 8) {
876  MSQ_SETERR(err)("num_m3d incompatible with element type.", MsqError::INVALID_ARG);
877  return;
878  }
879  A[0].set_column(0, vertices[v_i[1]]-vertices[v_i[0]]);
880  A[0].set_column(1, vertices[v_i[3]]-vertices[v_i[0]]);
881  A[0].set_column(2, vertices[v_i[4]]-vertices[v_i[0]]);
882 
883  A[1].set_column(0, vertices[v_i[2]]-vertices[v_i[1]]);
884  A[1].set_column(1, vertices[v_i[0]]-vertices[v_i[1]]);
885  A[1].set_column(2, vertices[v_i[5]]-vertices[v_i[1]]);
886 
887  A[2].set_column(0, vertices[v_i[3]]-vertices[v_i[2]]);
888  A[2].set_column(1, vertices[v_i[1]]-vertices[v_i[2]]);
889  A[2].set_column(2, vertices[v_i[6]]-vertices[v_i[2]]);
890 
891  A[3].set_column(0, vertices[v_i[0]]-vertices[v_i[3]]);
892  A[3].set_column(1, vertices[v_i[2]]-vertices[v_i[3]]);
893  A[3].set_column(2, vertices[v_i[7]]-vertices[v_i[3]]);
894 
895  A[4].set_column(0, vertices[v_i[7]]-vertices[v_i[4]]);
896  A[4].set_column(1, vertices[v_i[5]]-vertices[v_i[4]]);
897  A[4].set_column(2, vertices[v_i[0]]-vertices[v_i[4]]);
898 
899  A[5].set_column(0, vertices[v_i[4]]-vertices[v_i[5]]);
900  A[5].set_column(1, vertices[v_i[6]]-vertices[v_i[5]]);
901  A[5].set_column(2, vertices[v_i[1]]-vertices[v_i[5]]);
902 
903  A[6].set_column(0, vertices[v_i[5]]-vertices[v_i[6]]);
904  A[6].set_column(1, vertices[v_i[7]]-vertices[v_i[6]]);
905  A[6].set_column(2, vertices[v_i[2]]-vertices[v_i[6]]);
906 
907  A[7].set_column(0, vertices[v_i[6]]-vertices[v_i[7]]);
908  A[7].set_column(1, vertices[v_i[4]]-vertices[v_i[7]]);
909  A[7].set_column(2, vertices[v_i[3]]-vertices[v_i[7]]);
910 
911  break;
912 
913  default:
914  MSQ_SETERR(err)("element type not implemented.", MsqError::NOT_IMPLEMENTED);
915  return;
916  }// end switch over element type
917 }
requested functionality is not (yet) implemented
size_t * vertexIndices
Pointer to connectivity array.
invalid function argument passed
rational * A
Definition: vinci_lass.c:67
NVec< 3, double > Vector3D
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
EntityTopology get_element_type() const
Returns element type.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
void compute_corner_normals(Vector3D normals[], PatchData &pd, MsqError &err)
Uses a MeshDomain call-back function to compute the normal at the corner.
static const double MSQ_3RT_2_OVER_6RT_3
Definition: Mesquite.hpp:130

Here is the call graph for this function:

Here is the caller graph for this function:

void compute_corner_matrices ( PatchData pd,
Matrix3D  A[],
int  num_m3d,
MsqError err 
)

Compute matrices which column are the vectors issued from a corner.

Stores those corner matrices in the mTag data member.

void compute_corner_normals ( Vector3D  normals[],
PatchData pd,
MsqError err 
)

Uses a MeshDomain call-back function to compute the normal at the corner.

Gives the normal at the surface point corner_pt ... but if not available, gives the normalized cross product of corner_vec1 and corner_vec2.

Definition at line 670 of file Mesh/MsqMeshEntity.cpp.

References PatchData::domain_set(), PatchData::get_domain_normals_at_corners(), PatchData::get_element_index(), MsqMeshEntity::get_element_type(), i, MsqError::INVALID_ARG, Vector3D::length(), Mesquite::length(), MSQ_ERRRTN, MSQ_SETERR, Vector3D::normalize(), Mesquite::POLYGON, Mesquite::QUADRILATERAL, Mesquite::TRIANGLE, PatchData::vertex_by_index(), MsqMeshEntity::vertex_count(), and MsqMeshEntity::vertexIndices.

Referenced by MsqMeshEntity::compute_corner_matrices(), I_DFT::compute_element_analytical_gradient(), I_DFT::compute_element_analytical_hessian(), and I_DFT::evaluate_element().

673 {
675  if (type != TRIANGLE && type != QUADRILATERAL && type != POLYGON)
676  {
677  MSQ_SETERR(err)("Should only be used for faces (tri, quads, ...).",
679  return;
680  }
681 
682 
683  // There are two cases where we cannot get a normal from the
684  // geometry that are not errors:
685  // 1) There is no domain set
686  // 2) The vertex is at a degenerate point on the geometry (e.g.
687  // tip of a cone.)
688 
689  // Get normal from domain
690  if (pd.domain_set())
691  {
692  size_t index = pd.get_element_index(this);
693  pd.get_domain_normals_at_corners( index, normals, err );
694  MSQ_ERRRTN(err);
695  }
696 
697  // Check if normals are valid (none are valid if !pd.domain_set())
698  const unsigned count = vertex_count();
699  for (unsigned i = 0; i < count; ++i)
700  {
701  // If got valid normal from domain,
702  // make it a unit vector and continue.
703  if (pd.domain_set())
704  {
705  double length = normals[i].length();
706  if (length > DBL_EPSILON)
707  {
708  normals[i] /= length;
709  continue;
710  }
711  }
712 
713  const size_t prev_idx = vertexIndices[(i + count - 1) % count];
714  const size_t this_idx = vertexIndices[i];
715  const size_t next_idx = vertexIndices[(i + 1) % count];
716 
717  // Calculate normal using edges adjacent to corner
718  normals[i] = (pd.vertex_by_index(next_idx) - pd.vertex_by_index(this_idx))
719  * (pd.vertex_by_index(prev_idx) - pd.vertex_by_index(this_idx));
720  normals[i].normalize();
721  }
722 }
EntityTopology
Definition: Mesquite.hpp:92
size_t * vertexIndices
Pointer to connectivity array.
double length(Vector3D *const v, int n)
invalid function argument passed
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
blockLoc i
Definition: read.cpp:79
EntityTopology get_element_type() const
Returns element type.
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void compute_corner_normals ( Vector3D  normals[],
PatchData pd,
MsqError err 
)

Uses a MeshDomain call-back function to compute the normal at the corner.

double compute_signed_area ( PatchData pd,
MsqError err 
)

Computes the signed area of the element.

double compute_signed_area ( PatchData pd,
MsqError err 
)

Computes the signed area of the element.

Computes the area of the given element. Returned value can be negative. If the entity passed is not a two-dimensional element, an error is set.

Definition at line 419 of file Mesh/MsqMeshEntity.cpp.

References PatchData::get_domain_normal_at_element(), PatchData::get_element_index(), PatchData::get_vertex_array(), MsqError::INVALID_ARG, Vector3D::length(), MSQ_ERRZERO, MSQ_SETERR, MsqMeshEntity::mType, Mesquite::QUADRILATERAL, Mesquite::TRIANGLE, and MsqMeshEntity::vertexIndices.

419  {
420  MsqVertex* verts=pd.get_vertex_array(err);MSQ_ERRZERO(err);
421  double tem=0.0;
422  double tem2=0.0;
423  Vector3D surface_normal;
424  Vector3D cross_vec;
425  size_t element_index=pd.get_element_index(this);
426 
427  switch (mType)
428  {
429 
430  case TRIANGLE:
431  cross_vec=((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
432  (verts[vertexIndices[2]]-verts[vertexIndices[0]]));
433  pd.get_domain_normal_at_element(element_index,surface_normal,err);
434  MSQ_ERRZERO(err);
435  tem = (cross_vec.length()/2.0);
436  //if normals do not point in same general direction, negate area
437  if(cross_vec%surface_normal<0){
438  tem *= -1;
439  }
440 
441  return tem;
442 
443  case QUADRILATERAL:
444  cross_vec=((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
445  (verts[vertexIndices[3]]-verts[vertexIndices[0]]));
446  pd.get_domain_normal_at_element(element_index,surface_normal,err);
447  MSQ_ERRZERO(err);
448  tem = (cross_vec.length()/2.0);
449  //if normals do not point in same general direction, negate area
450  if(cross_vec%surface_normal<0){
451  tem *= -1;
452  }
453  cross_vec=((verts[vertexIndices[3]]-verts[vertexIndices[2]])*
454  (verts[vertexIndices[1]]-verts[vertexIndices[2]]));
455  tem2 = (cross_vec.length()/2.0);
456  //if normals do not point in same general direction, negate area
457  if(cross_vec%surface_normal<0){
458  tem2 *= -1;
459  //test to make sure surface normal existed
460  //if(surface_normal.length_squared()<.5){
461  //err.set_msg("compute_signed_area called without surface_normal available.");
462  //}
463  }
464  return (tem + tem2);
465 
466  default:
467  MSQ_SETERR(err)("Invalid type of element passed to compute unsigned area.",
469  return 0;
470  };
471  return 0.0;
472 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
size_t * vertexIndices
Pointer to connectivity array.
invalid function argument passed
NVec< 3, double > Vector3D
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.

Here is the call graph for this function:

double compute_signed_volume ( PatchData pd,
MsqError err 
)

Computes the signed volume of the element.

Computes the volume of the given element. Returned value can be negative. If the entity passed is not a three-dimensional element, an error is set.

Definition at line 478 of file Mesh/MsqMeshEntity.cpp.

References MsqMeshEntity::compute_weighted_jacobian(), PatchData::get_vertex_array(), Mesquite::HEXAHEDRON, MsqError::INVALID_ARG, MSQ_ERRZERO, MSQ_SETERR, MsqMeshEntity::mType, Mesquite::TETRAHEDRON, and MsqMeshEntity::vertexIndices.

478  {
479  Vector3D sample_point(.5,.5,.5);
480  Vector3D jac_vecs[3];
481  short num_jacobian_vectors=-1;
482  double tem=0;
483  MsqVertex *verts = pd.get_vertex_array(err);MSQ_ERRZERO(err);
484  switch (mType)
485  {
486  case TETRAHEDRON:
487  tem = (verts[vertexIndices[3]]-verts[vertexIndices[0]])%
488  ((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
489  (verts[vertexIndices[2]]-verts[vertexIndices[0]]))/6.0;
490  return tem;
491 
492  case HEXAHEDRON:
493  compute_weighted_jacobian(pd,sample_point,jac_vecs,
494  num_jacobian_vectors, err );
495  MSQ_ERRZERO(err);
496  return (jac_vecs[2]%(jac_vecs[0]*jac_vecs[1]));
497 
498  default:
499  MSQ_SETERR(err)("Invalid type of element passed to compute signed volume.",
501  return 0;
502  };
503  return 0.0;
504 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
size_t * vertexIndices
Pointer to connectivity array.
invalid function argument passed
NVec< 3, double > Vector3D
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void compute_weighted_jacobian(PatchData &pd, Vector3D &sample_point, Vector3D jacobian_vectors[], short &num_jacobian_vectors, MsqError &err)

Here is the call graph for this function:

double compute_signed_volume ( PatchData pd,
MsqError err 
)

Computes the signed volume of the element.

double compute_unsigned_area ( PatchData pd,
MsqError err 
)

Computes the area of the element.

Computes the area of the given element. Returned value is always non-negative. If the entity passed is not a two-dimensional element, an error is set.

The returned value is always non-negative.

Definition at line 357 of file Mesh/MsqMeshEntity.cpp.

References PatchData::get_vertex_array(), MsqError::INVALID_ARG, Mesquite::length(), MSQ_ERRZERO, MSQ_SETERR, MsqMeshEntity::mType, Mesquite::QUADRILATERAL, Mesquite::TRIANGLE, and MsqMeshEntity::vertexIndices.

Referenced by ASMQualityMetric::evaluate_element(), and CornerJacobianQualityMetric::evaluate_element().

357  {
358  MsqVertex* verts=pd.get_vertex_array(err);MSQ_ERRZERO(err);
359  double tem=0.0;
360  switch (mType)
361  {
362 
363  case TRIANGLE:
364  tem = ((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
365  (verts[vertexIndices[2]]-verts[vertexIndices[0]])).length()/2.0;
366  return tem;
367 
368  case QUADRILATERAL:
369  tem = ((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
370  (verts[vertexIndices[3]]-verts[vertexIndices[0]])).length();
371  tem += ((verts[vertexIndices[3]]-verts[vertexIndices[2]])*
372  (verts[vertexIndices[1]]-verts[vertexIndices[2]])).length();
373  return (tem/2.0);
374 
375  default:
376  MSQ_SETERR(err)("Invalid type of element passed to compute unsigned area.",
378  return 0;
379  }
380  return 0;
381 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
size_t * vertexIndices
Pointer to connectivity array.
double length(Vector3D *const v, int n)
invalid function argument passed
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.

Here is the call graph for this function:

Here is the caller graph for this function:

double compute_unsigned_area ( PatchData pd,
MsqError err 
)

Computes the area of the element.

The returned value is always non-negative.

double compute_unsigned_volume ( PatchData pd,
MsqError err 
)

Computes the volume of the element.

Computes the volume of the given element. Returned value is always non-negative. If the entity passed is not a three-dimensional element, an error is set.

The returned value is always non-negative.

Definition at line 387 of file Mesh/MsqMeshEntity.cpp.

References MsqMeshEntity::compute_weighted_jacobian(), PatchData::get_vertex_array(), Mesquite::HEXAHEDRON, MsqError::INVALID_ARG, MSQ_ERRZERO, MSQ_SETERR, MsqMeshEntity::mType, Mesquite::TETRAHEDRON, and MsqMeshEntity::vertexIndices.

Referenced by ASMQualityMetric::evaluate_element(), and CornerJacobianQualityMetric::evaluate_element().

387  {
388  Vector3D sample_point(.5,.5,.5);
389  Vector3D jac_vecs[3];
390  short num_jacobian_vectors=-1;
391  double tem=0;
392  MsqVertex *verts = pd.get_vertex_array(err);MSQ_ERRZERO(err);
393  switch (mType)
394  {
395  case TETRAHEDRON:
396  tem = (verts[vertexIndices[3]]-verts[vertexIndices[0]])%
397  ((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
398  (verts[vertexIndices[1]]-verts[vertexIndices[0]]))/6.0;
399  return fabs(tem);
400 
401  case HEXAHEDRON:
402  compute_weighted_jacobian(pd,sample_point,jac_vecs,
403  num_jacobian_vectors, err ); MSQ_ERRZERO(err);
404  return fabs(jac_vecs[2]%(jac_vecs[0]*jac_vecs[1]));
405 
406  default:
407  MSQ_SETERR(err)("Invalid type of element passed to compute unsigned volume.",
409  return 0;
410  }
411  return 0;
412 }
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
size_t * vertexIndices
Pointer to connectivity array.
invalid function argument passed
NVec< 3, double > Vector3D
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void compute_weighted_jacobian(PatchData &pd, Vector3D &sample_point, Vector3D jacobian_vectors[], short &num_jacobian_vectors, MsqError &err)

Here is the call graph for this function:

Here is the caller graph for this function:

double compute_unsigned_volume ( PatchData pd,
MsqError err 
)

Computes the volume of the element.

The returned value is always non-negative.

void compute_weighted_jacobian ( PatchData pd,
Vector3D sample_point,
Vector3D  jacobian_vectors[],
short &  num_jacobian_vectors,
MsqError err 
)
void compute_weighted_jacobian ( PatchData pd,
Vector3D sample_point,
Vector3D  jacobian_vectors[],
short &  num_jacobian_vectors,
MsqError err 
)

fills array of Vector3D's with the jacobian vectors and the number of jacobian vecotors.

Definition at line 118 of file Mesh/MsqMeshEntity.cpp.

References PatchData::get_vertex_array(), Mesquite::HEXAHEDRON, MSQ_ERRRTN, MSQ_SETERR, Mesquite::MSQ_SQRT_THREE_INV, Mesquite::MSQ_SQRT_TWO_INV, MsqError::NOT_IMPLEMENTED, Mesquite::QUADRILATERAL, Vector3D::set(), Mesquite::TETRAHEDRON, and Mesquite::TRIANGLE.

Referenced by VertexMover::check_feasible(), MsqMeshEntity::compute_signed_volume(), MsqMeshEntity::compute_unsigned_volume(), and GeneralizedConditionNumberQualityMetric::evaluate_element().

123 {
124  // v_v is just an alias for vertexIndices
125  const size_t* v_v = &vertexIndices[0];
126 
127  // vector<size_t> v_v;
128  // get_vertex_indices(v_v);
129  MsqVertex *vertices=pd.get_vertex_array(err); MSQ_ERRRTN(err);
130  switch (mType)
131  {
132  //Note:: For the linear tri case we do not use sample pt.
133  case TRIANGLE:
134  jacobian_vectors[0].set(vertices[v_v[1]]-vertices[v_v[0]]);
135  jacobian_vectors[1].set((2.0*vertices[v_v[2]]-vertices[v_v[0]]-
136  vertices[v_v[1]])*MSQ_SQRT_THREE_INV);
137  num_jacobian_vectors=2;
138  break;
139 
140  case QUADRILATERAL:
141  jacobian_vectors[0]=(vertices[v_v[1]]-vertices[v_v[0]]+sample_point[1]*
142  (vertices[v_v[2]]+vertices[v_v[0]]-vertices[v_v[3]]-
143  vertices[v_v[1]]));
144  jacobian_vectors[1]=(vertices[v_v[3]]-vertices[v_v[0]]+sample_point[0]*
145  (vertices[v_v[2]]+vertices[v_v[0]]-vertices[v_v[3]]-
146  vertices[v_v[1]]));
147  num_jacobian_vectors=2;
148  break;
149 
150  case TETRAHEDRON:
151  jacobian_vectors[0]=vertices[v_v[1]]-vertices[v_v[0]];
152  jacobian_vectors[1]=(2.0*vertices[v_v[2]]-vertices[v_v[0]]-
153  vertices[v_v[1]])*MSQ_SQRT_THREE_INV;
154  jacobian_vectors[2]=(3.0*vertices[v_v[3]]-vertices[v_v[2]]-
155  vertices[v_v[1]]-vertices[v_v[0]])*
156  MSQ_SQRT_TWO_INV*MSQ_SQRT_THREE_INV;
157  num_jacobian_vectors=3;
158  break;
159 
160  case HEXAHEDRON:
161 
162  jacobian_vectors[0]=vertices[v_v[1]]-vertices[v_v[0]]+
163  (sample_point[1]*(vertices[v_v[2]]+vertices[v_v[0]]-
164  vertices[v_v[3]]-vertices[v_v[1]]))+
165  (sample_point[2]*(vertices[v_v[5]]+vertices[v_v[0]]-
166  vertices[v_v[4]]-vertices[v_v[1]]))+
167  (sample_point[1]*sample_point[2]*(vertices[v_v[6]]+
168  vertices[v_v[4]]+
169  vertices[v_v[3]]+
170  vertices[v_v[1]]-
171  vertices[v_v[7]]-
172  vertices[v_v[5]]-
173  vertices[v_v[2]]-
174  vertices[v_v[0]])),
175  jacobian_vectors[1]=vertices[v_v[3]]-vertices[v_v[0]]+
176  (sample_point[0]*(vertices[v_v[2]]+vertices[v_v[0]]-
177  vertices[v_v[3]]-vertices[v_v[1]]))+
178  (sample_point[2]*(vertices[v_v[7]]+vertices[v_v[0]]-
179  vertices[v_v[4]]-vertices[v_v[3]]))+
180  (sample_point[0]*sample_point[2]*(vertices[v_v[6]]+
181  vertices[v_v[4]]+
182  vertices[v_v[3]]+
183  vertices[v_v[1]]-
184  vertices[v_v[7]]-
185  vertices[v_v[5]]-
186  vertices[v_v[2]]-
187  vertices[v_v[0]]));
188 
189  jacobian_vectors[2]=vertices[v_v[4]]-vertices[v_v[0]]+
190  (sample_point[0]*(vertices[v_v[5]]+vertices[v_v[0]]-
191  vertices[v_v[4]]-vertices[v_v[1]]))+
192  (sample_point[1]*(vertices[v_v[7]]+vertices[v_v[0]]-
193  vertices[v_v[4]]-vertices[v_v[3]]))+
194  (sample_point[0]*sample_point[1]*(vertices[v_v[6]]+
195  vertices[v_v[4]]+
196  vertices[v_v[3]]+
197  vertices[v_v[1]]-
198  vertices[v_v[7]]-
199  vertices[v_v[5]]-
200  vertices[v_v[2]]-
201  vertices[v_v[0]]));
202 
203  num_jacobian_vectors=3;
204  break;
205 
206  default:
207  MSQ_SETERR(err)(
208  "Compute_weighted_jacobian not yet defined for this entity.",
210  }
211 
212 }
requested functionality is not (yet) implemented
size_t * vertexIndices
Pointer to connectivity array.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
static const double MSQ_SQRT_TWO_INV
Definition: Mesquite.hpp:126
static const double MSQ_SQRT_THREE_INV
Definition: Mesquite.hpp:125
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

Here is the caller graph for this function:

void get_centroid ( Vector3D centroid,
const PatchData pd,
MsqError err 
) const

Returns the centroid of the element.

void get_centroid ( Vector3D centroid,
const PatchData pd,
MsqError err 
) const

Returns the centroid of the element.

The centroid of an element containing n vertices with equal masses is located at

\[ \b{x} = \frac{ \sum_{i=1}^{n} \b{x}_i }{ n } \]

where $ \b{x}_i ,\, i=1,...,n$ are the vertices coordinates.

Definition at line 106 of file Mesh/MsqMeshEntity.cpp.

References PatchData::get_vertex_array(), i, MSQ_ERRRTN, MsqMeshEntity::vertex_count(), and MsqMeshEntity::vertexIndices.

107 {
108  const MsqVertex* vtces = pd.get_vertex_array(err); MSQ_ERRRTN(err);
109  size_t nve = vertex_count();
110  for (size_t i=0; i<nve; ++i)
111  centroid += vtces[vertexIndices[i]];
112  centroid /= nve;
113 }
size_t * vertexIndices
Pointer to connectivity array.
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.
blockLoc i
Definition: read.cpp:79
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.

Here is the call graph for this function:

void get_connected_vertices ( msq_stdc::size_t  vertex_index,
msq_std::vector< msq_stdc::size_t > &  vert_indices,
MsqError err 
)

Fills a vector<size_t> with vertices connected to the given vertex through the edges of this MsqMeshEntity.

void get_connected_vertices ( msq_stdc::size_t  vertex_index,
msq_std::vector< msq_stdc::size_t > &  vert_indices,
MsqError err 
)

Fills a vector<size_t> with vertices connected to the given vertex through the edges of this MsqMeshEntity.

Referenced by VertexConditionNumberQualityMetric::evaluate_vertex(), and LocalSizeQualityMetric::evaluate_vertex().

Here is the caller graph for this function:

EntityTopology get_element_type ( ) const
inline

Returns element type.

Definition at line 78 of file src/Mesh/MsqMeshEntity.hpp.

References MsqMeshEntity::mType.

79  { return mType; }
void get_linear_quad_jac ( Vector3D sp,
Vector3D coord0,
Vector3D coord1,
Vector3D coord2,
Vector3D coord3,
Vector3D jac 
)
inlinestaticprivate

Definition at line 211 of file includeLinks/MsqMeshEntity.hpp.

217  {
218  jac[0]=coord1-coord0+(*sp)[1]*(coord2+coord0-coord3-coord1);
219  jac[1]=coord3-coord0+(*sp)[0]*(coord2+coord0-coord3-coord1);
220  }
static void get_linear_quad_jac ( Vector3D sp,
Vector3D coord0,
Vector3D coord1,
Vector3D coord2,
Vector3D coord3,
Vector3D jac 
)
staticprivate
void get_node_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const

gets the vertices of the mesh entity

void get_node_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const

gets the vertices of the mesh entity

void get_sample_points ( QualityMetric::ElementEvaluationMode  mode,
msq_std::vector< Vector3D > &  coords,
MsqError err 
)

Returns a list of sample points given an evaluationmode.

void get_sample_points ( QualityMetric::ElementEvaluationMode  mode,
msq_std::vector< Vector3D > &  coords,
MsqError err 
)

Returns a list of sample points given an evaluationmode.

Referenced by VertexMover::check_feasible(), and GeneralizedConditionNumberQualityMetric::evaluate_element().

Here is the caller graph for this function:

msq_stdc::size_t get_vertex_index ( msq_stdc::size_t  vertex_in_element) const
msq_stdc::size_t get_vertex_index ( msq_stdc::size_t  vertex_in_element) const
inline

Definition at line 203 of file includeLinks/MsqMeshEntity.hpp.

References MsqMeshEntity::vertex_count(), and MsqMeshEntity::vertexIndices.

Referenced by GeneralizedConditionNumberQualityMetric::compute_condition_number(), PatchData::get_subpatch(), and NonSmoothSteepestDescent::validity_check().

204  {
205  // Make sure we're in range
206  assert(vertex_in_element < vertex_count());
207  // Return the index
208  return vertexIndices[vertex_in_element];
209  }
size_t * vertexIndices
Pointer to connectivity array.
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.

Here is the call graph for this function:

Here is the caller graph for this function:

const msq_stdc::size_t* get_vertex_index_array ( ) const
inline

Very efficient retrieval of vertices indexes (corresponding to the PatchData vertex array).

msq_stdc::size_t* get_vertex_index_array ( )
inline
msq_stdc::size_t * get_vertex_index_array ( )
inline

Definition at line 199 of file includeLinks/MsqMeshEntity.hpp.

References MsqMeshEntity::vertexIndices.

200  { return vertexIndices; }
size_t * vertexIndices
Pointer to connectivity array.
void get_vertex_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const

gets the vertices of the mesh entity

void get_vertex_indices ( msq_std::vector< msq_stdc::size_t > &  vertex_list) const
msq_stdc::size_t node_count ( ) const
inline

Return number of nodes in element (number of corner vertices + number of higher-order nodes).

Definition at line 86 of file src/Mesh/MsqMeshEntity.hpp.

References MsqMeshEntity::numVertexIndices.

msq_stdc::size_t node_count ( ) const
inline

Return number of nodes in element (number of corner vertices + number of higher-order nodes).

Definition at line 86 of file includeLinks/MsqMeshEntity.hpp.

References MsqMeshEntity::numVertexIndices.

Referenced by PatchData::get_subpatch(), PatchData::initialize_data(), MeanMidNodeMover::loop_over_mesh(), and MsqMeshEntity::vertex_count().

Here is the caller graph for this function:

void set_connectivity ( msq_stdc::size_t *  indices,
size_t  num_vertices 
)
inline

Set connectivity data (vertex array) for element.

MsqMeshEntity keeps the pointer to the passed array, it does not copy it. The caller is still responsible for releasing the memory for the passed index array after the MsqMeshEntity is destroyed. The intention is that this is a pointer to a portion of a larger connectivity array managed by the owning PatchData.

Definition at line 189 of file includeLinks/MsqMeshEntity.hpp.

References MsqMeshEntity::numVertexIndices, and MsqMeshEntity::vertexIndices.

191  {
192  vertexIndices = indices;
193  numVertexIndices = num_vertices;
194  }
size_t * vertexIndices
Pointer to connectivity array.
void set_connectivity ( msq_stdc::size_t *  indices,
size_t  num_vertices 
)

Set connectivity data (vertex array) for element.

MsqMeshEntity keeps the pointer to the passed array, it does not copy it. The caller is still responsible for releasing the memory for the passed index array after the MsqMeshEntity is destroyed. The intention is that this is a pointer to a portion of a larger connectivity array managed by the owning PatchData.

void set_element_type ( EntityTopology  type)
inline

Sets element data.

Definition at line 101 of file src/Mesh/MsqMeshEntity.hpp.

References MsqMeshEntity::mType.

102  { mType = type; }
void set_element_type ( EntityTopology  type)
inline

Sets element data.

Definition at line 101 of file includeLinks/MsqMeshEntity.hpp.

References MsqMeshEntity::mType.

102  { mType = type; }
size_t vertex_count ( ) const
inline

Returns the number of vertices in this element, based on its element type.

Definition at line 185 of file includeLinks/MsqMeshEntity.hpp.

References TopologyInfo::corners(), MsqMeshEntity::mType, MsqMeshEntity::node_count(), Mesquite::POLYGON, and Mesquite::POLYHEDRON.

Referenced by MsqHessian::accumulate_entries(), LPtoPTemplate::compute_analytical_gradient(), LPtoPTemplate::compute_analytical_hessian(), MsqMeshEntity::compute_corner_normals(), RI_DFT::compute_element_analytical_gradient(), I_DFT::compute_element_analytical_gradient(), RI_DFT::compute_element_analytical_hessian(), I_DFT::compute_element_analytical_hessian(), QualityMetric::compute_element_numerical_hessian(), TargetCalculator::compute_guide_matrices(), WTargetCalculator::compute_target_matrices(), LVQDTargetCalculator::compute_target_matrices(), TargetCalculator::compute_target_matrices_and_check_det(), sI_DFT::evaluate_element(), sRI_DFT::evaluate_element(), RI_DFT::evaluate_element(), I_DFT::evaluate_element(), MsqMeshEntity::get_centroid(), PatchData::get_domain_normals_at_corners(), MsqMeshEntity::get_vertex_index(), MsqHessian::initialize(), PatchData::initialize_data(), CornerTagHandles::num_corners(), Mesquite::operator<<(), and CornerTagHandles::save_load_tags().

186  { return mType == POLYGON || mType == POLYHEDRON ?
187  node_count() : TopologyInfo::corners( mType ); }
msq_stdc::size_t node_count() const
Return number of nodes in element (number of corner vertices + number of higher-order nodes)...

Here is the call graph for this function:

Here is the caller graph for this function:

msq_stdc::size_t vertex_count ( ) const
inline

Returns the number of vertices in this element, based on its element type.

Friends And Related Function Documentation

msq_stdio::ostream& operator<< ( msq_stdio::ostream &  stream,
const MsqMeshEntity entity 
)
friend
msq_stdio::ostream& operator<< ( msq_stdio::ostream &  stream,
const MsqMeshEntity entity 
)
friend

Member Data Documentation

size_t numVertexIndices
private

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