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>
65template<
class TypeTag>
71 bool contains (Dune::GeometryType gt)
73 return gt.dim() == dim-1;
78 enum {dim=GridView::dimension};
79 using IS =
typename GridView::IndexSet;
80 using BlockType = Dune::FieldMatrix<Scalar, 1, 1>;
82 using MBlockType =
typename MatrixType::block_type;
83 using rowiterator =
typename MatrixType::RowIterator;
84 using coliterator =
typename MatrixType::ColIterator;
85 using BCBlockType = std::array<BoundaryConditions::Flags, 1>;
86 using SatType = Dune::BlockVector< Dune::FieldVector<double, 1> >;
87 using FaceMapper = Dune::MultipleCodimMultipleGeomTypeMapper<GridView>;
92 pressureEqIdx = Indices::pressureEqIdx,
98 return (4*dim - 1)*
size_;
115 if constexpr (Deprecated::hasUpdateGridView<FaceMapper, GridView>())
126 for (
unsigned int i = 0; i <
size_; i++)
130 std::vector<bool> visited(
size_,
false);
133 for (
const auto& element : elements(
gridView_))
135 int numFaces = element.subEntities(1);
137 for (
int i = 0; i < numFaces; i++)
143 A_.incrementrowsize(index);
144 visited[index] =
true;
147 A_.incrementrowsize(index, numFaces - 1);
157 visited.assign(
size_,
false);
160 for (
const auto& element : elements(
gridView_))
162 int numFaces = element.subEntities(1);
164 for (
int i = 0; i < numFaces; i++)
168 if (!visited[indexI])
170 A_.addindex(indexI,indexI);
171 visited[indexI] =
true;
173 for (
int k = 0; k < numFaces; k++)
177 A_.addindex(indexI, indexJ);
226 template <
class LocalStiffness,
class Vector>
231 if (u.N()!=
A_.M() || f.N()!=
A_.N())
232 DUNE_THROW(Dune::MathError,
"CROperatorAssemblerTwoP::assemble(): size mismatch");
238 std::vector<BCBlockType> essential(
faceMapper_.size());
239 for (
typename std::vector<BCBlockType>::size_type i=0; i<essential.size(); i++)
243 Dune::FieldVector<int, 2*dim> local2Global(0);
246 for (
const auto& element : elements(
gridView_))
248 unsigned int numFaces = element.subEntities(1);
251 for (
unsigned int k = 0; k < numFaces; k++)
254 local2Global[k] = alpha;
263 for (
unsigned int i=0; i<numFaces; i++)
266 for (
unsigned int j=0; j<numFaces; j++)
269 A_[local2Global[i]][local2Global[j]] += loc.
mat(i,j);
273 if (loc.
bc(i).isDirichlet(pressureEqIdx))
276 f[local2Global[i]][0] = loc.
rhs(i)[0];
279 f[local2Global[i]][0] += loc.
rhs(i)[0];
283 for (
const auto& element : elements(
gridView_))
285 unsigned int numFaces = element.subEntities(1);
288 for (
unsigned int k = 0; k < numFaces; k++)
291 local2Global[k] = alpha;
293 loc.completeRHS(element, local2Global, f);
297 rowiterator endi=
A_.end();
298 for (rowiterator i=
A_.begin(); i!=endi; ++i)
303 coliterator endj=(*i).end();
304 for (coliterator j=(*i).begin(); j!=endj; ++j)
307 if (j.index()==i.index())
315 coliterator endj=(*i).end();
316 for (coliterator j=(*i).begin(); j!=endj; ++j)
317 if (j.index()==i.index())
325 u[i.index()][0] = f[i.index()][0];
Definition of boundary condition types, extend if necessary.
Base class for assembling local stiffness matrices.
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Definition: common/pdesolver.hh:36
@ 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:67
const GridView gridView_
Definition: croperator.hh:331
CROperatorAssemblerTwoP(const GridView &gridview)
Definition: croperator.hh:104
FaceMapper faceMapper_
Definition: croperator.hh:332
unsigned int size_
Definition: croperator.hh:333
const FaceMapper & faceMapper() const
Definition: croperator.hh:204
const RepresentationType & operator*() const
Returns const reference to operator matrix.
Definition: croperator.hh:188
const FaceMapper & faceMapper()
Definition: croperator.hh:199
void assemble(LocalStiffness &loc, Vector &u, Vector &f)
Assembles global stiffness matrix.
Definition: croperator.hh:227
void initialize()
Initialize the CR operator assembler.
Definition: croperator.hh:113
RepresentationType A_
Definition: croperator.hh:334
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.