int dimension() const {return epetra_vec_->GlobalLength();}
TEUCHOS_UNIT_TEST(initial_condition_control, control) { using Teuchos::RCP; using Teuchos::rcp; Teuchos::RCP<const Epetra_Comm> comm = Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD)); // setup mesh ///////////////////////////////////////////// RCP<panzer_stk_classic::STK_Interface> mesh; { RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList); pl->set<int>("X Elements",2); pl->set<int>("Y Elements",2); pl->set<int>("X Blocks",2); pl->set<int>("Y Blocks",1); panzer_stk_classic::SquareQuadMeshFactory mesh_factory; mesh_factory.setParameterList(pl); mesh = mesh_factory.buildMesh(MPI_COMM_WORLD); mesh->writeToExodus("test.exo"); } RCP<const shards::CellTopology> ct = mesh->getCellTopology("eblock-0_0"); panzer::CellData cellData(4,ct); RCP<panzer::IntegrationRule> int_rule = rcp(new panzer::IntegrationRule(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); } }
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]; status=nc_put_vara_float(ncid,ss_id,start2,count2,temp_vec); if (status != NC_NOERR) handle_error(status); } } // Write the list of names of the nodal variables to the Netcdf file */ if ( comm.MyPID() == 0 ) { for(i=0; i<num_nod_var; ++i) { start2[0] = i; start2[1] = 0; count2[0] = 1; count2[1] = strlen(var_name[i]); /* printf("start2=%d %d\n",start2[0],start2[1]); printf("count2=%d %d\n",count2[0],count2[1]); */ status=nc_put_vara_text(ncid,name_nod_var_id,start2,count2,var_name[i]); if (status != NC_NOERR) handle_error(status); } status=nc_close(ncid); if (status != NC_NOERR) handle_error(status); } // Clean up. delete Proc0Map; if (temp_vec) delete [] temp_vec; }
TEUCHOS_UNIT_TEST(PdQuickGridDiscretization_MPI_np2, SimpleTensorProductMeshTest) { Teuchos::RCP<Epetra_Comm> comm; comm = rcp(new Epetra_MpiComm(MPI_COMM_WORLD)); int numProcs = comm->NumProc(); int rank = comm->MyPID(); TEST_COMPARE(numProcs, ==, 2); if(numProcs != 2){ std::cerr << "Unit test runtime ERROR: utPeridigm_PdQuickGridDiscretization_MPI_np2 only makes sense on 2 processors" << std::endl; return; } RCP<ParameterList> discParams = rcp(new ParameterList); // create a 2x2x2 discretization // specify a spherical neighbor search with the horizon a tad longer than the mesh spacing discParams->set("Type", "PdQuickGrid"); discParams->set("NeighborhoodType", "Spherical"); ParameterList& quickGridParams = discParams->sublist("TensorProduct3DMeshGenerator"); quickGridParams.set("Type", "PdQuickGrid"); quickGridParams.set("X Origin", 0.0); quickGridParams.set("Y Origin", 0.0); quickGridParams.set("Z Origin", 0.0); quickGridParams.set("X Length", 1.0); quickGridParams.set("Y Length", 1.0); quickGridParams.set("Z Length", 1.0); quickGridParams.set("Number Points X", 2); quickGridParams.set("Number Points Y", 2); quickGridParams.set("Number Points Z", 2); // initialize the horizon manager and set the horizon to 0.501 ParameterList blockParameterList; ParameterList& blockParams = blockParameterList.sublist("My Block"); blockParams.set("Block Names", "block_1"); blockParams.set("Horizon", 0.501); PeridigmNS::HorizonManager::self().loadHorizonInformationFromBlockParameters(blockParameterList); // create the discretization RCP<PdQuickGridDiscretization> discretization = rcp(new PdQuickGridDiscretization(comm, discParams)); // sanity check, calling with a dimension other than 1 or 3 should throw an exception TEST_THROW(discretization->getGlobalOwnedMap(0), Teuchos::Exceptions::InvalidParameter); TEST_THROW(discretization->getGlobalOwnedMap(2), Teuchos::Exceptions::InvalidParameter); TEST_THROW(discretization->getGlobalOwnedMap(4), Teuchos::Exceptions::InvalidParameter); // basic checks on the 1d map Teuchos::RCP<const Epetra_BlockMap> map = discretization->getGlobalOwnedMap(1); TEST_ASSERT(map->NumGlobalElements() == 8); TEST_ASSERT(map->NumMyElements() == 4); TEST_ASSERT(map->ElementSize() == 1); TEST_ASSERT(map->IndexBase() == 0); TEST_ASSERT(map->UniqueGIDs() == true); int* myGlobalElements = map->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); } // check the 1d overlap map // for this simple discretization, everything should be ghosted on both processors Teuchos::RCP<const Epetra_BlockMap> overlapMap = discretization->getGlobalOverlapMap(1); TEST_ASSERT(overlapMap->NumGlobalElements() == 16); TEST_ASSERT(overlapMap->NumMyElements() == 8); TEST_ASSERT(overlapMap->ElementSize() == 1); TEST_ASSERT(overlapMap->IndexBase() == 0); TEST_ASSERT(overlapMap->UniqueGIDs() == false); myGlobalElements = overlapMap->MyGlobalElements(); if(rank == 0){ TEST_ASSERT(myGlobalElements[0] == 0); TEST_ASSERT(myGlobalElements[1] == 2); TEST_ASSERT(myGlobalElements[2] == 4); TEST_ASSERT(myGlobalElements[3] == 6); TEST_ASSERT(myGlobalElements[4] == 1); TEST_ASSERT(myGlobalElements[5] == 3); TEST_ASSERT(myGlobalElements[6] == 5); TEST_ASSERT(myGlobalElements[7] == 7); } 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(myGlobalElements[4] == 0); TEST_ASSERT(myGlobalElements[5] == 2); TEST_ASSERT(myGlobalElements[6] == 4); TEST_ASSERT(myGlobalElements[7] == 6); } // same checks for 3d map map = discretization->getGlobalOwnedMap(3); TEST_ASSERT(map->NumGlobalElements() == 8); TEST_ASSERT(map->NumMyElements() == 4); TEST_ASSERT(map->ElementSize() == 3); TEST_ASSERT(map->IndexBase() == 0); TEST_ASSERT(map->UniqueGIDs() == true); myGlobalElements = map->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); } // check the 3d overlap map // for this simple discretization, everything should be ghosted on both processors overlapMap = discretization->getGlobalOverlapMap(3); TEST_ASSERT(overlapMap->NumGlobalElements() == 16); TEST_ASSERT(overlapMap->NumMyElements() == 8); TEST_ASSERT(overlapMap->ElementSize() == 3); TEST_ASSERT(overlapMap->IndexBase() == 0); TEST_ASSERT(overlapMap->UniqueGIDs() == false); myGlobalElements = overlapMap->MyGlobalElements(); if(rank == 0){ TEST_ASSERT(myGlobalElements[0] == 0); TEST_ASSERT(myGlobalElements[1] == 2); TEST_ASSERT(myGlobalElements[2] == 4); TEST_ASSERT(myGlobalElements[3] == 6); TEST_ASSERT(myGlobalElements[4] == 1); TEST_ASSERT(myGlobalElements[5] == 3); TEST_ASSERT(myGlobalElements[6] == 5); TEST_ASSERT(myGlobalElements[7] == 7); } 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(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); TEST_FLOATING_EQUALITY((*initialX)[11], 0.25, 1.0e-16); } // check cell volumes Teuchos::RCP<Epetra_Vector> volume = discretization->getCellVolume(); TEST_ASSERT(volume->MyLength() == 4); TEST_ASSERT(volume->GlobalLength() == 8); for(int i=0 ; i<volume->MyLength() ; ++i) TEST_FLOATING_EQUALITY((*volume)[i], 0.125, 1.0e-16); // check the neighbor lists Teuchos::RCP<PeridigmNS::NeighborhoodData> neighborhoodData = discretization->getNeighborhoodData(); TEST_ASSERT(neighborhoodData->NumOwnedPoints() == 4); int* ownedIds = neighborhoodData->OwnedIDs(); TEST_ASSERT(ownedIds[0] == 0); TEST_ASSERT(ownedIds[1] == 1); TEST_ASSERT(ownedIds[2] == 2); TEST_ASSERT(ownedIds[3] == 3); TEST_ASSERT(neighborhoodData->NeighborhoodListSize() == 16); int* neighborhood = neighborhoodData->NeighborhoodList(); int* neighborhoodPtr = neighborhoodData->NeighborhoodPtr(); // remember, these are local IDs on each processor, // which includes both owned and ghost nodes (confusing!) if(rank == 0){ TEST_ASSERT(neighborhoodPtr[0] == 0); TEST_ASSERT(neighborhood[0] == 3); TEST_ASSERT(neighborhood[1] == 4); TEST_ASSERT(neighborhood[2] == 1); TEST_ASSERT(neighborhood[3] == 2); TEST_ASSERT(neighborhoodPtr[1] == 4); TEST_ASSERT(neighborhood[4] == 3); TEST_ASSERT(neighborhood[5] == 0); TEST_ASSERT(neighborhood[6] == 5); TEST_ASSERT(neighborhood[7] == 3); TEST_ASSERT(neighborhoodPtr[2] == 8); TEST_ASSERT(neighborhood[8] == 3); TEST_ASSERT(neighborhood[9] == 0); TEST_ASSERT(neighborhood[10] == 6); TEST_ASSERT(neighborhood[11] == 3); TEST_ASSERT(neighborhoodPtr[3] == 12); TEST_ASSERT(neighborhood[12] == 3); TEST_ASSERT(neighborhood[13] == 1); TEST_ASSERT(neighborhood[14] == 2); TEST_ASSERT(neighborhood[15] == 7); } if(rank == 1){ TEST_ASSERT(neighborhoodPtr[0] == 0); TEST_ASSERT(neighborhood[0] == 3); TEST_ASSERT(neighborhood[1] == 2); TEST_ASSERT(neighborhood[2] == 6); TEST_ASSERT(neighborhood[3] == 1); TEST_ASSERT(neighborhoodPtr[1] == 4); TEST_ASSERT(neighborhood[4] == 3); TEST_ASSERT(neighborhood[5] == 3); TEST_ASSERT(neighborhood[6] == 0); TEST_ASSERT(neighborhood[7] == 7); TEST_ASSERT(neighborhoodPtr[2] == 8); TEST_ASSERT(neighborhood[8] == 3); TEST_ASSERT(neighborhood[9] == 4); TEST_ASSERT(neighborhood[10] == 3); TEST_ASSERT(neighborhood[11] == 0); TEST_ASSERT(neighborhoodPtr[3] == 12); TEST_ASSERT(neighborhood[12] == 3); TEST_ASSERT(neighborhood[13] == 2); TEST_ASSERT(neighborhood[14] == 5); TEST_ASSERT(neighborhood[15] == 1); } }
TEUCHOS_UNIT_TEST(initial_condition_builder2, block_structure) { using Teuchos::RCP; panzer_stk::STK_ExodusReaderFactory mesh_factory; Teuchos::RCP<user_app::MyFactory> eqset_factory = Teuchos::rcp(new user_app::MyFactory); user_app::BCFactory bc_factory; const std::size_t workset_size = 20; panzer::FieldManagerBuilder fmb; // setup mesh ///////////////////////////////////////////// RCP<panzer_stk::STK_Interface> mesh; { RCP<Teuchos::ParameterList> pl = rcp(new Teuchos::ParameterList); pl->set("File Name","block-decomp.exo"); mesh_factory.setParameterList(pl); mesh = mesh_factory.buildMesh(MPI_COMM_WORLD); mesh->writeToExodus("test.exo"); } // setup physic blocks ///////////////////////////////////////////// Teuchos::RCP<Teuchos::ParameterList> ipb = Teuchos::parameterList("Physics Blocks"); std::vector<panzer::BC> bcs; std::vector<Teuchos::RCP<panzer::PhysicsBlock> > physics_blocks; { testInitialzation_blockStructure(ipb, bcs); std::map<std::string,std::string> block_ids_to_physics_ids; block_ids_to_physics_ids["eblock-0_0"] = "PB A"; block_ids_to_physics_ids["eblock-1_0"] = "PB B"; 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"); Teuchos::RCP<panzer::GlobalData> gd = panzer::createGlobalData(); int default_integration_order = 1; 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); }