50
50
#include < ewoms/parallel/gridcommhandles.hh>
51
51
#include < ewoms/parallel/threadmanager.hh>
52
52
#include < ewoms/linear/nullborderlistmanager.hh>
53
- #include < ewoms/linear/istlsparsematrixadapter.hh>
54
53
#include < ewoms/common/simulator.hh>
55
54
#include < ewoms/common/alignedallocator.hh>
56
55
#include < ewoms/common/timer.hh>
76
75
#include < dune/fem/space/common/restrictprolongtuple.hh>
77
76
#include < dune/fem/function/blockvectorfunction.hh>
78
77
#include < dune/fem/misc/capabilities.hh>
79
-
80
- #if HAVE_PETSC
81
- #include < dune/fem/operator/linear/petscoperator.hh>
82
78
#endif
83
- #include < dune/fem/operator/linear/istloperator.hh>
84
- #include < dune/fem/operator/linear/spoperator.hh>
85
- #endif // endif HAVE_DUNE_FEM
86
79
87
80
#include < limits>
88
81
#include < list>
@@ -136,78 +129,6 @@ SET_TYPE_PROP(FvBaseDiscretization, DiscExtensiveQuantities, Ewoms::FvBaseExtens
136
129
// ! Calculates the gradient of any quantity given the index of a flux approximation point
137
130
SET_TYPE_PROP (FvBaseDiscretization, GradientCalculator, Ewoms::FvBaseGradientCalculator<TypeTag>);
138
131
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
-
211
132
// ! The maximum allowed number of timestep divisions for the
212
133
// ! Newton solver
213
134
SET_INT_PROP (FvBaseDiscretization, MaxTimeStepDivisions, 10 );
@@ -408,15 +329,13 @@ class FvBaseDiscretization
408
329
409
330
typedef typename LocalResidual::LocalEvalBlockVector LocalEvalBlockVector;
410
331
411
- typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
412
-
413
332
class BlockVectorWrapper
414
333
{
415
334
protected:
416
335
SolutionVector blockVector_;
417
336
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)
420
339
{}
421
340
422
341
SolutionVector& blockVector ()
@@ -426,12 +345,14 @@ class FvBaseDiscretization
426
345
};
427
346
428
347
#if HAVE_DUNE_FEM
348
+ typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunctionSpace) DiscreteFunctionSpace;
349
+
429
350
// discrete function storing solution data
430
- typedef typename GET_PROP_TYPE (TypeTag, DiscreteFunction) DiscreteFunction;
351
+ typedef Dune::Fem::ISTLBlockVectorDiscreteFunction<DiscreteFunctionSpace, PrimaryVariables> DiscreteFunction;
431
352
432
353
// 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;
435
356
436
357
// discrete function restriction and prolongation operator for adaptation
437
358
typedef Dune::Fem::RestrictProlongDefault< DiscreteFunction > DiscreteFunctionRestrictProlong;
@@ -440,6 +361,7 @@ class FvBaseDiscretization
440
361
typedef Dune::Fem::AdaptationManager<Grid, RestrictProlong > AdaptationManager;
441
362
#else
442
363
typedef BlockVectorWrapper DiscreteFunction;
364
+ typedef size_t DiscreteFunctionSpace;
443
365
#endif
444
366
445
367
// copying a discretization object is not a good idea
@@ -459,14 +381,14 @@ public:
459
381
, elementMapper_(gridView_)
460
382
, vertexMapper_(gridView_)
461
383
#endif
384
+ , newtonMethod_(simulator)
385
+ , localLinearizer_(ThreadManager::maxThreads())
386
+ , linearizer_(new Linearizer())
462
387
#if HAVE_DUNE_FEM
463
- , discreteFunctionSpace_ ( simulator.vanguard().gridPart() )
388
+ , space_ ( simulator.vanguard().gridPart() )
464
389
#else
465
- , discreteFunctionSpace_ ( asImp_().numGridDof() )
390
+ , space_ ( asImp_().numGridDof() )
466
391
#endif
467
- , newtonMethod_(simulator)
468
- , localLinearizer_(ThreadManager::maxThreads())
469
- , linearizer_(new Linearizer( ))
470
392
, enableGridAdaptation_( EWOMS_GET_PARAM(TypeTag, bool , EnableGridAdaptation) )
471
393
, enableIntensiveQuantityCache_(EWOMS_GET_PARAM(TypeTag, bool , EnableIntensiveQuantityCache))
472
394
, enableStorageCache_(EWOMS_GET_PARAM(TypeTag, bool , EnableStorageCache))
@@ -491,7 +413,7 @@ public:
491
413
492
414
size_t numDof = asImp_ ().numGridDof ();
493
415
for (unsigned timeIdx = 0 ; timeIdx < historySize; ++timeIdx) {
494
- solution_[timeIdx].reset (new DiscreteFunction (" solution" , discreteFunctionSpace_ ));
416
+ solution_[timeIdx].reset (new DiscreteFunction (" solution" , space_ ));
495
417
496
418
if (storeIntensiveQuantities ()) {
497
419
intensiveQuantityCache_[timeIdx].resize (numDof);
@@ -1156,16 +1078,6 @@ public:
1156
1078
SolutionVector& solution (unsigned timeIdx)
1157
1079
{ return solution_[timeIdx]->blockVector (); }
1158
1080
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
-
1169
1081
protected:
1170
1082
/* !
1171
1083
* \copydoc solution(int) const
@@ -1583,7 +1495,7 @@ public:
1583
1495
void resetLinearizer ()
1584
1496
{
1585
1497
delete linearizer_;
1586
- linearizer_ = new Linearizer () ;
1498
+ linearizer_ = new Linearizer;
1587
1499
linearizer_->init (simulator_);
1588
1500
}
1589
1501
@@ -1817,11 +1729,6 @@ public:
1817
1729
solution (timeIdx).resize (numDof);
1818
1730
1819
1731
auxMod->applyInitial ();
1820
-
1821
- #if DUNE_VERSION_NEWER( DUNE_FEM, 2, 7 )
1822
- discreteFunctionSpace_.extendSize ( asImp_ ().numAuxiliaryDof () );
1823
- #endif
1824
-
1825
1732
}
1826
1733
1827
1734
/* !
@@ -1888,11 +1795,6 @@ public:
1888
1795
const Ewoms::Timer& updateTimer () const
1889
1796
{ return updateTimer_; }
1890
1797
1891
- #if HAVE_DUNE_FEM
1892
- const DiscreteFunctionSpace& space () const { return discreteFunctionSpace_; }
1893
- #endif
1894
-
1895
-
1896
1798
protected:
1897
1799
void resizeAndResetIntensiveQuantitiesCache_ ()
1898
1800
{
@@ -1963,18 +1865,9 @@ protected:
1963
1865
ElementMapper elementMapper_;
1964
1866
VertexMapper vertexMapper_;
1965
1867
1966
- DiscreteFunctionSpace discreteFunctionSpace_;
1967
-
1968
1868
// a vector with all auxiliary equations to be considered
1969
1869
std::vector<BaseAuxiliaryModule<TypeTag>*> auxEqModules_;
1970
1870
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
-
1978
1871
NewtonMethod newtonMethod_;
1979
1872
1980
1873
Ewoms::Timer prePostProcessTimer_;
@@ -1993,6 +1886,15 @@ protected:
1993
1886
mutable IntensiveQuantitiesVector intensiveQuantityCache_[historySize];
1994
1887
mutable std::vector<bool > intensiveQuantityCacheUpToDate_[historySize];
1995
1888
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
+
1996
1898
std::list<BaseOutputModule<TypeTag>*> outputModules_;
1997
1899
1998
1900
Scalar gridTotalVolume_;
0 commit comments