39void transformGradients(
const gsMapData<T> & md, 
index_t k, 
const gsMatrix<T>& allGrads, gsMatrix<T>& trfGradsK)
 
   41    GISMO_ASSERT(allGrads.rows() % md.dim.first == 0, 
"Invalid size of gradient matrix");
 
   43    const index_t numGrads = allGrads.rows() / md.dim.first;
 
   44    const gsAsConstMatrix<T> grads_k(allGrads.col(k).data(), md.dim.first, numGrads);
 
   45    trfGradsK.noalias() = md.jacobian(k).cramerInverse().transpose() * grads_k;
 
   49void transformLaplaceHgrad( 
const gsMapData<T> & md, 
index_t k,
 
   50                        const gsMatrix<T> & allGrads,
 
   51                        const gsMatrix<T> & allHessians,
 
   56    transformDeriv2Hgrad(md, k, allGrads, allHessians, hessians);
 
   57    result = hessians.leftCols(md.dim.first).rowwise().sum(); 
 
   58    result.transposeInPlace();
 
   62void normal(
const gsMapData<T> & md, 
index_t k, gsVector<T> & result)
 
   64    GISMO_ASSERT( md.dim.first+1 == md.dim.second, 
"Codimension should be equal to one");
 
   65    result.resize(md.dim.first+1);
 
   66    const gsMatrix<T> Jk = md.jacobian(k);
 
   69    typename gsMatrix<T>::RowMinorMatrixType minor;
 
   70    for (
short_t i = 0; i <= md.dim.first; ++i) 
 
   72        Jk.rowMinor(i, minor);
 
   73        result[i] = alt_sgn * minor.determinant();
 
   79void outerNormal(
const gsMapData<T> & md, 
index_t k, boxSide s, gsVector<T> & result)
 
   82    short_t m_orientation = md.jacobian(k).determinant() >= 0 ? 1 : -1;
 
   85    const short_t dir = s.direction();
 
   88    result.resize(md.dim.second);
 
   90    if (md.dim.first + 1 == md.dim.second) 
 
   92        auto Jk = md.jacobian(k).col(!dir);
 
   94        normal(md, k, result);
 
   96        result = tmp.normalized().cross(sgn * Jk);
 
  115        GISMO_ASSERT(md.dim.first == md.dim.second, 
"Codim different than zero/one");
 
  117        if (1 == md.dim.second)
 
  123        const gsMatrix<T> Jk = md.jacobian(k);
 
  126        typename gsMatrix<T>::FirstMinorMatrixType minor;
 
  127        for (
short_t i = 0; i != md.dim.first; ++i) 
 
  129            Jk.firstMinor(i, dir, minor);
 
  130            result[i] = alt_sgn * minor.determinant();
 
  137void secDerToHessian(
typename gsMatrix<T>::constRef & secDers,
 
  138                     gsMatrix<T> & hessian,
 
  144            hessian.resize(1, 1);
 
  145            hessian(0, 0) = secDers(0, 0);
 
  148            hessian.resize(2, 2);
 
  149            hessian(0, 0) = secDers(0, 0);
 
  150            hessian(1, 1) = secDers(1, 0);
 
  152            hessian(1, 0) = secDers(2, 0);
 
  155            hessian.resize(3, 3);
 
  156            hessian(0, 0) = secDers(0, 0);
 
  157            hessian(1, 1) = secDers(1, 0);
 
  158            hessian(2, 2) = secDers(2, 0);
 
  160            hessian(1, 0) = secDers(3, 0);
 
  162            hessian(2, 0) = secDers(4, 0);
 
  164            hessian(2, 1) = secDers(5, 0);
 
  167            GISMO_ERROR(
"Parametric dimension 1, 2 or 3 was expected.");
 
  172void hessianToSecDer (
const gsMatrix<T> & hessian,
 
  173                      typename gsMatrix<T>::Row secDers,
 
  179            secDers(0, 0) = hessian(0, 0);
 
  182            secDers(0, 0) = hessian(0, 0);
 
  183            secDers(0, 1) = hessian(1, 1);
 
  184            secDers(0, 2) = (hessian(1, 0) + hessian(0, 1)) / 2.0;
 
  187            secDers(0, 0) = hessian(0, 0);
 
  188            secDers(0, 1) = hessian(1, 1);
 
  189            secDers(0, 2) = hessian(2, 2);
 
  190            secDers(0, 3) = (hessian(0, 1) + hessian(1, 0)) / 2.0;
 
  191            secDers(0, 4) = (hessian(0, 2) + hessian(2, 0)) / 2.0;
 
  192            secDers(0, 5) = (hessian(1, 2) + hessian(2, 1)) / 2.0;
 
  195            GISMO_ERROR(
"Parametric dimension 1, 2 or 3 was expected.");
 
  200void secDerToTensor(
typename gsEigen::DenseBase<gsEigen::Map<
const gsEigen::Matrix<T, -1, -1>, 0, gsEigen::Stride<0, 0> > >::ConstColXpr & secDers,
 
  204    const index_t dim = parDim * (parDim + 1) / 2;
 
  205    for (
short_t i = 0; i < geoDim; ++i)
 
  206        secDerToHessian<T>(secDers.segment(i * dim, dim), a[i], parDim);
 
  210void transformDeriv2Hgrad(
const gsMapData<T> & md,
 
  212                          const gsMatrix<T> &  funcGrad,
 
  213                          const gsMatrix<T> &  funcSecDir,
 
  214                          gsMatrix<T> &        result)
 
  217    const short_t ParDim = md.dim.first;
 
  218    const short_t GeoDim = md.dim.second;
 
  220        (ParDim == 1 && (GeoDim == 1 || GeoDim == 2 || GeoDim == 3))
 
  221        || (ParDim == 2 && (GeoDim == 2 || GeoDim == 3))
 
  222        || (ParDim == 3 && GeoDim == 3), 
"No implementation for this case");
 
  225    const index_t parSecDirSize = ParDim * (ParDim + 1) / 2;
 
  226    const index_t fisSecDirSize = GeoDim * (GeoDim + 1) / 2;
 
  229    const index_t numGrads = funcGrad.rows() / ParDim;
 
  231    result.resize(numGrads, fisSecDirSize);
 
  233    gsMatrix<T> JMT = md.jacobian(k).cramerInverse();  
 
  234    typename gsMatrix<T>::Tr JM1 = JMT.transpose();           
 
  237    gsMatrix<T> parFuncHessian;
 
  238    for (
index_t i = 0; i < numGrads; ++i)
 
  240        secDerToHessian<T>(funcSecDir.block(i * parSecDirSize, k, parSecDirSize, 1), parFuncHessian, ParDim);
 
  241        hessianToSecDer<T>(JM1 * parFuncHessian * JMT, result.row(i), GeoDim);
 
  245    const gsAsConstMatrix<T, -1, -1>  & secDer = md.deriv2(k);
 
  246    std::vector<gsMatrix<T> > DDG(GeoDim);
 
  247    secDerToTensor<T>(secDer.col(0), DDG.data(), ParDim, GeoDim);
 
  248    gsMatrix<T> HGT(GeoDim, fisSecDirSize);
 
  249    for (
short_t i = 0; i < GeoDim; ++i)
 
  250        hessianToSecDer<T>(JM1 * DDG[i] * JMT, HGT.row(i), GeoDim);
 
  253    const gsAsConstMatrix<T> grads_k(funcGrad.col(k).data(), ParDim, numGrads);
 
  254    result.noalias() -= grads_k.transpose() * JMT * HGT;
 
  270    typedef typename gsBoundaryConditions<T>::bcContainer bcContainer;
 
  310    virtual gsAssembler * 
create() 
const;
 
  313    virtual gsAssembler * 
clone() 
const;
 
  370                     "You cannot initialize a multipatch domain with bases on a single patch");
 
  375        for(
size_t c=0;c<basis.size();c++)
 
 
  396        return (deg + 
m_bases[0][k].dim()) * (deg + 1) * 2;
 
 
  427    template<
class ElementVisitor>
 
  430        for (
size_t np = 0; np < 
m_pde_ptr->domain().nPatches(); ++np)
 
 
  440    template<
class BElementVisitor>
 
  441    void push(
const bcContainer & BCs)
 
  443        for (
typename bcContainer::const_iterator it
 
  444             = BCs.begin(); it!= BCs.end(); ++it)
 
  446            BElementVisitor visitor(*
m_pde_ptr, *it);
 
  448            apply(visitor, it->patch(), it->side());
 
 
  454    template<
class ElementVisitor>
 
  455    void push(
const ElementVisitor & visitor)
 
  457        for (
size_t np = 0; np < 
m_pde_ptr->domain().nPatches(); ++np)
 
  459            ElementVisitor curVisitor = visitor;
 
  461            apply(curVisitor, np);
 
 
  466    template<
class BElementVisitor>
 
  469        BElementVisitor curVisitor = visitor;
 
 
  476    template<
class InterfaceVisitor>
 
  482        for ( 
typename gsMultiPatch<T>::const_iiterator
 
  483                  it = mp.iBegin(); it != mp.iEnd(); ++it )
 
  486                ( 
m_bases[0][it->first() .patch].numElements(it->first() .side() ) <
 
  487                  m_bases[0][it->second().patch].numElements(it->second().side() ) ?
 
  488                  it->getInverse() : *it );
 
  490            this->
apply(visitor, iFace);
 
 
  524            for(
size_t i=0;i<
m_ddof.size();++i)
 
 
  550                                   const gsMultiBasis<T> & mbasis,
 
  558                                    const gsMultiBasis<T> & mbasis,
 
  568                                   gsMultiPatch<T>& result, 
short_t unk = 0) 
const;
 
  580                                   gsMultiPatch<T>& result,
 
  581                                   const gsVector<index_t>  & unknowns) 
const;
 
  593                                gsMultiPatch<T>& result, T theta = (T)(1)) 
const;
 
  655    template<
class ElementVisitor>
 
  656    void apply(ElementVisitor & visitor,
 
  657               size_t patchIndex = 0,
 
  658               boxSide side = boundary::none);
 
  661    template<
class InterfaceVisitor>
 
  662    void apply(InterfaceVisitor & visitor,
 
 
  667template<
class ElementVisitor>
 
  686    const int tid = omp_get_thread_num();
 
  687    const int nt  = omp_get_num_threads();
 
  693    visitor_.initialize(bases, patchIndex, m_options, quRule);
 
  695    const gsGeometry<T> & patch = m_pde_ptr->patches()[patchIndex];
 
  698    typename gsBasis<T>::domainIter domIt = bases[0].makeDomainIterator(side);
 
  702    for ( domIt->next(tid); domIt->good(); domIt->next(nt) )
 
  704    for (; domIt->good(); domIt->next() )
 
  708        quRule.
mapTo( domIt->lowerCorner(), domIt->upperCorner(), quNodes, quWeights );
 
  711        visitor_.evaluate(bases, patch, quNodes);
 
  714        visitor_.assemble(*domIt, quWeights);
 
  717#pragma omp critical(localToGlobal) 
  718        visitor_.localToGlobal(patchIndex, m_ddof, m_system); 
 
 
  726template<
class InterfaceVisitor>
 
  734    const gsBasis<T> & B1 = m_bases[0][patchIndex1];
 
  735    const gsBasis<T> & B2 = m_bases[0][patchIndex2];
 
  742    visitor.initialize(B1, B2, bi, m_options, quRule);
 
  744    const gsGeometry<T> & patch1 = m_pde_ptr->patches()[patchIndex1];
 
  745    const gsGeometry<T> & patch2 = m_pde_ptr->patches()[patchIndex2];
 
  752    for (; domIt->good(); domIt->next() )
 
  757        quRule.
mapTo( domIt->lowerCorner(), domIt->upperCorner(), quNodes1, quWeights);
 
  758        interfaceMap.
eval_into(quNodes1,quNodes2);
 
  761        visitor.evaluate(B1, patch1, B2, patch2, quNodes1, quNodes2);
 
  764        visitor.assemble(*domIt,*domIt, quWeights);
 
  767        visitor.localToGlobal(patchIndex1, patchIndex2, m_ddof, m_system);
 
 
  775#ifndef GISMO_BUILD_LIB 
  776#include GISMO_HPP_HEADER(gsAssembler.hpp) 
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
The assembler class provides generic routines for volume and boundary integrals that are used for for...
Definition gsAssembler.h:266
void homogenizeFixedDofs(short_t unk=0)
Sets any Dirichlet values to homogeneous (if applicable)
Definition gsAssembler.h:520
index_t numDofs() const
Returns the number of (free) degrees of freedom.
Definition gsAssembler.h:633
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
const gsMatrix< T > & rhs() const
Returns the left-hand side vector(s) ( multiple right hand sides possible )
Definition gsAssembler.h:618
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 gsSparseSystem< T > & system() const
Returns the left-hand global matrix.
Definition gsAssembler.h:622
const gsMultiBasis< T > & multiBasis(index_t k=0) const
Return the multi-basis.
Definition gsAssembler.h:604
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
void finalize()
finishes the assembling of the system matrix, i.e. calls its .makeCompressed() method.
Definition gsAssembler.h:388
void penalizeDirichletDofs(short_t unk=0)
Definition gsAssembler.hpp:125
gsSparseSystem< T > m_system
Global sparse linear system.
Definition gsAssembler.h:290
virtual void refresh()
Creates the mappers and setups the sparse system. to be implemented in derived classes,...
Definition gsAssembler.hpp:45
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
void apply(ElementVisitor &visitor, size_t patchIndex=0, boxSide side=boundary::none)
Generic assembly routine for volume or boundary integrals.
Definition gsAssembler.h:668
std::vector< gsMultiBasis< T > > m_bases
Definition gsAssembler.h:282
void initialize(typename gsPde< T >::Ptr 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:328
void push(const bcContainer &BCs)
Iterates over all elements of the boundaries BCs and applies the BElementVisitor.
Definition gsAssembler.h:441
void initialize(const gsPde< T > &pde, const gsMultiBasis< T > &bases, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a multi-basis and assembler options.
Definition gsAssembler.h:342
void pushInterface()
Iterates over all elements of interfaces and applies the InterfaceVisitor.
Definition gsAssembler.h:477
gsOptionList m_options
Options.
Definition gsAssembler.h:285
const gsMatrix< T > & fixedDofs(short_t unk=0) const
Returns the Dirichlet values for a unknown (if applicable)
Definition gsAssembler.h:538
void scalarProblemGalerkinRefresh()
A prototype of the refresh function for a "standard" scalar problem. Creats one mapper based on the s...
Definition gsAssembler.hpp:102
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
void push(const BElementVisitor &visitor, const boundary_condition< T > &BC)
Applies the BElementVisitor to the boundary condition BC.
Definition gsAssembler.h:467
virtual void assemble()
Main assemble routine, to be implemented in derived classes.
Definition gsAssembler.hpp:51
void initialize(const gsPde< T > &pde, const gsBasisRefs< T > &basis, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a vector of bases and assembler options.
Definition gsAssembler.h:365
const gsPde< T > & pde() const
Return the Pde.
Definition gsAssembler.h:598
index_t numColNz() const
Provides an estimation of the number of non-zero matrix entries per column. This value can be used fo...
Definition gsAssembler.h:402
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
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
void setSparseSystem(gsSparseSystem< T > &sys)
Swaps the actual sparse system with the given one.
Definition gsAssembler.h:626
void push(const ElementVisitor &visitor)
Iterates over all elements of the domain and applies the ElementVisitor.
Definition gsAssembler.h:455
memory::shared_ptr< gsPde< T > > m_pde_ptr
Definition gsAssembler.h:276
std::vector< gsMatrix< T > > m_ddof
Definition gsAssembler.h:295
T penalty(index_t k) const
Penalty constant for patch k, used for Nitsche and / Discontinuous Galerkin methods.
Definition gsAssembler.h:393
void computeDirichletDofs(short_t unk=0)
Triggers computation of the Dirichlet dofs.
Definition gsAssembler.hpp:232
static gsOptionList defaultOptions()
Returns the list of default options for assembly.
Definition gsAssembler.hpp:30
gsMultiBasis< T > & multiBasis(index_t k=0)
Return the multi-basis. Note: if the basis is altered, then refresh() should be called.
Definition gsAssembler.h:608
bool check()
checks for consistency and legal values of the stored members.
Definition gsAssembler.hpp:67
virtual gsAssembler * clone() const
Clone this Assembler, making a deep copy.
Definition gsAssembler.hpp:63
void push()
Iterates over all elements of the domain and applies the ElementVisitor.
Definition gsAssembler.h:428
const gsMultiPatch< T > & patches() const
Return the multipatch.
Definition gsAssembler.h:601
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
const gsSparseMatrix< T > & matrix() const
Returns the left-hand global matrix.
Definition gsAssembler.h:614
size_t numMultiBasis() const
Returns the number of multi-bases.
Definition gsAssembler.h:611
const std::vector< gsMatrix< T > > & allFixedDofs() const
Returns all the Dirichlet values (if applicable)
Definition gsAssembler.h:534
Simple class to hold a list of gsBasis which discretize a PDE system on a given patch.
Definition gsBasisRefs.h:26
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
index_t freeSize() const
Returns the number of free (not eliminated) dofs.
Definition gsDofMapper.h:436
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
Class which holds a list of parameters/options, and provides easy access to them.
Definition gsOptionList.h:33
Abstract class representing a PDE (partial differential equation).
Definition gsPde.h:44
Class representing a reference quadrature rule.
Definition gsQuadRule.h:29
virtual void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps quadrature rule (i.e., points and weights) from the reference domain to an element.
Definition gsQuadRule.h:177
Provides a mapping between the corresponding sides of two patches sharing an interface.
Definition gsRemapInterface.h:54
gsDomainIterator< T >::uPtr makeDomainIterator() const
Returns a domain iterator.
Definition gsRemapInterface.hpp:434
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the interface map.
Definition gsRemapInterface.hpp:405
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
A sparse linear system indexed by sets of degrees of freedom.
Definition gsSparseSystem.h:30
const gsMatrix< T > & rhs() const
Access the right hand side.
Definition gsSparseSystem.h:402
const gsDofMapper & colMapper(const index_t c) const
colMapper returns the dofMapper for column block c
Definition gsSparseSystem.h:498
index_t numColNz(const gsMultiBasis< T > &mb, const gsOptionList &opt) const
Provides an estimation of the number of non-zero matrix entries per column. This value can be used fo...
Definition gsSparseSystem.h:359
void swap(gsSparseSystem &other)
swap swaps the content of the Sparse System with the other given one
Definition gsSparseSystem.h:309
index_t numColBlocks() const
returns the number of column blocks
Definition gsSparseSystem.h:472
const gsSparseMatrix< T > & matrix() const
Access the system Matrix.
Definition gsSparseSystem.h:394
bool initialized() const
checks if the system was initialized
Definition gsSparseSystem.h:532
Simple wrapper class for a vector of objects.
Definition gsStdVectorRef.h:28
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Implements an affine function.
Small class holding references to a list of gsBasis.
Provides gsBoundaryConditions class.
Provides a mapping between the corresponding sides of two patches sharing an interface,...
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides the gsDofMapper class for re-indexing DoFs.
Provides declaration of DomainIterator abstract interface.
Provides forward declarations of types and structs.
Provides declaration of MultiBasis class.
Provides a list of labeled parameters/options that can be set and accessed easily.
Base class of descriptions of a PDE problem.
Provides a base class for a quadrature rule.
Provides a mapping between the corresponding sides of two patches sharing an interface.
Class representing a sparse linear system (with dense right-hand side(s)), indexed by sets of degrees...
Small wrapper for std::vector.
shared_ptr< T > make_shared_not_owned(const T *x)
Creates a shared pointer which does not eventually delete the underlying raw pointer....
Definition gsMemory.h:189
The G+Smo namespace, containing all definitions for the library.
int sideOrientation(short_t s)
Definition gsBoundary.h:1029
Struct which represents an interface between two patches.
Definition gsBoundary.h:650
patchSide & first()
first, returns the first patchSide of this interface
Definition gsBoundary.h:776
patchSide & second()
second, returns the second patchSide of this interface
Definition gsBoundary.h:782
Class that defines a boundary condition for a side of a patch for some unknown variable of a PDE.
Definition gsBoundaryConditions.h:107
boxSide side() const
Returns the side to which this boundary condition refers to.
Definition gsBoundaryConditions.h:269
index_t patch() const
Returns the patch to which this boundary condition refers to.
Definition gsBoundaryConditions.h:266
index_t patch
The index of the patch.
Definition gsBoundary.h:234