24#ifndef DUMUX_CROPERATOR2P_HH
25#define DUMUX_CROPERATOR2P_HH
33#include<dune/common/timer.hh>
34#include<dune/common/fvector.hh>
35#include<dune/common/fmatrix.hh>
36#include<dune/common/exceptions.hh>
37#include<dune/geometry/type.hh>
38#include<dune/grid/common/grid.hh>
39#include<dune/grid/common/mcmgmapper.hh>
40#include<dune/istl/bvector.hh>
41#include<dune/istl/operators.hh>
42#include<dune/istl/bcrsmatrix.hh>
64template<
class TypeTag>
70 bool contains (Dune::GeometryType gt)
72 return gt.dim() == dim-1;
77 enum {dim=GridView::dimension};
78 using IS =
typename GridView::IndexSet;
79 using BlockType = Dune::FieldMatrix<Scalar, 1, 1>;
80 using MatrixType = Dune::BCRSMatrix<BlockType>;
81 using MBlockType =
typename MatrixType::block_type;
82 using rowiterator =
typename MatrixType::RowIterator;
83 using coliterator =
typename MatrixType::ColIterator;
84 using BCBlockType = std::array<BoundaryConditions::Flags, 1>;
85 using SatType = Dune::BlockVector< Dune::FieldVector<double, 1> >;
86 using FaceMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
88 using Indices =
typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
91 pressureEqIdx = Indices::pressureEqIdx,
97 return (4*dim - 1)*
size_;
122 for (
unsigned int i = 0; i <
size_; i++)
126 std::vector<bool> visited(
size_,
false);
129 for (
const auto& element : elements(
gridView_))
131 int numFaces = element.subEntities(1);
133 for (
int i = 0; i < numFaces; i++)
139 A_.incrementrowsize(index);
140 visited[index] =
true;
143 A_.incrementrowsize(index, numFaces - 1);
153 visited.assign(
size_,
false);
156 for (
const auto& element : elements(
gridView_))
158 int numFaces = element.subEntities(1);
160 for (
int i = 0; i < numFaces; i++)
164 if (!visited[indexI])
166 A_.addindex(indexI,indexI);
167 visited[indexI] =
true;
169 for (
int k = 0; k < numFaces; k++)
173 A_.addindex(indexI, indexJ);
222 template <
class LocalStiffness,
class Vector>
227 if (u.N()!=
A_.M() || f.N()!=
A_.N())
228 DUNE_THROW(Dune::MathError,
"CROperatorAssemblerTwoP::assemble(): size mismatch");
234 std::vector<BCBlockType> essential(
faceMapper_.size());
235 for (
typename std::vector<BCBlockType>::size_type i=0; i<essential.size(); i++)
239 Dune::FieldVector<int, 2*dim> local2Global(0);
242 for (
const auto& element : elements(
gridView_))
244 unsigned int numFaces = element.subEntities(1);
247 for (
unsigned int k = 0; k < numFaces; k++)
250 local2Global[k] = alpha;
259 for (
unsigned int i=0; i<numFaces; i++)
262 for (
unsigned int j=0; j<numFaces; j++)
265 A_[local2Global[i]][local2Global[j]] += loc.
mat(i,j);
269 if (loc.
bc(i).isDirichlet(pressureEqIdx))
272 f[local2Global[i]][0] = loc.
rhs(i)[0];
275 f[local2Global[i]][0] += loc.
rhs(i)[0];
279 for (
const auto& element : elements(
gridView_))
281 unsigned int numFaces = element.subEntities(1);
284 for (
unsigned int k = 0; k < numFaces; k++)
287 local2Global[k] = alpha;
289 loc.completeRHS(element, local2Global, f);
293 rowiterator endi=
A_.end();
294 for (rowiterator i=
A_.begin(); i!=endi; ++i)
299 coliterator endj=(*i).end();
300 for (coliterator j=(*i).begin(); j!=endj; ++j)
303 if (j.index()==i.index())
311 coliterator endj=(*i).end();
312 for (coliterator j=(*i).begin(); j!=endj; ++j)
313 if (j.index()==i.index())
321 u[i.index()][0] = f[i.index()][0];
#define GET_PROP_TYPE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:283
Definition of boundary condition types, extend if necessary.
Base class for assembling local stiffness matrices.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Definition: common/properties/model.hh:34
@ dirichlet
Dirichlet boundary.
Definition: boundaryconditions.hh:41
@ neumann
Neumann boundary.
Definition: boundaryconditions.hh:39
Extends CROperatorBase by a generic methods to assemble global stiffness matrix from local stiffness ...
Definition: croperator.hh:66
const GridView gridView_
Definition: croperator.hh:327
MatrixType RepresentationType
Definition: croperator.hh:101
CROperatorAssemblerTwoP(const GridView &gridview)
Definition: croperator.hh:103
FaceMapper faceMapper_
Definition: croperator.hh:328
unsigned int size_
Definition: croperator.hh:329
const FaceMapper & faceMapper() const
Definition: croperator.hh:200
const RepresentationType & operator*() const
Returns const reference to operator matrix.
Definition: croperator.hh:184
const FaceMapper & faceMapper()
Definition: croperator.hh:195
void assemble(LocalStiffness &loc, Vector &u, Vector &f)
Assembles global stiffness matrix.
Definition: croperator.hh:223
void initialize()
Initialize the CR operator assembler.
Definition: croperator.hh:112
RepresentationType A_
Definition: croperator.hh:330
Base class for local assemblers.
Definition: localstiffness.hh:60
const VBlockType & rhs(int i) const
Accesses right hand side.
Definition: localstiffness.hh:210
const MBlockType & mat(int i, int j) const
Accesses the local stiffness matrix.
Definition: localstiffness.hh:197
const BoundaryTypes & bc(int i) const
Accesses boundary condition for each dof.
Definition: localstiffness.hh:223
virtual void assemble(const Entity &e, int k=1)=0
Assembles local stiffness matrix including boundary conditions for given element and order.
Base file for properties related to sequential IMPET algorithms.