Feel++ 0.111.0-preview.14
Finite Element Embedded Library in C++
Feel::BilinearFormBase< T > Class Template Reference

Base class for Bilinear Forms handle algebraic representation and multithreading. More...

+ Inheritance diagram for Feel::BilinearFormBase< T >:
+ Collaboration diagram for Feel::BilinearFormBase< T >:

Classes

struct  DeferredDirichletState
 

Public Types

using deferred_dirichlet_set_type = vf::DeferredDirichletSet< value_type >
 
using deferred_dirichlet_state_ptrtype = std::shared_ptr< deferred_dirichlet_state_type >
 
using deferred_dirichlet_state_type = DeferredDirichletState
 
using layout_type = mp11::mp_if_c< is_row_major, ublas::row_major, ublas::column_major >
 
using list_block_type = Feel::vf::list_block_type
 
typedef std::shared_ptr< matrix_type > matrix_ptrtype
 
typedef MatrixSparse< value_type > matrix_type
 
using post_solve_type = typename Backend< value_type >::post_solve_type
 
using pre_solve_type = typename Backend< value_type >::pre_solve_type
 
using size_type = typename matrix_type::size_type
 
using super = CommObject
 
using value_type = T
 
using vector_ptrtype = typename matrix_type::vector_ptrtype
 
using vector_type = typename matrix_type::vector_type
 

Public Member Functions

BilinearFormBase & add (double alpha, BilinearFormBase const &a)
 
 BilinearFormBase (BilinearFormBase &&__vf)=default
 
 BilinearFormBase (BilinearFormBase const &__vf)
 
template<typename FE1 , typename FE2 >
 BilinearFormBase (std::string name, FE1 const &Xh, FE2 const &Yh, matrix_ptrtype &__M, list_block_type const &__lb={}, size_type rowstart=0, size_type colstart=0, bool do_threshold=false, value_type threshold=type_traits< value_type >::epsilon(), size_type graph_hints=Pattern::COUPLED)
 
template<typename FE1 , typename FE2 >
 BilinearFormBase (std::string name, FE1 const &Xh, FE2 const &Yh, matrix_ptrtype &__M, size_type rowstart=0, size_type colstart=0, bool build=true, bool do_threshold=false, value_type threshold=type_traits< value_type >::epsilon(), size_type graph_hints=Pattern::COUPLED)
 
virtual void get ()
 
BilinearFormBase & operator*= (value_type const &alpha)
 operator *= More...
 
BilinearFormBase & operator+= (BilinearFormBase const &a)
 
BilinearFormBase & operator-= (BilinearFormBase const &a)
 
BilinearFormBase & operator/= (value_type const &alpha)
 operator/= by a scalar More...
 
BilinearFormBase & operator= (BilinearFormBase const &form)
 copy operator
 
virtual void push_back (std::future< void > &&f)
 
BilinearFormBase & scale (double alpha)
 scale the form
 
- Public Member Functions inherited from Feel::CommObject
WorldComm const & comm () const
 
 CommObject (CommObject &&)=default
 
 CommObject (CommObject const &)=default
 
 CommObject (worldcomm_ptr_t &w)
 
 CommObject (worldcomm_ptr_t const &w)
 
bool hasWorldComm () const
 returns true if worldcomm is allocated, false othewise
 
CommObject & operator= (CommObject &&)=default
 
CommObject & operator= (CommObject const &)=default
 
virtual void setWorldComm (worldcomm_ptr_t const &w)
 
virtual void setWorldComm (worldcomm_t &w)
 
worldcomm_ptr_t & subWorldCommSeqPtr ()
 
worldcomm_ptr_t const & subWorldCommSeqPtr () const
 
WorldComm & worldComm ()
 
WorldComm const & worldComm () const
 
worldcomm_ptr_t & worldCommPtr ()
 
worldcomm_ptr_t const & worldCommPtr () const
 

Static Public Attributes

static const bool is_row_major = true
 

Methods

std::string M_name
 
size_type M_pattern
 
matrix_ptrtype M_matrix
 
list_block_type M_lb
 
size_type M_row_startInMatrix
 
size_type M_col_startInMatrix
 
bool M_do_build
 
bool M_do_threshold
 
value_type M_threshold
 
std::vector< size_type > M_n_nz
 
std::vector< size_type > M_n_oz
 
std::vector< size_type > const * M_dofIdToContainerIdTest
 
std::vector< size_type > const * M_dofIdToContainerIdTrial
 
deferred_dirichlet_state_ptrtype M_dirichletState
 
std::vector< std::future< void > > M_fut_assign
 
std::mutex b_mutex
 
void close ()
 
void closeBaseOperator ()
 
bool closed () const noexcept
 
bool baseOperatorClosed () const noexcept
 
void zeroRows (std::vector< int > const &__dofs, Vector< value_type > const &__values, Vector< value_type > &rhs, Feel::Context const &on_context, double value_on_diagonal)
 Diagonalize representation(matrix) associated to the BilinearForm at selected dofs dofs by putting 0 on the extra diagonal terms and 1 on the diagonal. More...
 
bool useDeferredDirichlet () const noexcept
 
vf::DeferredDirichletPolicy dirichletPolicy () const noexcept
 
void setDirichletPolicy (vf::DeferredDirichletPolicy policy) noexcept
 
void setDirichletInPlace (bool value)
 Select whether deferred Dirichlet constraints modify the matrix in place. More...
 
bool dirichletInPlace () const noexcept
 
bool hasUnconstrainedMatrix () const noexcept
 
void setUseDeferredDirichlet (bool value) noexcept
 
BilinearFormBase & deferDirichlet () noexcept
 
BilinearFormBase & autoDirichlet () noexcept
 
BilinearFormBase & immediateDirichlet () noexcept
 
bool hasDeferredDirichlet () const noexcept
 
bool hasPendingDirichletConstraints () const noexcept
 
bool hasDirichletConstraints () const noexcept
 
bool supportsConstrainedOperatorView () const noexcept
 
bool hasMaterializedConstrainedOperator () const noexcept
 
std::size_t localStoredDirichletColumnEntryCount () const noexcept
 
bool shouldDeferDirichlet (Feel::Context const &on_context) const noexcept
 
void deferZeroRows (std::vector< int > const &dofs, std::vector< value_type > const &values, Feel::Context const &on_context, double value_on_diagonal, std::uint8_t entity_priority=vf::deferredDirichletEntityPriority(vf::DeferredDirichletEntity::unspecified))
 
void clearDeferredDirichlet ()
 Remove deferred constraints while the operator is still unconstrained. More...
 
deferred_dirichlet_state_ptrtype const & deferredDirichletStatePtr () const noexcept
 
void shareDeferredDirichletState (deferred_dirichlet_state_ptrtype state)
 
matrix_ptrtype const & baseMatrixPtr () const
 
matrix_ptrtype & baseMatrixPtr ()
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
auto constrainedSystem (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
auto constrainedSystem (RhsType const &rhs)
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
auto activeSystem (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
auto activeSystem (RhsType const &rhs)
 
matrix_ptrtype constrainedMatrixPtr ()
 
matrix_ptrtype constrainedMatrixPtr () const
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
matrix_ptrtype constrainedMatrixPtr (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
matrix_ptrtype constrainedMatrixPtr (RhsType const &rhs)
 
matrix_ptrtype activeMatrixPtr ()
 
matrix_ptrtype activeMatrixPtr () const
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
matrix_ptrtype activeMatrixPtr (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
matrix_ptrtype activeMatrixPtr (RhsType const &rhs)
 
void materializeConstrainedOperator ()
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
void materializeConstrainedOperator (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
void materializeConstrainedOperator (RhsType const &rhs)
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
auto constrainedVectorPtr (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
auto constrainedVectorPtr (RhsType const &rhs)
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
auto activeVectorPtr (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
auto activeVectorPtr (RhsType const &rhs)
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
void applyDeferredDirichlet (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
void applyDeferredDirichlet (RhsType const &rhs)
 
template<typename RhsType >
requires requires( RhsType& rhs ) { rhs.vectorPtr(); }
void applyDeferredDirichletToBaseOperator (RhsType &rhs)
 
template<typename RhsType >
requires requires( RhsType const& rhs ) { rhs.vectorPtr(); }
void applyDeferredDirichletToBaseOperator (RhsType const &rhs)
 
void add (size_type i, size_type j, value_type const &v)
 add value v at position (i, j) of the matrix associated with the bilinear form
 
void addMatrix (int *rows, int nrows, int *cols, int ncols, value_type *data, size_type K=0, size_type K2=invalid_v< size_type >)
 add value v at position (i, j) of the matrix associated with the bilinear form
 
void set (size_type i, size_type j, value_type const &v)
 set value v at position (i, j) of the matrix associated with the bilinear form
 
void addToNOz (size_type i, size_type n)
 
void addToNNz (size_type i, size_type n)
 
size_type nOz (size_type i) const
 
size_type nNz (size_type i) const
 
template<typename X1 , typename X2 >
void allocateMatrix (std::shared_ptr< X1 > const &x1, std::shared_ptr< X2 > const &x2)
 
bool isMatrixAllocated () const
 
template<typename ... Ts>
Backend< value_type >::solve_return_type solve (Ts &&... v)
 
template<typename ... Ts>
Backend< value_type >::solve_return_type solveb (Ts &&... v)
 
deferred_dirichlet_state_type & ensureDeferredDirichletState ()
 
void invalidateMaterializedDeferredDirichlet ()
 
void resetDeferredDirichletAfterOperatorReset () noexcept
 
deferred_dirichlet_set_type allDeferredDirichletConstraints () const
 
void promotePendingDeferredDirichlet ()
 
template<typename EntryRange , typename VectorPtrType >
void materializeInPlaceDeferredDirichlet (EntryRange const &entries, VectorPtrType const &rhsContribution)
 
template<typename VectorPtrType >
void applyDeferredDirichletToBaseOperatorVector (VectorPtrType const &rhsVector)
 
template<typename VectorPtrType >
auto materializeConstrainedSystem (VectorPtrType const &rhsVector)
 
matrix_ptrtype materializeConstrainedMatrix ()
 
template<typename VectorPtrType >
auto materializeConstrainedVector (VectorPtrType const &rhsVector)
 

Accessors

std::string const & name () const
 
size_type pattern () const
 return the pattern
 
bool isPatternCoupled () const
 
bool isPatternDefault () const
 
bool isPatternNeighbor () const
 
bool isPatternExtended () const
 
bool isPatternSymmetric () const
 
matrix_type const & matrix () const
 
matrix_type & matrix ()
 
matrix_ptrtype const & matrixPtr () const
 
matrix_ptrtype & matrixPtr ()
 
auto l1Norm () const
 
auto linftyNorm () const
 
list_block_type const & blockList () const
 
size_type rowStartInMatrix () const
 
size_type colStartInMatrix () const
 
std::size_t nnz () const
 
void zero ()
 set the bilinear form to zero More...
 
value_type threshold () const
 
bool doThreshold (value_type const &v) const
 
bool doThreshold () const
 return true if do threshold. More...
 
std::vector< size_type > const & dofIdToContainerIdTest () const
 
std::vector< size_type > const & dofIdToContainerIdTrial () const
 

Mutators

void setThreshold (value_type eps)
 set a threshold value for the matrix entries associated with the bilinear form
 
void setDoThreshold (bool do_threshold)
 set the threshold strategy, true threshold the matrix entries, false do not threshold
 
void setDofIdToContainerIdTest (std::vector< size_type > const &gpmap)
 set mapping from test dof id to container id with global process numbering
 
void setDofIdToContainerIdTrial (std::vector< size_type > const &gpmap)
 set mapping from trial dof id to container id with global process numbering
 

Detailed Description

template<typename T = double>
class Feel::BilinearFormBase< T >

Base class for Bilinear Forms handle algebraic representation and multithreading.

Member Function Documentation

◆ baseMatrixPtr()

template<typename T = double>
matrix_ptrtype const & Feel::BilinearFormBase< T >::baseMatrixPtr ( ) const
Returns
the unconstrained matrix.
Precondition
In-place Dirichlet materialization has not occurred.

◆ clearDeferredDirichlet()

template<typename T = double>
void Feel::BilinearFormBase< T >::clearDeferredDirichlet ( )

Remove deferred constraints while the operator is still unconstrained.

Once in-place materialization has modified the matrix, zero() and a reassembly are required because clearing metadata cannot restore erased Dirichlet columns.

◆ dirichletInPlace()

template<typename T = double>
bool Feel::BilinearFormBase< T >::dirichletInPlace ( ) const
noexcept
Returns
true when deferred constraints are materialized in place.

◆ dofIdToContainerIdTest()

template<typename T = double>
std::vector< size_type > const & Feel::BilinearFormBase< T >::dofIdToContainerIdTest ( ) const
Returns
the mapping from test dof id to container id with global process numbering

◆ dofIdToContainerIdTrial()

template<typename T = double>
std::vector< size_type > const & Feel::BilinearFormBase< T >::dofIdToContainerIdTrial ( ) const
Returns
the mapping from trial dof id to container id with global process numbering

◆ doThreshold() [1/2]

template<typename T = double>
bool Feel::BilinearFormBase< T >::doThreshold ( ) const

return true if do threshold.

false otherwise

◆ doThreshold() [2/2]

template<typename T = double>
bool Feel::BilinearFormBase< T >::doThreshold ( value_type const &  v) const
Returns
true if threshold applies, false otherwise

◆ hasUnconstrainedMatrix()

template<typename T = double>
bool Feel::BilinearFormBase< T >::hasUnconstrainedMatrix ( ) const
noexcept
Returns
true while the original unconstrained operator is still available.

◆ isPatternCoupled()

template<typename T = double>
bool Feel::BilinearFormBase< T >::isPatternCoupled ( ) const
Returns
true if the pattern is coupled with respect to the components, false otherwise

◆ isPatternDefault()

template<typename T = double>
bool Feel::BilinearFormBase< T >::isPatternDefault ( ) const
Returns
true if the pattern is the default one, false otherwise

◆ isPatternNeighbor()

template<typename T = double>
bool Feel::BilinearFormBase< T >::isPatternNeighbor ( ) const
Returns
true if the pattern adds the neighboring elements, false otherwise

◆ localStoredDirichletColumnEntryCount()

template<typename T = double>
std::size_t Feel::BilinearFormBase< T >::localStoredDirichletColumnEntryCount ( ) const
noexcept
Returns
number of sparse Dirichlet-column entries retained on this rank.

◆ matrix()

template<typename T = double>
matrix_type const & Feel::BilinearFormBase< T >::matrix ( ) const
Returns
the matrix associated to the bilinear form

◆ name()

template<typename T = double>
std::string const & Feel::BilinearFormBase< T >::name ( ) const
Returns
the name of the bilinear form

◆ nnz()

template<typename T = double>
std::size_t Feel::BilinearFormBase< T >::nnz ( ) const
Returns
number of non-zero entries

◆ operator*=()

template<typename T = double>
BilinearFormBase & Feel::BilinearFormBase< T >::operator*= ( value_type const &  alpha)

operator *=

Parameters
__abilinear form
Returns
Bilinear&

◆ operator/=()

template<typename T = double>
BilinearFormBase & Feel::BilinearFormBase< T >::operator/= ( value_type const &  alpha)

operator/= by a scalar

Parameters
__ascalar to divide by
Returns
BilinearForm&

◆ setDirichletInPlace()

template<typename T = double>
void Feel::BilinearFormBase< T >::setDirichletInPlace ( bool  value)

Select whether deferred Dirichlet constraints modify the matrix in place.

The default (true) avoids cloning the complete sparse matrix. Ordinary row elimination needs no auxiliary matrix data. Symmetric elimination retains only the sparse Dirichlet-column entries needed to refresh the right-hand-side contribution when prescribed values change. Passing false preserves the unconstrained matrix and materializes a separate constrained matrix for compatibility or inspection purposes. The policy must be selected before constraints are materialized.

◆ threshold()

template<typename T = double>
value_type Feel::BilinearFormBase< T >::threshold ( ) const
Returns
the threshold

◆ zero()

template<typename T = double>
void Feel::BilinearFormBase< T >::zero ( )

set the bilinear form to zero

set the bilinear form and its algebraic representation to zero

◆ zeroRows()

template<typename T >
void Feel::BilinearFormBase< T >::zeroRows ( std::vector< int > const &  __dofs,
Vector< value_type > const &  __values,
Vector< value_type > &  rhs,
Feel::Context const &  on_context,
double  value_on_diagonal 
)

Diagonalize representation(matrix) associated to the BilinearForm at selected dofs dofs by putting 0 on the extra diagonal terms and 1 on the diagonal.

If ON_ELIMINATION_KEEP_DIAGONAL is set in on_context then the diagonal value of the matrix is kept and the right habd side rhs is modified accordingly.