33 opt.
addInt(
"DirichletStrategy",
"Method for enforcement of Dirichlet BCs [11..14]", 11 );
34 opt.
addInt(
"DirichletValues" ,
"Method for computation of Dirichlet DoF values [100..103]", 101);
35 opt.
addInt(
"InterfaceStrategy",
"Method of treatment of patch interfaces [0..3]", 1 );
36 opt.
addReal(
"quA",
"Number of quadrature points: quA*deg + quB", 1.0 );
37 opt.
addInt (
"quB",
"Number of quadrature points: quA*deg + quB", 1 );
38 opt.
addReal(
"bdA",
"Estimated nonzeros per column of the matrix: bdA*deg + bdB", 2.0 );
39 opt.
addInt (
"bdB",
"Estimated nonzeros per column of the matrix: bdA*deg + bdB", 1 );
40 opt.
addReal(
"bdO",
"Overhead of sparse mem. allocation: (1+bdO)(bdA*deg + bdB) [0..1]", 0.333);
47 gsWarn <<
" gsAssembler<T>::Refresh is an empty call\n";
72 const index_t np = m_bases.front().nBases();
73 for (
typename gsBoundaryConditions<T>::const_iterator it =
77 "Problem: a Dirichlet boundary condition is set "
78 "on a patch id which does not exist.");
81 for (
typename gsBoundaryConditions<T>::const_iterator it =
85 "Problem: a Neumann boundary condition is set "
86 "on a patch id which does not exist.");
91 if ( m_pde_ptr->domain().nPatches() == 0)
92 gsWarn<<
"No domain given ! \n";
94 const dirichlet::strategy dirStr =
static_cast<dirichlet::strategy
>(m_options.getInt(
"DirichletStrategy"));
95 if ( 0 == m_pde_ptr->bc().size() && dirStr!=dirichlet::none &&
static_cast<dirichlet::values
>(dirStr)==dirichlet::homogeneous )
96 gsWarn<<
"No boundary conditions given ! \n";
105 GISMO_ASSERT(this->check(),
"Incoherent data in Assembler");
107 GISMO_ASSERT(1==m_bases.size(),
"Expecting a single discrete space "
108 "for standard scalar Galerkin");
112 m_bases.front().getMapper(
113 static_cast<dirichlet::strategy>(m_options.getInt(
"DirichletStrategy")),
114 static_cast<iFace::strategy>(m_options.getInt(
"InterfaceStrategy")),
115 this->pde().bc(), mapper, 0);
117 if ( 0 == mapper.freeSize() )
118 gsWarn <<
" No internal DOFs, zero sized system.\n";
128 == dirichlet::penalize,
"Incorrect options");
130 static const T PP = 1e9;
133 const gsDofMapper & mapper = m_system.colMapper(unk);
135 const gsDofMapper & bmap = mbasis.getMapper(dirichlet::elimination,
136 static_cast<iFace::strategy>(m_options.getInt(
"InterfaceStrategy")),
137 m_pde_ptr->bc(), unk) ;
140 m_ddof[unk].cols() == m_pde_ptr->numRhs(),
141 "The Dirichlet DoFs were not computed.");
144 for (
typename gsBoundaryConditions<T>::const_iterator
145 it = m_pde_ptr->bc().dirichletBegin();
146 it != m_pde_ptr->bc().dirichletEnd(); ++it )
148 const gsBasis<T> & basis = mbasis[it->patch()];
151 for (
index_t k=0; k!= bnd.size(); ++k)
154 const index_t ii = mapper.
index ( bnd(k) , it->patch() );
158 m_system.matrix()(ii,ii) = PP;
159 m_system.rhs().row(ii) = PP * m_ddof[unk].row(bb);
164 for (
typename gsBoundaryConditions<T>::const_citerator
165 it = m_pde_ptr->bc().cornerBegin();
166 it != m_pde_ptr->bc().cornerEnd(); ++it )
168 const index_t i = mbasis[it->patch].functionAtCorner(it->corner);
170 m_system.matrix()(ii,ii) = PP;
171 m_system.rhs().row(ii).setConstant(PP * it->value);
178 GISMO_ASSERT( m_options.getInt(
"DirichletValues") == dirichlet::user,
"Incorrect options");
180 const dirichlet::strategy dirStr =
static_cast<dirichlet::strategy
>(m_options.getInt(
"DirichletStrategy"));
183 dirichlet::elimination == dirStr ? m_system.colMapper(unk)
184 : mbasis.getMapper(dirichlet::elimination,
185 static_cast<iFace::strategy>(m_options.getInt(
"InterfaceStrategy")),
186 m_pde_ptr->bc(), unk) ;
189 m_ddof[unk].cols() == m_pde_ptr->numRhs(),
190 "Fixed DoFs were not initialized");
193 for (
typename gsBoundaryConditions<T>::const_iterator
194 it = m_pde_ptr->bc().dirichletBegin();
195 it != m_pde_ptr->bc().dirichletEnd() ; ++it )
198 if ( k == static_cast<index_t>(patch) )
202 mbasis[k].boundary(it->side());
206 for (
index_t i=0; i!= boundary.size(); ++i)
212 m_ddof[unk].row(ii) = coefMatrix.row(boundary.
at(i));
222 m_ddof.resize(m_system.numColBlocks());
223 m_ddof[unk].swap(vals);
225 GISMO_ENSURE( m_ddof[unk].rows() == m_system.colMapper(unk).boundarySize()
227 "The Dirichlet DoFs were not provided correctly.");
244 m_ddof.resize(m_system.numUnknowns());
246 if ( m_options.getInt(
"DirichletStrategy") == dirichlet::nitsche)
251 dirichlet::elimination == m_options.getInt(
"DirichletStrategy") ?
252 m_system.colMapper(unk) :
253 mbasis.getMapper(dirichlet::elimination,
254 static_cast<iFace::strategy>(m_options.getInt(
"InterfaceStrategy")),
255 m_pde_ptr->bc(), unk);
260 switch ( m_options.getInt(
"DirichletValues") )
262 case dirichlet::homogeneous:
265 m_ddof[unk].setZero(mapper.
boundarySize(), m_system.unkSize(unk) * m_pde_ptr->numRhs() );
267 case dirichlet::interpolation:
268 computeDirichletDofsIntpl(mapper, mbasis,unk);
270 case dirichlet::l2Projection:
271 computeDirichletDofsL2Proj(mapper, mbasis,unk);
273 case dirichlet::user :
275 GISMO_ENSURE( m_ddof[unk].size() == mapper.
boundarySize()*m_system.unkSize(unk)* m_pde_ptr->numRhs(),
"The Dirichlet DoFs are not set.");
276 m_ddof[unk].resize(mapper.
boundarySize(), m_system.unkSize(unk)* m_pde_ptr->numRhs());
279 GISMO_ERROR(
"Something went wrong with Dirichlet values.");
283 for (
typename gsBoundaryConditions<T>::const_citerator
284 it = m_pde_ptr->bc().cornerBegin();
285 it != m_pde_ptr->bc().cornerEnd(); ++it )
287 if(it->unknown == unk)
289 const index_t i = mbasis[it->patch].functionAtCorner(it->corner);
291 m_ddof[unk].row(ii).setConstant(it->value);
319 m_ddof[unk_].resize(mapper.
boundarySize(), m_system.unkSize(unk_) * m_pde_ptr->numRhs() );
321 for (
typename gsBoundaryConditions<T>::const_iterator
322 it = m_pde_ptr->bc().dirichletBegin();
323 it != m_pde_ptr->bc().dirichletEnd(); ++it )
327 if(it->unknown()!=unk_)
335 if ( it->isHomogeneous() )
337 for (
index_t i=0; i!= boundary.size(); ++i)
340 m_ddof[unk_].row(ii).setZero();
346 short_t dir = it->side().direction( );
347 index_t param = (it->side().parameter() ? 1 : 0);
350 std::vector< gsVector<T> > rr;
351 rr.reserve( this->patches().parDim() );
353 for (
short_t i=0; i < this->patches().parDim(); ++i)
358 b[0] = ( basis.
component(i).support() ) (0, param);
363 rr.push_back( basis.
component(i).anchors().transpose() );
367 GISMO_ASSERT(it->function()->targetDim() == m_system.unkSize(unk_) * m_pde_ptr->numRhs(),
368 "Given Dirichlet boundary function does not match problem dimension."
369 <<it->function()->targetDim()<<
" != "<<m_system.unkSize(unk_) <<
" * " << m_system.rhs().cols()<<
"\n");
373 if ( it->parametric() )
374 fpts = it->function()->eval( gsPointGrid<T>( rr ) );
376 fpts = it->function()->eval( m_pde_ptr->domain()[it->patch()].eval( gsPointGrid<T>( rr ) ) );
384 for (
index_t l=0; l!= boundary.size(); ++l)
387 m_ddof[unk_].row(ii) = dVals.row(l);
397 m_ddof[unk_].resize( mapper.
boundarySize(), m_system.unkSize(unk_)* m_pde_ptr->numRhs());
403 globProjRhs.setZero( mapper.
boundarySize(), m_system.unkSize(unk_)* m_pde_ptr->numRhs() );
415 for (
typename gsBoundaryConditions<T>::const_iterator
416 iter = m_pde_ptr->bc().dirichletBegin();
417 iter != m_pde_ptr->bc().dirichletEnd(); ++iter )
419 if (iter->isHomogeneous() )
422 GISMO_ASSERT(iter->function()->targetDim() == m_system.unkSize(unk_)* m_pde_ptr->numRhs(),
423 "Given Dirichlet boundary function does not match problem dimension."
424 <<iter->function()->targetDim()<<
" != "<<m_system.unkSize(unk_)<<
"x"<<m_system.rhs().cols()<<
"\n");
426 const short_t unk = iter->unknown();
429 const index_t patchIdx = iter->patch();
430 const gsBasis<T> & basis = (m_bases[unk])[patchIdx];
432 const gsGeometry<T> & patch = m_pde_ptr->patches()[patchIdx];
443 for(; bdryIter->good(); bdryIter->next() )
445 bdQuRule.mapTo( bdryIter->lowerCorner(), bdryIter->upperCorner(),
454 rhsVals = iter->function()->eval( m_pde_ptr->domain()[patchIdx].eval( md.
points ) );
484 std::vector<index_t> eltBdryFcts;
486 for(
index_t i=0; i < globIdxAct.rows(); i++)
488 eltBdryFcts.push_back( i );
493 const T weight_k = quWeights[k] * md.measure(k);
496 for(
size_t i0=0; i0 < eltBdryFcts.size(); i0++ )
500 const unsigned i = eltBdryFcts[i0];
504 for(
size_t j0=0; j0 < eltBdryFcts.size(); j0++ )
506 const unsigned j = eltBdryFcts[j0];
513 projMatEntries.add(ii, jj, weight_k * basisVals(i,k) * basisVals(j,k));
516 globProjRhs.row(ii) += weight_k * basisVals(i,k) * rhsVals.col(k).transpose();
524 globProjMat.setFrom( projMatEntries );
525 globProjMat.makeCompressed();
531 typename gsSparseSolver<T>::CGDiagonal solver;
532 m_ddof[unk_] = solver.compute( globProjMat ).solve ( globProjRhs );
544 const gsDofMapper & mapper = m_system.colMapper(unk);
554 const index_t dim = ( 0!=solVector.cols() ? solVector.cols() : m_ddof[unk].cols() );
559 for (
size_t p = 0; p < m_pde_ptr->domain().nPatches(); ++p)
562 const size_t sz = m_bases[m_system.colBasis(unk)][p].size();
563 coeffs.resize(sz, dim);
565 for (
size_t i = 0; i < sz; ++i)
569 coeffs.row(i) = solVector.row( mapper.
index(i, p) );
573 coeffs.row(i) = m_ddof[unk].row( mapper.
bindex(i, p) ).head(dim);
577 result.
addPatch( m_bases[m_system.colBasis(unk)][p].makeGeometry(
give(coeffs) ) );
591 GISMO_ASSERT(solVector.cols()==1,
"Vector valued output only works for single rhs");
594 const short_t dim = unknowns.rows();
597 std::vector<gsDofMapper> mappers(dim);
598 for(
short_t unk = 0; unk<dim;++unk)
599 mappers[unk] = m_system.colMapper(unknowns[unk]);
605 for(
short_t unk = 0; unk<dim;++unk)
606 basisIndices[unk] = m_system.colBasis(unknowns[unk]);
608 for (
size_t p = 0; p < m_pde_ptr->domain().nPatches(); ++p)
610 const size_t sz = m_bases[basisIndices[0]][p].size();
611 coeffs.resize(sz, dim);
613 for(
short_t unk = 0; unk<dim;++unk)
616 for (
size_t i = 0; i < sz; ++i)
618 if ( mappers[unk].is_free(i, p) )
620 m_system.mapToGlobalColIndex(i,p,idx,unknowns[unk]);
621 coeffs(i,unk) = solVector(idx,0);
626 coeffs(i,unk) = m_ddof[unknowns[unk]](mappers[unk].bindex(i, p),0);
630 result.
addPatch( m_bases[basisIndices[0]][p].makeGeometry(
give(coeffs) ) );
642 constructSolution(solVector,*result, unk);
643 return gsField<T>(m_pde_ptr->domain(), result,
true);
655 for (
size_t p = 0; p < m_pde_ptr->domain().nPatches(); ++p)
658 const size_t sz = m_bases[0][p].size();
662 for (
index_t j = 0; j < m_system.numColBlocks(); ++j)
664 const gsDofMapper & mapper = m_system.colMapper(j);
665 for (
size_t i = 0; i < sz; ++i)
669 m_system.mapToGlobalColIndex(i,p,idx,j);
670 coeffs(i,j) += theta * solVector(idx,0);
memory::shared_ptr< gsMultiPatch > Ptr
Shared pointer for gsMultiPatch.
Definition: gsMultiPatch.h:41
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry<T>::uPtr.
Definition: gsMultiPatch.hpp:210
virtual gsAssembler * create() const
Create an empty Assembler of the derived type and return a pointer to it. Call the initialize functio...
Definition: gsAssembler.hpp:59
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
Class that provides a container for triplets (i,j,value) to be filled in a sparse matrix...
Definition: gsSparseMatrix.h:33
Provides the Gauss-Legendre quadrature rule.
gsBasis< T >::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
void computeDirichletDofsIntpl(const gsDofMapper &mapper, const gsMultiBasis< T > &mbasis, const short_t unk_=0)
calculates the values of the eliminated dofs based on Interpolation.
Definition: gsAssembler.hpp:315
const_iterator dirichletBegin() const
Definition: gsBoundaryConditions.h:490
void clear()
Clear (delete) all patches.
Definition: gsMultiPatch.h:319
Provides generic assembler routines.
index_t boundarySize() const
Returns the number of eliminated dofs.
Definition: gsDofMapper.h:457
void computeDirichletDofsL2Proj(const gsDofMapper &mapper, const gsMultiBasis< T > &mbasis, const short_t unk_=0)
calculates the values of the eliminated dofs based on L2 Projection.
Definition: gsAssembler.hpp:393
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
virtual void computeMap(gsMapData< T > &InOut) const
Computes map function data.
Definition: gsFunction.hpp:822
A scalar of vector field defined on a m_parametric geometry.
Definition: gsField.h:54
virtual gsAssembler * clone() const
Clone this Assembler, making a deep copy.
Definition: gsAssembler.hpp:63
#define short_t
Definition: gsConfig.h:35
virtual void updateSolution(const gsMatrix< T > &solVector, gsMultiPatch< T > &result, T theta=(T)(1)) const
Update solution by adding the computed solution vector to the current solution specified by...
Definition: gsAssembler.hpp:649
Provides declaration of MultiBasis class.
Struct that defines the boundary sides and corners and types of a geometric object.
Definition: gsBoundary.h:55
the gsMapData is a cache of pre-computed function (map) values.
Definition: gsFuncData.h:324
bool is_free(index_t i, index_t k=0, index_t c=0) const
Returns true if local dof i of patch k is not eliminated.
Definition: gsDofMapper.h:382
void penalizeDirichletDofs(short_t unk=0)
Definition: gsAssembler.hpp:125
S give(S &x)
Definition: gsMemory.h:266
const_iterator neumannBegin() const
Definition: gsBoundaryConditions.h:531
virtual void refresh()
Creates the mappers and setups the sparse system. to be implemented in derived classes, see scalarProblemGalerkinRefresh() for a possible implementation.
Definition: gsAssembler.hpp:45
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
virtual const gsBasis< T > & component(short_t i) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsBasis.hpp:514
void localToGlobal(const gsMatrix< index_t > &locals, index_t patchIndex, gsMatrix< index_t > &globals, index_t comp=0) const
Computes the global indices of the input local indices.
Definition: gsDofMapper.cpp:25
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Maintains a mapping from patch-local dofs to global dof indices and allows the elimination of individ...
Definition: gsDofMapper.h:68
void addInt(const std::string &label, const std::string &desc, const index_t &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:201
const_iterator neumannEnd() const
Definition: gsBoundaryConditions.h:536
index_t index(index_t i, index_t k=0, index_t c=0) const
Returns the global dof index associated to local dof i of patch k.
Definition: gsDofMapper.h:325
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
index_t global_to_bindex(index_t gl) const
Returns the boundary index of global dof gl.
Definition: gsDofMapper.h:364
bool is_boundary_index(index_t gl) const
Returns true if global dof gl is eliminated.
Definition: gsDofMapper.h:386
#define gsWarn
Definition: gsDebug.h:50
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
void setFixedDofs(const gsMatrix< T > &coefMatrix, short_t unk=0, size_t patch=0)
the user can manually set the dirichlet Dofs for a given patch and unknown, based on the Basis coeffi...
Definition: gsAssembler.hpp:176
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
Provides declaration of DomainIterator abstract interface.
void scalarProblemGalerkinRefresh()
A prototype of the refresh function for a "standard" scalar problem. Creats one mapper based on the s...
Definition: gsAssembler.hpp:102
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
Poisson equation element visitor.
The density of the measure pull back.
Definition: gsForwardDeclarations.h:76
index_t bindex(index_t i, index_t k=0, index_t c=0) const
Returns the boundary index of local dof i of patch k.
Definition: gsDofMapper.h:334
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition: gsGeometry.h:100
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsBasis.hpp:443
virtual memory::unique_ptr< gsGeometry< T > > interpolateAtAnchors(gsMatrix< T > const &vals) const
Applies interpolation of values pts using the anchors as parameter points. May be reimplemented in de...
Definition: gsBasis.hpp:244
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
bool check()
checks for consistency and legal values of the stored members.
Definition: gsAssembler.hpp:67
Class containing a set of boundary conditions.
Definition: gsBoundaryConditions.h:341
void addReal(const std::string &label, const std::string &desc, const Real &value)
Adds a option named label, with description desc and value value.
Definition: gsOptionList.cpp:211
Provides functions to generate structured point data.
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
gsMatrix< T > points
input (parametric) points
Definition: gsFuncData.h:348
virtual void constructSolution(const gsMatrix< T > &solVector, gsMultiPatch< T > &result, short_t unk=0) const
Construct solution from computed solution vector for a single unknows.
Definition: gsAssembler.hpp:537
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
virtual void assemble()
Main assemble routine, to be implemented in derived classes.
Definition: gsAssembler.hpp:51
Class that represents the (tensor) Gauss-Legendre quadrature rule.
Definition: gsGaussRule.h:27
This object is a cache for computed values from an evaluator.
void computeDirichletDofs(short_t unk=0)
Triggers computation of the Dirichlet dofs.
Definition: gsAssembler.hpp:232
virtual domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition: gsBasis.hpp:493
static gsOptionList defaultOptions()
Returns the list of default options for assembly.
Definition: gsAssembler.hpp:30
const_iterator dirichletEnd() const
Definition: gsBoundaryConditions.h:495
void setFixedDofVector(gsMatrix< T > vals, short_t unk=0)
the user can manually set the dirichlet Dofs for a given patch and unknown.
Definition: gsAssembler.hpp:219
gsMatrix< index_t > boundary(boxSide const &s) const
Returns the indices of the basis functions that are nonzero at the domain boundary as single-column-m...
Definition: gsBasis.h:520
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
Provides declaration of the Field class.
gsMatrix< T > & coefs()
Definition: gsGeometry.h:340
virtual void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Returns the indices of active basis functions at points u, as a list of indices, in result...
Definition: gsBasis.hpp:293