本文整理汇总了C++中PatchData::get_vertex_element_adjacencies方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::get_vertex_element_adjacencies方法的具体用法?C++ PatchData::get_vertex_element_adjacencies怎么用?C++ PatchData::get_vertex_element_adjacencies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchData
的用法示例。
在下文中一共展示了PatchData::get_vertex_element_adjacencies方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_vertex_evaluate
void PMeanPMetricTest::test_vertex_evaluate()
{
MsqError err;
FauxMetric m;
VertexPMeanP m1( 1.0, &m );
VertexPMeanP m2( 2.0, &m );
// evaluate average around vertex
double v1, v2;
m1.evaluate( pd, 0, v1, err );
CPPUNIT_ASSERT(!err);
m2.evaluate( pd, 0, v2, err );
CPPUNIT_ASSERT(!err);
// get elements adjacent to vertex
size_t num_elem;
const size_t* elems = pd.get_vertex_element_adjacencies( 0, num_elem, err );
CPPUNIT_ASSERT(!err);
// calculate expected values from underyling metric
double ev1 = 0.0, ev2 = 0.0;
for (unsigned i = 0; i < num_elem; ++i) {
const MsqMeshEntity& elem = pd.element_by_index( elems[i] );
const size_t* verts = elem.get_vertex_index_array();
const size_t* end = verts + elem.node_count();
const size_t* p = std::find( verts, end, (size_t)0 );
CPPUNIT_ASSERT( p < end );
size_t h = ElemSampleQM::handle( Sample(0,p - verts), elems[i] );
double v;
m.evaluate( pd, h, v, err );
CPPUNIT_ASSERT(!err);
ev1 += v;
ev2 += v*v;
}
ev1 /= num_elem;
ev2 /= num_elem;
CPPUNIT_ASSERT_DOUBLES_EQUAL( ev1, v1, 1e-6 );
CPPUNIT_ASSERT_DOUBLES_EQUAL( ev2, v2, 1e-6 );
}
示例2: evaluate_with_indices
bool VertexConditionNumberQualityMetric::evaluate_with_indices(
PatchData& pd,
size_t this_vert,
double& value,
std::vector<size_t>& indices,
MsqError& err )
{
bool rval = evaluate( pd, this_vert, value, err ); MSQ_ERRFALSE(err);
indices.clear();
MsqMeshEntity* elems = pd.get_element_array(err);
size_t num_elems;
const size_t *v_to_e_array = pd.get_vertex_element_adjacencies( this_vert, num_elems, err );
MSQ_ERRZERO(err);
//vector to hold the other verts which form a corner.
vector<size_t> other_vertices;
other_vertices.reserve(4);
size_t i=0;
//loop over the elements attached to this vertex
for(i=0;i<num_elems;++i){
//get the vertices connected to this vertex for this element
elems[v_to_e_array[i]].get_connected_vertices(this_vert,
other_vertices,
err); MSQ_ERRZERO(err);
for (unsigned j = 0; j < other_vertices.size(); ++j) {
if (other_vertices[j] < pd.num_free_vertices())
indices.push_back(other_vertices[j]);
}
}
std::sort( indices.begin(), indices.end() );
indices.erase( std::unique( indices.begin(), indices.end() ), indices.end() );
if (this_vert < pd.num_free_vertices())
indices.push_back( this_vert );
return rval;
}
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:39,代码来源:Mesquite_VertexConditionNumberQualityMetric.cpp
示例3: evaluate
/*!For the given vertex, vert, with connected elements, e_i for i=1...K,
the LocalSizeQualityMetric computes the corner volumes (or areas) of
each e_i at the corner defined by vert. The corner volume is defined
as the volume of the tet defined by the edges of an element which contain
the common vertex, vert. That volume is then diveded by the average corner
volume of all the element corners connected to this vertex. For
vertices attached to pyramid elements, this metric is undefined.
*/
bool LocalSizeQualityMetric::evaluate( PatchData &pd, size_t this_vert,
double &fval, MsqError &err )
{
fval=0.0;
//get the element array
MsqMeshEntity* elems = pd.get_element_array(err); MSQ_ERRZERO(err);
//get the vertex to element array and the offset array
//const size_t* elem_offset = pd.get_vertex_to_elem_offset(err); MSQ_ERRZERO(err);
//const size_t* v_to_e_array = pd.get_vertex_to_elem_array(err); MSQ_ERRZERO(err);
//find the offset for this vertex
//size_t this_offset = elem_offset[this_vert];
//get the number of elements attached to this vertex (given by the
//first entry in the vertex to element array)
//size_t num_elems = v_to_e_array[this_offset];
//PRINT_INFO("\nIN LOCAL SIZE CPP, num_elements = %i",num_elems);
size_t num_elems;
const size_t *v_to_e_array = pd.get_vertex_element_adjacencies( this_vert, num_elems, err );
MSQ_ERRZERO(err);
if(num_elems <= 0){
return true;
}
//create an array to store the local metric values before averaging
//Can we remove this dynamic allocatio?
double* met_vals = new double[num_elems];
//vector to hold the other verts which form a corner.
std::vector<size_t> other_vertices;
other_vertices.reserve(4);
double total_val=0.0;
size_t i=0;
//loop over the elements attached to this vertex
for(i=0;i<num_elems;++i){
//get the vertices which (with this_vert) form the corner of
//the ith element.
elems[v_to_e_array[i]].get_connected_vertices(this_vert,
other_vertices,
err); MSQ_ERRZERO(err);
////PRINT_INFO("\nINSIDE LOCAL SIZE CPP other_vertices size = %i",other_vertices.size());
switch(other_vertices.size()){
//if a surface element, compute the corner area
case 2:
met_vals[i] = compute_corner_area(pd, this_vert, other_vertices[0],
other_vertices[1], err); MSQ_ERRZERO(err);
break;
//if a volume element, compute the corner volume
case 3:
met_vals[i] = compute_corner_volume(pd, this_vert, other_vertices[0],
other_vertices[1],
other_vertices[2], err); MSQ_ERRZERO(err);
break;
default:
//otherwise, there is was an error. Either the wrong number
//of vertices were returned fom get_connected_vertices or
//the element does not have the correct number of edges
//connected to this vertex (possibly a pyramid element).
met_vals[i]=0.0;
MSQ_SETERR(err)("Incorrect number of vertices returned from "
"get_connected_vertices.", MsqError::UNSUPPORTED_ELEMENT);
return false;
};
//keep track of total so that we can compute the linear average
total_val+=met_vals[i];
//PRINT_INFO("\nIN LOCAL SIZE CPP, total_val = %f, i = %i",total_val,i);
//clear the vector of other_vertices for re-use.
other_vertices.clear();
//PRINT_INFO("\nIN LOCAL SIZE CPP, after clean size = %f",other_vertices.size());
}
//calculate the linear average... num_elems is non-zero here.
total_val /= (double) num_elems;
//PRINT_INFO("\nIN LOCAL SIZE CPP, average = %f",total_val);
//if the average is non-zero
//divide each entry by the linear average
if(total_val!=0){
for(i=0;i<num_elems;++i){
met_vals[i]/=total_val;
}
//calculate fval by averaging the corner values
fval = average_metrics(met_vals, num_elems, err); MSQ_ERRZERO(err);
//PRINT_INFO("\nIN LOCAL SIZE CPP, inside if statement");
}
//PRINT_INFO("\nIN LOCAL SIZE CPP, fval = %f",fval);
//clean up the dynamically allocated array
delete []met_vals;
//always return true... the vertex position is never invalid
return true;
}
示例4: get_edge_evaluations
void EdgeQM::get_edge_evaluations( PatchData& pd,
std::vector<size_t>& handles,
bool free_vertices_only,
bool single_pass_evaluate,
MsqError& err )
{
std::vector<EdgeData> vtx_edges;
size_t n_verts = free_vertices_only ? pd.num_free_vertices() : pd.num_nodes();
size_t n_cutoff = single_pass_evaluate ? pd.num_nodes() : n_verts;
handles.clear();
for (size_t i = 0; i < n_verts; ++i) {
if (!pd.vertex_by_index(i).is_flag_set( MsqVertex::MSQ_PATCH_VTX ))
continue;
vtx_edges.clear();
size_t n_elems;
const size_t* elems;
elems = pd.get_vertex_element_adjacencies( i, n_elems, err );
MSQ_ERRRTN(err);
for (size_t j = 0; j < n_elems; ++j) {
MsqMeshEntity& elem = pd.element_by_index(elems[j]);
unsigned n_edges = TopologyInfo::edges( elem.get_element_type() );
for (unsigned k = 0; k < n_edges; ++k) {
const unsigned* edge = TopologyInfo::edge_vertices( elem.get_element_type(), k, err );
MSQ_ERRRTN(err);
size_t vtx1 = elem.get_vertex_index_array()[edge[0]];
size_t vtx2 = elem.get_vertex_index_array()[edge[1]];
size_t other;
if (vtx1 == i)
other = vtx2;
else if (vtx2 == i)
other = vtx1;
else
continue;
// If !free_vertices_only, we'll visit every edge twice.
// The first check below ensures that we only add each edge
// once. The second check is never true unless free_vertices_only
// is true and single_pass_evaluate is false. In that case, it
// serves as an exception to the first rule for those cases in which
// we visit an edge only once. For single_pass_evaluate (e.g.
// BCD initialization or QualityAssessor) we want to avoid visiting
// and edge more than once for every patch rather than just within
// this patch.
if (other > i || other > n_cutoff) {
EdgeData d = { other, elems[j], k };
vtx_edges.push_back(d);
}
} // end for each edge in element
} // end for each element adjacent to vertex
std::sort( vtx_edges.begin(), vtx_edges.end() );
std::vector<EdgeData>::iterator it, end;
end = std::unique( vtx_edges.begin(), vtx_edges.end() );
for (it = vtx_edges.begin(); it != end; ++it)
handles.push_back( handle( it->elemEdge, it->adjElem ) );
} // end for each (free) vertex
}
示例5: evaluate
bool VertexConditionNumberQualityMetric::evaluate( PatchData& pd,
size_t this_vert,
double& fval,
MsqError& err )
{
//pd.generate_vertex_to_element_data();
bool return_flag;
fval=MSQ_MAX_CAP;
//get the element array
MsqMeshEntity* elems = pd.get_element_array(err);
//get the vertex to element array and the offset array
//const size_t* elem_offset = pd.get_vertex_to_elem_offset(err); MSQ_ERRZERO(err);
//const size_t* v_to_e_array = pd.get_vertex_to_elem_array(err); MSQ_ERRZERO(err);
//find the offset for this vertex
//size_t this_offset = elem_offset[this_vert];
//get the number of elements attached to this vertex (given by the
//first entry in the vertex to element array)
//size_t num_elems = v_to_e_array[this_offset];
//PRINT_INFO("\nIN LOCAL SIZE CPP, num_elements = %i",num_elems);
//if no elements, then return true
size_t num_elems;
const size_t *v_to_e_array = pd.get_vertex_element_adjacencies( this_vert, num_elems, err );
MSQ_ERRZERO(err);
if(num_elems <= 0){
return true;
}
//create an array to store the local metric values before averaging
//Can we remove this dynamic allocatio?
std::vector<double> met_vals(num_elems);
//vector to hold the other verts which form a corner.
vector<size_t> other_vertices;
other_vertices.reserve(4);
size_t i=0;
//only 3 temp_vec will be sent to cond-num calculator, but the
//additional vector3Ds may be needed during the calculations
size_t elem_index;
Vector3D temp_vec[6];
const MsqVertex *vertices=pd.get_vertex_array(err);
//loop over the elements attached to this vertex
for(i=0;i<num_elems;++i){
//get the vertices connected to this vertex for this element
elem_index = v_to_e_array[i];
elems[elem_index].get_connected_vertices(this_vert,
other_vertices,
err); MSQ_ERRZERO(err);
//switch over the element type of this element
switch(elems[v_to_e_array[i]].get_element_type()){
case TRIANGLE:
temp_vec[0]=vertices[other_vertices[0]]-vertices[this_vert];
temp_vec[2]=vertices[other_vertices[1]]-vertices[this_vert];
//make relative to equilateral
temp_vec[1]=((2*temp_vec[2])-temp_vec[0])*MSQ_SQRT_THREE_INV;
return_flag=condition_number_2d(temp_vec,elem_index,pd,met_vals[i],err); MSQ_ERRZERO(err);
if(!return_flag)
return return_flag;
break;
case QUADRILATERAL:
temp_vec[0]=vertices[other_vertices[0]]-vertices[this_vert];
temp_vec[1]=vertices[other_vertices[1]]-vertices[this_vert];
return_flag=condition_number_2d(temp_vec,elem_index,pd,met_vals[i],err); MSQ_ERRZERO(err);
if(!return_flag)
return return_flag;
break;
case TETRAHEDRON:
temp_vec[0]=vertices[other_vertices[0]]-vertices[this_vert];
temp_vec[3]=vertices[other_vertices[1]]-vertices[this_vert];
temp_vec[4]=vertices[other_vertices[2]]-vertices[this_vert];
//transform to equilateral tet
temp_vec[1]=((2*temp_vec[3])-temp_vec[0])/MSQ_SQRT_THREE;
temp_vec[2]=((3*temp_vec[4])-temp_vec[0]-temp_vec[3])/
(MSQ_SQRT_THREE*MSQ_SQRT_TWO);
return_flag=condition_number_3d(temp_vec,pd,met_vals[i],err); MSQ_ERRZERO(err);
if(!return_flag)
return return_flag;
break;
case HEXAHEDRON:
temp_vec[0]=vertices[other_vertices[0]]-vertices[this_vert];
temp_vec[1]=vertices[other_vertices[1]]-vertices[this_vert];
temp_vec[2]=vertices[other_vertices[2]]-vertices[this_vert];
return_flag=condition_number_3d(temp_vec,pd,met_vals[i],err); MSQ_ERRZERO(err);
if(!return_flag)
return return_flag;
break;
default:
MSQ_SETERR(err)(MsqError::UNSUPPORTED_ELEMENT,
"Element type (%d) not uspported in VertexConditionNumberQM.\n",
(int)(elems[v_to_e_array[i]].get_element_type()));
fval=MSQ_MAX_CAP;
return false;
}// end switch over element type
other_vertices.clear();
}//end loop over elements
fval = average_metrics(arrptr(met_vals), num_elems, err); MSQ_ERRZERO(err);
return true;
}
开发者ID:bartlettroscoe,项目名称:trilinos_old_public,代码行数:99,代码来源:Mesquite_VertexConditionNumberQualityMetric.cpp