本文整理汇总了C++中teuchos::RCP::GlobalLength方法的典型用法代码示例。如果您正苦于以下问题:C++ RCP::GlobalLength方法的具体用法?C++ RCP::GlobalLength怎么用?C++ RCP::GlobalLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类teuchos::RCP
的用法示例。
在下文中一共展示了RCP::GlobalLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dimension
int dimension() const {return epetra_vec_->GlobalLength();}
示例2: cellData
//.........这里部分代码省略.........
ICFieldDescriptor densDesc;
densDesc.fieldName = "DENSITY";
densDesc.basisName = "Const";
densDesc.basisOrder = 0;
ICFieldDescriptor condDesc;
condDesc.fieldName = "CONDUCTIVITY";
condDesc.basisName = "HGrad";
condDesc.basisOrder = 1;
RCP<panzer::PureBasis> const_basis = rcp(new panzer::PureBasis(densDesc.basisName,densDesc.basisOrder,cellData));
RCP<panzer::PureBasis> hgrad_basis = rcp(new panzer::PureBasis(condDesc.basisName,condDesc.basisOrder,cellData));
RCP<const panzer::FieldPattern> constFP = rcp(new panzer::Intrepid2FieldPattern(const_basis->getIntrepid2Basis()));
RCP<const panzer::FieldPattern> hgradFP = rcp(new panzer::Intrepid2FieldPattern(hgrad_basis->getIntrepid2Basis()));
// setup DOF manager
/////////////////////////////////////////////
RCP<panzer::ConnManager<int,int> > conn_manager
= Teuchos::rcp(new panzer_stk_classic::STKConnManager<int>(mesh));
RCP<panzer::DOFManager<int,int> > dofManager
= rcp(new panzer::DOFManager<int,int>(conn_manager,MPI_COMM_WORLD));
dofManager->addField(densDesc.fieldName, constFP);
dofManager->addField(condDesc.fieldName, hgradFP);
dofManager->buildGlobalUnknowns();
Teuchos::RCP<panzer::EpetraLinearObjFactory<panzer::Traits,int> > elof
= Teuchos::rcp(new panzer::EpetraLinearObjFactory<panzer::Traits,int>(comm.getConst(),dofManager));
Teuchos::RCP<panzer::LinearObjFactory<panzer::Traits> > lof = elof;
// setup worksets
/////////////////////////////////////////////
std::map<std::string,panzer::WorksetNeeds> needs;
needs["eblock-0_0"].cellData = cellData;
needs["eblock-0_0"].int_rules.push_back(int_rule);
needs["eblock-0_0"].bases = { const_basis, hgrad_basis};
needs["eblock-0_0"].rep_field_name = { densDesc.fieldName, condDesc.fieldName};
needs["eblock-1_0"].cellData = cellData;
needs["eblock-1_0"].int_rules.push_back(int_rule);
needs["eblock-1_0"].bases = { const_basis, hgrad_basis};
needs["eblock-1_0"].rep_field_name = { densDesc.fieldName, condDesc.fieldName};
Teuchos::RCP<panzer_stk_classic::WorksetFactory> wkstFactory
= Teuchos::rcp(new panzer_stk_classic::WorksetFactory(mesh)); // build STK workset factory
Teuchos::RCP<panzer::WorksetContainer> wkstContainer // attach it to a workset container (uses lazy evaluation)
= Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,needs));
// setup field manager builder
/////////////////////////////////////////////
// Add in the application specific closure model factory
panzer::ClosureModelFactory_TemplateManager<panzer::Traits> cm_factory;
user_app::STKModelFactory_TemplateBuilder cm_builder;
cm_factory.buildObjects(cm_builder);
Teuchos::ParameterList user_data("User Data");
Teuchos::ParameterList ic_closure_models("Initial Conditions");
ic_closure_models.sublist("eblock-0_0").sublist(densDesc.fieldName).set<double>("Value",3.0);
ic_closure_models.sublist("eblock-0_0").sublist(condDesc.fieldName).set<double>("Value",9.0);
ic_closure_models.sublist("eblock-1_0").sublist(densDesc.fieldName).set<double>("Value",3.0);
ic_closure_models.sublist("eblock-1_0").sublist(condDesc.fieldName).set<double>("Value",9.0);
std::map<std::string,Teuchos::RCP<const shards::CellTopology> > block_ids_to_cell_topo;
block_ids_to_cell_topo["eblock-0_0"] = mesh->getCellTopology("eblock-0_0");
block_ids_to_cell_topo["eblock-1_0"] = mesh->getCellTopology("eblock-1_0");
std::map<std::string,std::vector<ICFieldDescriptor> > block_ids_to_fields;
block_ids_to_fields["eblock-0_0"] = {densDesc,condDesc};
block_ids_to_fields["eblock-1_0"] = {densDesc,condDesc};
int workset_size = 4;
Teuchos::RCP<panzer::LinearObjContainer> loc = lof->buildLinearObjContainer();
lof->initializeContainer(panzer::LinearObjContainer::X,*loc);
Teuchos::RCP<panzer::EpetraLinearObjContainer> eloc = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(loc);
Teuchos::RCP<Thyra::VectorBase<double> > vec = eloc->get_x_th();
// this is the Function under test
panzer::setupControlInitialCondition(block_ids_to_cell_topo,
block_ids_to_fields,
*wkstContainer,
*lof,cm_factory,ic_closure_models,user_data,
workset_size,
0.0, // t0
vec);
Teuchos::RCP<Epetra_Vector> x = eloc->get_x();
out << x->GlobalLength() << " " << x->MyLength() << std::endl;
for (int i=0; i < x->MyLength(); ++i) {
double v = (*x)[i];
TEST_ASSERT(v==3.0 || v==9.0);
}
}
示例3: Write
void NetCDFFileIOHandler::Write( const Teuchos::RCP<const Epetra_MultiVector>& MV, const std::string& filename )
{
#ifdef EPETRA_MPI
Epetra_MpiComm comm( MPI_COMM_WORLD );
#else
Epetra_SerialComm comm;
#endif
//
// Variables for NetCDF
//
int status;
int ncid, len_string_id, num_nodes_id, num_nod_var_id, row_id, col_id, ss_id, name_nod_var_id;
int i,j;
int ss_dimids[2];
//size_t start[1],count[1];
size_t start2[2],count2[2];
//
// Variables for Epetra
//
int num_vecs = MV->NumVectors();
int dim = MV->GlobalLength();
Epetra_Map Map( dim, 0, comm );
Epetra_Map* Proc0Map;
const Epetra_Vector* col_newMV;
//
// Create map putting all elements of vector on Processor 0.
//
if ( comm.MyPID() == 0 ) {
Proc0Map = new Epetra_Map( dim, dim, 0, comm );
} else {
Proc0Map = new Epetra_Map( dim, 0, 0, comm );
}
Epetra_Vector Proc0Vector( *Proc0Map );
//
// Create an exporter to get the global Epetra_Vector to a local Epetra_Vector.
//
Epetra_Export exporter( MV->Map(), *Proc0Map );
//
if ( comm.MyPID() == 0 ) {
//
// Open basis output file and define output variables going into the file.
//
std::string temp_filename = out_path + filename;
status=nc_create(temp_filename.c_str(),NC_CLOBBER,&ncid);
if (status != NC_NOERR) handle_error(status);
status=nc_def_dim(ncid,"len_string",(long)len_string,&len_string_id);
if (status != NC_NOERR) handle_error(status);
status=nc_def_dim(ncid,"num_nodes",(long)num_nodes,&num_nodes_id);
if (status != NC_NOERR) handle_error(status);
status=nc_def_dim(ncid,"num_nod_var",(long)num_nod_var,&num_nod_var_id);
if (status != NC_NOERR) handle_error(status);
status=nc_def_dim(ncid,"row",NC_UNLIMITED,&row_id);
if (status != NC_NOERR) handle_error(status);
status=nc_def_dim(ncid,"col",(long)dim,&col_id);
if (status != NC_NOERR) handle_error(status);
ss_dimids[0]=row_id;
ss_dimids[1]=col_id;
status=nc_def_var(ncid,"snapshot",NC_FLOAT,2,ss_dimids,&ss_id);
if (status != NC_NOERR) handle_error(status);
ss_dimids[0]=num_nod_var_id;
ss_dimids[1]=len_string_id;
status=nc_def_var(ncid,"name_nod_var",NC_CHAR,2,ss_dimids,&name_nod_var_id);
if (status != NC_NOERR) handle_error(status);
status=nc_enddef(ncid);
if (status != NC_NOERR) handle_error(status);
}
// Initialize data pointers for writing out basis to file.
float* temp_vec = 0;
if ( comm.MyPID() == 0 )
temp_vec = new float[ dim ];
for (i=0; i<num_vecs; ++i) {
//
// Get column of Epetra_MultiVector in terms of Epetra_Vector.
//
col_newMV = (*MV)( i );
//
Proc0Vector.Export(*col_newMV, exporter, Insert);
//
if ( comm.MyPID()==0 ) {
start2[0] = i;
start2[1] = 0;
count2[0] = 1;
count2[1] = dim;
//
// Copy double precision vector to single precision and write out.
//
for (j=0; j<dim; ++j)
temp_vec[j] = Proc0Vector[j];
//.........这里部分代码省略.........
示例4: rcp
//.........这里部分代码省略.........
TEST_ASSERT(myGlobalElements[4] == 0);
TEST_ASSERT(myGlobalElements[5] == 2);
TEST_ASSERT(myGlobalElements[6] == 4);
TEST_ASSERT(myGlobalElements[7] == 6);
}
// check the bond map
// the horizon was chosen such that each point should have three neighbors
// note that if the NeighborhoodType parameter is not set to Spherical, this will fail
Teuchos::RCP<const Epetra_BlockMap> bondMap = discretization->getGlobalBondMap();
TEST_ASSERT(bondMap->NumGlobalElements() == 8);
TEST_ASSERT(bondMap->NumMyElements() == 4);
TEST_ASSERT(bondMap->IndexBase() == 0);
TEST_ASSERT(bondMap->UniqueGIDs() == true);
myGlobalElements = bondMap->MyGlobalElements();
if(rank == 0){
TEST_ASSERT(myGlobalElements[0] == 0);
TEST_ASSERT(myGlobalElements[1] == 2);
TEST_ASSERT(myGlobalElements[2] == 4);
TEST_ASSERT(myGlobalElements[3] == 6);
}
if(rank == 1){
TEST_ASSERT(myGlobalElements[0] == 5);
TEST_ASSERT(myGlobalElements[1] == 7);
TEST_ASSERT(myGlobalElements[2] == 1);
TEST_ASSERT(myGlobalElements[3] == 3);
}
TEST_ASSERT(discretization->getNumBonds() == 4*3);
// check the initial positions
// all three coordinates are contained in a single vector
Teuchos::RCP<Epetra_Vector> initialX = discretization->getInitialX();
TEST_ASSERT(initialX->MyLength() == 4*3);
TEST_ASSERT(initialX->GlobalLength() == 8*3);
if(rank == 0){
TEST_FLOATING_EQUALITY((*initialX)[0], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[1], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[2], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[3], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[4], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[5], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[6], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[7], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[8], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[9], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[10], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[11], 0.75, 1.0e-16);
}
if(rank == 1){
TEST_FLOATING_EQUALITY((*initialX)[0], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[1], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[2], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[3], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[4], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[5], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[6], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[7], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[8], 0.25, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[9], 0.75, 1.0e-16);
TEST_FLOATING_EQUALITY((*initialX)[10], 0.75, 1.0e-16);
示例5: closure_models
//.........这里部分代码省略.........
panzer::buildPhysicsBlocks(block_ids_to_physics_ids,
block_ids_to_cell_topo,
ipb,
default_integration_order,
workset_size,
eqset_factory,
gd,
false,
physics_blocks);
}
// setup worksets
/////////////////////////////////////////////
Teuchos::RCP<panzer_stk::WorksetFactory> wkstFactory
= Teuchos::rcp(new panzer_stk::WorksetFactory(mesh)); // build STK workset factory
Teuchos::RCP<panzer::WorksetContainer> wkstContainer // attach it to a workset container (uses lazy evaluation)
= Teuchos::rcp(new panzer::WorksetContainer(wkstFactory,physics_blocks,workset_size));
// get vector of element blocks
std::vector<std::string> elementBlocks;
mesh->getElementBlockNames(elementBlocks);
// build volume worksets from container
std::map<panzer::BC,Teuchos::RCP<std::map<unsigned,panzer::Workset> >,panzer::LessBC> bc_worksets;
panzer::getSideWorksetsFromContainer(*wkstContainer,bcs,bc_worksets);
// setup DOF manager
/////////////////////////////////////////////
const Teuchos::RCP<panzer::ConnManager<int,int> > conn_manager
= Teuchos::rcp(new panzer_stk::STKConnManager<int>(mesh));
Teuchos::RCP<const panzer::UniqueGlobalIndexerFactory<int,int,int,int> > indexerFactory
= Teuchos::rcp(new panzer::DOFManagerFactory<int,int>);
const Teuchos::RCP<panzer::UniqueGlobalIndexer<int,int> > dofManager
= indexerFactory->buildUniqueGlobalIndexer(Teuchos::opaqueWrapper(MPI_COMM_WORLD),physics_blocks,conn_manager);
// and linear object factory
Teuchos::RCP<const Teuchos::MpiComm<int> > tComm = Teuchos::rcp(new Teuchos::MpiComm<int>(MPI_COMM_WORLD));
Teuchos::RCP<panzer::EpetraLinearObjFactory<panzer::Traits,int> > elof
= Teuchos::rcp(new panzer::EpetraLinearObjFactory<panzer::Traits,int>(tComm.getConst(),dofManager));
Teuchos::RCP<panzer::LinearObjFactory<panzer::Traits> > lof = elof;
// setup field manager builder
/////////////////////////////////////////////
// Add in the application specific closure model factory
panzer::ClosureModelFactory_TemplateManager<panzer::Traits> cm_factory;
user_app::STKModelFactory_TemplateBuilder cm_builder;
cm_factory.buildObjects(cm_builder);
Teuchos::ParameterList closure_models("Closure Models");
closure_models.sublist("solid").sublist("SOURCE_TEMPERATURE").set<double>("Value",1.0);
closure_models.sublist("solid").sublist("SOURCE_ELECTRON_TEMPERATURE").set<double>("Value",1.0);
closure_models.sublist("ion solid").sublist("SOURCE_ION_TEMPERATURE").set<double>("Value",1.0);
Teuchos::ParameterList user_data("User Data");
user_data.sublist("Panzer Data").set("Mesh", mesh);
user_data.sublist("Panzer Data").set("DOF Manager", dofManager);
user_data.sublist("Panzer Data").set("Linear Object Factory", lof);
fmb.setWorksetContainer(wkstContainer);
fmb.setupVolumeFieldManagers(physics_blocks,cm_factory,closure_models,*elof,user_data);
fmb.setupBCFieldManagers(bcs,physics_blocks,*eqset_factory,cm_factory,bc_factory,closure_models,*elof,user_data);
Teuchos::ParameterList ic_closure_models("Initial Conditions");
ic_closure_models.sublist("eblock-0_0").sublist("TEMPERATURE").set<double>("Value",3.0);
ic_closure_models.sublist("eblock-0_0").sublist("ELECTRON_TEMPERATURE").set<double>("Value",3.0);
ic_closure_models.sublist("eblock-1_0").sublist("TEMPERATURE").set<double>("Value",3.0);
ic_closure_models.sublist("eblock-1_0").sublist("ION_TEMPERATURE").set<double>("Value",3.0);
std::map<std::string, Teuchos::RCP< PHX::FieldManager<panzer::Traits> > > phx_ic_field_managers;
panzer::setupInitialConditionFieldManagers(*wkstContainer,
physics_blocks,
cm_factory,
ic_closure_models,
*elof,
user_data,
true,
"initial_condition_test",
phx_ic_field_managers);
Teuchos::RCP<panzer::LinearObjContainer> loc = elof->buildLinearObjContainer();
elof->initializeContainer(panzer::EpetraLinearObjContainer::X,*loc);
Teuchos::RCP<panzer::EpetraLinearObjContainer> eloc = Teuchos::rcp_dynamic_cast<EpetraLinearObjContainer>(loc);
eloc->get_x()->PutScalar(0.0);
panzer::evaluateInitialCondition(*wkstContainer, phx_ic_field_managers, loc, *elof, 0.0);
Teuchos::RCP<Epetra_Vector> x = eloc->get_x();
out << x->GlobalLength() << " " << x->MyLength() << std::endl;
for (int i=0; i < x->MyLength(); ++i)
TEST_FLOATING_EQUALITY((*x)[i], 3.0, 1.0e-10);
}