本文整理汇总了C++中stk::mesh::BulkData::mesh_meta_data方法的典型用法代码示例。如果您正苦于以下问题:C++ BulkData::mesh_meta_data方法的具体用法?C++ BulkData::mesh_meta_data怎么用?C++ BulkData::mesh_meta_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stk::mesh::BulkData
的用法示例。
在下文中一共展示了BulkData::mesh_meta_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: setup_node_coords
void setup_node_coords(const stk::mesh::BulkData& bulk, const CoordFieldType& coords, const stk::mesh::Selector& selector)
{
const stk::mesh::BucketVector& nodeBuckets = bulk.buckets(stk::topology::NODE_RANK);
bucketCapacity = nodeBuckets[0]->capacity();
unsigned nodeAllocSize = nodeBuckets.size()*bucketCapacity;
nodeCoords = DeviceViewMatrixType("DNodeCoords", nodeAllocSize, bulk.mesh_meta_data().spatial_dimension());
constNodeCoords = nodeCoords;
hostNodeCoords = Kokkos::create_mirror_view(nodeCoords);
for(unsigned bktIndex = 0; bktIndex < nodeBuckets.size(); ++bktIndex)
{
const stk::mesh::Bucket& bucket = *nodeBuckets[bktIndex];
for(unsigned nodeIndex = 0; nodeIndex < bucket.size(); ++nodeIndex)
{
stk::mesh::Entity node = bucket[nodeIndex];
double *node_coords = stk::mesh::field_data(coords, node);
unsigned nodeCoordIndex = host_get_index(node);
for(unsigned k=0; k<bulk.mesh_meta_data().spatial_dimension(); ++k)
{
hostNodeCoords(nodeCoordIndex, k) = node_coords[k];
}
}
}
Kokkos::deep_copy(nodeCoords, hostNodeCoords);
}
示例3: copy_mesh_subset
void copy_mesh_subset(stk::mesh::BulkData &inputBulk, stk::mesh::Selector selectedElems, stk::mesh::BulkData &outputBulk)
{
ThrowRequireMsg(&inputBulk != &outputBulk, "Can't copy to same mesh.");
stk::mesh::MetaData &inputMeta = inputBulk.mesh_meta_data();
stk::mesh::MetaData &outputMeta = outputBulk.mesh_meta_data();
outputMeta.initialize(inputMeta.spatial_dimension(), inputMeta.entity_rank_names());
copy_parts(inputMeta, outputMeta);
copy_fields(inputMeta, outputMeta);
}
示例4: bucket_part_memberships_match
bool bucket_part_memberships_match(const stk::mesh::BulkData& bulk, stk::EnvData& env_data)
{
int numGlobalDiffs = bucket_counts_match(bulk, env_data);
if(numGlobalDiffs > 0)
{
for(size_t irank = 0; irank < bulk.mesh_meta_data().entity_rank_count(); ++irank)
{
stk::CommSparse comm(env_data.m_worldComm);
stk::CommBuffer &buff = stk::diff::get_comm_buffer_for_destination_proc(comm);
stk::mesh::EntityRank rank = static_cast<stk::mesh::EntityRank>(irank);
stk::mesh::EntityVector entities;
stk::mesh::get_entities(bulk, rank, entities);
for(int iphase = 0; iphase < 2; ++iphase)
{
for(size_t i=0;i<entities.size();++i)
{
const stk::mesh::PartVector& parts = bulk.bucket(entities[i]).supersets();
std::string part_names_for_entity = create_string_from_parts(parts);
std::string string_to_send;
if(irank != 1 && irank != 2)
{
string_to_send = std::to_string(bulk.identifier(entities[i])) + " " + part_names_for_entity;
}
else
{
string_to_send = part_names_for_entity;
}
stk::diff::pack_string(buff, string_to_send);
}
stk::diff::allocate_or_communicate(iphase, comm);
}
}
}
for(size_t irank = 0; irank < bulk.mesh_meta_data().entity_rank_count(); ++irank)
{
stk::CommSparse comm(env_data.m_worldComm);
stk::mesh::EntityRank rank = static_cast<stk::mesh::EntityRank>(irank);
const stk::mesh::BucketVector& buckets = bulk.buckets(rank);
for(int iphase = 0; iphase < 2; ++iphase)
{
pack_buckets_parts(buckets, stk::diff::get_comm_buffer_for_destination_proc(comm));
stk::diff::allocate_or_communicate(iphase, comm);
}
}
numGlobalDiffs += get_global_bucket_part_membership_differences(env_data.m_worldComm, 0);
return numGlobalDiffs == 0;
}
示例5: graph
std::map<stk::mesh::EntityId, std::pair<stk::mesh::EntityId, int> > get_split_coincident_elements(stk::mesh::BulkData& bulkData)
{
stk::mesh::Selector sel = bulkData.mesh_meta_data().locally_owned_part();
ElemGraphForDiagnostics graph(bulkData, sel);
const stk::mesh::impl::SparseGraph& coingraph = graph.get_coincident_graph();
std::map<stk::mesh::EntityId, std::pair<stk::mesh::EntityId, int> > badElements;
for(const stk::mesh::impl::SparseGraph::value_type& extractedEdgesForElem : coingraph)
{
const std::vector<stk::mesh::GraphEdge>& coincidentEdgesForElem = extractedEdgesForElem.second;
for(const stk::mesh::GraphEdge& edge : coincidentEdgesForElem)
{
if(edge.elem2 < 0)
{
stk::mesh::Entity entity = graph.get_entity(edge.elem1);
stk::mesh::EntityId id = bulkData.identifier(entity);
stk::mesh::impl::ParallelGraphInfo& par_info = graph.get_parallel_info();
stk::mesh::impl::ParallelGraphInfo::iterator iter = par_info.find(edge);
ThrowRequireMsg(iter!=par_info.end(), "Program error. Contact [email protected] for support.");
badElements[id] = std::make_pair(-edge.elem2, iter->second.m_other_proc);
}
}
}
return badElements;
}
示例6: 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();
}
示例7: Kernel
MomentumBuoyancyBoussinesqSrcElemKernel<AlgTraits>::MomentumBuoyancyBoussinesqSrcElemKernel(
const stk::mesh::BulkData& bulkData,
const SolutionOptions& solnOpts,
ElemDataRequests& dataPreReqs)
: Kernel(),
rhoRef_(solnOpts.referenceDensity_),
ipNodeMap_(sierra::nalu::MasterElementRepo::get_volume_master_element(AlgTraits::topo_)->ipNodeMap())
{
const stk::mesh::MetaData& metaData = bulkData.mesh_meta_data();
ScalarFieldType *temperature = metaData.get_field<ScalarFieldType>(stk::topology::NODE_RANK, "temperature");
temperatureNp1_ = &(temperature->field_of_state(stk::mesh::StateNP1));
coordinates_ = metaData.get_field<VectorFieldType>(stk::topology::NODE_RANK, solnOpts.get_coordinates_name());
const std::vector<double>& solnOptsGravity = solnOpts.get_gravity_vector(AlgTraits::nDim_);
for (int i = 0; i < AlgTraits::nDim_; i++)
gravity_(i) = solnOptsGravity[i];
tRef_ = solnOpts.referenceTemperature_;
rhoRef_ = solnOpts.referenceDensity_;
beta_ = solnOpts.thermalExpansionCoeff_;
MasterElement* meSCV = sierra::nalu::MasterElementRepo::get_volume_master_element(AlgTraits::topo_);
get_scv_shape_fn_data<AlgTraits>([&](double* ptr){meSCV->shape_fcn(ptr);}, v_shape_function_);
// add master elements
dataPreReqs.add_cvfem_volume_me(meSCV);
// fields and data
dataPreReqs.add_coordinates_field(*coordinates_, AlgTraits::nDim_, CURRENT_COORDINATES);
dataPreReqs.add_gathered_nodal_field(*temperatureNp1_, 1);
dataPreReqs.add_master_element_call(SCV_VOLUME, CURRENT_COORDINATES);
}
示例8: createBoundingBoxesForSidesInSidesets
inline void createBoundingBoxesForSidesInSidesets(const stk::mesh::BulkData& bulk, std::vector<FloatBox>& domainBoxes)
{
stk::mesh::ExodusTranslator exoTranslator(bulk);
size_t numberBoundingBoxes = 0;
std::vector<int64_t> sidesetIds;
exoTranslator.fill_side_set_ids(sidesetIds);
for (size_t i=0;i<sidesetIds.size();i++)
{
numberBoundingBoxes += exoTranslator.get_local_num_entities_for_id(sidesetIds[i], bulk.mesh_meta_data().side_rank());
}
domainBoxes.resize(numberBoundingBoxes);
stk::mesh::FieldBase const * coords = bulk.mesh_meta_data().coordinate_field();
size_t boxCounter = 0;
std::vector<double> boxCoordinates(6);
for (size_t ssetCounter=0;ssetCounter<sidesetIds.size();ssetCounter++)
{
const stk::mesh::Part* sideset = exoTranslator.get_exodus_part_of_rank(sidesetIds[ssetCounter], bulk.mesh_meta_data().side_rank());
stk::mesh::EntityVector sides;
stk::mesh::Selector sel = bulk.mesh_meta_data().locally_owned_part() & *sideset;
stk::mesh::get_selected_entities(sel, bulk.buckets(bulk.mesh_meta_data().side_rank()), sides);
for(size_t j=0;j<sides.size();++j)
{
unsigned num_nodes_per_side = bulk.num_nodes(sides[j]);
const stk::mesh::Entity* nodes = bulk.begin_nodes(sides[j]);
std::vector<double> coordinates(3*num_nodes_per_side,0);
for(unsigned k=0;k<num_nodes_per_side;++k)
{
double *data = static_cast<double*>(stk::mesh::field_data(*coords, nodes[k]));
coordinates[3*k] = data[0];
coordinates[3*k+1] = data[1];
coordinates[3*k+2] = data[2];
}
findBoundingBoxCoordinates(coordinates, boxCoordinates);
domainBoxes[boxCounter].set_box(boxCoordinates[0], boxCoordinates[1], boxCoordinates[2],
boxCoordinates[3], boxCoordinates[4], boxCoordinates[5]);
boxCounter++;
}
}
ThrowRequireMsg(boxCounter == numberBoundingBoxes, "Program error. Please contact sierra-help for support");
}
示例9: Kernel
MomentumNSOKeElemKernel<AlgTraits>::MomentumNSOKeElemKernel(
const stk::mesh::BulkData& bulkData,
const SolutionOptions& solnOpts,
VectorFieldType* ,
GenericFieldType* Gju,
const double fourthFac,
ElemDataRequests& dataPreReqs)
: Kernel(),
Gju_(Gju),
lrscv_(sierra::nalu::MasterElementRepo::get_surface_master_element(AlgTraits::topo_)->adjacentNodes()),
fourthFac_(fourthFac),
shiftedGradOp_(solnOpts.get_shifted_grad_op("velocity"))
{
const stk::mesh::MetaData& metaData = bulkData.mesh_meta_data();
velocityNp1_ = metaData.get_field<VectorFieldType>(
stk::topology::NODE_RANK, "velocity");
densityNp1_ = metaData.get_field<ScalarFieldType>(
stk::topology::NODE_RANK, "density");
pressure_ = metaData.get_field<ScalarFieldType>(
stk::topology::NODE_RANK, "pressure");
if (solnOpts.does_mesh_move())
velocityRTM_ = metaData.get_field<VectorFieldType>(
stk::topology::NODE_RANK, "velocity_rtm");
else
velocityRTM_ = metaData.get_field<VectorFieldType>(
stk::topology::NODE_RANK, "velocity");
pressure_ = metaData.get_field<ScalarFieldType>(
stk::topology::NODE_RANK, "pressure");
coordinates_ = metaData.get_field<VectorFieldType>(
stk::topology::NODE_RANK, solnOpts.get_coordinates_name());
Gjp_ = metaData.get_field<VectorFieldType>(stk::topology::NODE_RANK, "dpdx");
MasterElement *meSCS = sierra::nalu::MasterElementRepo::get_surface_master_element(AlgTraits::topo_);
get_scs_shape_fn_data<AlgTraits>([&](double* ptr){meSCS->shape_fcn(ptr);}, v_shape_function_);
// add master elements
dataPreReqs.add_cvfem_surface_me(meSCS);
// fields
dataPreReqs.add_gathered_nodal_field(*Gju_, AlgTraits::nDim_, AlgTraits::nDim_);
dataPreReqs.add_coordinates_field(*coordinates_, AlgTraits::nDim_, CURRENT_COORDINATES);
dataPreReqs.add_gathered_nodal_field(*velocityNp1_, AlgTraits::nDim_);
dataPreReqs.add_gathered_nodal_field(*velocityRTM_, AlgTraits::nDim_);
dataPreReqs.add_gathered_nodal_field(*Gjp_, AlgTraits::nDim_);
dataPreReqs.add_gathered_nodal_field(*densityNp1_,1);
dataPreReqs.add_gathered_nodal_field(*pressure_,1);
// master element data
dataPreReqs.add_master_element_call(SCS_AREAV, CURRENT_COORDINATES);
if ( shiftedGradOp_ )
dataPreReqs.add_master_element_call(SCS_SHIFTED_GRAD_OP, CURRENT_COORDINATES);
else
dataPreReqs.add_master_element_call(SCS_GRAD_OP, CURRENT_COORDINATES);
dataPreReqs.add_master_element_call(SCS_GIJ, CURRENT_COORDINATES);
}
示例10: send_part_names_to_diffing_tool_except
void send_part_names_to_diffing_tool_except(const stk::mesh::BulkData& bulk, stk::ParallelMachine communicator, stk::mesh::Part* skipPart)
{
stk::CommSparse comm(communicator);
for(int iphase = 0; iphase < 2; ++iphase)
{
pack_part_names_except(get_comm_buffer_for_destination_proc(comm), bulk.mesh_meta_data().get_parts(), skipPart);
allocate_or_communicate(iphase, comm);
}
}
示例11: fillCoordinates
void Vertices::fillCoordinates(const stk::mesh::BulkData& bulkData,
const std::string& coords_field_name,
const stk::mesh::EntityVector &entities)
{
mVertexCoordinates.resize(entities.size()*mSpatialDim, 0);
const stk::mesh::FieldBase * coord = bulkData.mesh_meta_data().get_field(stk::topology::NODE_RANK, coords_field_name);
for(size_t i=0;i<entities.size();++i)
stk::balance::internal::fillEntityCentroid(bulkData, coord, entities[i], &mVertexCoordinates[mSpatialDim*i]);
}
示例12: put_mesh_into_part
void put_mesh_into_part(stk::mesh::BulkData& bulkData, stk::mesh::Part& part)
{
stk::mesh::EntityVector entitiesToMakeActive;
std::vector<stk::mesh::PartVector> add_parts;
std::vector<stk::mesh::PartVector> rm_parts;
for(stk::topology::rank_t rank=stk::topology::BEGIN_RANK; rank < bulkData.mesh_meta_data().entity_rank_count(); rank++)
{
const stk::mesh::BucketVector &buckets = bulkData.get_buckets(rank, bulkData.mesh_meta_data().locally_owned_part());
for(const stk::mesh::Bucket *bucket : buckets)
{
for(stk::mesh::Entity entity : *bucket)
{
entitiesToMakeActive.push_back(entity);
add_parts.push_back(stk::mesh::PartVector(1, &part));
rm_parts.push_back(stk::mesh::PartVector());
}
}
}
bulkData.batch_change_entity_parts(entitiesToMakeActive, add_parts, rm_parts);
}
示例13:
stk::parallel::DistributedIndex::KeyTypeVector get_all_local_keys(const stk::mesh::BulkData & bulkData)
{
stk::parallel::DistributedIndex::KeyTypeVector localKeys;
for(stk::mesh::EntityRank rank = stk::topology::NODE_RANK;rank < bulkData.mesh_meta_data().entity_rank_count();++rank)
{
stk::mesh::EntityVector entities;
stk::mesh::get_selected_entities(get_owned_or_shared_selector(bulkData), bulkData.buckets(rank), entities);
for(stk::mesh::Entity entity: entities)
localKeys.push_back(bulkData.entity_key(entity));
}
return localKeys;
}
示例14: get_number_sides_in_sideset
inline size_t get_number_sides_in_sideset(const stk::mesh::BulkData& bulk,
int sideset_id,
stk::mesh::Selector selector,
stk::topology stk_element_topology,
const stk::mesh::BucketVector& buckets)
{
if (bulk.has_sideset_data())
{
selector &= ( bulk.mesh_meta_data().locally_owned_part() | bulk.mesh_meta_data().globally_shared_part());
size_t num_sides = 0;
const stk::mesh::SideSet& sset = bulk.get_sideset_data(sideset_id);
for(const stk::mesh::SideSetEntry& elem_and_side : sset)
{
stk::mesh::Entity element = elem_and_side.element;
stk::mesh::Entity side = stk::mesh::get_side_entity_for_elem_side_pair(bulk, element, elem_and_side.side);
if(bulk.is_valid(side))
{
if(selector(bulk.bucket(side)))
{
if(stk_element_topology == stk::topology::INVALID_TOPOLOGY ||
stk_element_topology == bulk.bucket(element).topology())
{
++num_sides;
}
}
}
}
return num_sides;
}
else
{
selector &= bulk.mesh_meta_data().locally_owned_part();
return count_selected_entities(selector, buckets);
}
}
示例15: mEntitiesToBalance
GeometricVertices::GeometricVertices(const stk::balance::BalanceSettings& balanceSettings,
const stk::mesh::BulkData& bulkData,
const stk::mesh::EntityVector& entities_to_balance,
const std::vector<stk::mesh::Selector> criteria)
: mEntitiesToBalance(entities_to_balance)
, mSelectors(criteria)
{
set_num_field_criteria( balanceSettings.getNumCriteria() );
set_spatial_dim( bulkData.mesh_meta_data().spatial_dimension() );
fillVertexIds(bulkData, mEntitiesToBalance);
fillCoordinates(bulkData, balanceSettings.getCoordinateFieldName(), mEntitiesToBalance);
fillVertexWeights(bulkData, balanceSettings, mEntitiesToBalance, mSelectors);
}