本文整理汇总了C++中NumericVector::type方法的典型用法代码示例。如果您正苦于以下问题:C++ NumericVector::type方法的具体用法?C++ NumericVector::type怎么用?C++ NumericVector::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NumericVector
的用法示例。
在下文中一共展示了NumericVector::type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: idx
void PetscVector<T>::localize (NumericVector<T>& v_local_in,
const std::vector<numeric_index_type>& send_list) const
{
// FIXME: Workaround for a strange bug at large-scale.
// If we have ghosting, PETSc lets us just copy the solution, and
// doing so avoids a segfault?
if (v_local_in.type() == GHOSTED &&
this->type() == PARALLEL)
{
v_local_in = *this;
return;
}
// Normal code path begins here
this->_restore_array();
// Make sure the NumericVector passed in is really a PetscVector
PetscVector<T>* v_local = libmesh_cast_ptr<PetscVector<T>*>(&v_local_in);
libmesh_assert(v_local);
libmesh_assert_equal_to (v_local->size(), this->size());
libmesh_assert_less_equal (send_list.size(), v_local->size());
PetscErrorCode ierr=0;
const numeric_index_type n_sl = send_list.size();
IS is;
VecScatter scatter;
std::vector<PetscInt> idx(n_sl + this->local_size());
for (numeric_index_type i=0; i<n_sl; i++)
idx[i] = static_cast<PetscInt>(send_list[i]);
for (numeric_index_type i = 0; i != this->local_size(); ++i)
idx[n_sl+i] = i + this->first_local_index();
// Create the index set & scatter object
if (idx.empty())
ierr = ISCreateLibMesh(libMesh::COMM_WORLD,
n_sl+this->local_size(), PETSC_NULL, PETSC_USE_POINTER, &is);
else
ierr = ISCreateLibMesh(libMesh::COMM_WORLD,
n_sl+this->local_size(), &idx[0], PETSC_USE_POINTER, &is);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
ierr = VecScatterCreate(_vec, is,
v_local->_vec, is,
&scatter);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
// Perform the scatter
#if PETSC_VERSION_LESS_THAN(2,3,3)
ierr = VecScatterBegin(_vec, v_local->_vec, INSERT_VALUES,
SCATTER_FORWARD, scatter);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
ierr = VecScatterEnd (_vec, v_local->_vec, INSERT_VALUES,
SCATTER_FORWARD, scatter);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
#else
// API argument order change in PETSc 2.3.3
ierr = VecScatterBegin(scatter, _vec, v_local->_vec,
INSERT_VALUES, SCATTER_FORWARD);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
ierr = VecScatterEnd (scatter, _vec, v_local->_vec,
INSERT_VALUES, SCATTER_FORWARD);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
#endif
// Clean up
ierr = LibMeshISDestroy (&is);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
ierr = LibMeshVecScatterDestroy(&scatter);
CHKERRABORT(libMesh::COMM_WORLD,ierr);
// Make sure ghost dofs are up to date
if (v_local->type() == GHOSTED)
v_local->close();
}