本文整理汇总了C++中stk::mesh::BulkData::declare_relation方法的典型用法代码示例。如果您正苦于以下问题:C++ BulkData::declare_relation方法的具体用法?C++ BulkData::declare_relation怎么用?C++ BulkData::declare_relation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stk::mesh::BulkData
的用法示例。
在下文中一共展示了BulkData::declare_relation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
stk::mesh::Entity declare_element_to_sub_topology_with_nodes(stk::mesh::BulkData &mesh, stk::mesh::Entity elem, stk::mesh::EntityVector &sub_topology_nodes,
stk::mesh::EntityId global_sub_topology_id, stk::mesh::EntityRank to_rank, stk::mesh::Part &part)
{
std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation = get_ordinal_and_permutation(mesh, elem, to_rank, sub_topology_nodes);
if ((ordinalAndPermutation.first == stk::mesh::ConnectivityOrdinal::INVALID_CONNECTIVITY_ORDINAL)
|| (ordinalAndPermutation.second == stk::mesh::Permutation::INVALID_PERMUTATION))
{
stk::mesh::Entity invalid;
invalid = stk::mesh::Entity::InvalidEntity;
return invalid;
}
stk::mesh::Entity side = mesh.declare_entity(to_rank, global_sub_topology_id, part);
for (unsigned i=0;i<sub_topology_nodes.size();++i)
{
mesh.declare_relation(side, sub_topology_nodes[i], i);
}
mesh.declare_relation(elem, side, ordinalAndPermutation.first, ordinalAndPermutation.second);
return side;
}
示例2: mesh
//.........这里部分代码省略.........
node[0] = create_node( node_parts, node_id_base, iz , ir , ia_1 );
node[1] = create_node( node_parts, node_id_base, iz_1, ir , ia_1 );
node[2] = create_node( node_parts, node_id_base, iz_1, ir , ia );
node[3] = create_node( node_parts, node_id_base, iz , ir , ia );
node[4] = create_node( node_parts, node_id_base, iz , ir_1, ia_1 );
node[5] = create_node( node_parts, node_id_base, iz_1, ir_1, ia_1 );
node[6] = create_node( node_parts, node_id_base, iz_1, ir_1, ia );
node[7] = create_node( node_parts, node_id_base, iz , ir_1, ia );
#if 0 /* VERIFY_CENTROID */
// Centroid of the element for verification
const double TWO_PI = 2.0 * acos( -1.0 );
const double angle = m_ang_inc * (0.5 + ia);
const double z = m_center[2] + m_z_min + m_z_inc * (0.5 + iz);
double c[3] = { 0 , 0 , 0 };
for ( size_t j = 0 ; j < 8 ; ++j ) {
double * const coord_data = field_data( m_model_coord , *node[j] );
c[0] += coord_data[0] ;
c[1] += coord_data[1] ;
c[2] += coord_data[2] ;
}
c[0] /= 8 ; c[1] /= 8 ; c[2] /= 8 ;
c[0] -= m_center[0] ;
c[1] -= m_center[1] ;
double val_a = atan2( c[1] , c[0] );
if ( val_a < 0 ) { val_a += TWO_PI ; }
const double err_a = angle - val_a ;
const double err_z = z - c[2] ;
const double eps = 100 * std::numeric_limits<double>::epsilon();
if ( err_z < - eps || eps < err_z ||
err_a < - eps || eps < err_a ) {
std::string msg ;
msg.append("problem setup element centroid error" );
throw std::logic_error( msg );
}
#endif
stk::mesh::Entity elem =
M.declare_entity( element_rank, elem_id, elem_parts );
for ( size_t j = 0 ; j < 8 ; ++j ) {
M.declare_relation( elem , node[j] ,
static_cast<unsigned>(j) );
}
}
}
}
}
// Array of faces on the surface
{
const size_t ir = m_rad_num - 1 ;
for ( size_t ia = 0 ; ia < m_angle_num ; ++ia ) {
for ( size_t iz = 0 ; iz < m_z_num - 1 ; ++iz ) {
stk::mesh::EntityId elem_id_gear =
identifier( m_z_num-1 , m_rad_num-1 , iz , ir-1 , ia );
if ( ( ( elem_id_gear * p_size ) / elem_id_gear_max ) == p_rank ) {
stk::mesh::EntityId elem_id = elem_id_base + elem_id_gear ;
unsigned face_ord = 5 ;
stk::mesh::EntityId face_id = elem_id * 10 + face_ord + 1;
stk::mesh::Entity node[4] ;
const size_t ia_1 = ( ia + 1 ) % m_angle_num ;
const size_t iz_1 = iz + 1 ;
node[0] = create_node( node_parts, node_id_base, iz , ir , ia_1 );
node[1] = create_node( node_parts, node_id_base, iz_1, ir , ia_1 );
node[2] = create_node( node_parts, node_id_base, iz_1, ir , ia );
node[3] = create_node( node_parts, node_id_base, iz , ir , ia );
stk::mesh::Entity face =
M.declare_entity( side_rank, face_id, face_parts );
for ( size_t j = 0 ; j < 4 ; ++j ) {
M.declare_relation( face , node[j] ,
static_cast<unsigned>(j) );
}
stk::mesh::Entity elem = M.get_entity(element_rank, elem_id);
M.declare_relation( elem , face , face_ord );
}
}
}
}
M.modification_begin();
}
示例3: verify_unbuildable_element
void verify_unbuildable_element(stk::mesh::BulkData &bulk,
const stk::topology topo,
const stk::mesh::EntityIdVector & elem_node_ids,
const stk::mesh::EntityIdVector & side_ids,
const std::vector < std::vector < unsigned > > &gold_side_node_ids,
bool *sides_connectibility_check,
const stk::mesh::EntityIdVector & edge_ids,
const std::vector < std::vector < unsigned > > &gold_edge_node_ids,
bool *edges_connectibility_check)
{
stk::mesh::EntityId element_id[1] = {1};
stk::mesh::MetaData &meta = bulk.mesh_meta_data();
stk::mesh::Part &elem_part = meta.declare_part_with_topology("elem_part", topo);
meta.commit();
bulk.modification_begin();
stk::mesh::Entity elem = stk::mesh::declare_element(bulk, elem_part, element_id[0], elem_node_ids);
stk::mesh::EntityVector side_nodes;
uint num_sides = topo.num_sides();
stk::topology::rank_t sub_topo_rank = topo.side_rank();
for(uint i = 0; i < num_sides; ++i)
{
stk::topology sub_topo = topo.side_topology(i);
side_nodes.clear();
stk::mesh::Entity side = bulk.declare_entity(sub_topo_rank, side_ids[i], meta.get_topology_root_part(sub_topo));
for (uint j = 0; j < sub_topo.num_nodes(); ++j)
{
stk::mesh::Entity side_node = bulk.get_entity(stk::topology::NODE_RANK, gold_side_node_ids[i][j]);
side_nodes.push_back(side_node);
bulk.declare_relation(side, side_node, j);
}
std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation
= stk::mesh::get_ordinal_and_permutation(bulk, elem, sub_topo_rank, side_nodes);
if (sides_connectibility_check[i])
{
EXPECT_NE(ordinalAndPermutation.first, stk::mesh::ConnectivityOrdinal::INVALID_CONNECTIVITY_ORDINAL);
EXPECT_NE(ordinalAndPermutation.second, stk::mesh::Permutation::INVALID_PERMUTATION);
}
else
{
EXPECT_EQ(ordinalAndPermutation.first, stk::mesh::ConnectivityOrdinal::INVALID_CONNECTIVITY_ORDINAL);
EXPECT_EQ(ordinalAndPermutation.second, stk::mesh::Permutation::INVALID_PERMUTATION);
}
}
if (edge_ids.empty()) {
bulk.modification_end();
return;
}
stk::mesh::EntityVector edge_nodes;
uint num_edges = topo.num_edges();
for(uint i = 0; i < num_edges; ++i)
{
edge_nodes.clear();
stk::mesh::Entity edge = bulk.declare_entity(stk::topology::EDGE_RANK, edge_ids[i],
meta.get_topology_root_part(topo.edge_topology()));
for (uint j = 0; j < topo.edge_topology().num_nodes(); ++j)
{
stk::mesh::Entity edge_node = bulk.get_entity(stk::topology::NODE_RANK, gold_edge_node_ids[i][j]);
edge_nodes.push_back(edge_node);
bulk.declare_relation(edge, edge_node, j);
}
std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation
= stk::mesh::get_ordinal_and_permutation(bulk, elem, stk::topology::EDGE_RANK, edge_nodes);
if (edges_connectibility_check[i])
{
EXPECT_NE(ordinalAndPermutation.first, stk::mesh::ConnectivityOrdinal::INVALID_CONNECTIVITY_ORDINAL);
EXPECT_NE(ordinalAndPermutation.second, stk::mesh::Permutation::INVALID_PERMUTATION);
}
else
{
EXPECT_EQ(ordinalAndPermutation.first, stk::mesh::ConnectivityOrdinal::INVALID_CONNECTIVITY_ORDINAL);
EXPECT_EQ(ordinalAndPermutation.second, stk::mesh::Permutation::INVALID_PERMUTATION);
}
}
bulk.modification_end();
}
示例4: build_element_from_topology_verify_ordinals_and_permutations
void build_element_from_topology_verify_ordinals_and_permutations(stk::mesh::BulkData &bulk,
const stk::topology topo,
const stk::mesh::EntityIdVector & elem_node_ids,
const stk::mesh::EntityIdVector & edge_ids,
const std::vector < std::vector < unsigned > > &gold_side_node_ids,
const unsigned * gold_side_permutations,
const std::vector < std::vector < unsigned > > &gold_edge_node_ids,
const unsigned * gold_edge_permutations)
{
stk::mesh::EntityId element_id[1] = {1};
stk::mesh::MetaData &meta = bulk.mesh_meta_data();
stk::mesh::Part &elem_part = meta.declare_part_with_topology("elem_part", topo);
meta.commit();
bulk.modification_begin();
stk::mesh::Entity elem = stk::mesh::declare_element(bulk, elem_part, element_id[0], elem_node_ids);
stk::mesh::EntityVector side_nodes;
uint num_sides = topo.num_sides();
stk::topology::rank_t sub_topo_rank = topo.side_rank();
for(uint i = 0; i < num_sides; ++i)
{
stk::topology sub_topo = topo.side_topology(i);
bulk.declare_element_side(elem, i, {&meta.get_topology_root_part(sub_topo)});
side_nodes.clear();
for (uint j = 0; j < sub_topo.num_nodes(); ++j)
{
stk::mesh::Entity side_node = bulk.get_entity(stk::topology::NODE_RANK, gold_side_node_ids[i][j]);
side_nodes.push_back(side_node);
}
stk::mesh::OrdinalAndPermutation ordinalAndPermutation = stk::mesh::get_ordinal_and_permutation(bulk, elem, sub_topo_rank, side_nodes);
EXPECT_EQ(ordinalAndPermutation.second, gold_side_permutations[i]) << topo;
EXPECT_EQ(ordinalAndPermutation.first, i) << topo;
}
if (edge_ids.empty()) {
bulk.modification_end();
return;
}
stk::mesh::EntityVector edge_nodes;
uint num_edges = topo.num_edges();
for(uint i = 0; i < num_edges; ++i)
{
edge_nodes.clear();
stk::mesh::Entity edge = bulk.declare_entity(stk::topology::EDGE_RANK, edge_ids[i],
meta.get_topology_root_part(topo.edge_topology()));
for (uint j = 0; j < topo.edge_topology().num_nodes(); ++j)
{
stk::mesh::Entity edge_node = bulk.get_entity(stk::topology::NODE_RANK, gold_edge_node_ids[i][j]);
edge_nodes.push_back(edge_node);
bulk.declare_relation(edge, edge_node, j);
}
std::pair<stk::mesh::ConnectivityOrdinal, stk::mesh::Permutation> ordinalAndPermutation
= stk::mesh::get_ordinal_and_permutation(bulk, elem, stk::topology::EDGE_RANK, edge_nodes);
EXPECT_EQ(ordinalAndPermutation.second, gold_edge_permutations[i]) << topo;
EXPECT_EQ(ordinalAndPermutation.first, i) << topo;
}
bulk.modification_end();
}