G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsElPoissonAssembler.hpp
Go to the documentation of this file.
1
15#pragma once
16
18
19#include <gsPde/gsPoissonPde.h>
21
22namespace gismo
23{
24
25template<class T>
26gsElPoissonAssembler<T>::gsElPoissonAssembler(const gsMultiPatch<T> & patches,
27 const gsMultiBasis<T> & basis,
28 const gsBoundaryConditions<T> & bconditions,
29 const gsFunction<T> & body_force)
30{
31 gsPiecewiseFunction<T> rightHandSides;
32 rightHandSides.addPiece(body_force);
33 typename gsPde<T>::Ptr pde( new gsPoissonPde<T>(patches,bconditions,rightHandSides) );
34 m_bases.push_back(basis);
35 Base::initialize(pde, m_bases, defaultOptions());
36}
37
38template <class T>
39gsOptionList gsElPoissonAssembler<T>::defaultOptions()
40{
41 gsOptionList opt = Base::defaultOptions();
42 opt.addReal("LocalStiff","Stiffening degree for the Jacobian-based local stiffening",0.);
43 return opt;
44}
45
46template <class T>
47void gsElPoissonAssembler<T>::refresh()
48{
49 std::vector<gsDofMapper> m_dofMappers(m_bases.size());
50 m_bases[0].getMapper((dirichlet::strategy)m_options.getInt("DirichletStrategy"),
51 iFace::glue,m_pde_ptr->bc(),m_dofMappers[0],0,true);
52
53 m_system = gsSparseSystem<T>(m_dofMappers[0]);
54 m_system.reserve(m_bases[0], m_options, m_pde_ptr->numRhs());
55 Base::computeDirichletDofs(0);
56}
57
58template<class T>
59void gsElPoissonAssembler<T>::assemble(bool saveEliminationMatrix)
60{
61 m_system.matrix().setZero();
62 m_system.reserve(m_bases[0], m_options, m_pde_ptr->numRhs());
63 m_system.rhs().setZero(Base::numDofs(),m_pde_ptr->numRhs());
64
65 if (saveEliminationMatrix)
66 {
67 eliminationMatrix.resize(Base::numDofs(),Base::numFixedDofs());
68 eliminationMatrix.setZero();
69 eliminationMatrix.reservePerColumn(m_system.numColNz(m_bases[0],m_options));
70 }
71
72 gsVisitorElPoisson<T> visitor(*m_pde_ptr, saveEliminationMatrix ? &eliminationMatrix : nullptr);
73 Base::template push<gsVisitorElPoisson<T> >(visitor);
74
75 m_system.matrix().makeCompressed();
76
77 if (saveEliminationMatrix)
78 {
79 Base::rhsWithZeroDDofs = m_system.rhs();
80 eliminationMatrix.makeCompressed();
81 }
82}
83
84template <class T>
85void gsElPoissonAssembler<T>::constructSolution(const gsMatrix<T> & solVector,
86 const std::vector<gsMatrix<T> > & fixedDoFs,
87 gsMultiPatch<T> & result) const
88{
89 Base::constructSolution(solVector,fixedDoFs,result,gsVector<index_t>::Zero(1));
90}
91
92}// namespace gismo ends
Provides stiffness matrix for Poisson's equations.
Describes a Poisson PDE.
Visitor class for Poisson's equation.
The G+Smo namespace, containing all definitions for the library.