// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. /** \file SubDomainSolver.h */ #ifndef AMDIS_SUBDOMAIN_SOLVER_H #define AMDIS_SUBDOMAIN_SOLVER_H #include #include #include #include #include "parallel/MeshDistributor.h" #include "parallel/ParallelDofMapping.h" namespace AMDiS { using namespace std; class SubDomainSolver { public: SubDomainSolver(MeshDistributor *md, MPI::Intracomm mpiComm0, MPI::Intracomm mpiComm1) : meshDistributor(md), level(0), mpiCommCoarseSpace(mpiComm0), mpiCommInterior(mpiComm1), coarseSpaceMap(NULL), interiorMap(NULL) {} void setLevel(int l) { level = l; } void setDofMapping(ParallelDofMapping *coarseDofs, ParallelDofMapping *interiorDofs); void fillPetscMatrix(Matrix *mat); void fillPetscRhs(SystemVector *vec); void solvePetscMatrix(SystemVector &vec, AdaptInfo *adaptInfo); void destroyVectorData(); void destroyMatrixData(); void solve(Vec &rhs, Vec &sol); void solveGlobal(Vec &rhs, Vec &sol); inline bool isCoarseSpace(const FiniteElemSpace *feSpace, DegreeOfFreedom dof) { return (*coarseSpaceMap)[feSpace].isSet(dof); } inline Vec& getRhsCoarseSpace() { return rhsCoarseSpace; } inline Vec& getRhsInterior() { return rhsInterior; } inline Mat& getMatIntInt() { return matIntInt; } inline Mat& getMatCoarseCoarse() { return matCoarseCoarse; } inline Mat& getMatIntCoarse() { return matIntCoarse; } inline Mat& getMatCoarseInt() { return matCoarseInt; } protected: /// Returns a vector with the FE spaces of each row in the matrix. Thus, the /// resulting vector may contain the same FE space multiple times. vector getFeSpaces(Matrix *mat); /// Returns a vector with the FE spaces of all components of a system vector. vector getFeSpaces(SystemVector *vec); protected: MeshDistributor *meshDistributor; int level; int rStartInterior; int nGlobalOverallInterior; MPI::Intracomm mpiCommCoarseSpace; MPI::Intracomm mpiCommInterior; ParallelDofMapping* coarseSpaceMap; ParallelDofMapping* interiorMap; Vec rhsCoarseSpace; Vec rhsInterior; Mat matIntInt, matCoarseCoarse, matIntCoarse, matCoarseInt; KSP kspInterior; }; } #endif