// @HEADER // ***************************************************************************** // Panzer: A partial differential equation assembly // engine for strongly coupled complex multiphysics systems // // Copyright 2011 NTESS and the Panzer contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #include #include #include #include #include #include #include "Panzer_TpetraLinearObjFactory.hpp" #include "Panzer_Traits.hpp" // for testing gather/scatter construction #include "Panzer_PureBasis.hpp" #include "Panzer_IntegrationRule.hpp" #include "Panzer_CellData.hpp" #include "Panzer_PauseToAttach.hpp" #include "UnitTest_GlobalIndexer.hpp" #ifdef HAVE_MPI #include "Teuchos_DefaultMpiComm.hpp" #else #include "NO_SERIAL_BUILD.h" #endif #include "Tpetra_Map.hpp" #include "Tpetra_MultiVector.hpp" #include "Thyra_TpetraThyraWrappers.hpp" using Teuchos::rcp; using Teuchos::rcp_dynamic_cast; using Teuchos::RCP; using Teuchos::rcpFromRef; typedef Tpetra::MultiVector MultiVector; typedef Tpetra::Vector Vector; typedef Tpetra::CrsMatrix CrsMatrix; typedef Tpetra::CrsGraph CrsGraph; typedef Tpetra::Map Map; namespace panzer { /* RCP getTpetraMultiVector(RCP > & vec,const Map & map) { return Thyra::get_Tpetra_MultiVector(map,vec); } */ TEUCHOS_UNIT_TEST(tTpetraLinearObjFactory, gather_scatter_constr) { // build global (or serial communicator) #ifdef HAVE_MPI Teuchos::RCP > tComm = Teuchos::rcp(new Teuchos::MpiComm(Teuchos::opaqueWrapper(MPI_COMM_WORLD))); #else Teuchos::RCP > failure_comm = THIS_,_SERIAL_BUILDS_,_SHOULD_FAIL; #endif using Teuchos::RCP; using Teuchos::rcp; using Teuchos::rcp_dynamic_cast; int myRank = tComm->getRank(); int numProc = tComm->getSize(); // panzer::pauseToAttach(); RCP indexer = rcp(new unit_test::GlobalIndexer(myRank,numProc)); // setup factory Teuchos::RCP > la_factory = Teuchos::rcp(new panzer::TpetraLinearObjFactory(tComm.getConst(),indexer)); // build parameter lists for gather and scatters ////////////////////////////////////////////////////////////////// std::size_t numCells = 10; Teuchos::ParameterList gatherParams; { Teuchos::RCP topo = Teuchos::rcp(new shards::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<4> >())); // auxiliary information needed to construct basis object std::string basisType = "Q1"; panzer::CellData cellData(numCells,topo); // build DOF names RCP > dofNames = rcp(new std::vector); dofNames->push_back("ux"); // in practice these probably would not be gathered together! dofNames->push_back("p"); // build basis RCP basis = rcp(new panzer::PureBasis(basisType,1,cellData)); // build gather parameter list gatherParams.set > >("DOF Names",dofNames); gatherParams.set > >("Indexer Names",dofNames); gatherParams.set >("Basis",basis); } Teuchos::ParameterList scatterParams; { Teuchos::RCP topo = Teuchos::rcp(new shards::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<4> >())); std::string basisType = "Q1"; panzer::CellData cellData(numCells,topo); // build basis RCP basis = rcp(new panzer::PureBasis(basisType,1,cellData)); std::string scatterName = "Residual_NS"; // build DOF names RCP > evaluatedNames = rcp(new std::vector); evaluatedNames->push_back("Residual_ux"); // in practice these probably would not be scattered together! evaluatedNames->push_back("Residual_p"); // build evaluated map RCP > evaluatedMap = rcp(new std::map); evaluatedMap->insert(std::make_pair("Residual_ux","ux")); // in practice these probably would not be scattered together! evaluatedMap->insert(std::make_pair("Residual_p","p")); // build scatter parameter list scatterParams.set("Scatter Name",scatterName); scatterParams.set > >("Dependent Names",evaluatedNames); scatterParams.set > >("Dependent Map",evaluatedMap); scatterParams.set("Basis",basis); } Teuchos::ParameterList scatterDirichletParams; { Teuchos::RCP topo = Teuchos::rcp(new shards::CellTopology(shards::getCellTopologyData< shards::Quadrilateral<4> >())); std::string basisType = "Q1"; panzer::CellData cellData(numCells,topo); // build basis RCP basis = rcp(new panzer::PureBasis(basisType,1,cellData)); std::string scatterName = "Residual_NS"; // build DOF names RCP > evaluatedNames = rcp(new std::vector); evaluatedNames->push_back("Residual_ux"); // in practice these probably would not be scattered together! evaluatedNames->push_back("Residual_p"); // build evaluated map RCP > evaluatedMap = rcp(new std::map); evaluatedMap->insert(std::make_pair("Residual_ux","ux")); // in practice these probably would not be scattered together! evaluatedMap->insert(std::make_pair("Residual_p","p")); // build scatter parameter list scatterDirichletParams.set("Scatter Name",scatterName); scatterDirichletParams.set > >("Dependent Names",evaluatedNames); scatterDirichletParams.set > >("Dependent Map",evaluatedMap); scatterDirichletParams.set >("Basis",basis); scatterDirichletParams.set("Side Subcell Dimension",1); scatterDirichletParams.set("Local Side ID",2); scatterDirichletParams.set("Check Apply BC",false); } // Evaluator construction tests /////////////////////////////////////////////////////// RCP > evaluator; { typedef panzer::Traits::Residual EvalType; // gather test { evaluator = la_factory->buildGather(gatherParams); TEST_ASSERT(evaluator!=Teuchos::null); RCP > gatherSolutionEval = rcp_dynamic_cast >(evaluator); TEST_ASSERT(gatherSolutionEval!=Teuchos::null); const std::vector > & fields = gatherSolutionEval->evaluatedFields(); TEST_EQUALITY(fields.size(),2); TEST_EQUALITY(fields[0]->name(),"ux"); TEST_EQUALITY(fields[1]->name(),"p"); TEST_EQUALITY(fields[0]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[0]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 TEST_EQUALITY(fields[1]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[1]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 } // scatter test { evaluator = la_factory->buildScatter(scatterParams); out << "SCATTER RES NAME: \"" << evaluator->getName() << "\"" << std::endl; TEST_ASSERT(evaluator!=Teuchos::null); RCP > scatterResidual = rcp_dynamic_cast >(evaluator); TEST_ASSERT(scatterResidual!=Teuchos::null); const std::vector > & evalFields = scatterResidual->evaluatedFields(); TEST_EQUALITY(evalFields.size(),1); // this is a dummy holder for the sake of the field manager const std::vector > & fields = scatterResidual->dependentFields(); TEST_EQUALITY(fields.size(),2); // these store the residual values TEST_EQUALITY(fields[0]->name(),"Residual_ux"); TEST_EQUALITY(fields[1]->name(),"Residual_p"); TEST_EQUALITY(fields[0]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[0]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 TEST_EQUALITY(fields[1]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[1]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 } // scatter dirichlet test { evaluator = la_factory->buildScatterDirichlet(scatterDirichletParams); out << "SCATTER DIRICHLET RES NAME: \"" << evaluator->getName() << "\"" << std::endl; TEST_ASSERT(evaluator!=Teuchos::null); RCP > scatterResidual = rcp_dynamic_cast >(evaluator); TEST_ASSERT(scatterResidual!=Teuchos::null); const std::vector > & evalFields = scatterResidual->evaluatedFields(); TEST_EQUALITY(evalFields.size(),1); // this is a dummy holder for the sake of the field manager const std::vector > & fields = scatterResidual->dependentFields(); TEST_EQUALITY(fields.size(),2); // these store the residual values TEST_EQUALITY(fields[0]->name(),"Residual_ux"); TEST_EQUALITY(fields[1]->name(),"Residual_p"); TEST_EQUALITY(fields[0]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[0]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 TEST_EQUALITY(fields[1]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[1]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 } } { typedef panzer::Traits::Jacobian EvalType; // gather test { evaluator = la_factory->buildGather(gatherParams); TEST_ASSERT(evaluator!=Teuchos::null); RCP > gatherSolutionEval = rcp_dynamic_cast >(evaluator); TEST_ASSERT(gatherSolutionEval!=Teuchos::null); const std::vector > & fields = gatherSolutionEval->evaluatedFields(); TEST_EQUALITY(fields.size(),2); TEST_EQUALITY(fields[0]->name(),"ux"); TEST_EQUALITY(fields[1]->name(),"p"); TEST_EQUALITY(fields[0]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[0]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 TEST_EQUALITY(fields[1]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[1]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 } // scatter test { evaluator = la_factory->buildScatter(scatterParams); TEST_ASSERT(evaluator!=Teuchos::null); RCP > scatterResidual = rcp_dynamic_cast >(evaluator); TEST_ASSERT(scatterResidual!=Teuchos::null); const std::vector > & evalFields = scatterResidual->evaluatedFields(); TEST_EQUALITY(evalFields.size(),1); // this is a dummy holder for the sake of the field manager const std::vector > & fields = scatterResidual->dependentFields(); TEST_EQUALITY(fields.size(),2); // these store the residual values TEST_EQUALITY(fields[0]->name(),"Residual_ux"); TEST_EQUALITY(fields[1]->name(),"Residual_p"); TEST_EQUALITY(fields[0]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[0]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 TEST_EQUALITY(fields[1]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[1]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 } // scatter dirichlet test { evaluator = la_factory->buildScatterDirichlet(scatterDirichletParams); out << "SCATTER DIRICHLET RES NAME: \"" << evaluator->getName() << "\"" << std::endl; TEST_ASSERT(evaluator!=Teuchos::null); RCP > scatterResidual = rcp_dynamic_cast >(evaluator); TEST_ASSERT(scatterResidual!=Teuchos::null); const std::vector > & evalFields = scatterResidual->evaluatedFields(); TEST_EQUALITY(evalFields.size(),1); // this is a dummy holder for the sake of the field manager const std::vector > & fields = scatterResidual->dependentFields(); TEST_EQUALITY(fields.size(),2); // these store the residual values TEST_EQUALITY(fields[0]->name(),"Residual_ux"); TEST_EQUALITY(fields[1]->name(),"Residual_p"); TEST_EQUALITY(fields[0]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[0]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 TEST_EQUALITY(fields[1]->dataLayout().extent_int(0),Teuchos::as(numCells)); TEST_EQUALITY(fields[1]->dataLayout().extent_int(1),Teuchos::as(4)); // for Q1 } } } TEUCHOS_UNIT_TEST(tTpetraLinearObjFactory, adjustDirichlet) { // build global (or serial communicator) #ifdef HAVE_MPI Teuchos::RCP > tComm = Teuchos::rcp(new Teuchos::MpiComm(Teuchos::opaqueWrapper(MPI_COMM_WORLD))); #else Teuchos::RCP > failure_comm = THIS_,_SERIAL_BUILDS_,_SHOULD_FAIL; #endif using Teuchos::RCP; using Teuchos::rcp; using Teuchos::rcp_dynamic_cast; int myRank = tComm->getRank(); int numProc = tComm->getSize(); typedef TpetraLinearObjContainer LOC; RCP indexer = rcp(new unit_test::GlobalIndexer(myRank,numProc)); // setup factory Teuchos::RCP > la_factory = Teuchos::rcp(new panzer::TpetraLinearObjFactory(tComm.getConst(),indexer)); RCP ghosted_0 = la_factory->buildGhostedLinearObjContainer(); RCP ghosted_1 = la_factory->buildGhostedLinearObjContainer(); RCP ghosted_sys = la_factory->buildGhostedLinearObjContainer(); la_factory->initializeGhostedContainer(LinearObjContainer::F,*ghosted_0); la_factory->initializeGhostedContainer(LinearObjContainer::F,*ghosted_1); la_factory->initializeGhostedContainer(LinearObjContainer::F | LinearObjContainer::Mat,*ghosted_sys); RCP t_0 = rcp_dynamic_cast(ghosted_0); RCP t_1 = rcp_dynamic_cast(ghosted_1); RCP t_sys = rcp_dynamic_cast(ghosted_sys); Teuchos::ArrayRCP x_0_a = t_0->get_f()->get1dViewNonConst(); Teuchos::ArrayRCP x_1_a = t_1->get_f()->get1dViewNonConst(); Teuchos::ArrayRCP f_a = t_sys->get_f()->get1dViewNonConst(); TEST_ASSERT(!Teuchos::is_null(t_0->get_f())); TEST_ASSERT(!Teuchos::is_null(t_1->get_f())); TEST_ASSERT(!Teuchos::is_null(t_sys->get_f())); TEST_ASSERT(!Teuchos::is_null(t_sys->get_A())); t_sys->get_f()->putScalar(-3.0); // put some garbage in the systems t_sys->get_A()->setAllToScalar(-3.0); // there are 3 cases for adjustDirichlet // 1. Local set only for GID // 2. Set on multiple processors // 3. Set remotely if(myRank==0) { // case 0 x_0_a[0] = 1.0; // GID = 0 x_1_a[0] = 1.0; // GID = 0 // case 1 x_0_a[2] = 1.0; // GID = 2 x_1_a[2] = 2.0; // GID = 2 // case 2 x_1_a[5] = 2.0; // GID = 5 } else if(myRank==1) { // case 0 x_0_a[3] = 1.0; // GID = 9 x_1_a[3] = 1.0; // GID = 9 // case 1 x_0_a[0] = 1.0; // GID = 2 x_1_a[0] = 2.0; // GID = 2 // case 2 x_1_a[6] = 2.0; // GID = 4 } else TEUCHOS_ASSERT(false); // run test for conditions la_factory->beginFill(*ghosted_sys); la_factory->adjustForDirichletConditions(*ghosted_0,*ghosted_1,*ghosted_sys); la_factory->endFill(*ghosted_sys); std::size_t sz = t_sys->get_A()->getLocalMaxNumRowEntries(); std::size_t numEntries = 0; typename CrsMatrix::nonconst_local_inds_host_view_type indices("indices", sz); typename CrsMatrix::nonconst_values_host_view_type values("values", sz); if(myRank==0) { TEST_EQUALITY(f_a[0],-3.0); // case 0 t_sys->get_A()->getLocalRowCopy(0,indices,values,numEntries); for(std::size_t i=0;iget_A()->getLocalRowCopy(2,indices,values,numEntries); for(std::size_t i=0;iget_A()->getLocalRowCopy(5,indices,values,numEntries); for(std::size_t i=0;iget_A()->getLocalRowCopy(3,indices,values,numEntries); for(std::size_t i=0;iget_A()->getLocalRowCopy(0,indices,values,numEntries); for(std::size_t i=0;iget_A()->getLocalRowCopy(6,indices,values,numEntries); for(std::size_t i=0;i > tComm = Teuchos::rcp(new Teuchos::MpiComm(Teuchos::opaqueWrapper(MPI_COMM_WORLD))); #else Teuchos::RCP > failure_comm = THIS_,_SERIAL_BUILDS_,_SHOULD_FAIL; #endif using Teuchos::RCP; using Teuchos::rcp; using Teuchos::rcp_dynamic_cast; int myRank = tComm->getRank(); int numProc = tComm->getSize(); typedef TpetraLinearObjContainer LOC; RCP indexer = rcp(new unit_test::GlobalIndexer(myRank,numProc)); std::vector ownedIndices, ownedAndGhostedIndices; indexer->getOwnedIndices(ownedIndices); indexer->getOwnedAndGhostedIndices(ownedAndGhostedIndices); // setup factory Teuchos::RCP > la_factory = Teuchos::rcp(new panzer::TpetraLinearObjFactory(tComm.getConst(),indexer)); RCP container = la_factory->buildLinearObjContainer(); RCP ghostedContainer = la_factory->buildGhostedLinearObjContainer(); RCP > tContainer = rcp_dynamic_cast >(container); RCP > tGhostedContainer = rcp_dynamic_cast >(ghostedContainer); // tests global initialize { // Generic code ///////////////////////////////////////////////////////////// // test individial initializers la_factory->initializeContainer(LOC::X,*container); TEST_ASSERT(tContainer->get_x()!=Teuchos::null); TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_EQUALITY(tContainer->get_A(), Teuchos::null) TEST_EQUALITY(tContainer->get_x()->getLocalLength(),(std::size_t) ownedIndices.size()); la_factory->initializeContainer(LOC::DxDt,*container); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_ASSERT(tContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_EQUALITY(tContainer->get_A(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt()->getLocalLength(),(std::size_t) ownedIndices.size()); la_factory->initializeContainer(LOC::F,*container); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tContainer->get_f()!=Teuchos::null); TEST_EQUALITY(tContainer->get_A(), Teuchos::null) TEST_EQUALITY(tContainer->get_f()->getLocalLength(),(std::size_t) ownedIndices.size()); la_factory->initializeContainer(LOC::Mat,*container); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_ASSERT(tContainer->get_A()!=Teuchos::null); TEST_EQUALITY(tContainer->get_A()->getLocalNumRows(),(std::size_t) ownedIndices.size()); // jacobian and residual vector output la_factory->initializeContainer(LOC::F | LOC::Mat,*container); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tContainer->get_f()!=Teuchos::null); TEST_ASSERT(tContainer->get_A()!=Teuchos::null); // x and time dertivative input la_factory->initializeContainer(LOC::X | LOC::DxDt,*container); TEST_ASSERT(tContainer->get_x()!=Teuchos::null); TEST_ASSERT(tContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_EQUALITY(tContainer->get_A(), Teuchos::null) // everything la_factory->initializeContainer(LOC::X | LOC::DxDt | LOC::F | LOC::Mat,*container); TEST_ASSERT(tContainer->get_x()!=Teuchos::null); TEST_ASSERT(tContainer->get_dxdt()!=Teuchos::null); TEST_ASSERT(tContainer->get_f()!=Teuchos::null); TEST_ASSERT(tContainer->get_A()!=Teuchos::null); // Tpetra specific code ///////////////////////////////////////////////////////////// // test individial initializers la_factory->initializeContainer(LOC::X,*tContainer); TEST_ASSERT(tContainer->get_x()!=Teuchos::null); TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_EQUALITY(tContainer->get_A(), Teuchos::null) la_factory->initializeContainer(LOC::DxDt,*tContainer); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_ASSERT(tContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_EQUALITY(tContainer->get_A(), Teuchos::null) la_factory->initializeContainer(LOC::F,*tContainer); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tContainer->get_f()!=Teuchos::null); TEST_EQUALITY(tContainer->get_A(), Teuchos::null) la_factory->initializeContainer(LOC::Mat,*tContainer); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_ASSERT(tContainer->get_A()!=Teuchos::null); // jacobian and residual vector output la_factory->initializeContainer(LOC::F | LOC::Mat,*tContainer); TEST_EQUALITY(tContainer->get_x(), Teuchos::null) TEST_EQUALITY(tContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tContainer->get_f()!=Teuchos::null); TEST_ASSERT(tContainer->get_A()!=Teuchos::null); // x and time dertivative input la_factory->initializeContainer(LOC::X | LOC::DxDt,*tContainer); TEST_ASSERT(tContainer->get_x()!=Teuchos::null); TEST_ASSERT(tContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tContainer->get_f(), Teuchos::null) TEST_EQUALITY(tContainer->get_A(), Teuchos::null) // everything la_factory->initializeContainer(LOC::X | LOC::DxDt | LOC::F | LOC::Mat,*tContainer); TEST_ASSERT(tContainer->get_x()!=Teuchos::null); TEST_ASSERT(tContainer->get_dxdt()!=Teuchos::null); TEST_ASSERT(tContainer->get_f()!=Teuchos::null); TEST_ASSERT(tContainer->get_A()!=Teuchos::null); } // tests ghosted initialize { // Generic code ///////////////////////////////////////////////////////////// // test individial initializers la_factory->initializeGhostedContainer(LOC::X,*ghostedContainer); TEST_ASSERT(tGhostedContainer->get_x()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_x()->getLocalLength(),(std::size_t) ownedAndGhostedIndices.size()); la_factory->initializeGhostedContainer(LOC::DxDt,*ghostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt()->getLocalLength(),(std::size_t) ownedAndGhostedIndices.size()); la_factory->initializeGhostedContainer(LOC::F,*ghostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_f()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_f()->getLocalLength(),(std::size_t) ownedAndGhostedIndices.size()); la_factory->initializeGhostedContainer(LOC::Mat,*ghostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_A()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_A()->getLocalNumRows(),(std::size_t) ownedAndGhostedIndices.size()); // jacobian and residual vector output la_factory->initializeGhostedContainer(LOC::F | LOC::Mat,*ghostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_f()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_A()!=Teuchos::null); // x and time dertivative input la_factory->initializeGhostedContainer(LOC::X | LOC::DxDt,*ghostedContainer); TEST_ASSERT(tGhostedContainer->get_x()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) // everything la_factory->initializeGhostedContainer(LOC::X | LOC::DxDt | LOC::F | LOC::Mat,*ghostedContainer); TEST_ASSERT(tGhostedContainer->get_x()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_dxdt()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_f()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_A()!=Teuchos::null); // Tpetra specific code ///////////////////////////////////////////////////////////// // test individial initializers la_factory->initializeGhostedContainer(LOC::X,*tGhostedContainer); TEST_ASSERT(tGhostedContainer->get_x()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) la_factory->initializeGhostedContainer(LOC::DxDt,*tGhostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) la_factory->initializeGhostedContainer(LOC::F,*tGhostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_f()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) la_factory->initializeGhostedContainer(LOC::Mat,*tGhostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_A()!=Teuchos::null); // jacobian and residual vector output la_factory->initializeGhostedContainer(LOC::F | LOC::Mat,*tGhostedContainer); TEST_EQUALITY(tGhostedContainer->get_x(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_dxdt(), Teuchos::null) TEST_ASSERT(tGhostedContainer->get_f()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_A()!=Teuchos::null); // x and time dertivative input la_factory->initializeGhostedContainer(LOC::X | LOC::DxDt,*tGhostedContainer); TEST_ASSERT(tGhostedContainer->get_x()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_dxdt()!=Teuchos::null); TEST_EQUALITY(tGhostedContainer->get_f(), Teuchos::null) TEST_EQUALITY(tGhostedContainer->get_A(), Teuchos::null) // everything la_factory->initializeGhostedContainer(LOC::X | LOC::DxDt | LOC::F | LOC::Mat,*tGhostedContainer); TEST_ASSERT(tGhostedContainer->get_x()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_dxdt()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_f()!=Teuchos::null); TEST_ASSERT(tGhostedContainer->get_A()!=Teuchos::null); } } }