本文整理汇总了C++中stk::mesh::BulkData::parallel_rank方法的典型用法代码示例。如果您正苦于以下问题:C++ BulkData::parallel_rank方法的具体用法?C++ BulkData::parallel_rank怎么用?C++ BulkData::parallel_rank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stk::mesh::BulkData
的用法示例。
在下文中一共展示了BulkData::parallel_rank方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupKeyholeMesh2D_case2
inline
void setupKeyholeMesh2D_case2(stk::mesh::BulkData& bulk)
{
//
// proc 0 proc 1
// |
// | block_2 block_3
// |
// block_1 | 12---11
// | | 4 |
// 4----3 | 3----6 6----10
// | 1 | | | 2 |
// 1----2 | 2----5 5----9
// | | 3 |
// | 7----8
// |
//
//nodes 5 and 6 are ghosts (aura) on proc 0,
//and should be members of block_2 and block_3 on proc 0
//if edges are added, the edge between nodes 5 and 6 should
//be a member of block_2 not block_3.
//
stk::mesh::MetaData& meta = bulk.mesh_meta_data();
stk::mesh::Part& block_1 = meta.declare_part_with_topology("block_1", stk::topology::QUAD_4_2D);
stk::mesh::Part& block_2 = meta.declare_part_with_topology("block_2", stk::topology::QUAD_4_2D);
stk::mesh::Part& block_3 = meta.declare_part_with_topology("block_3", stk::topology::QUAD_4_2D);
meta.commit();
bulk.modification_begin();
stk::mesh::EntityIdVector elem1_nodes {1, 2, 3, 4};
stk::mesh::EntityIdVector elem2_nodes {2, 5, 6, 3};
stk::mesh::EntityIdVector elem3_nodes {7, 8, 9, 5};
stk::mesh::EntityIdVector elem4_nodes {6, 10, 11, 12};
stk::mesh::EntityId elemId = 1;
if (bulk.parallel_rank() == 0) {
stk::mesh::declare_element(bulk, block_1, elemId, elem1_nodes);
stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
stk::mesh::Entity node3 = bulk.get_entity(stk::topology::NODE_RANK, 3);
bulk.add_node_sharing(node2, 1);
bulk.add_node_sharing(node3, 1);
}
else if (bulk.parallel_rank() == 1) {
elemId = 2;
stk::mesh::declare_element(bulk, block_2, elemId, elem2_nodes);
elemId = 3;
stk::mesh::declare_element(bulk, block_3, elemId, elem3_nodes);
elemId = 4;
stk::mesh::declare_element(bulk, block_3, elemId, elem4_nodes);
stk::mesh::Entity node2 = bulk.get_entity(stk::topology::NODE_RANK, 2);
stk::mesh::Entity node3 = bulk.get_entity(stk::topology::NODE_RANK, 3);
bulk.add_node_sharing(node2, 0);
bulk.add_node_sharing(node3, 0);
}
bulk.modification_end();
}
示例2: createBoundingBoxesForElementsInElementBlocks
inline void createBoundingBoxesForElementsInElementBlocks(const stk::mesh::BulkData &bulk, FlaotBoxVector& domainBoxes)
{
stk::mesh::EntityVector elements;
stk::mesh::get_selected_entities(bulk.mesh_meta_data().locally_owned_part(), bulk.buckets(stk::topology::ELEM_RANK), elements);
size_t numberBoundingBoxes = elements.size();
domainBoxes.resize(numberBoundingBoxes);
stk::mesh::FieldBase const * coords = bulk.mesh_meta_data().coordinate_field();
std::vector<double> boxCoordinates(6);
for(size_t i=0;i<elements.size();++i)
{
unsigned num_nodes = bulk.num_nodes(elements[i]);
std::vector<double> coordinates(3*num_nodes,0);
const stk::mesh::Entity* nodes = bulk.begin_nodes(elements[i]);
for(unsigned j=0;j<num_nodes;++j)
{
double* data = static_cast<double*>(stk::mesh::field_data(*coords, nodes[j]));
coordinates[3*j] = data[0];
coordinates[3*j+1] = data[1];
coordinates[3*j+2] = data[2];
}
findBoundingBoxCoordinates(coordinates, boxCoordinates);
unsigned id = bulk.identifier(elements[i]);
Ident domainBoxId(id, bulk.parallel_rank());
domainBoxes[i] = std::make_pair(FloatBox(boxCoordinates[0], boxCoordinates[1], boxCoordinates[2],
boxCoordinates[3], boxCoordinates[4], boxCoordinates[5]),
domainBoxId);
}
}
示例3: setupKeyholeMesh3D_case2
inline
void setupKeyholeMesh3D_case2(stk::mesh::BulkData& bulk)
{
ThrowRequire(bulk.parallel_size() == 3);
stk::io::fill_mesh("generated:3x1x3", bulk);
stk::mesh::EntityProcVec elementProcChanges;
if (bulk.parallel_rank() == 1) {
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,4),2));
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,6),2));
}
bulk.change_entity_owner(elementProcChanges);
bulk.modification_begin();
if (bulk.parallel_rank() == 1) {
stk::mesh::Entity local_element5 = bulk.get_entity(stk::topology::ELEM_RANK,5);
const bool delete_success = bulk.destroy_entity(local_element5);
ThrowRequire(delete_success);
}
bulk.modification_end();
}
示例4: print_entity_proc_map
void print_entity_proc_map( stk::diag::Writer & writer ,
const stk::mesh::BulkData & mesh )
{
const stk::mesh::MetaData & meta = mesh.mesh_meta_data();
const std::vector<stk::mesh::Entity*> & comm = mesh.entity_comm();
const std::vector<stk::mesh::Ghosting*> & ghost = mesh.ghostings();
size_t counter = 0 ;
for ( size_t ig = 0 ; ig < ghost.size() ; ++ig ) {
const stk::mesh::Ghosting & g = * ghost[ig] ;
writer << "P" << mesh.parallel_rank()
<< " " << g.name() << " Communication:" << std::endl ;
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = comm.begin() ; i != comm.end() ; ++i ) {
const stk::mesh::Entity & entity = **i ;
std::vector<unsigned> procs ;
stk::mesh::comm_procs( g , entity , procs );
if ( ! procs.empty() ) {
writer << "[" << counter << "] "
<< meta.entity_rank_name( entity.entity_rank() )
<< "[" << entity.identifier() << " " ;
if ( entity.owner_rank() != mesh.parallel_rank() ) {
writer << "not_" ;
}
writer << "owned ] {" ;
for ( size_t j = 0 ; j < procs.size() ; ++j ) {
writer << " " << procs[j] ;
}
writer << " }" << std::endl ;
}
}
}
}
示例5: get_non_unique_key_messages
std::string get_non_unique_key_messages(const stk::mesh::BulkData& bulkData, const std::vector<stk::mesh::EntityKeyProc> &badKeyProcs)
{
std::ostringstream os;
for(const stk::mesh::EntityKeyProc& keyProc : badKeyProcs)
{
stk::mesh::Entity entity = bulkData.get_entity(keyProc.first);
os << "[" << bulkData.parallel_rank() << "] Key " << keyProc.first <<
get_topology(bulkData.bucket(entity).topology()) << "is also present (inappropriately) on processor " <<
keyProc.second << "." << std::endl;
}
return os.str();
}
示例6: setupKeyholeMesh3D_case1
// element ids / proc_id:
// |-------|-------|-------|
// | | | |
// | 1/0 | 4/2 | 7/2 |
// | | | |
// |-------|-------|-------|
// | | | |
// | 2/0 | 5/1 | 8/2 |
// | | | |
// |-------|-------|-------|
// | | | |
// | 3/0 | 6/2 | 9/2 |
// | | | |
// |-------|-------|-------|
inline
void setupKeyholeMesh3D_case1(stk::mesh::BulkData& bulk)
{
ThrowRequire(bulk.parallel_size() == 3);
stk::io::fill_mesh("generated:3x1x3", bulk);
stk::mesh::EntityProcVec elementProcChanges;
if (bulk.parallel_rank() == 1) {
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,4u),2));
elementProcChanges.push_back(stk::mesh::EntityProc(bulk.get_entity(stk::topology::ELEM_RANK,6u),2));
}
bulk.change_entity_owner(elementProcChanges);
}
示例7: add_nodes_to_move
inline void add_nodes_to_move(stk::mesh::BulkData& bulk,
stk::mesh::Entity elem,
int dest_proc,
std::vector<stk::mesh::EntityProc>& entities_to_move)
{
const stk::mesh::Entity* nodes = bulk.begin_nodes(elem);
for(unsigned i = 0; i < bulk.num_nodes(elem); ++i)
{
if(bulk.parallel_owner_rank(nodes[i]) == bulk.parallel_rank())
{
entities_to_move.push_back(stk::mesh::EntityProc(nodes[i], dest_proc));
}
}
}
示例8: get_message_for_split_coincident_elements
std::string get_message_for_split_coincident_elements(const stk::mesh::BulkData& bulkData, const std::map<stk::mesh::EntityId, std::pair<stk::mesh::EntityId, int> > & splitCoincidentElements)
{
std::ostringstream out;
for(const auto& item : splitCoincidentElements) {
stk::mesh::Entity element = bulkData.get_entity(stk::topology::ELEM_RANK,item.first);
const stk::mesh::PartVector& elementParts = bulkData.bucket(element).supersets();
std::string blockNames;
blockNames = "{";
for (const stk::mesh::Part* part : elementParts) {
if (stk::mesh::impl::is_element_block(*part)) {
blockNames += " " + part->name();
}
}
blockNames += " }";
out << "[" << bulkData.parallel_rank() << "] Element " << item.first << " (" << bulkData.bucket(element).topology() << ") in blocks " << blockNames << " is coincident with element " << item.second.first << " on processor " << item.second.second << std::endl;
}
return out.str();
}
示例9: key
std::vector<stk::mesh::EntityKeyProc> get_non_unique_keys(const stk::mesh::BulkData& bulkData, const stk::parallel::DistributedIndex& distributedIndex,
const stk::parallel::DistributedIndex::KeyTypeVector& localKeys)
{
stk::parallel::DistributedIndex::KeyProcVector sharedKeyProcs;
distributedIndex.query_to_usage(localKeys, sharedKeyProcs);
std::vector<stk::mesh::EntityKeyProc> badKeys;
for (const stk::parallel::DistributedIndex::KeyProc& sharedKeyProc : sharedKeyProcs)
{
stk::mesh::EntityKey key( static_cast<stk::mesh::EntityKey::entity_key_t>(sharedKeyProc.first) );
if ( bulkData.parallel_rank() != sharedKeyProc.second )
{
if(!bulkData.in_shared(key, sharedKeyProc.second))
badKeys.push_back({key, sharedKeyProc.second});
}
}
return badKeys;
}
示例10: fill_sharing_data
void fill_sharing_data(stk::mesh::BulkData& bulkData, stk::mesh::ElemElemGraph &graph, const stk::mesh::EntityVector& sidesThatNeedFixing, std::vector<SideSharingData>& sideSharingDataThisProc, std::vector<stk::mesh::impl::IdViaSidePair>& idAndSides)
{
// Element 1, side 5: face 15
// Element 2, side 3: face 23
// Are these faces the same? Yes: delete face 23, then connect face 15 to element 2 with negative permutation
const stk::mesh::PartOrdinal sharedOrd = bulkData.mesh_meta_data().globally_shared_part().mesh_meta_data_ordinal();
for(size_t i=0;i<sidesThatNeedFixing.size();++i)
{
stk::mesh::impl::ElementViaSidePair elementAndSide = get_element_and_side_ordinal(bulkData, sidesThatNeedFixing[i]);
stk::mesh::impl::LocalId localElemId = graph.get_local_element_id(elementAndSide.element);
for(const stk::mesh::GraphEdge& edge : graph.get_edges_for_element(localElemId))
{
if(edge.side1() == elementAndSide.side && edge.elem2() < 0)
{
const stk::mesh::impl::ParallelInfo &pInfo = graph.get_parallel_info_for_graph_edge(edge);
const stk::mesh::Entity* nodes = bulkData.begin_nodes(sidesThatNeedFixing[i]);
unsigned numNodes = bulkData.num_nodes(sidesThatNeedFixing[i]);
SideSharingData localTemp({bulkData.identifier(elementAndSide.element), elementAndSide.side},
sidesThatNeedFixing[i],
pInfo.get_proc_rank_of_neighbor(),
std::min(bulkData.parallel_rank(),pInfo.get_proc_rank_of_neighbor()),
bulkData.identifier(sidesThatNeedFixing[i]));
localTemp.sideNodes.resize(numNodes);
for(unsigned j=0; j<numNodes; ++j) {
localTemp.sideNodes[j] = bulkData.identifier(nodes[j]);
}
fill_part_ordinals_besides_owned_and_shared(bulkData.bucket(sidesThatNeedFixing[i]), sharedOrd, localTemp.partOrdinals);
sideSharingDataThisProc.push_back(localTemp);
stk::mesh::EntityId localId = -edge.elem2();
idAndSides.push_back({localId, edge.side2()});
}
}
}
}
示例11: make_small_hybrid_mesh
void make_small_hybrid_mesh(stk::mesh::MetaData &meta, stk::mesh::BulkData &mesh,
bool user_attempt_no_induce = false, bool user_parts_force_no_induce = true)
{
stk::ParallelMachine pm = MPI_COMM_WORLD;
int p_size = stk::parallel_machine_size(pm);
if(p_size > 2)
{
return;
}
const unsigned p_rank = mesh.parallel_rank();
stk::mesh::Part * hexPart = &meta.get_topology_root_part(stk::topology::HEX_8);
stk::mesh::Part * pyrPart = &meta.get_topology_root_part(stk::topology::PYRAMID_5);
stk::mesh::Part * tetPart = &meta.get_topology_root_part(stk::topology::TET_4);
if (user_attempt_no_induce)
{
hexPart = &meta.declare_part_with_topology("my_hex_part",stk::topology::HEX_8, user_parts_force_no_induce);
pyrPart = &meta.declare_part_with_topology("my_pyr_part",stk::topology::PYRAMID_5, user_parts_force_no_induce);
tetPart = &meta.declare_part_with_topology("my_tet_part",stk::topology::TET_4, user_parts_force_no_induce);
EXPECT_EQ(user_parts_force_no_induce, hexPart->force_no_induce());
EXPECT_EQ(user_parts_force_no_induce, pyrPart->force_no_induce());
EXPECT_EQ(user_parts_force_no_induce, tetPart->force_no_induce());
}
meta.commit();
const size_t numHex = 1;
stk::mesh::EntityIdVector hexNodeIDs[] {
{ 1, 2, 3, 4, 5, 6, 7, 8 }
};
stk::mesh::EntityId hexElemIDs[] = { 1 };
const size_t numPyr = 1;
stk::mesh::EntityIdVector pyrNodeIDs[] {
{ 5, 6, 7, 8, 9 }
};
stk::mesh::EntityId pyrElemIDs[] = { 2 };
const size_t numTet = 4;
stk::mesh::EntityIdVector tetNodeIDs[] {
{ 7, 8, 9, 12 },
{ 6, 9, 10, 7 },
{ 7, 9, 10, 12 },
{ 7, 12, 10, 11 }
};
stk::mesh::EntityId tetElemIDs[] = { 3, 4, 5, 6 };
// list of triplets: (owner-proc, shared-nodeID, sharing-proc)
std::vector< std::vector<unsigned> > shared_nodeIDs_and_procs
{
{ 0, 5, 1 }, // proc 0
{ 0, 6, 1 },
{ 0, 7, 1 },
{ 0, 8, 1 },
{ 1, 5, 0 }, // proc 1
{ 1, 6, 0 },
{ 1, 7, 0 },
{ 1, 8, 0 }
};
mesh.modification_begin();
if (0 == p_rank) {
for (size_t i = 0; i < numHex; ++i) {
stk::mesh::declare_element(mesh, *hexPart, hexElemIDs[i], hexNodeIDs[i]);
}
}
if ( (1 == p_rank) || (1 == p_size) ) { // setup the pyramids/tets for either np 2 or serial
for (size_t i = 0; i < numPyr; ++i) {
stk::mesh::declare_element(mesh, *pyrPart, pyrElemIDs[i], pyrNodeIDs[i]);
}
for (size_t i = 0; i < numTet; ++i) {
stk::mesh::declare_element(mesh, *tetPart, tetElemIDs[i], tetNodeIDs[i]);
}
}
if (p_size > 1)
{
for (size_t nodeIdx = 0, end = shared_nodeIDs_and_procs.size(); nodeIdx < end; ++nodeIdx) {
if (p_rank == shared_nodeIDs_and_procs[nodeIdx][0]) {
stk::mesh::EntityId nodeID = shared_nodeIDs_and_procs[nodeIdx][1];
int sharingProc = shared_nodeIDs_and_procs[nodeIdx][2];
stk::mesh::Entity node = mesh.get_entity(stk::topology::NODE_RANK, nodeID);
mesh.add_node_sharing(node, sharingProc);
}
}
}
mesh.modification_end();
}
示例12: fixup_ghosted_to_shared_nodes
void fixup_ghosted_to_shared_nodes(stk::mesh::BulkData & bulk)
{
stk::mesh::EntityVector ghosted_nodes_that_are_now_shared;
find_ghosted_nodes_that_need_to_be_shared(bulk, ghosted_nodes_that_are_now_shared);
stk::CommSparse comm(bulk.parallel());
for (int phase=0;phase<2;++phase)
{
for (size_t i = 0; i < ghosted_nodes_that_are_now_shared.size(); ++i)
{
stk::mesh::Entity node = ghosted_nodes_that_are_now_shared[i];
int proc = bulk.parallel_owner_rank(node);
comm.send_buffer(proc).pack<stk::mesh::EntityKey>(bulk.entity_key(node));
}
if (phase == 0 )
{
comm.allocate_buffers();
}
else
{
comm.communicate();
}
}
stk::mesh::EntityVector sharedNodes;
for (int process=0;process<bulk.parallel_size();++process)
{
while(comm.recv_buffer(process).remaining())
{
stk::mesh::EntityKey key;
comm.recv_buffer(process).unpack<stk::mesh::EntityKey>(key);
stk::mesh::Entity entity = bulk.get_entity(key);
if ( bulk.state(entity) != stk::mesh::Deleted && bulk.is_valid(entity) )
{
bulk.add_node_sharing(entity, process);
sharedNodes.push_back(entity);
}
}
}
/////////////////////////
stk::CommSparse commSecondStage(bulk.parallel());
for (int phase=0;phase<2;++phase)
{
for (size_t i=0;i<sharedNodes.size();++i)
{
std::vector<int> procs;
stk::mesh::EntityKey key = bulk.entity_key(sharedNodes[i]);
bulk.comm_shared_procs(key, procs);
for (size_t j=0;j<procs.size();++j)
{
if ( procs[j] != bulk.parallel_rank() )
{
commSecondStage.send_buffer(procs[j]).pack<int>(bulk.parallel_rank()).pack<stk::mesh::EntityKey>(key);
for (size_t k=0;k<procs.size();++k)
{
commSecondStage.send_buffer(procs[j]).pack<int>(procs[k]).pack<stk::mesh::EntityKey>(key);
}
}
}
}
if (phase == 0 )
{
commSecondStage.allocate_buffers();
}
else
{
commSecondStage.communicate();
}
}
for (int proc_that_sent_message=0;proc_that_sent_message<bulk.parallel_size();++proc_that_sent_message)
{
if ( proc_that_sent_message == bulk.parallel_rank() ) continue;
while(commSecondStage.recv_buffer(proc_that_sent_message).remaining())
{
stk::mesh::EntityKey key;
int sharingProc;
commSecondStage.recv_buffer(proc_that_sent_message).unpack<int>(sharingProc).unpack<stk::mesh::EntityKey>(key);
if ( sharingProc != bulk.parallel_rank() )
{
stk::mesh::Entity entity = bulk.get_entity(key);
if ( bulk.state(entity) != stk::mesh::Deleted && bulk.is_valid(entity) && !bulk.in_shared(key, sharingProc) )
{
bulk.add_node_sharing(entity, sharingProc);
}
}
}
}
}
示例13: setup2Block2HexMesh
inline
void setup2Block2HexMesh(stk::mesh::BulkData& bulk)
{
//
// proc 0 proc 1
// |
// block_1 | block_2
// |
// 8----7 | 7----12
// / /| | / / |
// 5----6 3 | 6----11 10
// | 1 |/ | | 2 | /
// 1----2 | 2----9
// |
// |
// |
//
//shared nodes 2, 3, 6, 7
//
if (bulk.parallel_size() > 2) {
return;
}
stk::mesh::MetaData& meta = bulk.mesh_meta_data();
stk::topology hex = stk::topology::HEX_8;
stk::mesh::Part& block_1 = meta.declare_part_with_topology("block_1", hex);
stk::mesh::Part& block_2 = meta.declare_part_with_topology("block_2", hex);
meta.commit();
bulk.modification_begin();
stk::mesh::EntityIdVector elem1_nodes {1, 2, 3, 4, 5, 6, 7, 8};
stk::mesh::EntityIdVector elem2_nodes {2, 9, 10, 3, 6, 11, 12, 7};
stk::mesh::EntityId elemId = 1;
if (bulk.parallel_rank() == 0) {
stk::mesh::declare_element(bulk, block_1, elemId, elem1_nodes);
}
if (bulk.parallel_rank() == 1 || bulk.parallel_size() == 1) {
elemId = 2;
stk::mesh::declare_element(bulk, block_2, elemId, elem2_nodes);
}
if(bulk.parallel_rank() == 0 && bulk.parallel_size() == 2)
{
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 2), 1);
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 3), 1);
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 6), 1);
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 7), 1);
}
if(bulk.parallel_rank() == 1 && bulk.parallel_size() == 2)
{
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 2), 0);
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 3), 0);
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 6), 0);
bulk.add_node_sharing(bulk.get_entity(stk::topology::NODE_RANK , 7), 0);
}
bulk.modification_end();
}
示例14: communicate_field_data
void communicate_field_data( const stk::mesh::BulkData & mesh ,
const std::vector< const stk::mesh::FieldBase * > & fields )
{
if ( fields.empty() ) { return; }
const unsigned parallel_size = mesh.parallel_size();
const unsigned parallel_rank = mesh.parallel_rank();
// Sizing for send and receive
const unsigned zero = 0 ;
std::vector<unsigned> send_size( parallel_size , zero );
std::vector<unsigned> recv_size( parallel_size , zero );
std::vector<unsigned> procs ;
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = mesh.entity_comm().begin() ;
i != mesh.entity_comm().end() ; ++i ) {
stk::mesh::Entity & e = **i ;
unsigned size = 0 ;
for ( std::vector<const stk::mesh::FieldBase *>::const_iterator
fi = fields.begin() ; fi != fields.end() ; ++fi ) {
const stk::mesh::FieldBase & f = **fi ;
size += stk::mesh::field_data_size( f , e );
}
if ( size ) {
if ( e.owner_rank() == parallel_rank ) {
// owner sends
stk::mesh::comm_procs( e , procs );
for ( std::vector<unsigned>::iterator
ip = procs.begin() ; ip != procs.end() ; ++ip ) {
send_size[ *ip ] += size ;
}
}
else {
// non-owner receives
recv_size[ e.owner_rank() ] += size ;
}
}
}
// Allocate send and receive buffers:
stk::CommAll sparse ;
{
const unsigned * const s_size = & send_size[0] ;
const unsigned * const r_size = & recv_size[0] ;
sparse.allocate_buffers( mesh.parallel(), parallel_size / 4 , s_size, r_size);
}
// Send packing:
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = mesh.entity_comm().begin() ;
i != mesh.entity_comm().end() ; ++i ) {
stk::mesh::Entity & e = **i ;
if ( e.owner_rank() == parallel_rank ) {
stk::mesh::comm_procs( e , procs );
for ( std::vector<const stk::mesh::FieldBase *>::const_iterator
fi = fields.begin() ; fi != fields.end() ; ++fi ) {
const stk::mesh::FieldBase & f = **fi ;
const unsigned size = stk::mesh::field_data_size( f , e );
if ( size ) {
unsigned char * ptr =
reinterpret_cast<unsigned char *>(stk::mesh::field_data( f , e ));
for ( std::vector<unsigned>::iterator
ip = procs.begin() ; ip != procs.end() ; ++ip ) {
stk::CommBuffer & b = sparse.send_buffer( *ip );
b.pack<unsigned char>( ptr , size );
}
}
}
}
}
// Communicate:
sparse.communicate();
// Unpack for recv:
for ( std::vector<stk::mesh::Entity*>::const_iterator
i = mesh.entity_comm().begin() ;
i != mesh.entity_comm().end() ; ++i ) {
stk::mesh::Entity & e = **i ;
if ( e.owner_rank() != parallel_rank ) {
for ( std::vector<const stk::mesh::FieldBase *>::const_iterator
fi = fields.begin() ; fi != fields.end() ; ++fi ) {
const stk::mesh::FieldBase & f = **fi ;
const unsigned size = stk::mesh::field_data_size( f , e );
//.........这里部分代码省略.........
示例15: use_case_5_generate_mesh
void use_case_5_generate_mesh(
const std::string& mesh_options ,
stk::mesh::BulkData & mesh ,
const VectorFieldType & node_coord ,
stk::mesh::Part & hex_block ,
stk::mesh::Part & quad_shell_block )
{
mesh.modification_begin();
const unsigned parallel_size = mesh.parallel_size();
const unsigned parallel_rank = mesh.parallel_rank();
double t = 0 ;
size_t num_hex = 0 ;
size_t num_shell = 0 ;
size_t num_nodes = 0 ;
size_t num_block = 0 ;
int error_flag = 0 ;
try {
Iogn::GeneratedMesh gmesh( mesh_options, parallel_size, parallel_rank );
num_nodes = gmesh.node_count_proc();
num_block = gmesh.block_count();
t = stk::wall_time();
std::vector<int> node_map( num_nodes , 0 );
gmesh.node_map( node_map );
{
for ( size_t i = 1 ; i <= num_block ; ++i ) {
const size_t num_elem = gmesh.element_count_proc(i);
const std::pair<std::string,int> top_info = gmesh.topology_type(i);
std::vector<int> elem_map( num_elem , 0 );
std::vector<int> elem_conn( num_elem * top_info.second );
gmesh.element_map( i, elem_map );
gmesh.connectivity( i , elem_conn );
if ( top_info.second == 8 ) {
for ( size_t j = 0 ; j < num_elem ; ++j ) {
const int * const local_node_id = & elem_conn[ j * 8 ] ;
const stk::mesh::EntityId node_id[8] = {
local_node_id[0] ,
local_node_id[1] ,
local_node_id[2] ,
local_node_id[3] ,
local_node_id[4] ,
local_node_id[5] ,
local_node_id[6] ,
local_node_id[7]
};
const stk::mesh::EntityId elem_id = elem_map[ j ];
stk::mesh::fem::declare_element( mesh , hex_block , elem_id , node_id );
++num_hex ;
}
}
else if ( top_info.second == 4 ) {
for ( size_t j = 0 ; j < num_elem ; ++j ) {
const int * const local_node_id = & elem_conn[ j * 4 ] ;
const stk::mesh::EntityId node_id[4] = {
local_node_id[0] ,
local_node_id[1] ,
local_node_id[2] ,
local_node_id[3]
};
const stk::mesh::EntityId elem_id = elem_map[ j ];
stk::mesh::fem::declare_element( mesh , quad_shell_block , elem_id , node_id );
++num_shell ;
}
}
}
}
std::vector<double> node_coordinates( 3 * node_map.size() );
gmesh.coordinates( node_coordinates );
if ( 3 * node_map.size() != node_coordinates.size() ) {
std::ostringstream msg ;
msg << " P" << mesh.parallel_rank()
<< ": ERROR, node_map.size() = "
<< node_map.size()
//.........这里部分代码省略.........