本文整理汇总了C++中STK_Interface::setSolutionFieldData方法的典型用法代码示例。如果您正苦于以下问题:C++ STK_Interface::setSolutionFieldData方法的具体用法?C++ STK_Interface::setSolutionFieldData怎么用?C++ STK_Interface::setSolutionFieldData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STK_Interface
的用法示例。
在下文中一共展示了STK_Interface::setSolutionFieldData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: charge_density
void
CustomMeshFactory::fillSolutionFieldData(STK_Interface &mesh) const
{
for (int blk=0;blk<NumBlocks_;++blk) {
std::stringstream block_id;
block_id << "eblock-" << blk;
// elements in this processor for this block
std::vector<stk_classic::mesh::Entity*> elements;
mesh.getMyElements(block_id.str(), elements);
// size of elements in the current block
std::size_t n_elements = elements.size();
// build local element index
std::vector<std::size_t> local_ids;
for (std::vector<stk_classic::mesh::Entity*>::const_iterator
itr=elements.begin();itr!=elements.end();++itr)
local_ids.push_back(mesh.elementLocalId(*itr));
// re-index solution fields in the same order of local_ids
std::vector<double> charge_density_by_local_ids, electric_potential_by_local_ids;
for (std::vector<stk_classic::mesh::Entity*>::const_iterator
itr=elements.begin();itr!=elements.end();++itr) {
int q = (*itr)->identifier() - OffsetToGlobalElementIDs_;
for (int k=0;k<8;++k) {
int loc = q*8 + k;
charge_density_by_local_ids.push_back(ChargeDensity_[loc]);
electric_potential_by_local_ids.push_back(ElectricPotential_[loc]);
}
}
// wrap the buffer with a proper container
FieldContainer charge_density(n_elements, 8, &charge_density_by_local_ids[0]),
electric_potential(n_elements, 8, &electric_potential_by_local_ids[0]);
// write out to stk mesh
mesh.setSolutionFieldData("CHARGE_DENSITY",
block_id.str(),
local_ids,
charge_density, 1.0);
mesh.setSolutionFieldData("ELECTRIC_POTENTIAL",
block_id.str(),
local_ids,
electric_potential, 1.0);
}
}