本文整理汇总了C++中PatchData::get_domain_normal_at_element方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::get_domain_normal_at_element方法的具体用法?C++ PatchData::get_domain_normal_at_element怎么用?C++ PatchData::get_domain_normal_at_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchData
的用法示例。
在下文中一共展示了PatchData::get_domain_normal_at_element方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_get_element_normals_infinite_domain
void PatchDataTestNormals::test_get_element_normals_infinite_domain()
{
MsqPrintError err(cout);
Vector3D expected_normals[] = { Vector3D( 0, 0, -1),
Vector3D( 0, 0, 1),
Vector3D( 1, 0, 0),
Vector3D( 0, 1, 0),
Vector3D( -1, 0, 0),
Vector3D( 0, -1, 0) };
CPPUNIT_ASSERT( unboundedMesh.num_elements() == 6u );
for (size_t i = 0; i < 6u; ++i)
{
Vector3D norm;
unboundedMesh.get_domain_normal_at_element( i, norm, err );
CPPUNIT_ASSERT(!err);
ASSERT_VECTORS_EQUAL( expected_normals[i], norm );
}
}
示例2:
static inline void untangle_function_2d( double beta,
const Vector3D temp_vec[],
size_t e_ind,
PatchData &pd,
double &fval,
MsqError &err)
{
Vector3D surface_normal;
pd.get_domain_normal_at_element(e_ind,surface_normal,err); MSQ_ERRRTN(err);
Vector3D cross_vec=temp_vec[0]*temp_vec[1];
//cout<<"\nsurface_normal "<<surface_normal;
//cout<<"\cross_vec "<<cross_vec;
double temp_var=cross_vec.length();
if(cross_vec%surface_normal<0.0){
temp_var*=-1;
}
temp_var -= beta;
//cout<<"temp_var == "<<temp_var;
fval=0.0;
if(temp_var<0.0){
fval=fabs(temp_var)-temp_var;
}
// cout<<"\nfval == "<<fval<<" e_ind "<<e_ind;
}
示例3: evaluate
bool IdealWeightMeanRatio::evaluate( PatchData& pd,
size_t handle,
double& m,
MsqError& err )
{
const MsqMeshEntity* e = &pd.element_by_index(handle);
EntityTopology topo = e->get_element_type();
const MsqVertex *vertices = pd.get_vertex_array(err);
const size_t *v_i = e->get_vertex_index_array();
Vector3D n; // Surface normal for 2D objects
// Prism and Hex element descriptions
static const int locs_pri[6][4] = {{0, 1, 2, 3}, {1, 2, 0, 4},
{2, 0, 1, 5}, {3, 5, 4, 0},
{4, 3, 5, 1}, {5, 4, 3, 2}};
static const int locs_hex[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5},
{2, 3, 1, 6}, {3, 0, 2, 7},
{4, 7, 5, 0}, {5, 4, 6, 1},
{6, 5, 7, 2}, {7, 6, 4, 3}};
const Vector3D d_con(1.0, 1.0, 1.0);
int i;
m = 0.0;
bool metric_valid = false;
switch(topo) {
case TRIANGLE:
pd.get_domain_normal_at_element(e, n, err); MSQ_ERRZERO(err);
n = n / n.length(); // Need unit normal
mCoords[0] = vertices[v_i[0]];
mCoords[1] = vertices[v_i[1]];
mCoords[2] = vertices[v_i[2]];
metric_valid = m_fcn_2e(m, mCoords, n, a2Con, b2Con, c2Con);
if (!metric_valid) return false;
break;
case QUADRILATERAL:
pd.get_domain_normal_at_element(e, n, err); MSQ_ERRZERO(err);
for (i = 0; i < 4; ++i) {
n = n / n.length(); // Need unit normal
mCoords[0] = vertices[v_i[locs_hex[i][0]]];
mCoords[1] = vertices[v_i[locs_hex[i][1]]];
mCoords[2] = vertices[v_i[locs_hex[i][2]]];
metric_valid = m_fcn_2i(mMetrics[i], mCoords, n,
a2Con, b2Con, c2Con, d_con);
if (!metric_valid) return false;
}
m = average_metrics(mMetrics, 4, err); MSQ_ERRZERO(err);
break;
case TETRAHEDRON:
mCoords[0] = vertices[v_i[0]];
mCoords[1] = vertices[v_i[1]];
mCoords[2] = vertices[v_i[2]];
mCoords[3] = vertices[v_i[3]];
metric_valid = m_fcn_3e(m, mCoords, a3Con, b3Con, c3Con);
if (!metric_valid) return false;
break;
case PYRAMID:
for (i = 0; i < 4; ++i) {
mCoords[0] = vertices[v_i[ i ]];
mCoords[1] = vertices[v_i[(i+1)%4]];
mCoords[2] = vertices[v_i[(i+3)%4]];
mCoords[3] = vertices[v_i[ 4 ]];
metric_valid = m_fcn_3p(mMetrics[i], mCoords, a3Con, b3Con, c3Con);
if (!metric_valid) return false;
}
m = average_metrics(mMetrics, 4, err); MSQ_ERRZERO(err);
break;
case PRISM:
for (i = 0; i < 6; ++i) {
mCoords[0] = vertices[v_i[locs_pri[i][0]]];
mCoords[1] = vertices[v_i[locs_pri[i][1]]];
mCoords[2] = vertices[v_i[locs_pri[i][2]]];
mCoords[3] = vertices[v_i[locs_pri[i][3]]];
metric_valid = m_fcn_3w(mMetrics[i], mCoords, a3Con, b3Con, c3Con);
if (!metric_valid) return false;
}
m = average_metrics(mMetrics, 6, err); MSQ_ERRZERO(err);
break;
case HEXAHEDRON:
for (i = 0; i < 8; ++i) {
mCoords[0] = vertices[v_i[locs_hex[i][0]]];
mCoords[1] = vertices[v_i[locs_hex[i][1]]];
mCoords[2] = vertices[v_i[locs_hex[i][2]]];
mCoords[3] = vertices[v_i[locs_hex[i][3]]];
metric_valid = m_fcn_3i(mMetrics[i], mCoords,
a3Con, b3Con, c3Con, d_con);
if (!metric_valid) return false;
}
m = average_metrics(mMetrics, 8, err); MSQ_ERRZERO(err);
break;
default:
//.........这里部分代码省略.........
示例4: evaluate_with_Hessian
bool IdealWeightMeanRatio::evaluate_with_Hessian( PatchData& pd,
size_t handle,
double& m,
std::vector<size_t>& indices,
std::vector<Vector3D>& g,
std::vector<Matrix3D>& h,
MsqError& err )
{
// FUNCTION_TIMER_START(__FUNC__);
const MsqMeshEntity* e = &pd.element_by_index(handle);
EntityTopology topo = e->get_element_type();
if (!analytical_average_hessian() &&
topo != TRIANGLE &&
topo != TETRAHEDRON) {
static bool print = true;
if (print) {
MSQ_DBGOUT(1) << "Analyical gradient not available for selected averaging scheme. "
<< "Using (possibly much slower) numerical approximation of gradient"
<< " of quality metric. " << std::endl;
print = false;
}
return QualityMetric::evaluate_with_Hessian( pd, handle, m, indices, g, h, err );
}
const MsqVertex *vertices = pd.get_vertex_array(err);
const size_t *v_i = e->get_vertex_index_array();
Vector3D n; // Surface normal for 2D objects
// Prism and Hex element descriptions
static const int locs_pri[6][4] = {{0, 1, 2, 3}, {1, 2, 0, 4},
{2, 0, 1, 5}, {3, 5, 4, 0},
{4, 3, 5, 1}, {5, 4, 3, 2}};
static const int locs_hex[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5},
{2, 3, 1, 6}, {3, 0, 2, 7},
{4, 7, 5, 0}, {5, 4, 6, 1},
{6, 5, 7, 2}, {7, 6, 4, 3}};
const Vector3D d_con(1.0, 1.0, 1.0);
int i;
bool metric_valid = false;
const uint32_t fm = fixed_vertex_bitmap( pd, e, indices );
m = 0.0;
switch(topo) {
case TRIANGLE:
pd.get_domain_normal_at_element(e, n, err); MSQ_ERRZERO(err);
n = n / n.length(); // Need unit normal
mCoords[0] = vertices[v_i[0]];
mCoords[1] = vertices[v_i[1]];
mCoords[2] = vertices[v_i[2]];
g.resize(3), h.resize(6);
if (!h_fcn_2e(m, arrptr(g), arrptr(h), mCoords, n, a2Con, b2Con, c2Con)) return false;
break;
case QUADRILATERAL:
pd.get_domain_normal_at_element(e, n, err); MSQ_ERRZERO(err);
n = n / n.length(); // Need unit normal
for (i = 0; i < 4; ++i) {
mCoords[0] = vertices[v_i[locs_hex[i][0]]];
mCoords[1] = vertices[v_i[locs_hex[i][1]]];
mCoords[2] = vertices[v_i[locs_hex[i][2]]];
if (!h_fcn_2i(mMetrics[i], mGradients+3*i, mHessians+6*i, mCoords, n,
a2Con, b2Con, c2Con, d_con)) return false;
}
g.resize(4), h.resize(10);
m = average_corner_hessians( QUADRILATERAL, fm, 4,
mMetrics, mGradients, mHessians,
arrptr(g), arrptr(h), err );
MSQ_ERRZERO( err );
break;
case TETRAHEDRON:
mCoords[0] = vertices[v_i[0]];
mCoords[1] = vertices[v_i[1]];
mCoords[2] = vertices[v_i[2]];
mCoords[3] = vertices[v_i[3]];
g.resize(4), h.resize(10);
metric_valid = h_fcn_3e(m, arrptr(g), arrptr(h), mCoords, a3Con, b3Con, c3Con);
if (!metric_valid) return false;
break;
case PYRAMID:
for (i = 0; i < 4; ++i) {
mCoords[0] = vertices[v_i[ i ]];
mCoords[1] = vertices[v_i[(i+1)%4]];
mCoords[2] = vertices[v_i[(i+3)%4]];
mCoords[3] = vertices[v_i[ 4 ]];
metric_valid = h_fcn_3p(mMetrics[i], mGradients+4*i,
mHessians+10*i, mCoords, a3Con, b3Con, c3Con);
if (!metric_valid) return false;
}
g.resize(5), h.resize(15);
//.........这里部分代码省略.........