本文整理汇总了C++中teuchos::ArrayRCP类的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRCP类的具体用法?C++ ArrayRCP怎么用?C++ ArrayRCP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayRCP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeToScreen
void writeToScreen(std::ostream & os,const Thyra::VectorBase<double> & src)
{
const Thyra::SpmdVectorBase<double> & spmdSrc =
Teuchos::dyn_cast<const Thyra::SpmdVectorBase<double> >(src);
// get access to data
Teuchos::ArrayRCP<const double> srcData;
spmdSrc.getLocalData(Teuchos::ptrFromRef(srcData));
os << "Local Size = " << srcData.size() << std::endl;
for (int i=0; i < srcData.size(); ++i) {
os << " " << srcData[i] << std::endl;
}
}
示例2:
void LocalAggregationAlgorithm<LocalOrdinal, GlobalOrdinal, Node, LocalMatOps>::RandomReorder(Teuchos::ArrayRCP<LO> list) const {
//TODO: replace int
int n = list.size();
for(int i=0; i<n-1; i++) {
std::swap(list[i], list[RandomOrdinal(i,n-1)]);
}
}
示例3: buildEvaluators
//------------------------------------------------------------------------------
void
Albany::MechanicsProblem::
buildProblem(
Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct>> meshSpecs,
Albany::StateManager& stateMgr)
{
// Construct All Phalanx Evaluators
int physSets = meshSpecs.size();
*out << "Num MeshSpecs: " << physSets << '\n';
fm.resize(physSets);
bool haveSidesets = false;
*out << "Calling MechanicsProblem::buildEvaluators" << '\n';
for (int ps = 0; ps < physSets; ++ps) {
fm[ps] = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
buildEvaluators(*fm[ps], *meshSpecs[ps], stateMgr, BUILD_RESID_FM,
Teuchos::null);
if (meshSpecs[ps]->ssNames.size() > 0) haveSidesets = true;
}
constructDirichletEvaluators(*meshSpecs[0]);
if (haveSidesets)
constructNeumannEvaluators(meshSpecs[0]);
}
示例4: buildProblem
void Hydrology::buildProblem (Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > meshSpecs,
Albany::StateManager& stateMgr)
{
// Building cell basis and cubature
const CellTopologyData * const cell_top = &meshSpecs[0]->ctd;
intrepidBasis = Albany::getIntrepid2Basis(*cell_top);
cellType = Teuchos::rcp(new shards::CellTopology (cell_top));
Intrepid2::DefaultCubatureFactory cubFactory;
cubature = cubFactory.create<PHX::Device, RealType, RealType>(*cellType, meshSpecs[0]->cubatureDegree);
elementBlockName = meshSpecs[0]->ebName;
const int worksetSize = meshSpecs[0]->worksetSize;
const int numCellVertices = cellType->getNodeCount();
const int numCellNodes = intrepidBasis->getCardinality();
const int numCellQPs = cubature->getNumPoints();
dl = Teuchos::rcp(new Albany::Layouts(worksetSize,numCellVertices,numCellNodes,numCellQPs,numDim));
/* Construct All Phalanx Evaluators */
TEUCHOS_TEST_FOR_EXCEPTION(meshSpecs.size()!=1,std::logic_error,"Problem supports one Material Block");
fm.resize(1);
fm[0] = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
buildEvaluators(*fm[0], *meshSpecs[0], stateMgr, Albany::BUILD_RESID_FM,Teuchos::null);
if(meshSpecs[0]->nsNames.size() > 0) {
// Build a nodeset evaluator if nodesets are present
constructDirichletEvaluators(*meshSpecs[0]);
}
if(meshSpecs[0]->ssNames.size() > 0) {
// Build a sideset evaluator if sidesets are present
constructNeumannEvaluators(meshSpecs[0]);
}
}
示例5: function_coeffs
void IntrepidKernel<Scalar>::evaluate(
Teuchos::ArrayRCP<Scalar> &function_values,
const Teuchos::ArrayRCP<Scalar> &coeffs,
const Teuchos::ArrayRCP<Scalar> &dfunc_values )
{
int dim1 = this->b_cardinality;
testPrecondition( dim1 == (int) coeffs.size(),
"Function coefficients size does not match basis cardinality" );
MDArray function_coeffs( 1, dim1 );
for ( int m = 0; m < dim1; ++m )
{
function_coeffs(0,m) = coeffs[m];
}
MDArray basis_eval( 1, dim1, 1 );
for ( int i = 0; i < dim1; ++i )
{
basis_eval( 0, i, 0 ) = dfunc_values[i];
}
Teuchos::Tuple<int,2> function_dimensions;
function_dimensions[0] = 1;
function_dimensions[1] = 1;
MDArray function_eval( function_dimensions, function_values );
Intrepid::FunctionSpaceTools::evaluate<Scalar>( function_eval,
function_coeffs,
basis_eval );
}
示例6: buildEvaluators
void
Albany::PNPProblem::
buildProblem(
Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > meshSpecs,
Albany::StateManager& stateMgr)
{
using Teuchos::rcp;
/* Construct All Phalanx Evaluators */
int physSets = meshSpecs.size();
std::cout << "PNP Problem Num MeshSpecs: " << physSets << std::endl;
fm.resize(physSets);
for (int ps=0; ps<physSets; ps++) {
fm[ps] = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
buildEvaluators(*fm[ps], *meshSpecs[ps], stateMgr, BUILD_RESID_FM,
Teuchos::null);
}
if(meshSpecs[0]->nsNames.size() > 0) // Build a nodeset evaluator if nodesets are present
constructDirichletEvaluators(*meshSpecs[0]);
if(meshSpecs[0]->ssNames.size() > 0) // Build a sideset evaluator if sidesets are present
constructNeumannEvaluators(meshSpecs[0]);
}
示例7: rcp
void
Albany::NavierStokes::
buildProblem(
Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > meshSpecs,
Albany::StateManager& stateMgr)
{
using Teuchos::rcp;
/* Construct All Phalanx Evaluators */
TEUCHOS_TEST_FOR_EXCEPTION(meshSpecs.size()!=1,std::logic_error,"Problem supports one Material Block");
fm.resize(1);
fm[0] = rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
buildEvaluators(*fm[0], *meshSpecs[0], stateMgr, BUILD_RESID_FM,
Teuchos::null);
if(meshSpecs[0]->nsNames.size() > 0) // Build a nodeset evaluator if nodesets are present
constructDirichletEvaluators(meshSpecs[0]->nsNames);
if(meshSpecs[0]->ssNames.size() > 0) // Build a sideset evaluator if sidesets are present
constructNeumannEvaluators(meshSpecs[0]);
}
示例8: buildEvaluators
void
Albany::HMCProblem::
buildProblem(
Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct>> meshSpecs,
Albany::StateManager& stateMgr)
{
/* Construct All Phalanx Evaluators */
TEUCHOS_TEST_FOR_EXCEPTION(meshSpecs.size()!=1,std::logic_error,"Problem supports one Material Block");
fm.resize(1);
fm[0] = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
buildEvaluators(*fm[0], *meshSpecs[0], stateMgr, BUILD_RESID_FM,
Teuchos::null);
if(meshSpecs[0]->nsNames.size() > 0) // Build a nodeset evaluator if nodesets are present
constructDirichletEvaluators(*meshSpecs[0]);
if(meshSpecs[0]->ssNames.size() > 0) // Build a sideset evaluator if sidesets are present
constructNeumannEvaluators(meshSpecs[0]);
#ifdef ALBANY_ATO
if( params->isType<Teuchos::RCP<ATO::Topology>>("Topology") )
setupTopOpt(meshSpecs,stateMgr);
#endif
}
示例9: p
DataTransferKit::FieldContainer<double>
MultiAppDTKUserObjectEvaluator::evaluate(const Teuchos::ArrayRCP<GlobalOrdinal>& bids, const Teuchos::ArrayRCP<double>& coords)
{
Teuchos::RCP<const Teuchos::Comm<int> > comm = Teuchos::rcp(new Teuchos::MpiComm<int>(Teuchos::rcp(new Teuchos::OpaqueWrapper<MPI_Comm>(libMesh::COMM_WORLD))));
int num_values = bids.size();
Teuchos::ArrayRCP<double> evaluated_data(num_values);
unsigned int dim = 3; // TODO: REPLACE ME!!!!!!!!!
for (GlobalOrdinal i=0; i<num_values; i++)
{
// See if this app is on this processor
if (std::binary_search(_box_ids.begin(), _box_ids.end(), bids[i]))
{
GlobalOrdinal app = bids[i];
Point p;
for(unsigned int j=0; j<dim; j++)
p(j) = coords[(j*num_values)+i];
evaluated_data[i] = _multi_app.appUserObjectBase(app, _user_object_name).spatialValue(p);
}
else
evaluated_data[i] = 0.0;
}
return DataTransferKit::FieldContainer<double>(evaluated_data, 1);
}
示例10: buildEvaluators
void
Albany::PoissonsEquationProblem::
buildProblem(
Teuchos::ArrayRCP<Teuchos::RCP<Albany::MeshSpecsStruct> > meshSpecs,
Albany::StateManager& stateMgr)
{
int physSets = meshSpecs.size();
*out << "Num MeshSpecs: " << physSets << '\n';
fm.resize(physSets);
bool haveSidesets = false;
*out << "Calling PoissonsEquationProblem::buildEvaluators" << '\n';
for (int ps = 0; ps < physSets; ++ps) {
fm[ps] = Teuchos::rcp(new PHX::FieldManager<PHAL::AlbanyTraits>);
buildEvaluators(*fm[ps], *meshSpecs[ps], stateMgr, BUILD_RESID_FM,
Teuchos::null);
if (meshSpecs[ps]->ssNames.size() > 0) haveSidesets = true;
}
constructDirichletEvaluators(*meshSpecs[0]);
if( haveSidesets )
constructNeumannEvaluators(meshSpecs[0]);
if( params->isType<Teuchos::RCP<ATO::Topology> >("Topology") )
setupTopOpt(meshSpecs,stateMgr);
}
示例11: evaluate
MyField evaluate(
const Teuchos::ArrayRCP<MyMesh::global_ordinal_type>& elements,
const Teuchos::ArrayRCP<double>& coords )
{
int num_elements = elements.size();
MyField evaluated_data( num_elements, 3 );
for ( int n = 0; n < num_elements; ++n )
{
if ( std::find( d_mesh.elementsBegin(),
d_mesh.elementsEnd(),
elements[n] ) != d_mesh.elementsEnd() )
{
*(evaluated_data.begin() + n ) = d_comm->getRank() + 1.0;
*(evaluated_data.begin() + num_elements + n ) =
d_comm->getRank() + 1.0;
*(evaluated_data.begin() + 2*num_elements + n ) =
d_comm->getRank() + 1.0;
}
else
{
*(evaluated_data.begin() + n ) = 0.0;
*(evaluated_data.begin() + num_elements + n ) = 0.0;
*(evaluated_data.begin() + 2*num_elements + n ) = 0.0;
}
}
return evaluated_data;
}
示例12: set_local
//-----------------------------------------------------------------------------
void TpetraVector::set_local(const std::vector<double>& values)
{
dolfin_assert(!_x.is_null());
const std::size_t num_values = local_size();
if (values.size() != num_values)
{
dolfin_error("TpetraVector.cpp",
"set local values of Tpetra vector",
"Size of values array is not equal to local vector size");
}
if (num_values == 0)
return;
Teuchos::ArrayRCP<double> arr = _x->getDataNonConst(0);
std::copy(values.begin(), values.end(), arr.get());
}
示例13: ownedActive
void
Filtered_UniqueGlobalIndexer<LocalOrdinalT,GlobalOrdinalT>::
getOwnedAndGhostedNotFilteredIndicator(std::vector<int> & indicator) const
{
using Teuchos::RCP;
typedef GlobalOrdinalT GO;
typedef LocalOrdinalT LO;
typedef panzer::TpetraNodeType Node;
typedef Tpetra::Map<LO, GO, Node> Map;
typedef Tpetra::Vector<GO,LO,GO,Node> Vector;
typedef Tpetra::Import<LO,GO,Node> Import;
std::vector<GlobalOrdinalT> ownedIndices;
std::vector<GlobalOrdinalT> ghostedIndices;
// build owned and ghosted maps
getOwnedIndices(ownedIndices);
getOwnedAndGhostedIndices(ghostedIndices);
RCP<const Map> ownedMap
= Tpetra::createNonContigMap<LO,GO>(ownedIndices,getComm());
RCP<const Map> ghostedMap
= Tpetra::createNonContigMap<LO,GO>(ghostedIndices,getComm());
// allocate the owned vector, mark those GIDs as unfiltered
// (they are by definition)
Vector ownedActive(ownedMap);
ownedActive.putScalar(1);
// Initialize all indices to zero
Vector ghostedActive(ghostedMap);
ghostedActive.putScalar(0);
// do communication, marking unfiltered indices as 1 (filtered
// indices locally are marked as zero)
Import importer(ownedMap,ghostedMap);
ghostedActive.doImport(ownedActive,importer,Tpetra::INSERT);
Teuchos::ArrayRCP<const GO> data = ghostedActive.getData();
// copy communicated data (clear it out first)
indicator.clear();
indicator.insert(indicator.end(),data.begin(),data.end());
}
示例14: evaluate
DataTransferKit::FieldContainer<double> evaluate(
const Teuchos::ArrayRCP<int>& gids,
const Teuchos::ArrayRCP<double>& coords )
{
Teuchos::ArrayRCP<double> evaluated_data( gids.size() );
for ( int n = 0; n < gids.size(); ++n )
{
if ( std::find( d_geom_gids.begin(),
d_geom_gids.end(),
gids[n] ) != d_geom_gids.end() )
{
evaluated_data[n] = 1.0 + gids[n];
}
else
{
evaluated_data[n] = 0.0;
}
}
return DataTransferKit::FieldContainer<double>( evaluated_data, 1 );
}
示例15: evaluate
MyField evaluate(
const Teuchos::ArrayRCP<int>& gids,
const Teuchos::ArrayRCP<double>& coords )
{
MyField evaluated_data( gids.size(), 1 );
for ( int n = 0; n < gids.size(); ++n )
{
if ( std::find( d_geom_gids.begin(),
d_geom_gids.end(),
gids[n] ) != d_geom_gids.end() )
{
*(evaluated_data.begin() + n ) = 1.0;
}
else
{
*(evaluated_data.begin() + n ) = 0.0;
}
}
return evaluated_data;
}