本文整理汇总了C++中map_type::getNode方法的典型用法代码示例。如果您正苦于以下问题:C++ map_type::getNode方法的具体用法?C++ map_type::getNode怎么用?C++ map_type::getNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map_type
的用法示例。
在下文中一共展示了map_type::getNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: newColMap
/// \brief Return an optimized reordering of the given column Map.
/// Optionally, recompute an Import from the input domain Map to
/// the new column Map.
/// \tparam MapType A specialization of Map.
///
/// See the documentation of the free function
/// makeOptimizedColMapAndImport().
///
/// \param errStream [out] Output stream for human-readable error
/// reporting. This is local to the calling process and may
/// differ on different processes.
/// \param lclErr [out] On output: true if anything went wrong on
/// the calling process. This value is local to the calling
/// process and may differ on different processes.
/// \param domMap [in] Domain Map of a CrsGraph or CrsMatrix.
/// \param colMap [in] <i>Original</i> column Map of the same
/// CrsGraph or CrsMatrix as \c domMap.
/// \param oldImport [in] Optional pointer to the "original
/// Import: an Import from \c domMap to \c colMap. This is not
/// required, but if you supply this, this function may use it
/// to avoid some communication and/or work when setting up the
/// new Import object. This function will <i>only</i> look at
/// this pointer if \c makeImport is true.
/// \param makeImport [in] Whether to make and return an Import from
/// the input domain Map to the new column Map.
///
/// \return The possibly reordered column Map \c newColMap, and the
/// corresponding Import from \c domMap to \c newColMap. The
/// latter is nonnull if and only if \c makeImport is true.
///
/// \pre \c domMap and \c colMap must have the same or congruent
/// communicators.
/// \pre On all calling processes, the indices in \c colMap must be
/// a subset of the indices in \c domMap.
static std::pair<map_type, Teuchos::RCP<import_type> >
make (std::ostream& errStream,
bool& lclErr,
const map_type& domMap,
const map_type& colMap,
const import_type* oldImport,
const bool makeImport)
{
using Teuchos::Array;
using Teuchos::ArrayView;
using Teuchos::RCP;
using Teuchos::rcp;
using std::endl;
typedef local_ordinal_type LO;
typedef global_ordinal_type GO;
const char prefix[] = "Tpetra::makeOptimizedColMapAndImport: ";
std::ostream& err = errStream;
(void) oldImport; // We don't currently use this argument.
RCP<const Teuchos::Comm<int> > comm = colMap.getComm ();
const LO colMapMinLid = colMap.getMinLocalIndex ();
const LO colMapMaxLid = colMap.getMaxLocalIndex ();
// Count the numbers of GIDs in colMap that are in and not in
// domMap on the calling process. Check for zero indices on the
// calling process first, because if it's true, then we shouldn't
// trust [getMinLocalIndex(), getMaxLocalIndex()] to return a
// correct range.
LO numOwnedGids = 0;
LO numRemoteGids = 0;
if (colMap.getNodeNumElements () != 0) {
for (LO colMapLid = colMapMinLid; colMapLid <= colMapMaxLid; ++colMapLid) {
const GO colMapGid = colMap.getGlobalElement (colMapLid);
if (domMap.isNodeLocalElement (colMapGid)) {
++numOwnedGids;
} else {
++numRemoteGids;
}
}
}
// Put all colMap GIDs on the calling process in a single array.
// Owned GIDs go in front, and remote GIDs at the end.
Array<GO> allGids (numOwnedGids + numRemoteGids);
ArrayView<GO> ownedGids = allGids.view (0, numOwnedGids);
ArrayView<GO> remoteGids = allGids.view (numOwnedGids, numRemoteGids);
// Fill ownedGids and remoteGids (and therefore allGids). We use
// two loops, one to count (above) and one to fill (here), in
// order to avoid dynamic memory allocation during the loop (in
// this case, lots of calls to push_back()). That will simplify
// use of Kokkos to parallelize these loops later.
LO ownedPos = 0;
LO remotePos = 0;
if (colMap.getNodeNumElements () != 0) {
for (LO colMapLid = colMapMinLid; colMapLid <= colMapMaxLid; ++colMapLid) {
const GO colMapGid = colMap.getGlobalElement (colMapLid);
if (domMap.isNodeLocalElement (colMapGid)) {
ownedGids[ownedPos++] = colMapGid;
} else {
remoteGids[remotePos++] = colMapGid;
}
}
}
//.........这里部分代码省略.........