boxproperties.hh 12.8 KB
Newer Older
Andreas Lauser's avatar
Andreas Lauser committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// $Id$
/*****************************************************************************
 *   Copyright (C) 2009 by Andreas Lauser                                    *
 *   Copyright (C) 2008 by Bernd Flemisch                                    *
 *   Institute of Hydraulic Engineering                                      *
 *   University of Stuttgart, Germany                                        *
 *   email: <givenname>.<name>@iws.uni-stuttgart.de                          *
 *                                                                           *
 *   This program is free software; you can redistribute it and/or modify    *
 *   it under the terms of the GNU General Public License as published by    *
 *   the Free Software Foundation; either version 2 of the License, or       *
 *   (at your option) any later version, as long as this copyright notice    *
 *   is included in its original form.                                       *
 *                                                                           *
 *   This program is distributed WITHOUT ANY WARRANTY.                       *
 *****************************************************************************/
#ifndef DUMUX_BOX_PROPERTIES_HH
#define DUMUX_BOX_PROPERTIES_HH

#include <dumux/common/propertysystem.hh>

/*!
 * \file
 * \brief Specify the shape functions, operator assemblers, etc
 *        used for the BoxModel.
 */
namespace Dumux
{

namespace Properties
{
/*!
 * \addtogroup BoxModel
 */
// \{

//////////////////////////////////////////////////////////////////
// Type tags tags
//////////////////////////////////////////////////////////////////

//! The type tag for models based on the box-scheme
NEW_TYPE_TAG(BoxModel);

//////////////////////////////////////////////////////////////////
// Property tags
//////////////////////////////////////////////////////////////////

//!< Property tag for scalar vaslues
NEW_PROP_TAG(Scalar);

NEW_PROP_TAG(Grid);     //!< The type of the DUNE grid
NEW_PROP_TAG(GridView); //!< The type of the grid view

NEW_PROP_TAG(ReferenceElements); //!< DUNE reference elements to be used
NEW_PROP_TAG(FVElementGeometry); //! The type of the finite-volume geometry in the box scheme

NEW_PROP_TAG(Problem);       //!< The type of the problem
NEW_PROP_TAG(Model);         //!< The type of the discretization
NEW_PROP_TAG(NumEq);         //!< Number of equations in the system of PDEs
NEW_PROP_TAG(LocalResidual); //!< The type of the local residual function
NEW_PROP_TAG(LocalJacobian); //!< The type of the local jacobian operator

NEW_PROP_TAG(JacobianAssembler); //!< Assembles the global jacobian matrix
NEW_PROP_TAG(JacobianMatrix); //!< Type of the global jacobian matrix
NEW_PROP_TAG(BoundaryTypes); //!< Stores the boundary types of a single degree of freedom
NEW_PROP_TAG(ElementBoundaryTypes); //!< Stores the boundary types on an element

68
NEW_PROP_TAG(PrimaryVariables); //!< A vector of primary variables within a sub-control volume
Andreas Lauser's avatar
Andreas Lauser committed
69
70
71
NEW_PROP_TAG(SolutionVector); //!< Vector containing all primary variable vector of the grid
NEW_PROP_TAG(ElementSolutionVector); //!< A vector of primary variables within a sub-control volume

72
73
74
NEW_PROP_TAG(VolumeVariables);  //!< The secondary variables within a sub-control volume
NEW_PROP_TAG(ElementVolumeVariables); //!< The secondary variables of all sub-control volumes in an element
NEW_PROP_TAG(FluxVariables); //!< Data required to calculate a flux over a face
Andreas Lauser's avatar
Andreas Lauser committed
75
76

// high level simulation control
77
NEW_PROP_TAG(TimeManager);  //!< Manages the simulation time
Andreas Lauser's avatar
Andreas Lauser committed
78
79
80
81
82
83
84
85
86
87
88
89
NEW_PROP_TAG(NewtonMethod);     //!< The type of the newton method
NEW_PROP_TAG(NewtonController); //!< The type of the newton controller

// properties for the PDELab wrapper
NEW_PROP_TAG(LocalFEMSpace); //!< The local finite element space used for the finite element interpolation
NEW_PROP_TAG(ScalarGridFunctionSpace); //!< The used grid function space for a single finite element function
NEW_PROP_TAG(GridFunctionSpace); //!< The used grid function space
NEW_PROP_TAG(Constraints); //!< The constraints on the grid function space
NEW_PROP_TAG(ConstraintsTrafo); //!< The type of PDELab's constraints transformation
NEW_PROP_TAG(LocalOperator); //!< The type of the local operator used by PDELab
NEW_PROP_TAG(GridOperatorSpace); //!< The used grid operator space

90
91
92
93
94
//! Specify whether the jacobian matrix of the last iteration of a
//! time step should be re-used as the jacobian of the first iteration
//! of the next time step.
NEW_PROP_TAG(EnableJacobianRecycling);

95
96
97
98
99
//! Specify whether the jacobian matrix should be only reassembled for
//! elements where at least one vertex is above the specified
//! tolerance
NEW_PROP_TAG(EnablePartialReassemble);

Andreas Lauser's avatar
Andreas Lauser committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// mappers from local to global indices
NEW_PROP_TAG(VertexMapper);
NEW_PROP_TAG(ElementMapper);
NEW_PROP_TAG(DofMapper);
}
}


#include <dumux/nonlinear/newtonmethod.hh>
#include <dumux/nonlinear/newtoncontroller.hh>

#include "boxfvelementgeometry.hh"
#include "pdelabboxassembler.hh"
#include "pdelabboxistlvectorbackend.hh"
//#include <dumux/boxmodels/pdelab/boxdirichletconstraints.hh>

#include <dumux/common/boundarytypes.hh>
#include <dumux/common/timemanager.hh>

namespace Dumux {

template<typename TypeTag>
class BoxFVElementGeometry;

template<typename TypeTag>
class BoxElementBoundaryTypes;

template<typename TypeTag>
128
class BoxElementVolumeVariables;
Andreas Lauser's avatar
Andreas Lauser committed
129

130
131
132
template<typename TypeTag>
class BoxLocalJacobian;

Andreas Lauser's avatar
Andreas Lauser committed
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
namespace PDELab {
template<typename TypeTag>
class BoxLocalOperator;

template<typename TypeTag>
class BoxAssembler;

template<typename TypeTag>
class BoxISTLVectorBackend;
};

namespace Properties {
//////////////////////////////////////////////////////////////////
// Some defaults for very fundamental properties
//////////////////////////////////////////////////////////////////

//! Set the default type for scalar values to double
SET_PROP_DEFAULT(Scalar)
{ typedef double type; };

//! Set the default type for the time manager
SET_PROP_DEFAULT(TimeManager)
{ typedef Dumux::TimeManager<TypeTag> type; };

/*!
 * \brief Specify the reference elements which we ought to use.
 *
 * We use Dune::ReferenceElements by default (-> old entity
 * numbering).
 *
 * TODO: Some specialization if the grid only supports one kind of
 *       cells would be nice. this would be better fixed inside DUNE,
 *       though. something like:
 *       Dune::GenericReferenceElements<Dune::GeometryType<cube, dim> >
 */
SET_PROP_DEFAULT(ReferenceElements)
{
private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Grid)) Grid;

    typedef typename Grid::ctype CoordScalar;
    static const int dim = Grid::dimension;

public:
    typedef Dune::GenericReferenceElements<CoordScalar, dim> Container;
    typedef Dune::GenericReferenceElement<CoordScalar, dim>  ReferenceElement;
};

//////////////////////////////////////////////////////////////////
// Properties
//////////////////////////////////////////////////////////////////

//! Use the leaf grid view if not defined otherwise
SET_PROP(BoxModel, GridView)
{
private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Grid)) Grid;

public:
    typedef typename Grid::LeafGridView type;
};

//! Set the default for the FVElementGeometry
SET_PROP(BoxModel, FVElementGeometry)
{
    typedef Dumux::BoxFVElementGeometry<TypeTag>  type;
};

//! Set the default for the ElementBoundaryTypes
SET_PROP(BoxModel, ElementBoundaryTypes)
{ typedef Dumux::BoxElementBoundaryTypes<TypeTag> type; };

//! use the plain newton method for the box scheme by default
SET_PROP(BoxModel, NewtonMethod)
{public:
    typedef Dumux::NewtonMethod<TypeTag> type;
};

//! use the plain newton controller for the box scheme by default
SET_PROP(BoxModel, NewtonController)
{public:
    typedef Dumux::NewtonController<TypeTag> type;
};

//! Mapper for the grid view's vertices.
SET_PROP(BoxModel, VertexMapper)
{private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView;

    template<int dim>
    struct VertexLayout {
        bool contains (Dune::GeometryType gt) const
        { return gt.dim() == 0; }
    };
public:
    typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, VertexLayout> type;
};

//! Mapper for the grid view's elements.
SET_PROP(BoxModel, ElementMapper)
{private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView;

    template<int dim>
    struct ElementLayout {
        bool contains (Dune::GeometryType gt) const
        { return gt.dim() == dim; }
    };
public:
    typedef Dune::MultipleCodimMultipleGeomTypeMapper<GridView, ElementLayout> type;
};

//! Mapper for the degrees of freedoms.
SET_PROP(BoxModel, DofMapper)
{ typedef typename GET_PROP_TYPE(TypeTag, PTAG(VertexMapper)) type; };

249
250
//! The local jacobian operator for the box scheme
SET_TYPE_PROP(BoxModel, LocalJacobian, Dumux::BoxLocalJacobian<TypeTag>);
Andreas Lauser's avatar
Andreas Lauser committed
251
252
253
254
255
256

/*!
 * \brief The type of a solution for the whole grid at a fixed time.
 */
SET_PROP(BoxModel, SolutionVector)
{ private:
257
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
Andreas Lauser's avatar
Andreas Lauser committed
258
259
260
261
262
263
264
265
266
267
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridFunctionSpace)) GridFunctionSpace;
public:
    typedef typename GridFunctionSpace::template VectorContainer<Scalar>::Type type;
};

/*!
 * \brief The type of a solution for a whole element.
 */
SET_PROP(BoxModel, ElementSolutionVector)
{ private:
268
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(PrimaryVariables)) PrimaryVariables;
Andreas Lauser's avatar
Andreas Lauser committed
269
public:
270
    typedef Dune::BlockVector<PrimaryVariables> type;
Andreas Lauser's avatar
Andreas Lauser committed
271
272
273
274
275
};

/*!
 * \brief A vector of primary variables.
 */
276
SET_PROP(BoxModel, PrimaryVariables)
Andreas Lauser's avatar
Andreas Lauser committed
277
278
279
280
281
{ typedef typename GET_PROP_TYPE(TypeTag, PTAG(SolutionVector))::block_type type; };

/*!
 * \brief An array of secondary variable containers.
 */
282
SET_TYPE_PROP(BoxModel, ElementVolumeVariables, Dumux::BoxElementVolumeVariables<TypeTag>);
Andreas Lauser's avatar
Andreas Lauser committed
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304

/*!
 * \brief Boundary types at a single degree of freedom.
 */
SET_PROP(BoxModel, BoundaryTypes)
{ private:
    enum { numEq = GET_PROP_VALUE(TypeTag, PTAG(NumEq)) };
public:
    typedef Dumux::BoundaryTypes<numEq>  type;
};

/*!
 * \brief Assembler for the global jacobian matrix.
 */
SET_TYPE_PROP(BoxModel, JacobianAssembler, Dumux::PDELab::BoxAssembler<TypeTag>);

//! Extract the type of a global jacobian matrix from the solution types
SET_PROP(BoxModel, JacobianMatrix)
{
private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridOperatorSpace)) GridOperatorSpace;
305
public:
Andreas Lauser's avatar
Andreas Lauser committed
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
    typedef typename GridOperatorSpace::template MatrixContainer<Scalar>::Type type;
};

//! use the local FEM space associated with cubes by default
SET_PROP(BoxModel, LocalFEMSpace)
{
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView;
    enum{dim = GridView::dimension};

public:
    typedef Dune::PDELab::Q1LocalFiniteElementMap<Scalar,Scalar,dim>  type;
};

SET_PROP(BoxModel, GridFunctionSpace)
{private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(LocalFEMSpace)) FEM;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridView)) GridView;
    enum{numEq = GET_PROP_VALUE(TypeTag, PTAG(NumEq))};
public:
    //typedef MyBoxConstraints Constraints;
    typedef Dune::PDELab::NoConstraints Constraints;

    typedef Dune::PDELab::GridFunctionSpace<GridView, FEM, Constraints, Dumux::PDELab::BoxISTLVectorBackend<TypeTag> >
        ScalarGridFunctionSpace;

    typedef Dune::PDELab::PowerGridFunctionSpace<ScalarGridFunctionSpace, numEq, Dune::PDELab::GridFunctionSpaceBlockwiseMapper>
        type;
335
336

    typedef typename type::template ConstraintsContainer<Scalar>::Type
Andreas Lauser's avatar
Andreas Lauser committed
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
        ConstraintsTrafo;
};

SET_PROP(BoxModel, ConstraintsTrafo)
{ typedef typename GET_PROP(TypeTag, PTAG(GridFunctionSpace))::ConstraintsTrafo type; };
SET_PROP(BoxModel, Constraints)
{ typedef typename GET_PROP(TypeTag, PTAG(GridFunctionSpace))::Constraints type; };
SET_PROP(BoxModel, ScalarGridFunctionSpace)
{ typedef typename GET_PROP(TypeTag, PTAG(GridFunctionSpace))::ScalarGridFunctionSpace type; };

SET_PROP(BoxModel, GridOperatorSpace)
{ private:
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(ConstraintsTrafo)) ConstraintsTrafo;
    typedef typename GET_PROP_TYPE(TypeTag, PTAG(GridFunctionSpace)) GridFunctionSpace;
    enum{numEq = GET_PROP_VALUE(TypeTag, PTAG(NumEq))};

354
public:
Andreas Lauser's avatar
Andreas Lauser committed
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
    typedef Dumux::PDELab::BoxLocalOperator<TypeTag> LocalOperator;

    typedef Dune::PDELab::GridOperatorSpace<GridFunctionSpace,
        GridFunctionSpace,
        LocalOperator,
        ConstraintsTrafo,
        ConstraintsTrafo,
        Dune::PDELab::ISTLBCRSMatrixBackend<numEq, numEq>,
        true
        > type;
};


SET_PROP(BoxModel, LocalOperator)
{ typedef typename GET_PROP(TypeTag, PTAG(GridOperatorSpace))::LocalOperator type; };

371
372
373
// disable jacobian matrix recycling by default
SET_BOOL_PROP(BoxModel, EnableJacobianRecycling, false);
// disable partial reassembling by default
374
SET_BOOL_PROP(BoxModel, EnablePartialReassemble, false);
375

Andreas Lauser's avatar
Andreas Lauser committed
376
377
378
379
380
381
// \}

}
}

#endif