// @HEADER // ***************************************************************************** // Rapid Optimization Library (ROL) Package // // Copyright 2014 NTESS and the ROL contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER /*! \file data.hpp \brief Generates and manages data for the Poisson example, including all mesh and discretization data, matrices, etc. */ #ifndef ROL_PDEOPT_POISSON_DATA_H #define ROL_PDEOPT_POISSON_DATA_H #include "Teuchos_GlobalMPISession.hpp" #include "Teuchos_TimeMonitor.hpp" #include "Tpetra_MultiVector.hpp" #include "Tpetra_Vector.hpp" #include "Tpetra_CrsGraph.hpp" #include "Tpetra_CrsMatrix.hpp" #include "Tpetra_Version.hpp" #include "Tpetra_RowMatrixTransposer.hpp" #include "MatrixMarket_Tpetra.hpp" #include "Intrepid_HGRAD_QUAD_C2_FEM.hpp" #include "Intrepid_HGRAD_QUAD_C1_FEM.hpp" #include "Intrepid_DefaultCubatureFactory.hpp" #include "Intrepid_FunctionSpaceTools.hpp" #include "Intrepid_CellTools.hpp" #include "Amesos2.hpp" #include "../TOOLS/dofmanager.hpp" template class PoissonData { private: using GO = typename Tpetra::Map<>::global_ordinal_type; ROL::Ptr > meshMgr_; ROL::Ptr > dofMgr_; std::vector > > > basisPtrs_; ROL::Ptr > commPtr_; int myRank_; int numProcs_; Real alpha_; int basisOrder_; ROL::Ptr > myOverlapMap_; ROL::Ptr > myUniqueMap_; ROL::Ptr > matGraph_; ROL::Ptr > matA_; ROL::Ptr > matA_dirichlet_; ROL::Ptr > matA_dirichlet_trans_; ROL::Ptr > matM_; ROL::Ptr > matM_dirichlet_; ROL::Ptr > matM_dirichlet_trans_; ROL::Ptr > vecUd_; ROL::Ptr > vecF_; ROL::Ptr > vecF_overlap_; ROL::Ptr > vecF_dirichlet_; Teuchos::Array myCellIds_; ROL::Ptr, Tpetra::MultiVector<> > > solverA_; ROL::Ptr, Tpetra::MultiVector<> > > solverA_trans_; shards::CellTopology cellType_; int spaceDim_; int numNodesPerCell_; int numCubPoints_; GO totalNumCells_; GO totalNumDofs_; GO numCells_; ROL::Ptr > cubPoints_; ROL::Ptr > cubWeights_; ROL::Ptr > cellNodes_; ROL::Ptr > cellJac_; ROL::Ptr > cellJacInv_; ROL::Ptr > cellJacDet_; ROL::Ptr > cellWeightedMeasure_; ROL::Ptr > valReference_; ROL::Ptr > gradReference_; ROL::Ptr > valPhysical_; ROL::Ptr > gradPhysical_; ROL::Ptr > valPhysicalWeighted_; ROL::Ptr > gradPhysicalWeighted_; ROL::Ptr > gradgradMats_; ROL::Ptr > valvalMats_; ROL::Ptr > cubPointsPhysical_; ROL::Ptr > dataF_; ROL::Ptr > datavalVecF_; ROL::Ptr > dofPoints_; ROL::Ptr > dofPointsPhysical_; ROL::Ptr > dataUd_; public: PoissonData(const ROL::Ptr > &comm, const Teuchos::RCP &parlist, const ROL::Ptr &outStream) { /************************************/ /*** Retrieve communication data. ***/ /************************************/ commPtr_ = comm; myRank_ = commPtr_->getRank(); numProcs_ = commPtr_->getSize(); *outStream << "Total number of processors: " << numProcs_ << std::endl; /************************************/ /************************************/ /*************************************/ /*** Retrieve parameter list data. ***/ /*************************************/ alpha_ = parlist->sublist("Problem").get("Control penalty parameter", 1e-2); basisOrder_ = parlist->sublist("Problem").get("Order of FE discretization", 1); int cellSplit = parlist->sublist("Geometry").get("Partition type", 1); /*************************************/ /*************************************/ /****************************************************************************/ /*** Initialize mesh / finite element fields / degree-of-freedom manager. ***/ /****************************************************************************/ // Mesh manager. meshMgr_ = ROL::makePtr>(*parlist); printMeshData(*outStream); // Finite element fields. ROL::Ptr > > basisPtr; if (basisOrder_ == 1) { basisPtr = ROL::makePtr >>(); } else if (basisOrder_ == 2) { basisPtr = ROL::makePtr >>(); } basisPtrs_.resize(1, ROL::nullPtr); basisPtrs_[0] = basisPtr; // DOF coordinate interface. ROL::Ptr > > coord_iface = ROL::dynamicPtrCast > >(basisPtrs_[0]); // Degree-of-freedom manager. dofMgr_ = ROL::makePtr>(meshMgr_, basisPtrs_); // Retrieve total number of cells in the mesh. totalNumCells_ = meshMgr_->getNumCells(); // Retrieve total number of degrees of freedom in the mesh. totalNumDofs_ = dofMgr_->getNumDofs(); /****************************************************************************/ /****************************************************************************/ /****************************************************/ /*** Build parallel communication infrastructure. ***/ /****************************************************/ // Partition the cells in the mesh. We use a basic quasi-equinumerous partitioning, // where the remainder, if any, is assigned to the last processor. Teuchos::Array myGlobIds_; Teuchos::Array cellOffsets_(numProcs_, 0); GO cellsPerProc = totalNumCells_ / numProcs_; numCells_ = cellsPerProc; switch(cellSplit) { case 0: if (myRank_ == 0) { // remainder in the first numCells_ += totalNumCells_ % numProcs_; } for (int i=1; i(i==1))*(totalNumCells_ % numProcs_); } break; case 1: if (myRank_ == numProcs_-1) { // remainder in the last numCells_ += totalNumCells_ % numProcs_; } for (int i=1; i(i-1<(totalNumCells_%numProcs_))); } break; } Intrepid::FieldContainer &cellDofs = *(dofMgr_->getCellDofs()); int numLocalDofs = cellDofs.dimension(1); *outStream << "Cell offsets across processors: " << cellOffsets_ << std::endl; for (int i=0; i>(Teuchos::OrdinalTraits::invalid(), myGlobIds_, 0, comm); //std::cout << std::endl << myOverlapMap_->getLocalElementList(); /** One can also use the non-member function: myOverlapMap_ = Tpetra::createNonContigMap(myGlobIds_, comm); to build the overlap map. **/ myUniqueMap_ = Tpetra::createOneToOne(myOverlapMap_); //std::cout << std::endl << myUniqueMap_->getLocalElementList() << std::endl; /****************************************************/ /****************************************************/ /****************************************************/ /*** Set up local discretization data and arrays. ***/ /****************************************************/ // Retrieve some basic cell information. cellType_ = (basisPtrs_[0])->getBaseCellTopology(); // get the cell type from any basis spaceDim_ = cellType_.getDimension(); // retrieve spatial dimension numNodesPerCell_ = cellType_.getNodeCount(); // retrieve number of nodes per cell // Cubature data. Intrepid::DefaultCubatureFactory cubFactory; // create cubature factory int cubDegree = 4; // set cubature degree, e.g., 2 ROL::Ptr > cellCub = cubFactory.create(cellType_, cubDegree); // create default cubature numCubPoints_ = cellCub->getNumPoints(); // retrieve number of cubature points int lfs = dofMgr_->getLocalFieldSize(0); // Discretization data. cubPoints_ = ROL::makePtr>(numCubPoints_, spaceDim_); cubWeights_ = ROL::makePtr>(numCubPoints_); cubPointsPhysical_ = ROL::makePtr>(numCells_, numCubPoints_, spaceDim_); dofPoints_ = ROL::makePtr>(lfs, spaceDim_); dofPointsPhysical_ = ROL::makePtr>(numCells_, lfs, spaceDim_); cellNodes_ = ROL::makePtr>(numCells_, numNodesPerCell_, spaceDim_); cellJac_ = ROL::makePtr>(numCells_, numCubPoints_, spaceDim_, spaceDim_); cellJacInv_ = ROL::makePtr>(numCells_, numCubPoints_, spaceDim_, spaceDim_); cellJacDet_ = ROL::makePtr>(numCells_, numCubPoints_); cellWeightedMeasure_ = ROL::makePtr>(numCells_, numCubPoints_); valReference_ = ROL::makePtr>(lfs, numCubPoints_); gradReference_ = ROL::makePtr>(lfs, numCubPoints_, spaceDim_); valPhysical_ = ROL::makePtr>(numCells_, lfs, numCubPoints_); gradPhysical_ = ROL::makePtr>(numCells_, lfs, numCubPoints_, spaceDim_); valPhysicalWeighted_ = ROL::makePtr>(numCells_, lfs, numCubPoints_); gradPhysicalWeighted_ = ROL::makePtr>(numCells_, lfs, numCubPoints_, spaceDim_); gradgradMats_ = ROL::makePtr>(numCells_, lfs, lfs); valvalMats_ = ROL::makePtr>(numCells_, lfs, lfs); dataF_ = ROL::makePtr>(numCells_, numCubPoints_); datavalVecF_ = ROL::makePtr>(numCells_, lfs); dataUd_ = ROL::makePtr>(numCells_, lfs); // Geometric definition of the cells in the mesh, based on the cell-to-node map and the domain partition. Intrepid::FieldContainer &nodes = *meshMgr_->getNodes(); Intrepid::FieldContainer &ctn = *meshMgr_->getCellToNodeMap(); for (GO i=0; igetCubature(*cubPoints_, *cubWeights_); // retrieve cubature points and weights (*basisPtrs_[0]).getValues(*gradReference_, *cubPoints_, Intrepid::OPERATOR_GRAD); // evaluate grad operator at cubature points (*basisPtrs_[0]).getValues(*valReference_, *cubPoints_, Intrepid::OPERATOR_VALUE); // evaluate value operator at cubature points Intrepid::CellTools::setJacobian(*cellJac_, *cubPoints_, *cellNodes_, cellType_); // compute cell Jacobians Intrepid::CellTools::setJacobianInv(*cellJacInv_, *cellJac_); // compute inverses of cell Jacobians Intrepid::CellTools::setJacobianDet(*cellJacDet_, *cellJac_); // compute determinants of cell Jacobians Intrepid::FunctionSpaceTools::computeCellMeasure(*cellWeightedMeasure_, // compute weighted cell measure *cellJacDet_, *cubWeights_); Intrepid::FunctionSpaceTools::HGRADtransformGRAD(*gradPhysical_, // transform reference gradients into physical space *cellJacInv_, *gradReference_); Intrepid::FunctionSpaceTools::multiplyMeasure(*gradPhysicalWeighted_, // multiply with weighted measure *cellWeightedMeasure_, *gradPhysical_); Intrepid::FunctionSpaceTools::integrate(*gradgradMats_, // compute local grad.grad (stiffness) matrices *gradPhysical_, *gradPhysicalWeighted_, Intrepid::COMP_CPP); Intrepid::FunctionSpaceTools::HGRADtransformVALUE(*valPhysical_, // transform reference values into physical space *valReference_); Intrepid::FunctionSpaceTools::multiplyMeasure(*valPhysicalWeighted_, // multiply with weighted measure *cellWeightedMeasure_, *valPhysical_); Intrepid::FunctionSpaceTools::integrate(*valvalMats_, // compute local val.val (mass) matrices *valPhysical_, *valPhysicalWeighted_, Intrepid::COMP_CPP); Intrepid::CellTools::mapToPhysicalFrame(*cubPointsPhysical_, // map reference cubature points to physical space *cubPoints_, *cellNodes_, cellType_); for (GO i=0; i(*datavalVecF_, // compute local data.val vectors for RHS F *dataF_, *valPhysicalWeighted_, Intrepid::COMP_CPP); coord_iface->getDofCoords(*dofPoints_); // get coordinates of DOFs in reference cell Intrepid::CellTools::mapToPhysicalFrame(*dofPointsPhysical_, // map reference DOF locations to physical space *dofPoints_, *cellNodes_, cellType_); for (GO i=0; i cellDofsArrayRCP = cellDofs.getData(); Teuchos::Array graphEntriesPerRow(myUniqueMap_->getLocalNumElements()); for (GO i=0; iisNodeGlobalElement(gid)) graphEntriesPerRow[myUniqueMap_->getLocalElement(gid)] += numLocalDofs; } } matGraph_ = ROL::makePtr>(myUniqueMap_, graphEntriesPerRow()); for (GO i=0; iinsertGlobalIndices(cellDofs(myCellIds_[i],j), cellDofsArrayRCP(myCellIds_[i]*numLocalDofs, numLocalDofs)); } } matGraph_->fillComplete(); // Assemble matrices. // Stiffness matrix A. matA_ = ROL::makePtr>(matGraph_); int numLocalMatEntries = numLocalDofs*numLocalDofs; Teuchos::ArrayRCP gradgradArrayRCP = gradgradMats_->getData(); for (GO i=0; isumIntoGlobalValues(cellDofs(myCellIds_[i],j), cellDofsArrayRCP(myCellIds_[i]*numLocalDofs, numLocalDofs), gradgradArrayRCP(i*numLocalMatEntries+j*numLocalDofs, numLocalDofs)); } } matA_->fillComplete(); // Mass matrix M. matM_ = ROL::makePtr>(matGraph_); Teuchos::ArrayRCP valvalArrayRCP = valvalMats_->getData(); for (GO i=0; isumIntoGlobalValues(cellDofs(myCellIds_[i],j), cellDofsArrayRCP(myCellIds_[i]*numLocalDofs, numLocalDofs), valvalArrayRCP(i*numLocalMatEntries+j*numLocalDofs, numLocalDofs)); } } matM_->fillComplete(); // Assemble vectors. // vecF_ requires assembly using vecF_overlap_ and redistribution vecF_ = ROL::makePtr>(matA_->getRangeMap(), 1, true); vecF_overlap_ = ROL::makePtr>(myOverlapMap_, 1, true); for (GO i=0; isumIntoGlobalValue(cellDofs(myCellIds_[i],j), 0, (*datavalVecF_)[i*numLocalDofs+j]); } } Tpetra::Export<> exporter(vecF_overlap_->getMap(), vecF_->getMap()); // redistribution: vecF_->doExport(*vecF_overlap_, exporter, Tpetra::ADD); // from the overlap map to the unique map // vecUd_ does not require assembly vecUd_ = ROL::makePtr>(matA_->getDomainMap(), 1, true); for (GO i=0; igetMap()->isNodeGlobalElement(cellDofs(myCellIds_[i],j))) { vecUd_->replaceGlobalValue(cellDofs(myCellIds_[i],j), 0, (*dataUd_)[i*numLocalDofs+j]); } } } // Apply Dirichlet conditions. // Stiffness matrix with Dirichlet conditions: // AD = [ A11 A12 ] where A = [ A11 A12 ] // [ 0 I ] [ A21 A22 ] // Mass matrix with Dirichlet conditions: // MD = [ M11 M12 ] where M = [ M11 M12 ] // [ 0 0 ] [ M21 M22 ] // Vector F with Dirichlet conditions G: // FD = [ F1 ] where F = [ F1 ] // [ G ] [ F2 ] matA_dirichlet_ = ROL::makePtr>(*matA_, Teuchos::DataAccess::Copy); matM_dirichlet_ = ROL::makePtr>(*matM_, Teuchos::DataAccess::Copy); vecF_dirichlet_ = ROL::makePtr>(matA_->getRangeMap(), 1, true); Tpetra::deep_copy(*vecF_dirichlet_, *vecF_); ROL::Ptr > > > dirichletSideSets = meshMgr_->getSideSets(); std::vector > > &dss = *dirichletSideSets; Teuchos::Array mySortedCellIds_(myCellIds_); std::sort(mySortedCellIds_.begin(), mySortedCellIds_.end()); mySortedCellIds_.erase( std::unique(mySortedCellIds_.begin(), mySortedCellIds_.end()), mySortedCellIds_.end() ); std::vector > myDirichletCellIds_(dss[0].size()); for (int i=0; i(dss[0].size()); ++i) { for (int j=0; j &cte = *(meshMgr_->getCellToEdgeMap()); Intrepid::FieldContainer &nodeDofs = *(dofMgr_->getNodeDofs()); Intrepid::FieldContainer &edgeDofs = *(dofMgr_->getEdgeDofs()); std::vector > dofTags = (basisPtrs_[0])->getAllDofTags(); int numDofsPerNode = 0; int numDofsPerEdge = 0; for (int j=0; j<(basisPtrs_[0])->getCardinality(); ++j) { if (dofTags[j][0] == 0) { numDofsPerNode = dofTags[j][3]; } if (dofTags[j][0] == 1) { numDofsPerEdge = dofTags[j][3]; } } Teuchos::Array myDirichletDofs_; for (int i=0; i(myDirichletCellIds_.size()); ++i) { for (int j=0; j locNodes(const_cast(ctd->subcell[spaceDim_-1][i].node), cellType_.getVertexCount(spaceDim_-1, i)); for (int l=0; l(cellType_.getVertexCount(spaceDim_-1, i)); ++l) { myDirichletDofs_.push_back(nodeDofs(ctn(myDirichletCellIds_[i][j], locNodes[l]), k)); } } for (int k=0; kresumeFill(); matM_dirichlet_->resumeFill(); for (int i=0; iisNodeGlobalElement(myDirichletDofs_[i])) { size_t numRowEntries = matA_dirichlet_->getNumEntriesInGlobalRow(myDirichletDofs_[i]); Teuchos::Array indices(numRowEntries, 0); Teuchos::Array values(numRowEntries, 0); Teuchos::Array canonicalValues(numRowEntries, 0); Teuchos::Array zeroValues(numRowEntries, 0); matA_dirichlet_->getGlobalRowCopy(myDirichletDofs_[i], indices, values, numRowEntries); matM_dirichlet_->getGlobalRowCopy(myDirichletDofs_[i], indices, values, numRowEntries); for (int j=0; jreplaceGlobalValues(myDirichletDofs_[i], indices, canonicalValues); matM_dirichlet_->replaceGlobalValues(myDirichletDofs_[i], indices, zeroValues); vecF_dirichlet_->replaceGlobalValue(myDirichletDofs_[i], 0, 0); } } matA_dirichlet_->fillComplete(); matM_dirichlet_->fillComplete(); // Create matrix transposes. Tpetra::RowMatrixTransposer<> transposerA(matA_dirichlet_); Tpetra::RowMatrixTransposer<> transposerM(matM_dirichlet_); matA_dirichlet_trans_ = transposerA.createTranspose(); matM_dirichlet_trans_ = transposerM.createTranspose(); /*********************************/ /*** Construct solver objects. ***/ /*********************************/ // Construct solver using Amesos2 factory. try{ solverA_ = Amesos2::create< Tpetra::CrsMatrix<>,Tpetra::MultiVector<> >("KLU2", matA_dirichlet_); } catch (std::invalid_argument& e) { std::cout << e.what() << std::endl; } try{ solverA_trans_ = Amesos2::create< Tpetra::CrsMatrix<>,Tpetra::MultiVector<> >("KLU2", matA_dirichlet_trans_); } catch (std::invalid_argument& e) { std::cout << e.what() << std::endl; } solverA_->numericFactorization(); solverA_trans_->numericFactorization(); /****************************************/ /****************************************/ //outputTpetraData(); } ROL::Ptr > getMatA(const bool &transpose = false) const { if (transpose) { return matA_dirichlet_trans_; } else { return matA_dirichlet_; } } ROL::Ptr > getMatB(const bool &transpose = false) const { if (transpose) { return matM_dirichlet_trans_; } else { return matM_dirichlet_; } } ROL::Ptr > getMatM() const { return matM_; } ROL::Ptr > getMatR() const { return matM_; } ROL::Ptr > getVecUd() const { return vecUd_; } ROL::Ptr > getVecF() const { return vecF_dirichlet_; } ROL::Ptr, Tpetra::MultiVector<> > > getSolver(const bool &transpose = false) const { if (transpose) { return solverA_trans_; } else { return solverA_; } } Real funcRHS(const Real &x1, const Real &x2) const { return 2.0*M_PI*M_PI*std::sin(M_PI*x1)*std::sin(M_PI*x2) + (1.0/(alpha_*128.0*M_PI*M_PI))*std::sin(8.0*M_PI*x1)*std::sin(8.0*M_PI*x2); } Real funcTarget(const Real &x1, const Real &x2) const { return std::sin(M_PI*x1)*std::sin(M_PI*x2) - std::sin(8.0*M_PI*x1)*std::sin(8.0*M_PI*x2); } Real funcStateSolution(const Real &x1, const Real &x2) const { return std::sin(M_PI*x1)*std::sin(M_PI*x2); } Real computeStateError(const ROL::Ptr > &soln) const { ROL::Ptr > soln_overlap = ROL::makePtr>(vecF_overlap_->getMap(), 1, true); Tpetra::Import<> importer(vecUd_->getMap(), soln_overlap->getMap()); // redistribution: soln_overlap->doImport(*soln, importer, Tpetra::REPLACE); // from the unique map to the overlap map Intrepid::DefaultCubatureFactory cubFactory; // create cubature factory int cubDeg = 6; // set cubature degree, e.g., 6 ROL::Ptr > cellCub = cubFactory.create(cellType_, cubDeg); // create cubature for error computation int numCubPts = cellCub->getNumPoints(); // retrieve number of cubature points int lfs = dofMgr_->getLocalFieldSize(0); Intrepid::FieldContainer cubPts(numCubPts, spaceDim_); Intrepid::FieldContainer cubWts(numCubPts); Intrepid::FieldContainer cubPtsPhys(numCells_, numCubPts, spaceDim_); Intrepid::FieldContainer jac(numCells_, numCubPts, spaceDim_, spaceDim_); Intrepid::FieldContainer jacDet(numCells_, numCubPts); Intrepid::FieldContainer valRef(lfs, numCubPts); Intrepid::FieldContainer valPhys(numCells_, lfs, numCubPts); Intrepid::FieldContainer wtMeas(numCells_, numCubPts); Intrepid::FieldContainer inCoeffs(numCells_, lfs); Intrepid::FieldContainer funcVals(numCells_, numCubPts); Intrepid::FieldContainer funcValsWt(numCells_, numCubPts); Intrepid::FieldContainer normSquaredError(numCells_); cellCub->getCubature(cubPts, cubWts); // retrieve cubature points and weights (*basisPtrs_[0]).getValues(valRef, cubPts, Intrepid::OPERATOR_VALUE); // evaluate value operator at cubature points Intrepid::CellTools::setJacobian(jac, cubPts, *cellNodes_, cellType_); // compute cell Jacobians Intrepid::CellTools::setJacobianDet(jacDet, jac); // compute determinants of cell Jacobians Intrepid::FunctionSpaceTools::HGRADtransformVALUE(valPhys, // transform reference values into physical space valRef); Intrepid::FunctionSpaceTools::computeCellMeasure(wtMeas, // compute weighted cell measure jacDet, cubWts); Intrepid::CellTools::mapToPhysicalFrame(cubPtsPhys, // map reference cubature points to physical space cubPts, *cellNodes_, cellType_); Intrepid::FieldContainer &cellDofs = *(dofMgr_->getCellDofs()); Teuchos::ArrayRCP soln_data = soln_overlap->get1dView(); // populate inCoeffs for (int i=0; igetMap()->getLocalElement(cellDofs(myCellIds_[i],j))]; } } Intrepid::FunctionSpaceTools::evaluate(funcVals, inCoeffs, valPhys); for (int i=0; i(funcValsWt, // multiply with weighted measure wtMeas, funcVals); Intrepid::FunctionSpaceTools::integrate(normSquaredError, // compute norm squared of local error funcVals, funcValsWt, Intrepid::COMP_CPP); Real localErrorSum(0); Real globalErrorSum(0); for (int i=0; i > comm = soln_overlap->getMap()->getComm(); Teuchos::reduceAll(*comm, Teuchos::REDUCE_SUM, 1, &localErrorSum, &globalErrorSum); return globalErrorSum; } void printMeshData(std::ostream &outStream) const { ROL::Ptr > nodesPtr = meshMgr_->getNodes(); ROL::Ptr > cellToNodeMapPtr = meshMgr_->getCellToNodeMap(); Intrepid::FieldContainer &nodes = *nodesPtr; Intrepid::FieldContainer &cellToNodeMap = *cellToNodeMapPtr; outStream << "Number of nodes = " << meshMgr_->getNumNodes() << std::endl; outStream << "Number of cells = " << meshMgr_->getNumCells() << std::endl; outStream << "Number of edges = " << meshMgr_->getNumEdges() << std::endl; // Print mesh to file. if ((myRank_ == 0)) { std::ofstream meshfile; meshfile.open("cell_to_node_quad.txt"); for (int i=0; i > matWriter; matWriter.writeSparseFile("stiffness_mat", matA_); matWriter.writeSparseFile("dirichlet_mat", matA_dirichlet_); matWriter.writeSparseFile("mass_mat", matM_); matWriter.writeDenseFile("Ud_vec", vecUd_); } void outputTpetraVector(const ROL::Ptr > &vec, const std::string &filename) const { Tpetra::MatrixMarket::Writer< Tpetra::CrsMatrix<> > vecWriter; vecWriter.writeDenseFile(filename, vec); } }; // class PoissonData #endif