G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsGenericAssembler.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 #include <gsPde/gsLaplacePde.h>
18 
22 
23 namespace gismo
24 {
25 
31 template <class T>
33 {
34 public:
35  typedef gsAssembler<T> Base;
36 
37 public:
38 
41 
49  const gsMultiBasis<T> & bases,
50  const gsOptionList & opt = defaultOptions(),
51  const gsBoundaryConditions<T> * bc = NULL)
52  : m_pde(patches)
53  {
54  if ( bc != NULL)
55  {
56  m_pde.boundaryConditions() = *bc;
57  this->m_ddof.resize(1);
58  }
59 
60  Base::initialize(m_pde, bases, opt);
62  }
63 
64  /* TODO (id geometry)
65  // Constructor with gsMultiBasis
66  gsGenericAssembler( gsMultiBasis<T> const & bases,
67  bool conforming = false,
68  const gsBoundaryConditions<T> * bc = NULL)
69  : Base(patches)
70  {
71  m_bases.push_back(bases);
72 
73  Base::initialize(m_pde, bases, opt);
74  gsGenericAssembler::refresh();
75  }
76  */
77 
79  void refresh()
80  {
81  // Setup sparse system
82  gsDofMapper mapper;
83  m_bases[0].getMapper(
84  (dirichlet::strategy)(m_options.getInt("DirichletStrategy")),
85  (iFace::strategy)(m_options.getInt("InterfaceStrategy")),
86  this->pde().bc(), mapper, 0);
87  m_system = gsSparseSystem<T>(mapper);
88  //note: no allocation here
89  // const index_t nz = m_options.numColNz(m_bases[0][0]);
90  // m_system.reserve(nz, 1);
91  }
92 
94  void refresh(gsDofMapper mapper)
95  {
96  m_system = gsSparseSystem<T>(mapper);
97  }
98 
103  const gsSparseMatrix<T> & assembleMass(const index_t patchIndex = -1, bool refresh = true);
104 
109  {
110  typedef typename gsExprAssembler<T>::geometryMap geometryMap;
111  typedef typename gsExprAssembler<T>::space space;
112 
113  // Elements used for numerical integration
114  gsExprAssembler<T> A(1,1);
115  A.setIntegrationElements(m_bases.front());
116  geometryMap G = A.getMap(m_pde_ptr->patches());
117  space u = A.getSpace(m_bases.front());
118 
119  A.initSystem();
120  //m_system.matrix() = A.assemble( u * u.tr() * meas(G) );
121  A.assemble( u * u.tr() * meas(G) );
122  m_system.matrix() = A.matrix();
123 
124  return m_system.matrix();
125  }
126 
131  const gsSparseMatrix<T> & assembleStiffness(const index_t patchIndex = -1, const bool refresh = true);
132 
138  const gsMatrix<T> & assembleMoments(const gsFunction<T> & func, index_t patchIndex = -1, bool refresh = true);
139 
145  const gsSparseMatrix<T> & assembleDG(const boundaryInterface & iFace, bool refresh = true);
146 
151  const gsSparseMatrix<T> & assembleNeumann(const boundary_condition<T> & bc, bool refresh = true);
152 
159  const gsSparseMatrix<T> & assembleNitsche(const boundary_condition<T> & bc, bool refresh = true);
160 
167  {
168  return m_system.matrix().template selfadjointView<Lower>();
169  }
170 
177  {
178  return m_system.matrix().template selfadjointView<Lower>();
179  }
180 
181 
182 private:
183 
184  // Members from gsAssembler
185  using Base::m_pde_ptr;
186  using Base::m_bases;
187  using Base::m_ddof;
188  using Base::m_options;
189  using Base::m_system;
190 
191 private:
192 
193  gsLaplacePde<T> m_pde;
194 };
195 
196 
197 
198 } // namespace gismo
199 
200 #ifndef GISMO_BUILD_LIB
201 #include GISMO_HPP_HEADER(gsGenericAssembler.hpp)
202 #endif
memory::shared_ptr< gsPde< T > > m_pde_ptr
Definition: gsAssembler.h:276
static gsOptionList defaultOptions()
Returns the list of default options for assembly.
Definition: gsGenericAssembler.hpp:28
Definition: gsExprAssembler.h:30
Provides generic assembler routines.
gsExprHelper< T >::geometryMap geometryMap
Geometry map type.
Definition: gsExprAssembler.h:58
const gsSparseMatrix< T > & assembleStiffness(const index_t patchIndex=-1, const bool refresh=true)
Stiffness assembly routine.
Definition: gsGenericAssembler.hpp:65
void refresh(gsDofMapper mapper)
Refreshes the sparse system based on given dof mapper.
Definition: gsGenericAssembler.h:94
const gsSparseMatrix< T > & assembleNeumann(const boundary_condition< T > &bc, bool refresh=true)
Assemble Neumann boundary terms.
Definition: gsGenericAssembler.hpp:139
gsOptionList m_options
Options.
Definition: gsAssembler.h:285
std::vector< gsMultiBasis< T > > m_bases
Definition: gsAssembler.h:282
Defines different expressions.
const gsSparseMatrix< T >::constFullView fullMatrix() const
Returns an expression of the &quot;full&quot; assembled sparse matrix.
Definition: gsGenericAssembler.h:176
The Laplace equation.
Definition: gsLaplacePde.h:34
void assemble(const expr &...args)
Adds the expressions args to the system matrix/rhs The arguments are considered as integrals over the...
Definition: gsExprAssembler.h:756
#define index_t
Definition: gsConfig.h:32
Generic expressions helper.
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
const gsMatrix< T > & assembleMoments(const gsFunction< T > &func, index_t patchIndex=-1, bool refresh=true)
Moments assembly routine.
Definition: gsGenericAssembler.hpp:93
const index_t & getInt(const std::string &label) const
Reads value for option label from options.
Definition: gsOptionList.cpp:37
Maintains a mapping from patch-local dofs to global dof indices and allows the elimination of individ...
Definition: gsDofMapper.h:68
const gsSparseMatrix< T > & matrix() const
Returns the left-hand global matrix.
Definition: gsExprAssembler.h:116
const gsMultiPatch< T > & patches() const
Return the multipatch.
Definition: gsAssembler.h:601
const gsSparseMatrix< T > & matrix() const
Access the system Matrix.
Definition: gsSparseSystem.h:394
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
gsGenericAssembler(const gsMultiPatch< T > &patches, const gsMultiBasis< T > &bases, const gsOptionList &opt=defaultOptions(), const gsBoundaryConditions< T > *bc=NULL)
Constructor.
Definition: gsGenericAssembler.h:48
void initialize(const gsPde< T > &pde, const gsStdVectorRef< gsMultiBasis< T > > &bases, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a vector of multi-basis and assembler optio...
Definition: gsAssembler.h:317
gsSparseMatrix< T >::fullView fullMatrix()
Returns an expression of the &quot;full&quot; assembled sparse matrix.
Definition: gsGenericAssembler.h:166
const gsSparseMatrix< T > & assembleNitsche(const boundary_condition< T > &bc, bool refresh=true)
Assemble Nitsche terms for weakly imposing Dirichlet conditions.
Definition: gsGenericAssembler.hpp:160
Definition: gsDirichletValues.h:23
const gsSparseMatrix< T > & assembleMass(const index_t patchIndex=-1, bool refresh=true)
Mass assembly routine.
Definition: gsGenericAssembler.hpp:37
geometryMap getMap(const gsFunctionSet< T > &g)
Registers g as an isogeometric geometry map and return a handle to it.
Definition: gsExprAssembler.h:161
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
const gsPde< T > & pde() const
Return the Pde.
Definition: gsAssembler.h:598
space getSpace(const gsFunctionSet< T > &mp, index_t dim=1, index_t id=0)
Definition: gsExprAssembler.h:166
gsSparseSystem< T > m_system
Global sparse linear system.
Definition: gsAssembler.h:290
Class that defines a boundary condition for a side of a patch for some unknown variable of a PDE...
Definition: gsBoundaryConditions.h:106
std::vector< gsMatrix< T > > m_ddof
Definition: gsAssembler.h:295
Assembles mass and stiffness matrices and right-hand sides on a given domain.
Definition: gsGenericAssembler.h:32
void refresh()
Refreshes the sparse system (deletes assembled matrices and vectors)
Definition: gsGenericAssembler.h:79
Class containing a set of boundary conditions.
Definition: gsBoundaryConditions.h:341
EIGEN_STRONG_INLINE meas_expr< T > meas(const gsGeometryMap< T > &G)
The measure of a geometry map.
Definition: gsExpressions.h:4557
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
const gsSparseMatrix< T > & assembleDG(const boundaryInterface &iFace, bool refresh=true)
Assemble dG interface terms.
Definition: gsGenericAssembler.hpp:116
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
The assembler class provides generic routines for volume and boundary integrals that are used for for...
Definition: gsAssembler.h:265
void setIntegrationElements(const gsMultiBasis< T > &mesh)
Sets the domain of integration.
Definition: gsExprAssembler.h:136
const gsSparseMatrix< T > & assembleMass2()
Mass assembly routine.
Definition: gsGenericAssembler.h:108
void initSystem(const index_t numRhs=1)
Initializes the sparse system (sparse matrix and rhs)
Definition: gsExprAssembler.h:290
Generic expressions matrix assembly.
Describes a Laplace equation.