Loading...
Searching...
No Matches
asmhandler.hpp
Go to the documentation of this file.
//==============================================================================
//==============================================================================
#ifndef ASMHANDLER_HPP_
#define ASMHANDLER_HPP_
#include <opm/common/utility/platform_dependent/disable_warnings.h>
#include <dune/geometry/referenceelements.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bvector.hh>
#include <dune/common/fvector.hh>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/elasticity/logutils.hpp>
#include <opm/elasticity/mpc.hh>
#include <opm/elasticity/matrixops.hpp>
namespace Opm {
namespace Elasticity {
template<class GridType>
class ASMHandler {
public:
static const int dim = GridType::dimension;
typedef typename GridType::LeafGridView::IndexSet LeafIndexSet;
typedef typename GridType::LeafGridView::template Codim<0>::Iterator LeafIterator;
explicit ASMHandler(const GridType& gv_) : gv(gv_), maxeqn(0)
{
}
~ASMHandler()
{
for (MPCMap::iterator it=mpcs.begin(); it != mpcs.end();++it)
delete it->second;
}
ASMHandler(const ASMHandler&) = delete;
ASMHandler& operator=(const ASMHandler&) = delete;
typedef Dune::FieldVector<double,dim> NodeValue;
size_t getEqns() const
{
return maxeqn;
}
int getEquationForDof(int node, int dof)
{
return meqn[node*dim+dof];
}
Matrix& getOperator()
{
return A;
}
Vector& getLoadVector()
{
return b;
}
void initForAssembly();
template<int esize>
void addElement(const Dune::FieldMatrix<double,esize,esize>* K,
const Dune::FieldVector<double,esize>* S,
const LeafIterator& cell,
Vector* b=NULL);
void addMatElement(const int i, const int j, const double val)
{
A[i][j] += val;
}
template<int comp>
void extractValues(Dune::FieldVector<double,comp>& v,
const Vector& u, const LeafIterator& it);
void expandSolution(Vector& result, const Vector& u);
void addMPC(MPC* mpc);
MPC* getMPC(int node, int dof);
void updateFixedNode(int node,
const std::pair<Direction,NodeValue>& entry);
bool isFixed(int node)
{
return (fixedNodes.find(node) != fixedNodes.end());
}
void printOperator() const;
void printLoadVector() const;
AdjacencyPattern& getAdjacencyPattern()
{
return adjacencyPattern;
}
protected:
void resolveMPCChains()
{
for (MPCMap::iterator it = mpcs.begin();
it != mpcs.end();++it)
resolveMPCChain(it->second);
}
void resolveMPCChain(MPC* mpc);
void preprocess();
void nodeAdjacency(const LeafIterator& it, int vertexsize, int row);
void determineAdjacencyPattern();
template<int esize>
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);
MPCMap mpcs;
std::vector<int> meqn;
typedef std::pair<Direction,NodeValue> fixEntry;
typedef std::map<int,fixEntry> fixMap;
typedef typename fixMap::iterator fixIt;
fixMap fixedNodes;
AdjacencyPattern adjacencyPattern;
Matrix A;
Vector b;
const GridType& gv;
size_t maxeqn;
};
}
}
#include "asmhandler_impl.hpp"
#endif
asmhandler_impl.hpp
Class handling finite element assembly - template implementations.
Opm::Elasticity::ASMHandler::dim
static const int dim
The dimension of the grid.
Definition asmhandler.hpp:38
Opm::Elasticity::ASMHandler::fixEntry
std::pair< Direction, NodeValue > fixEntry
Fixed nodes.
Definition asmhandler.hpp:216
Opm::Elasticity::ASMHandler::isFixed
bool isFixed(int node)
Check if a node is marked as fixed (in any direction).
Definition asmhandler.hpp:149
Opm::Elasticity::ASMHandler::initForAssembly
void initForAssembly()
This function needs to be called before starting the element assembly.
Definition asmhandler_impl.hpp:22
Opm::Elasticity::ASMHandler::mpcs
MPCMap mpcs
The set of MPC.
Definition asmhandler.hpp:210
Opm::Elasticity::ASMHandler::resolveMPCChain
void resolveMPCChain(MPC *mpc)
Internal function.
Definition asmhandler_impl.hpp:250
Opm::Elasticity::ASMHandler::~ASMHandler
~ASMHandler()
Destructor.
Definition asmhandler.hpp:53
Opm::Elasticity::ASMHandler::gv
const GridType & gv
A reference to the grid in use.
Definition asmhandler.hpp:237
Opm::Elasticity::ASMHandler::fixedNodes
fixMap fixedNodes
The map holding information about our fixed nodes.
Definition asmhandler.hpp:225
Opm::Elasticity::ASMHandler::operator=
ASMHandler & operator=(const ASMHandler &)=delete
No copying of this class.
Opm::Elasticity::ASMHandler::NodeValue
Dune::FieldVector< double, dim > NodeValue
A vectorial node value.
Definition asmhandler.hpp:66
Opm::Elasticity::ASMHandler::maxeqn
size_t maxeqn
The number of equations in the system.
Definition asmhandler.hpp:240
Opm::Elasticity::ASMHandler::adjacencyPattern
AdjacencyPattern adjacencyPattern
Holds the adjacency pattern of the sparse matrix.
Definition asmhandler.hpp:228
Opm::Elasticity::ASMHandler::meqn
std::vector< int > meqn
Vector of (interleaved) dof<->eqn mapping.
Definition asmhandler.hpp:213
Opm::Elasticity::ASMHandler::fixIt
fixMap::iterator fixIt
Iterator over a fixmap.
Definition asmhandler.hpp:222
Opm::Elasticity::ASMHandler::getLoadVector
Vector & getLoadVector()
Obtain a reference to the load vector.
Definition asmhandler.hpp:93
Opm::Elasticity::ASMHandler::LeafIndexSet
GridType::LeafGridView::IndexSet LeafIndexSet
A set of indices.
Definition asmhandler.hpp:41
Opm::Elasticity::ASMHandler::getEquationForDof
int getEquationForDof(int node, int dof)
Get the equation number for a given dof on a given node.
Definition asmhandler.hpp:79
Opm::Elasticity::ASMHandler::ASMHandler
ASMHandler(const ASMHandler &)=delete
No copying of this class.
Opm::Elasticity::ASMHandler::addElement
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
Opm::Elasticity::ASMHandler::resolveMPCChains
void resolveMPCChains()
Resolve chained MPCs.
Definition asmhandler.hpp:168
Opm::Elasticity::ASMHandler::b
Vector b
The load vector.
Definition asmhandler.hpp:234
Opm::Elasticity::ASMHandler::ASMHandler
ASMHandler(const GridType &gv_)
The default constructor.
Definition asmhandler.hpp:48
Opm::Elasticity::ASMHandler::fixMap
std::map< int, fixEntry > fixMap
A mapping from dof to fix value info.
Definition asmhandler.hpp:219
Opm::Elasticity::ASMHandler::A
Matrix A
The linear operator.
Definition asmhandler.hpp:231
Opm::Elasticity::ASMHandler::updateFixedNode
void updateFixedNode(int node, const std::pair< Direction, NodeValue > &entry)
Update/add a fixed node.
Definition asmhandler_impl.hpp:214
Opm::Elasticity::ASMHandler::extractValues
void extractValues(Dune::FieldVector< double, comp > &v, const Vector &u, const LeafIterator &it)
Extract values corresponding to cell.
Definition asmhandler_impl.hpp:114
Opm::Elasticity::ASMHandler::expandSolution
void expandSolution(Vector &result, const Vector &u)
Expand a system vector to a solution vector.
Definition asmhandler_impl.hpp:145
Opm::Elasticity::ASMHandler::addMPC
void addMPC(MPC *mpc)
Add a MPC.
Definition asmhandler_impl.hpp:187
Opm::Elasticity::ASMHandler::getAdjacencyPattern
AdjacencyPattern & getAdjacencyPattern()
Access current adjacency pattern.
Definition asmhandler.hpp:162
Opm::Elasticity::ASMHandler::preprocess
void preprocess()
Internal function. Generate meqn for registered MPC/fixed nodes.
Definition asmhandler_impl.hpp:315
Opm::Elasticity::ASMHandler::nodeAdjacency
void nodeAdjacency(const LeafIterator &it, int vertexsize, int row)
Internal function.
Definition asmhandler_impl.hpp:351
Opm::Elasticity::ASMHandler::LeafIterator
GridType::LeafGridView::template Codim< 0 >::Iterator LeafIterator
An iterator over grid cells.
Definition asmhandler.hpp:44
Opm::Elasticity::ASMHandler::printLoadVector
void printLoadVector() const
Print the current load vector.
Definition asmhandler_impl.hpp:241
Opm::Elasticity::ASMHandler::getOperator
Matrix & getOperator()
Obtain a reference to the linear operator.
Definition asmhandler.hpp:86
Opm::Elasticity::ASMHandler::getMPC
MPC * getMPC(int node, int dof)
Look for and return a MPC for a specified node+dof.
Definition asmhandler_impl.hpp:205
Opm::Elasticity::ASMHandler::getEqns
size_t getEqns() const
Get the number of equations in the system.
Definition asmhandler.hpp:70
Opm::Elasticity::ASMHandler::determineAdjacencyPattern
void determineAdjacencyPattern()
Internal function. Calculate adjacency pattern.
Definition asmhandler_impl.hpp:375
Opm::Elasticity::ASMHandler::addDOF
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.
Definition asmhandler_impl.hpp:52
Opm::Elasticity::ASMHandler::printOperator
void printOperator() const
Print the current operator.
Definition asmhandler_impl.hpp:235
Opm::Elasticity::MPC
A class for representing a general multi-point constraint equation.
Definition mpc.hh:59
Opm::GridType
logutils.hpp
Logging helper utilities.
matrixops.hpp
Helper class with some matrix operations.
Opm::Elasticity::Matrix
Dune::BCRSMatrix< Dune::FieldMatrix< double, 1, 1 > > Matrix
A sparse matrix holding our operator.
Definition matrixops.hpp:27
Opm::Elasticity::Vector
Dune::BlockVector< Dune::FieldVector< double, 1 > > Vector
A vector holding our RHS.
Definition matrixops.hpp:33
Opm::Elasticity::AdjacencyPattern
std::vector< std::set< int > > AdjacencyPattern
For storing matrix adjacency/sparsity patterns.
Definition matrixops.hpp:30
mpc.hh
Representation of multi-point constraint (MPC) equations.
Opm::Elasticity::MPCMap
std::map< int, MPC * > MPCMap
A mapping from dof to MPCs.
Definition mpc.hh:156
Opm
Inverting small matrices.
Definition ImplicitAssembly.hpp:43