5050#include < ewoms/parallel/gridcommhandles.hh>
5151#include < ewoms/parallel/threadmanager.hh>
5252#include < ewoms/linear/nullborderlistmanager.hh>
53- #include < ewoms/linear/istlsparsematrixadapter.hh>
5453#include < ewoms/common/simulator.hh>
5554#include < ewoms/common/alignedallocator.hh>
5655#include < ewoms/common/timer.hh>
7675#include < dune/fem/space/common/restrictprolongtuple.hh>
7776#include < dune/fem/function/blockvectorfunction.hh>
7877#include < dune/fem/misc/capabilities.hh>
79-
80- #if HAVE_PETSC
81- #include < dune/fem/operator/linear/petscoperator.hh>
8278#endif
83- #include < dune/fem/operator/linear/istloperator.hh>
84- #include < dune/fem/operator/linear/spoperator.hh>
85- #endif // endif HAVE_DUNE_FEM
8679
8780#include < limits>
8881#include < list>
@@ -136,78 +129,6 @@ SET_TYPE_PROP(FvBaseDiscretization, DiscExtensiveQuantities, Ewoms::FvBaseExtens
136129// ! Calculates the gradient of any quantity given the index of a flux approximation point
137130SET_TYPE_PROP (FvBaseDiscretization, GradientCalculator, Ewoms::FvBaseGradientCalculator<TypeTag>);
138131
139- // ! Set the type of a global Jacobian matrix from the solution types
140- #if HAVE_DUNE_FEM
141- SET_PROP (FvBaseDiscretization, DiscreteFunction)
142- {
143- private:
144- typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
145- typedef typename GET_PROP_TYPE (TypeTag, PrimaryVariables) PrimaryVariables;
146- public:
147- // discrete function storing solution data
148- typedef Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, PrimaryVariables> type;
149- };
150- #endif
151-
152- #if USE_DUNE_FEM_SOLVERS
153- SET_PROP (FvBaseDiscretization, SparseMatrixAdapter)
154- {
155- private:
156- typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
157- typedef typename GET_PROP_TYPE (TypeTag, Scalar) Scalar;
158- // discrete function storing solution data
159- typedef Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace> DiscreteFunction;
160-
161- #if USE_DUNE_FEM_PETSC_SOLVERS
162- #warning "Using Dune-Fem PETSc solvers"
163- typedef Dune::Fem::PetscLinearOperator< DiscreteFunction, DiscreteFunction > LinearOperator;
164- #elif USE_DUNE_FEM_VIENNACL_SOLVERS
165- #warning "Using Dune-Fem ViennaCL solvers"
166- typedef Dune::Fem::SparseRowLinearOperator < DiscreteFunction, DiscreteFunction > LinearOperator;
167- #else
168- #warning "Using Dune-Fem ISTL solvers"
169- typedef Dune::Fem::ISTLLinearOperator < DiscreteFunction, DiscreteFunction > LinearOperator;
170- #endif
171-
172- struct FemMatrixBackend : public LinearOperator
173- {
174- typedef LinearOperator ParentType;
175- typedef typename LinearOperator :: MatrixType Matrix;
176- typedef typename ParentType :: MatrixBlockType MatrixBlock;
177- template <class Simulator >
178- FemMatrixBackend ( const Simulator& simulator )
179- : LinearOperator(" eWoms::Jacobian" , simulator.model().space(), simulator.model().space() )
180- {}
181-
182- void commit ()
183- {
184- this ->flushAssembly ();
185- }
186-
187- template < class LocalBlock >
188- void addToBlock ( const size_t row, const size_t col, const LocalBlock& block )
189- {
190- this ->addBlock ( row, col, block );
191- }
192-
193- void clearRow ( const size_t row, const Scalar diag = 1.0 ) { this ->unitRow ( row ); }
194- };
195- public:
196- typedef FemMatrixBackend type;
197- };
198- #else
199- SET_PROP (FvBaseDiscretization, SparseMatrixAdapter)
200- {
201- private:
202- typedef typename GET_PROP_TYPE (TypeTag, Scalar) Scalar;
203- enum { numEq = GET_PROP_VALUE (TypeTag, NumEq) };
204- typedef Ewoms::MatrixBlock<Scalar, numEq, numEq> Block;
205-
206- public:
207- typedef typename Ewoms::Linear::IstlSparseMatrixAdapter<Block> type;
208- };
209- #endif
210-
211132// ! The maximum allowed number of timestep divisions for the
212133// ! Newton solver
213134SET_INT_PROP (FvBaseDiscretization, MaxTimeStepDivisions, 10 );
@@ -408,15 +329,13 @@ class FvBaseDiscretization
408329
409330 typedef typename LocalResidual::LocalEvalBlockVector LocalEvalBlockVector;
410331
411- typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
412-
413332 class BlockVectorWrapper
414333 {
415334 protected:
416335 SolutionVector blockVector_;
417336 public:
418- BlockVectorWrapper (const std::string& name OPM_UNUSED, const DiscreteFunctionSpace& space )
419- : blockVector_(space. size() )
337+ BlockVectorWrapper (const std::string& name OPM_UNUSED, const size_t size )
338+ : blockVector_(size)
420339 {}
421340
422341 SolutionVector& blockVector ()
@@ -426,12 +345,14 @@ class FvBaseDiscretization
426345 };
427346
428347#if HAVE_DUNE_FEM
348+ typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
349+
429350 // discrete function storing solution data
430- typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunction) DiscreteFunction;
351+ typedef Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, PrimaryVariables> DiscreteFunction;
431352
432353 // problem restriction and prolongation operator for adaptation
433- typedef typename GET_PROP_TYPE (TypeTag, Problem) Problem;
434- typedef typename Problem :: RestrictProlongOperator ProblemRestrictProlongOperator;
354+ typedef typename GET_PROP_TYPE (TypeTag, Problem) Problem;
355+ typedef typename Problem :: RestrictProlongOperator ProblemRestrictProlongOperator;
435356
436357 // discrete function restriction and prolongation operator for adaptation
437358 typedef Dune::Fem::RestrictProlongDefault< DiscreteFunction > DiscreteFunctionRestrictProlong;
@@ -440,6 +361,7 @@ class FvBaseDiscretization
440361 typedef Dune::Fem::AdaptationManager<Grid, RestrictProlong > AdaptationManager;
441362#else
442363 typedef BlockVectorWrapper DiscreteFunction;
364+ typedef size_t DiscreteFunctionSpace;
443365#endif
444366
445367 // copying a discretization object is not a good idea
@@ -459,14 +381,14 @@ public:
459381 , elementMapper_(gridView_)
460382 , vertexMapper_(gridView_)
461383#endif
384+ , newtonMethod_(simulator)
385+ , localLinearizer_(ThreadManager::maxThreads())
386+ , linearizer_(new Linearizer())
462387#if HAVE_DUNE_FEM
463- , discreteFunctionSpace_ ( simulator.vanguard().gridPart() )
388+ , space_ ( simulator.vanguard().gridPart() )
464389#else
465- , discreteFunctionSpace_ ( asImp_().numGridDof() )
390+ , space_ ( asImp_().numGridDof() )
466391#endif
467- , newtonMethod_(simulator)
468- , localLinearizer_(ThreadManager::maxThreads())
469- , linearizer_(new Linearizer( ))
470392 , enableGridAdaptation_( EWOMS_GET_PARAM(TypeTag, bool , EnableGridAdaptation) )
471393 , enableIntensiveQuantityCache_(EWOMS_GET_PARAM(TypeTag, bool , EnableIntensiveQuantityCache))
472394 , enableStorageCache_(EWOMS_GET_PARAM(TypeTag, bool , EnableStorageCache))
@@ -491,7 +413,7 @@ public:
491413
492414 size_t numDof = asImp_ ().numGridDof ();
493415 for (unsigned timeIdx = 0 ; timeIdx < historySize; ++timeIdx) {
494- solution_[timeIdx].reset (new DiscreteFunction (" solution" , discreteFunctionSpace_ ));
416+ solution_[timeIdx].reset (new DiscreteFunction (" solution" , space_ ));
495417
496418 if (storeIntensiveQuantities ()) {
497419 intensiveQuantityCache_[timeIdx].resize (numDof);
@@ -1156,16 +1078,6 @@ public:
11561078 SolutionVector& solution (unsigned timeIdx)
11571079 { return solution_[timeIdx]->blockVector (); }
11581080
1159- template <class BVector >
1160- void communicate ( BVector& x ) const
1161- {
1162- #if HAVE_DUNE_FEM
1163- typedef Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, typename BVector::block_type> DF;
1164- DF tmpX (" temp-x" , discreteFunctionSpace_, x);
1165- tmpX.communicate ();
1166- #endif
1167- }
1168-
11691081 protected:
11701082 /* !
11711083 * \copydoc solution(int) const
@@ -1583,7 +1495,7 @@ public:
15831495 void resetLinearizer ()
15841496 {
15851497 delete linearizer_;
1586- linearizer_ = new Linearizer () ;
1498+ linearizer_ = new Linearizer;
15871499 linearizer_->init (simulator_);
15881500 }
15891501
@@ -1817,11 +1729,6 @@ public:
18171729 solution (timeIdx).resize (numDof);
18181730
18191731 auxMod->applyInitial ();
1820-
1821- #if DUNE_VERSION_NEWER( DUNE_FEM, 2, 7 )
1822- discreteFunctionSpace_.extendSize ( asImp_ ().numAuxiliaryDof () );
1823- #endif
1824-
18251732 }
18261733
18271734 /* !
@@ -1888,11 +1795,6 @@ public:
18881795 const Ewoms::Timer& updateTimer () const
18891796 { return updateTimer_; }
18901797
1891- #if HAVE_DUNE_FEM
1892- const DiscreteFunctionSpace& space () const { return discreteFunctionSpace_; }
1893- #endif
1894-
1895-
18961798protected:
18971799 void resizeAndResetIntensiveQuantitiesCache_ ()
18981800 {
@@ -1963,18 +1865,9 @@ protected:
19631865 ElementMapper elementMapper_;
19641866 VertexMapper vertexMapper_;
19651867
1966- DiscreteFunctionSpace discreteFunctionSpace_;
1967-
19681868 // a vector with all auxiliary equations to be considered
19691869 std::vector<BaseAuxiliaryModule<TypeTag>*> auxEqModules_;
19701870
1971- mutable std::array< std::unique_ptr< DiscreteFunction >, historySize > solution_;
1972-
1973- #if HAVE_DUNE_FEM
1974- std::unique_ptr< RestrictProlong > restrictProlong_;
1975- std::unique_ptr< AdaptationManager> adaptationManager_;
1976- #endif
1977-
19781871 NewtonMethod newtonMethod_;
19791872
19801873 Ewoms::Timer prePostProcessTimer_;
@@ -1993,6 +1886,15 @@ protected:
19931886 mutable IntensiveQuantitiesVector intensiveQuantityCache_[historySize];
19941887 mutable std::vector<bool > intensiveQuantityCacheUpToDate_[historySize];
19951888
1889+ DiscreteFunctionSpace space_;
1890+ mutable std::array< std::unique_ptr< DiscreteFunction >, historySize > solution_;
1891+
1892+ #if HAVE_DUNE_FEM
1893+ std::unique_ptr<RestrictProlong> restrictProlong_;
1894+ std::unique_ptr<AdaptationManager> adaptationManager_;
1895+ #endif
1896+
1897+
19961898 std::list<BaseOutputModule<TypeTag>*> outputModules_;
19971899
19981900 Scalar gridTotalVolume_;
0 commit comments