Commit d72b4cfb authored by akbib's avatar akbib Committed by akbib@FU-BERLIN.DE
Browse files

neohookeassembler is now derives from operatorassembler.hh.

added a class neohookelocalassembler which does the assembling former done by the function getLocalMatrix()

[[Imported from SVN: r10473]]
parent 1594a456
......@@ -5,52 +5,121 @@
#include <dune/common/fmatrix.hh>
#include <dune/istl/matrixindexset.hh>
#include <dune/istl/matrix.hh>
#include <dune/ag-common/assemblers/operatorassembler.hh>
/** \brief
\tparam GridType a DUNE grid type
\tparam TiralLocalFE a local finite element of the trial space
\tparam AnsatzLocalFE a local finite element of the trial space
*/
template <class GridType, class TrialLocalFE, class AnsatzLocalFE, int polOrd>
class NeoHookeLocalAssembler
:public LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, Dune::FieldMatrix<double,GridType::dimension,GridType::dimension> >
{
public:
typedef typename Dune::FieldMatrix<double,GridType::dimension,GridType::dimension> T;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::ElementPointer ElementPointer;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE,T >::BoolMatrix BoolMatrix;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE,T >::LocalMatrix LocalMatrix;
// some other sizes
enum {dim=GridType::dimension};
// define the number of components of your system, this is used outside
// to allocate the correct size of (dense) blocks with a FieldMatrix
enum {m=dim};
// /////////////////////////////////
// The material parameters
// /////////////////////////////////
/** \brief Material constants */
double lambda_;
double mu_;
//! Default Constructor
NeoHookeLocalAssembler()
{}
//! Constructor
NeoHookeLocalAssembler (double lambda, double mu)
: lambda_(lambda), mu_(mu)
{}
/** \brief Set material parameters */
void setEandNu(double E, double nu)
{
lambda_ = E*nu / ((1+nu)*(1-2*nu));
mu_ = E / (2*(1+nu));
}
void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
{
isNonZero = true;
}
void assemble(const ElementPointer& element,
const Dune::BlockVector<Dune::FieldVector<double,dim> >& localSolution,
LocalMatrix& localMatrix,
const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
{
Dune::BlockVector<Dune::FieldVector<double,dim>> dummy;
dummy=0;
assemble(element,localSolution,localMatrix,dummy,tFE,aFE);
}
//this method is used by the OgdenAssembler to assemble the matrix and the right hand side
void assemble(const ElementPointer& element,
const Dune::BlockVector<Dune::FieldVector<double,dim> >& localSolution,
LocalMatrix& localMatrix, Dune::BlockVector<Dune::FieldVector<double,dim>>& localRhs,
const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const;
};
namespace Dune
{
/** \brief The FEM operator for elasticity with a Neo-Hookean material
* \todo Choose correct quadrature order for the different elements
*/
template <class GridType, int polOrd>
class NeoHookeAssembler {
typedef typename GridType::template Codim<0>::Entity EntityType;
typedef typename GridType::template Codim<0>::LevelIterator ElementIterator;
template <class TrialBasis, class AnsatzBasis, int polOrd>
class NeoHookeAssembler :
public OperatorAssembler<TrialBasis,AnsatzBasis>
{
typedef typename TrialBasis::GridView GridView;
typedef typename GridView::template Codim<0>::Iterator ElementIterator;
//! The grid's dimension
enum { dim = GridType::dimension };
enum { dim = GridView::dimension };
enum { elementOrder = 1 };
//!
typedef FieldMatrix<double, dim, dim> MatrixBlock;
//!
typedef FieldVector<double, (dim+1)*dim/2> SymmTensor;
public:
/** \todo Does actually belong into the base class */
BCRSMatrix<MatrixBlock>* matrix_;
/** \todo Does actually belong into the base class */
const GridType* grid_;
//!
typedef FieldMatrix<double, dim, dim> MatrixBlock;
/** \brief Material constants */
double lambda_;
double mu_;
//! ???
NeoHookeAssembler(const GridType& grid) :
grid_(&grid), matrix_(NULL)
{
lambda_ = 144230;
mu_ = 96153;
}
~NeoHookeAssembler() {
delete(matrix_);
}
NeoHookeAssembler(const TrialBasis& tBasis, const AnsatzBasis& aBasis) :
OperatorAssembler<TrialBasis,AnsatzBasis>(tBasis,aBasis)
{
lambda_ = 144230;
mu_ = 96153;
}
/** \brief Set the material parameters
\param E Young's modulus
......@@ -60,28 +129,14 @@ namespace Dune
void setEandNu(double E, double nu) {
lambda_ = E*nu / ((1+nu)*(1-2*nu));
mu_ = E / (2*(1+nu));
}
//! Returns the actual matrix if it is assembled
const BCRSMatrix<FieldMatrix<double, dim, dim> >* getMatrix() const {
return this->matrix_;
}
void getNeighborsPerVertex(MatrixIndexSet& nb) const;
}
/** \brief Assemble the tangent stiffness matrix and the right hand side
*/
void assembleMatrix(const BlockVector<FieldVector<double, dim> >& sol,
BlockVector<FieldVector<double, dim> >& rhs);
void assembleProblem(BCRSMatrix<FieldMatrix<double,dim,dim>>& globalMatrix,
const BlockVector<FieldVector<double, dim> >& sol,
BlockVector<FieldVector<double, dim> >& rhs);
/** \brief Compute the element tangent stiffness matrix */
template <class MatrixType>
void getLocalMatrix( EntityType &entity,
const BlockVector<FieldVector<double, dim> >& localSolution,
const int matSize, MatrixType& mat,
BlockVector<FieldVector<double, dim> >& localRhs) const;
/** \brief Compute the energy of a deformation state */
double computeEnergy(const BlockVector<FieldVector<double, dim> >& sol) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment