本文整理汇总了C++中teuchos::Array::getRawPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::getRawPtr方法的具体用法?C++ Array::getRawPtr怎么用?C++ Array::getRawPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::Array
的用法示例。
在下文中一共展示了Array::getRawPtr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Teuchos::Array<GO>
Albany::NodeGIDsSolutionCullingStrategy::
selectedGIDsT(Teuchos::RCP<const Tpetra_Map> sourceMapT) const
{
Teuchos::Array<GO> result;
{
Teuchos::Array<GO> mySelectedGIDs;
// Subract 1 to convert exodus GIDs to our GIDs
for (int i=0; i<nodeGIDs_.size(); i++)
if (sourceMapT->isNodeGlobalElement(nodeGIDs_[i] -1) ) mySelectedGIDs.push_back(nodeGIDs_[i] - 1);
Teuchos::RCP<const Teuchos::Comm<int> >commT = sourceMapT->getComm();
{
GO selectedGIDCount;
{
GO mySelectedGIDCount = mySelectedGIDs.size();
Teuchos::reduceAll<LO, GO>(*commT, Teuchos::REDUCE_SUM, 1, &mySelectedGIDCount, &selectedGIDCount);
}
result.resize(selectedGIDCount);
}
const int ierr = Tpetra::GatherAllV(
commT,
mySelectedGIDs.getRawPtr(), mySelectedGIDs.size(),
result.getRawPtr(), result.size());
TEUCHOS_ASSERT(ierr == 0);
}
std::sort(result.begin(), result.end());
return result;
}
示例2: x_view
// Get a Kokkos::View of a Teuchos::ArrayView, and make sure that
// it points to the same data. Thanks to Christian Trott for
// implementing the necessary functionality (View constructor for
// certain View specializations, that takes a raw pointer and
// dimensions) in Kokkos Array.
//
// This example will be useful for implementing the
// Tpetra::MultiVector methods get1dCopy and get2dCopy.
TEUCHOS_UNIT_TEST( LinkTeuchosAndKokkos, ViewOfArrayView ) {
typedef Teuchos::Array<double>::size_type size_type;
typedef Kokkos::View<double*, Kokkos::LayoutLeft, Kokkos::Threads, Kokkos::MemoryUnmanaged> ka_view_type;
typedef Kokkos::View<const double*, Kokkos::LayoutLeft, Kokkos::Threads, Kokkos::MemoryUnmanaged> ka_const_view_type;
const size_type numElts = 10;
Teuchos::Array<double> x (numElts);
for (size_type k = 0; k < numElts; ++k) {
x[k] = 42.0 + static_cast<double> (k);
}
// You can make an (unmanaged) View of a raw array with left or
// right (Fortran or C) layout on the HostSpace device, just by passing
// the array and stride(s) into the constructor. If you want the
// dimensions to differ from the strides, you'll have to create a
// subview with the desired dimensions.
ka_view_type x_view (x.getRawPtr (), x.size ());
TEST_EQUALITY( x.size(), static_cast<size_type>(x_view.dimension_0()) );
for (size_type k = 0; k < x.size (); ++k) {
TEST_EQUALITY( x_view[k], x[k] );
}
// This ensures that conversions from double* to const double* work correctly.
// x.getRawPtr() returns double*.
ka_const_view_type x_view_const ( (const double*) x.getRawPtr (), x.size ());
TEST_EQUALITY( x.size(), static_cast<size_type>(x_view_const.dimension_0()) );
for (size_type k = 0; k < x.size (); ++k) {
TEST_EQUALITY( x_view_const[k], x[k] );
}
}
示例3: getEntityNodeCoordinates
//---------------------------------------------------------------------------//
// Get the coordinates of the entity nodes in canonical order.
void MoabHelpers::getEntityNodeCoordinates(
const moab::EntityHandle& moab_entity,
const Teuchos::Ptr<moab::ParallelComm>& moab_mesh,
Teuchos::Array<double>& coordinates )
{
const moab::EntityHandle* entity_nodes;
int num_nodes = 0;
std::vector<moab::EntityHandle> storage;
DTK_CHECK_ERROR_CODE(
moab_mesh->get_moab()->get_connectivity( moab_entity,
entity_nodes,
num_nodes,
false,
&storage )
);
coordinates.resize( 3 * num_nodes );
DTK_CHECK_ERROR_CODE(
moab_mesh->get_moab()->get_coords( entity_nodes,
num_nodes,
coordinates.getRawPtr() )
);
}
示例4: Indices
//TpetraCrsGraph_To_EpetraCrsGraph: takes in Tpetra::CrsGraph object, converts it to its equivalent Epetra_CrsGraph object,
//and returns an RCP pointer to this Epetra_CrsGraph
Teuchos::RCP<Epetra_CrsGraph> Petra::TpetraCrsGraph_To_EpetraCrsGraph(const Teuchos::RCP<const Tpetra_CrsGraph>& tpetraCrsGraph_,
const Teuchos::RCP<const Epetra_Comm>& comm_)
{
//get row map of Tpetra::CrsGraph & convert to Epetra::Map
Teuchos::RCP<const Tpetra_Map> tpetraRowMap_ = tpetraCrsGraph_->getRowMap();
Teuchos::RCP<const Epetra_Map> epetraRowMap_ = TpetraMap_To_EpetraMap(tpetraRowMap_, comm_);
//get col map of Tpetra::CrsGraph & convert to Epetra::Map
Teuchos::RCP<const Tpetra_Map> tpetraColMap_ = tpetraCrsGraph_->getColMap();
Teuchos::RCP<const Epetra_Map> epetraColMap_ = TpetraMap_To_EpetraMap(tpetraColMap_, comm_);
int maxEntries = Teuchos::as<int>(tpetraCrsGraph_->getGlobalMaxNumRowEntries());
Teuchos::RCP<Epetra_CrsGraph> epetraCrsGraph_= Teuchos::rcp(new Epetra_CrsGraph(Copy, *epetraRowMap_, *epetraColMap_, maxEntries));
Teuchos::Array<LO> Indices;
for (LO i=0; i<tpetraCrsGraph_->getNodeNumRows(); i++) {
auto NumEntries = tpetraCrsGraph_->getNumEntriesInLocalRow(i);
Indices.resize(NumEntries);
tpetraCrsGraph_->getLocalRowCopy(i, Indices(), NumEntries);
epetraCrsGraph_->InsertMyIndices(i, NumEntries, Indices.getRawPtr());
}
epetraCrsGraph_->FillComplete();
return epetraCrsGraph_;
}
示例5: out
//.........这里部分代码省略.........
*out << "Warning: MueLu_ENABLE_ML=OFF. The parameter list cannot be validated." << std::endl;
paramList.set("ML validate parameter list", false);
#endif // HAVE_MUELU_ML
} // if(validate)
} // scope
// stringstream for concatenating xml parameter strings.
std::stringstream mueluss;
// create surrounding MueLu parameter list
mueluss << "<ParameterList name=\"MueLu\">" << std::endl;
// loop over all ML parameters in provided parameter list
for (ParameterList::ConstIterator param = paramListWithSubList.begin(); param != paramListWithSubList.end(); ++param) {
// extract ML parameter name
const std::string & pname=paramListWithSubList.name(param);
// extract corresponding (ML) value
// remove ParameterList specific information from result string
std::stringstream valuess;
valuess << paramList.entry(param);
std::string valuestr = valuess.str();
replaceAll(valuestr, "[unused]", "");
replaceAll(valuestr, "[default]", "");
valuestr = trim(valuestr);
// transform ML parameter to corresponding MueLu parameter and generate XML string
std::string valueInterpreterStr = "\"" + valuestr + "\"";
std::string ret = MasterList::interpretParameterName(MasterList::ML2MueLu(pname),valueInterpreterStr);
// add XML string
if (ret != "") {
mueluss << ret << std::endl;
// remove parameter from ML parameter list
adaptingParamList.remove(pname,false);
}
// special handling for energy minimization
// TAW: this is not optimal for symmetric problems but at least works.
// for symmetric problems the "energy minimization" parameter should not exist anyway...
if (pname == "energy minimization: enable") {
mueluss << "<Parameter name=\"problem: symmetric\" type=\"bool\" value=\"false\"/>" << std::endl;
mueluss << "<Parameter name=\"transpose: use implicit\" type=\"bool\" value=\"false\"/>" << std::endl;
}
// special handling for smoothers
if (pname == "smoother: type") {
mueluss << GetSmootherFactory(paramList, adaptingParamList, pname, valuestr);
}
// special handling for level-specific smoothers
if (pname.find("smoother: list (level",0) == 0) {
// Scan pname (ex: pname="smoother: type (level 2)")
std::string type, option;
int levelID=-1;
{
typedef Teuchos::ArrayRCP<char>::size_type size_type;
Teuchos::Array<char> ctype (size_type(pname.size()+1));
Teuchos::Array<char> coption(size_type(pname.size()+1));
int matched = sscanf(pname.c_str(),"%s %[^(](level %d)", ctype.getRawPtr(), coption.getRawPtr(), &levelID); // use [^(] instead of %s to allow for strings with white-spaces (ex: "ifpack list")
type = std::string(ctype.getRawPtr());
option = std::string(coption.getRawPtr()); option.resize(option.size () - 1); // remove final white-space
if (matched != 3 || (type != "smoother:")) {
TEUCHOS_TEST_FOR_EXCEPTION(true, MueLu::Exceptions::RuntimeError, "MueLu::CreateSublist(), Line " << __LINE__ << ". "
<< "Error in creating level-specific sublists" << std::endl
<< "Offending parameter: " << pname << std::endl);
}
mueluss << "<ParameterList name=\"level " << levelID << "\">" << std::endl;
mueluss << GetSmootherFactory(paramList.sublist(pname),adaptingParamList.sublist(pname), "smoother: type", paramList.sublist(pname).get<std::string>("smoother: type"));
mueluss << "</ParameterList>" << std::endl;
}
}
// special handling for coarse level
TEUCHOS_TEST_FOR_EXCEPTION(paramList.isParameter("coarse: type"), Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter::Setup(): The parameter \"coarse: type\" should not exist but being stored in \"coarse: list\" instead.");
if ( pname == "coarse: list" ) {
// interpret smoother/coarse solver data.
// Note, that we inspect the "coarse: list" sublist to define the "coarse" smoother/solver
// Be aware, that MueLu::CreateSublists renames the prefix of the parameters in the "coarse: list" from "coarse" to "smoother".
// Therefore, we have to check the values of the "smoother" parameters
TEUCHOS_TEST_FOR_EXCEPTION(!paramList.sublist("coarse: list").isParameter("smoother: type"), Exceptions::RuntimeError, "MueLu::MLParameterListInterpreter::Setup(): no coarse grid solver defined.");
mueluss << GetSmootherFactory(paramList.sublist("coarse: list"), adaptingParamList.sublist("coarse: list"), "coarse: type", paramList.sublist("coarse: list").get<std::string>("smoother: type"));
}
} // for
mueluss << "</ParameterList>" << std::endl;
return mueluss.str();
}