diff --git a/dumux/decoupled/2p/diffusion/mimetic/croperator.hh b/dumux/decoupled/2p/diffusion/mimetic/croperator.hh index df97b7909038fe3ed3fff977a6a4f18bcf9c7f20..3a590974c74691c29fa72d870d37689daccb183d 100644 --- a/dumux/decoupled/2p/diffusion/mimetic/croperator.hh +++ b/dumux/decoupled/2p/diffusion/mimetic/croperator.hh @@ -141,7 +141,16 @@ public: CROperatorAssembler (const GridView& gridview) : gridView_(gridview), is_(gridView_.indexSet()), faceMapper_(gridView_), allMapper_(gridView_), A_(size(), size(), nnz(is_), RepresentationType::random) + {} + + //!Initialize the global matrix of the system of equations to solve + void initializeMatrix() { + faceMapper_.update(); + allMapper_.update(); + + A_.setSize(size(), size()); + assert(nnz(is_) != 0); // set size of all rows to zero diff --git a/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh b/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh index 8bbbe601991a7df809e7032cd5aa6917d1098e71..5fb1fa382dbf54bb661a3bf200e5ac942bd837c7 100644 --- a/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh +++ b/dumux/decoupled/2p/diffusion/mimetic/mimeticpressure2p.hh @@ -155,6 +155,10 @@ public: void initialize(bool solveTwice = true) { updateMaterialLaws(); + A_.initializeMatrix(); + f_.resize(problem_.gridView().size(1));//resize to make sure the final grid size (after the problem was completely built) is used! + pressure_.resize(problem_.gridView().size(0)); + pressTrace_.resize(problem_.gridView().size(1)); pressure_ = 0; pressTrace_ = 0; f_ = 0; diff --git a/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh b/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh index a4d62df8f2fd1816b283b7769091e57e624c7114..13c821fa03dfd71ba9bf6c67dc50bf6fd47a7055 100644 --- a/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh +++ b/dumux/decoupled/2p2c/fvpressure2p2cmultiphysics.hh @@ -67,6 +67,7 @@ namespace Dumux template<class TypeTag> class FVPressure2P2CMultiPhysics : public FVPressure2P2C<TypeTag> { + typedef FVPressure2P2C<TypeTag> ParentType; typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView; typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes; @@ -139,6 +140,20 @@ public: void get1pFluxOnBoundary(Dune::FieldVector<Scalar, 2>&, const Intersection&, const CellData&); + //initialize mult-physics-specific pressure model stuff + void initialize() + { + // assign whole domain to most complex subdomain, => 2p + int size = this->problem().gridView().size(0); + for (int i = 0; i < size; i++) + { + CellData& cellData = this->problem().variables().cellData(i); + cellData.subdomain() = 2; + } + nextSubdomain.resize(size); + ParentType::initialize(); + } + //constitutive functions are initialized and stored in the variables object void updateMaterialLaws(); @@ -169,16 +184,7 @@ public: */ FVPressure2P2CMultiPhysics(Problem& problem) : FVPressure2P2C<TypeTag>(problem), gravity_(problem.gravity()), timer_(false) - { - // assign whole domain to most complex subdomain, => 2p - int size = problem.gridView().size(0); - for (int i = 0; i < size; i++) - { - CellData& cellData = problem.variables().cellData(i); - cellData.subdomain() = 2; - } - nextSubdomain.resize(size); - } + {} private: // subdomain map diff --git a/dumux/decoupled/2p2c/fvpressurecompositional.hh b/dumux/decoupled/2p2c/fvpressurecompositional.hh index 598f42373f3f505e18c321fbd618936b4378a9fa..dbc27a79a981a95a8c49628a1587a82f99405d18 100644 --- a/dumux/decoupled/2p2c/fvpressurecompositional.hh +++ b/dumux/decoupled/2p2c/fvpressurecompositional.hh @@ -63,6 +63,8 @@ namespace Dumux template<class TypeTag> class FVPressureCompositional : public FVPressure<TypeTag> { + typedef FVPressure<TypeTag> ParentType; + typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView; typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar; typedef typename GET_PROP_TYPE(TypeTag, PTAG(TransportSolutionType)) TransportSolutionType; @@ -327,8 +329,7 @@ protected: template<class TypeTag> void FVPressureCompositional<TypeTag>::initialize(bool solveTwice) { - //prepare stiffness Matrix and Vectors - problem_.pressureModel().initializeMatrix(); + ParentType::initialize(); // initialguess: set saturations, determine visco and mobility for initial pressure equation // at this moment, the pressure is unknown. Hence, dont regard compositional effects. diff --git a/dumux/decoupled/2p2c/fvtransport2p2c.hh b/dumux/decoupled/2p2c/fvtransport2p2c.hh index 3b4a7016736cb82cf2ea6e8a7955386d08b1ee3b..d20e4897300fb1dbe3a077fae8fb7861b066539e 100644 --- a/dumux/decoupled/2p2c/fvtransport2p2c.hh +++ b/dumux/decoupled/2p2c/fvtransport2p2c.hh @@ -116,7 +116,10 @@ public: * This method is called before first pressure equation is solved from Dumux::IMPET. */ void initialize() - {}; + { + totalConcentration_[wCompIdx].resize(problem_.gridView().size(0)); + totalConcentration_[nCompIdx].resize(problem_.gridView().size(0)); + }; void evalBoundary(GlobalPosition,const Intersection&,FluidState &, PhaseVector &); diff --git a/dumux/decoupled/common/fv/fvpressure.hh b/dumux/decoupled/common/fv/fvpressure.hh index 64fbd6557857bba19814a0d83be66893fd83ff21..9864d7a472df56e3b8b784015a59a0a75625cd85 100644 --- a/dumux/decoupled/common/fv/fvpressure.hh +++ b/dumux/decoupled/common/fv/fvpressure.hh @@ -170,7 +170,11 @@ public: */ void initialize() { - initializeMatrix(); + size_ = problem_.gridView().size(0);//resize to make sure the final grid size (after the problem was completely built) is used! + A_.setSize(size_, size_); + f_.resize(size_); + pressure_.resize(size_); + initializeMatrix();// initialize sparse matrix pressure_ = 0; } diff --git a/dumux/decoupled/common/impetproblem.hh b/dumux/decoupled/common/impetproblem.hh index 450e907fb54a39843e973315ef4f0b7aa5101ffc..b961289c7ae3a9e30ecdbba93216999b5c515d51 100644 --- a/dumux/decoupled/common/impetproblem.hh +++ b/dumux/decoupled/common/impetproblem.hh @@ -382,6 +382,7 @@ public: void init() { // set the initial condition of the model + variables_.initialize(); model().initialize(); } diff --git a/dumux/decoupled/common/onemodelproblem.hh b/dumux/decoupled/common/onemodelproblem.hh index 07a7f751d9ede1ea3536f9440fff74c3d7f4d030..206ba8c175c0a930638514429794e4a3f28e5fa3 100644 --- a/dumux/decoupled/common/onemodelproblem.hh +++ b/dumux/decoupled/common/onemodelproblem.hh @@ -343,6 +343,7 @@ public: void init() { // set the initial condition of the model + variables_.initialize(); model().initialize(); } diff --git a/dumux/decoupled/common/variableclass.hh b/dumux/decoupled/common/variableclass.hh index be8df9087abf462bf77004f3de97f3ca38236495..3e3e3377c5d524ab7417483754392e20726b13b5 100644 --- a/dumux/decoupled/common/variableclass.hh +++ b/dumux/decoupled/common/variableclass.hh @@ -89,11 +89,20 @@ public: */ VariableClass(const GridView& gridView) : gridView_(gridView), elementMapper_(gridView), vertexMapper_(gridView) + {} + + + //! Initializes the variable class + /*! Method initializes the cellData vector. + * Should be called from problem init() + */ + void initialize() { - cellDataVector_.resize(gridView.size(0)); + elementMapper_.update(); + vertexMapper_.update(); + cellDataVector_.resize(gridView_.size(0)); } - //! Resizes decoupled variable vectors /*! Method that change the size of the vectors for h-adaptive simulations. *