asmhandler.hpp
Go to the documentation of this file.
1//==============================================================================
11//==============================================================================
12#ifndef ASMHANDLER_HPP_
13#define ASMHANDLER_HPP_
14
15#include <opm/common/utility/platform_dependent/disable_warnings.h>
16
17#include <dune/geometry/referenceelements.hh>
18#include <dune/common/fmatrix.hh>
19#include <dune/istl/bvector.hh>
20#include <dune/common/fvector.hh>
21
22#include <opm/common/utility/platform_dependent/reenable_warnings.h>
23
24
26#include <opm/elasticity/mpc.hh>
28
29namespace Opm {
30namespace Elasticity {
31
32
34 template<class GridType>
36 public:
38 static const int dim = GridType::dimension;
39
41 typedef typename GridType::LeafGridView::IndexSet LeafIndexSet;
42
44 typedef typename GridType::LeafGridView::template Codim<0>::Iterator LeafIterator;
45
48 explicit ASMHandler(const GridType& gv_) : gv(gv_), maxeqn(0)
49 {
50 }
51
54 {
55 for (MPCMap::iterator it=mpcs.begin(); it != mpcs.end();++it)
56 delete it->second;
57 }
58
60 ASMHandler(const ASMHandler&) = delete;
61
63 ASMHandler& operator=(const ASMHandler&) = delete;
64
66 typedef Dune::FieldVector<double,dim> NodeValue;
67
70 size_t getEqns() const
71 {
72 return maxeqn;
73 }
74
79 int getEquationForDof(int node, int dof)
80 {
81 return meqn[node*dim+dof];
82 }
83
87 {
88 return A;
89 }
90
94 {
95 return b;
96 }
97
100 void initForAssembly();
101
108 template<int esize>
109 void addElement(const Dune::FieldMatrix<double,esize,esize>* K,
110 const Dune::FieldVector<double,esize>* S,
111 const LeafIterator& cell,
112 Vector* b=NULL);
113
114 void addMatElement(const int i, const int j, const double val)
115 {
116 A[i][j] += val;
117 }
118
123 template<int comp>
124 void extractValues(Dune::FieldVector<double,comp>& v,
125 const Vector& u, const LeafIterator& it);
126
128 void expandSolution(Vector& result, const Vector& u);
129
133 void addMPC(MPC* mpc);
134
139 MPC* getMPC(int node, int dof);
140
144 void updateFixedNode(int node,
145 const std::pair<Direction,NodeValue>& entry);
146
149 bool isFixed(int node)
150 {
151 return (fixedNodes.find(node) != fixedNodes.end());
152 }
153
155 void printOperator() const;
156
158 void printLoadVector() const;
159
163 {
164 return adjacencyPattern;
165 }
166 protected:
169 {
170 for (MPCMap::iterator it = mpcs.begin();
171 it != mpcs.end();++it)
172 resolveMPCChain(it->second);
173 }
174
177 void resolveMPCChain(MPC* mpc);
178
180 void preprocess();
181
186 void nodeAdjacency(const LeafIterator& it, int vertexsize, int row);
187
190
200 template<int esize>
201 void addDOF(int row, int erow,
202 const Dune::FieldMatrix<double,esize,esize>* K,
203 const Dune::FieldVector<double,esize>* S,
204 const LeafIndexSet& set,
205 const LeafIterator& cell,
206 Vector* b,
207 double scale=1.f);
208
211
213 std::vector<int> meqn;
214
216 typedef std::pair<Direction,NodeValue> fixEntry;
217
219 typedef std::map<int,fixEntry> fixMap;
220
222 typedef typename fixMap::iterator fixIt;
223
226
229
232
235
237 const GridType& gv;
238
240 size_t maxeqn;
241};
242
243}
244}
245
246#include "asmhandler_impl.hpp"
247
248#endif
Class handling finite element assembly - template implementations.
Class handling finite element assembly.
Definition: asmhandler.hpp:35
static const int dim
The dimension of the grid.
Definition: asmhandler.hpp:38
std::pair< Direction, NodeValue > fixEntry
Fixed nodes.
Definition: asmhandler.hpp:216
bool isFixed(int node)
Check if a node is marked as fixed (in any direction)
Definition: asmhandler.hpp:149
void initForAssembly()
This function needs to be called before starting the element assembly.
Definition: asmhandler_impl.hpp:22
MPCMap mpcs
The set of MPC.
Definition: asmhandler.hpp:210
void resolveMPCChain(MPC *mpc)
Internal function. Handles a single MPC.
Definition: asmhandler_impl.hpp:250
~ASMHandler()
Destructor.
Definition: asmhandler.hpp:53
const GridType & gv
A reference to the grid in use.
Definition: asmhandler.hpp:237
fixMap fixedNodes
The map holding information about our fixed nodes.
Definition: asmhandler.hpp:225
ASMHandler & operator=(const ASMHandler &)=delete
No copying of this class.
Dune::FieldVector< double, dim > NodeValue
A vectorial node value.
Definition: asmhandler.hpp:66
size_t maxeqn
The number of equations in the system.
Definition: asmhandler.hpp:240
AdjacencyPattern adjacencyPattern
Holds the adjacency pattern of the sparse matrix.
Definition: asmhandler.hpp:228
std::vector< int > meqn
Vector of (interleaved) dof<->eqn mapping.
Definition: asmhandler.hpp:213
fixMap::iterator fixIt
Iterator over a fixmap.
Definition: asmhandler.hpp:222
Vector & getLoadVector()
Obtain a reference to the load vector.
Definition: asmhandler.hpp:93
GridType::LeafGridView::IndexSet LeafIndexSet
A set of indices.
Definition: asmhandler.hpp:41
int getEquationForDof(int node, int dof)
Get the equation number for a given dof on a given node.
Definition: asmhandler.hpp:79
ASMHandler(const ASMHandler &)=delete
No copying of this class.
void addElement(const Dune::FieldMatrix< double, esize, esize > *K, const Dune::FieldVector< double, esize > *S, const LeafIterator &cell, Vector *b=NULL)
Add an element matrix/vector to the system.
Definition: asmhandler_impl.hpp:85
void resolveMPCChains()
Resolve chained MPCs.
Definition: asmhandler.hpp:168
Vector b
The load vector.
Definition: asmhandler.hpp:234
ASMHandler(const GridType &gv_)
The default constructor.
Definition: asmhandler.hpp:48
std::map< int, fixEntry > fixMap
A mapping from dof to fix value info.
Definition: asmhandler.hpp:219
Matrix A
The linear operator.
Definition: asmhandler.hpp:231
void updateFixedNode(int node, const std::pair< Direction, NodeValue > &entry)
Update/add a fixed node.
Definition: asmhandler_impl.hpp:214
void extractValues(Dune::FieldVector< double, comp > &v, const Vector &u, const LeafIterator &it)
Extract values corresponding to cell.
Definition: asmhandler_impl.hpp:114
void expandSolution(Vector &result, const Vector &u)
Expand a system vector to a solution vector.
Definition: asmhandler_impl.hpp:145
void addMPC(MPC *mpc)
Add a MPC.
Definition: asmhandler_impl.hpp:187
AdjacencyPattern & getAdjacencyPattern()
Access current adjacency pattern.
Definition: asmhandler.hpp:162
void preprocess()
Internal function. Generate meqn for registered MPC/fixed nodes.
Definition: asmhandler_impl.hpp:315
void nodeAdjacency(const LeafIterator &it, int vertexsize, int row)
Internal function. Generate adjacency pattern for a given node.
Definition: asmhandler_impl.hpp:351
void addMatElement(const int i, const int j, const double val)
Definition: asmhandler.hpp:114
GridType::LeafGridView::template Codim< 0 >::Iterator LeafIterator
An iterator over grid cells.
Definition: asmhandler.hpp:44
void printLoadVector() const
Print the current load vector.
Definition: asmhandler_impl.hpp:241
Matrix & getOperator()
Obtain a reference to the linear operator.
Definition: asmhandler.hpp:86
MPC * getMPC(int node, int dof)
Look for and return a MPC for a specified node+dof.
Definition: asmhandler_impl.hpp:205
size_t getEqns() const
Get the number of equations in the system.
Definition: asmhandler.hpp:70
void determineAdjacencyPattern()
Internal function. Calculate adjacency pattern.
Definition: asmhandler_impl.hpp:375
void addDOF(int row, int erow, const Dune::FieldMatrix< double, esize, esize > *K, const Dune::FieldVector< double, esize > *S, const LeafIndexSet &set, const LeafIterator &cell, Vector *b, double scale=1.f)
Internal function. Assemble entries for a single DOF.
Definition: asmhandler_impl.hpp:52
void printOperator() const
Print the current operator.
Definition: asmhandler_impl.hpp:235
A class for representing a general multi-point constraint equation.
Definition: mpc.hh:59
Logging helper utilities.
Helper class with some matrix operations.
Representation of multi-point constraint (MPC) equations.
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition: matrixops.hpp:27
int j
Definition: elasticity_upscale_impl.hpp:658
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition: matrixops.hpp:33
std::vector< std::set< int > > AdjacencyPattern
For storing matrix adjacency/sparsity patterns.
Definition: matrixops.hpp:30
std::map< int, MPC * > MPCMap
A mapping from dof to MPCs.
Definition: mpc.hh:156
Definition: ImplicitAssembly.hpp:43