HIFLOW  2.0
Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
hiflow::GlobalAssembler< DataType > Class Template Referenceabstract

Abstract interface for classes implementing a Global Assembly strategy. More...

#include <assembly.h>

Inheritance diagram for hiflow::GlobalAssembler< DataType >:
[legend]

Public Types

typedef boost::function4< void, const Element< DataType > &, int, const Quadrature< DataType > &, LocalMatrix & > BoundaryMatrixAssemblyFunction
 Generalized function type used for matrix local assembly functions on the boundary. More...
 
typedef boost::function4< void, const Element< DataType > &, int, const Quadrature< DataType > &, LocalVector & > BoundaryScalarAssemblyFunction
 Generalized function type used for scalar local assembly functions on the boundary. More...
 
typedef boost::function4< void, const Element< DataType > &, int, const Quadrature< DataType > &, LocalVector & > BoundaryVectorAssemblyFunction
 Generalized function type used for vector local assembly functions on the boundary. More...
 
typedef boost::function3< void, const Element< DataType > &, Quadrature< DataType > &, const intFacetQuadratureSelectionFunction
 
typedef la::Matrix< DataType > GlobalMatrix
 
typedef la::Vector< DataType > GlobalVector
 
typedef la::SeqDenseMatrix< DataType > LocalMatrix
 
typedef std::vector< DataType > LocalVector
 
typedef boost::function3< void, const Element< DataType > &, const Quadrature< DataType > &, LocalMatrix & > MatrixAssemblyFunction
 Generalized function type used for matrix local assembly functions. More...
 
typedef boost::function3< void, const Element< DataType > &, const Quadrature< DataType > &, LocalVector & > MultipleScalarAssemblyFunction
 Generalized function type used for multiple scalar local assembly functions. More...
 
typedef boost::function2< void, const Element< DataType > &, Quadrature< DataType > & > QuadratureSelectionFunction
 Generalized function type used for quadrature selection. More...
 
typedef boost::function3< void, const Element< DataType > &, const Quadrature< DataType > &, DataType & > ScalarAssemblyFunction
 Generalized function type used for scalar local assembly functions. More...
 
typedef boost::function3< void, const Element< DataType > &, const Quadrature< DataType > &, LocalVector & > VectorAssemblyFunction
 Generalized function type used for vector local assembly functions. More...
 

Public Member Functions

void assemble_matrix (const VectorSpace< DataType > &space, MatrixAssemblyFunction local_asm, GlobalMatrix &matrix) const
 Assemble global matrix for a VectorSpace. More...
 
void assemble_matrix_boundary (const VectorSpace< DataType > &space, BoundaryMatrixAssemblyFunction local_asm, GlobalMatrix &matrix) const
 Assemble global matrix for a VectorSpace, defined by a boundary integral. More...
 
void assemble_multiple_scalar (const VectorSpace< DataType > &space, MultipleScalarAssemblyFunction local_asm, const int num_scalars, std::vector< std::vector< DataType > > &vec) const
 Compute element-wise integral for a VectorSpace. More...
 
void assemble_scalar (const VectorSpace< DataType > &space, ScalarAssemblyFunction local_asm, std::vector< DataType > &vec) const
 Compute element-wise integral for a VectorSpace. More...
 
void assemble_scalar_boundary (const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, std::vector< DataType > &vec) const
 Compute facet-wise boundary integral for a VectorSpace. More...
 
void assemble_vector (const VectorSpace< DataType > &space, VectorAssemblyFunction local_asm, GlobalVector &vec) const
 Assemble global vector for a VectorSpace. More...
 
void assemble_vector_boundary (const VectorSpace< DataType > &space, BoundaryVectorAssemblyFunction local_asm, GlobalVector &vec) const
 Assemble global vector for a VectorSpace, defined by a boundary integral. More...
 
void compute_sparsity_structure (const VectorSpace< DataType > &space, SparsityStructure &sparsity, std::vector< std::vector< bool > > *coupling_vars=new std::vector< std::vector< bool > >(0)) const
 Compute the matrix graph for the assembly. More...
 
 GlobalAssembler ()
 
void integrate_multiple_scalar (const VectorSpace< DataType > &space, MultipleScalarAssemblyFunction local_asm, const int num_scalars, std::vector< DataType > &integral) const
 Compute integral for a VectorSpace. More...
 
void integrate_scalar (const VectorSpace< DataType > &space, ScalarAssemblyFunction local_asm, DataType &integral) const
 Compute integral for a VectorSpace. More...
 
void integrate_scalar_boundary (const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, DataType &integral) const
 Compute boundary integral for a VectorSpace. More...
 
void maximize_scalar_boundary (const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, DataType &maximum) const
 Compute boundary maximum for a VectorSpace. More...
 
void set_quadrature_selection_function (QuadratureSelectionFunction q_select)
 Set the function used to determine which quadrature rule should be used. More...
 
void should_reset_assembly_target (bool should_reset)
 Change whether the assembled object should be reset prior to assembly. More...
 
virtual ~GlobalAssembler ()
 

Protected Attributes

bool should_reset_assembly_target_
 

Private Member Functions

virtual void assemble_matrix_boundary_impl (const VectorSpace< DataType > &space, BoundaryMatrixAssemblyFunction local_asm, GlobalMatrix &mat, FacetQuadratureSelectionFunction fq_select) const =0
 
virtual void assemble_matrix_impl (const VectorSpace< DataType > &space, MatrixAssemblyFunction local_asm, GlobalMatrix &mat, QuadratureSelectionFunction q_select) const =0
 
virtual void assemble_multiple_scalar_impl (const VectorSpace< DataType > &space, MultipleScalarAssemblyFunction local_asm, const int num_scalars, std::vector< std::vector< DataType > > &vec, QuadratureSelectionFunction q_select) const =0
 
virtual void assemble_scalar_boundary_impl (const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, std::vector< DataType > &vec, FacetQuadratureSelectionFunction fq_select) const =0
 
virtual void assemble_scalar_impl (const VectorSpace< DataType > &space, ScalarAssemblyFunction local_asm, std::vector< DataType > &vec, QuadratureSelectionFunction q_select) const =0
 
virtual void assemble_vector_boundary_impl (const VectorSpace< DataType > &space, BoundaryVectorAssemblyFunction local_asm, GlobalVector &vec, FacetQuadratureSelectionFunction fq_select) const =0
 
virtual void assemble_vector_impl (const VectorSpace< DataType > &space, VectorAssemblyFunction local_asm, GlobalVector &vec, QuadratureSelectionFunction q_select) const =0
 
virtual void compute_sparsity_structure_impl (const VectorSpace< DataType > &space, SparsityStructure &sparsity, std::vector< std::vector< bool > > *coupling_vars) const =0
 
template<>
const GlobalAssembler< double >::FacetQuadratureSelectionFunction default_facet_select_
 
template<>
const GlobalAssembler< float >::FacetQuadratureSelectionFunction default_facet_select_
 
template<>
const GlobalAssembler< double >::QuadratureSelectionFunction default_select_
 
template<>
const GlobalAssembler< float >::QuadratureSelectionFunction default_select_
 

Private Attributes

FacetQuadratureSelectionFunction fq_select_
 
QuadratureSelectionFunction q_select_
 

Static Private Attributes

static const FacetQuadratureSelectionFunction default_facet_select_
 
static const QuadratureSelectionFunction default_select_
 

Detailed Description

template<class DataType>
class hiflow::GlobalAssembler< DataType >

Abstract interface for classes implementing a Global Assembly strategy.

Definition at line 64 of file assembly.h.

Member Typedef Documentation

◆ BoundaryMatrixAssemblyFunction

template<class DataType>
typedef boost::function4<void, const Element<DataType>&, int, const Quadrature<DataType>&, LocalMatrix&> hiflow::GlobalAssembler< DataType >::BoundaryMatrixAssemblyFunction

Generalized function type used for matrix local assembly functions on the boundary.

Definition at line 115 of file assembly.h.

◆ BoundaryScalarAssemblyFunction

template<class DataType>
typedef boost::function4<void, const Element<DataType>&, int, const Quadrature<DataType>&, LocalVector&> hiflow::GlobalAssembler< DataType >::BoundaryScalarAssemblyFunction

Generalized function type used for scalar local assembly functions on the boundary.

Definition at line 101 of file assembly.h.

◆ BoundaryVectorAssemblyFunction

template<class DataType>
typedef boost::function4<void, const Element<DataType>&, int, const Quadrature<DataType>&, LocalVector&> hiflow::GlobalAssembler< DataType >::BoundaryVectorAssemblyFunction

Generalized function type used for vector local assembly functions on the boundary.

Definition at line 108 of file assembly.h.

◆ FacetQuadratureSelectionFunction

template<class DataType>
typedef boost::function3<void, const Element<DataType>&, Quadrature<DataType>&, const int> hiflow::GlobalAssembler< DataType >::FacetQuadratureSelectionFunction

Definition at line 124 of file assembly.h.

◆ GlobalMatrix

template<class DataType>
typedef la::Matrix<DataType> hiflow::GlobalAssembler< DataType >::GlobalMatrix

Definition at line 67 of file assembly.h.

◆ GlobalVector

template<class DataType>
typedef la::Vector<DataType> hiflow::GlobalAssembler< DataType >::GlobalVector

Definition at line 68 of file assembly.h.

◆ LocalMatrix

template<class DataType>
typedef la::SeqDenseMatrix<DataType> hiflow::GlobalAssembler< DataType >::LocalMatrix

Definition at line 69 of file assembly.h.

◆ LocalVector

template<class DataType>
typedef std::vector<DataType> hiflow::GlobalAssembler< DataType >::LocalVector

Definition at line 70 of file assembly.h.

◆ MatrixAssemblyFunction

template<class DataType>
typedef boost::function3<void, const Element<DataType>&, const Quadrature<DataType>&, LocalMatrix&> hiflow::GlobalAssembler< DataType >::MatrixAssemblyFunction

Generalized function type used for matrix local assembly functions.

Definition at line 94 of file assembly.h.

◆ MultipleScalarAssemblyFunction

template<class DataType>
typedef boost::function3<void, const Element<DataType>&, const Quadrature<DataType>&, LocalVector&> hiflow::GlobalAssembler< DataType >::MultipleScalarAssemblyFunction

Generalized function type used for multiple scalar local assembly functions.

Definition at line 82 of file assembly.h.

◆ QuadratureSelectionFunction

template<class DataType>
typedef boost::function2<void, const Element<DataType>&, Quadrature<DataType>&> hiflow::GlobalAssembler< DataType >::QuadratureSelectionFunction

Generalized function type used for quadrature selection.

Definition at line 120 of file assembly.h.

◆ ScalarAssemblyFunction

template<class DataType>
typedef boost::function3<void, const Element<DataType>&, const Quadrature<DataType>&, DataType&> hiflow::GlobalAssembler< DataType >::ScalarAssemblyFunction

Generalized function type used for scalar local assembly functions.

Definition at line 76 of file assembly.h.

◆ VectorAssemblyFunction

template<class DataType>
typedef boost::function3<void, const Element<DataType>&, const Quadrature<DataType>&, LocalVector&> hiflow::GlobalAssembler< DataType >::VectorAssemblyFunction

Generalized function type used for vector local assembly functions.

Definition at line 88 of file assembly.h.

Constructor & Destructor Documentation

◆ GlobalAssembler()

template<class DataType >
hiflow::GlobalAssembler< DataType >::GlobalAssembler ( )

Definition at line 130 of file assembly.cc.

132  {
133  }
bool should_reset_assembly_target_
Definition: assembly.h:448
QuadratureSelectionFunction q_select_
Definition: assembly.h:444
const GlobalAssembler< double >::FacetQuadratureSelectionFunction default_facet_select_
Definition: assembly.cc:500
FacetQuadratureSelectionFunction fq_select_
Definition: assembly.h:445
const GlobalAssembler< double >::QuadratureSelectionFunction default_select_
Definition: assembly.cc:497

◆ ~GlobalAssembler()

template<class DataType >
hiflow::GlobalAssembler< DataType >::~GlobalAssembler ( )
virtual

Definition at line 136 of file assembly.cc.

137  {
138  }

Member Function Documentation

◆ assemble_matrix()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_matrix ( const VectorSpace< DataType > &  space,
MatrixAssemblyFunction  local_asm,
GlobalMatrix matrix 
) const

Assemble global matrix for a VectorSpace.

Assembles a matrix $A_{ij} = \int_{\Omega}{f(x,\varphi_i, \varphi_j)dx}$ over the domain defined by the mesh associated to a VectorSpace. The integrand is defined through a MatrixAssemblyFunction, which should return the locally assembled matrix for each element.

Parameters
[in]spacethe VectorSpace for which the assembly is performed
[in]local_asmfunction or functor that performs local matrix assembly
[out]global_matrixthe assembled matrix $A_{ij}$
See also
Concept for assembly and integration

Definition at line 247 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_matrix_impl(), hiflow::GlobalAssembler< DataType >::q_select_, hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_, and hiflow::la::Matrix< DataType >::Zeros().

250  {
252  {
253  matrix.Zeros ( );
254  }
255 
256  assemble_matrix_impl ( space, local_asm, matrix, q_select_ );
257  }
virtual void assemble_matrix_impl(const VectorSpace< DataType > &space, MatrixAssemblyFunction local_asm, GlobalMatrix &mat, QuadratureSelectionFunction q_select) const =0
bool should_reset_assembly_target_
Definition: assembly.h:448
QuadratureSelectionFunction q_select_
Definition: assembly.h:444

◆ assemble_matrix_boundary()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_matrix_boundary ( const VectorSpace< DataType > &  space,
BoundaryMatrixAssemblyFunction  local_asm,
GlobalMatrix matrix 
) const

Assemble global matrix for a VectorSpace, defined by a boundary integral.

Assembles a matrix $A_{ij} = \int_{\partial\Omega}{f(x,\varphi_i, \varphi_j)dx}$ over the boundary of the domain defined by the mesh associated to a VectorSpace. The integrand is defined through a BoundaryMatrixAssemblyFunction, which should return the locally assembled matrix for each boundary facet.

Parameters
[in]spacethe VectorSpace for which the assembly is performed
[in]local_asmfunction or functor that performs local matrix assembly
[out]global_matrixthe assembled matrix $A_{ij}$
See also
Concept for assembly and integration

Definition at line 314 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_matrix_boundary_impl(), hiflow::GlobalAssembler< DataType >::fq_select_, hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_, and hiflow::la::Matrix< DataType >::Zeros().

317  {
319  {
320  matrix.Zeros ( );
321  }
322 
323  assemble_matrix_boundary_impl ( space, local_asm, matrix, fq_select_ );
324  }
bool should_reset_assembly_target_
Definition: assembly.h:448
FacetQuadratureSelectionFunction fq_select_
Definition: assembly.h:445
virtual void assemble_matrix_boundary_impl(const VectorSpace< DataType > &space, BoundaryMatrixAssemblyFunction local_asm, GlobalMatrix &mat, FacetQuadratureSelectionFunction fq_select) const =0

◆ assemble_matrix_boundary_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_matrix_boundary_impl ( const VectorSpace< DataType > &  space,
BoundaryMatrixAssemblyFunction  local_asm,
GlobalMatrix mat,
FacetQuadratureSelectionFunction  fq_select 
) const
privatepure virtual

◆ assemble_matrix_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_matrix_impl ( const VectorSpace< DataType > &  space,
MatrixAssemblyFunction  local_asm,
GlobalMatrix mat,
QuadratureSelectionFunction  q_select 
) const
privatepure virtual

◆ assemble_multiple_scalar()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_multiple_scalar ( const VectorSpace< DataType > &  space,
MultipleScalarAssemblyFunction  local_asm,
const int  num_scalars,
std::vector< std::vector< DataType > > &  vec 
) const

Compute element-wise integral for a VectorSpace.

Computes an integral $\int_{K}{f(x)dx}$ over the cells $K$ in the mesh associated to a VectorSpace. The vector-valued integrand is defined through the MultipleScalarAssemblyFunction, which should return the values of the integral for each element.

Parameters
[in]spacethe VectorSpace to integrate over
[in]local_asmfunction or functor that performs local integration
[in]num_scalarsdimension of vector valued integrand
[out]vecthe values of the integral for each cell in the mesh
See also
Concept for assembly and integration

Definition at line 215 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_multiple_scalar_impl(), hiflow::VectorSpace< DataType >::mesh(), hiflow::GlobalAssembler< DataType >::q_select_, and hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_.

Referenced by hiflow::HpFemAssembler< DataType >::assemble_multiple_scalar_impl().

218  {
220  {
221  vec.clear ( );
222  const size_t num_cells = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) );
223  vec.resize ( num_cells );
224  for ( int l = 0; l < num_cells; ++l )
225  {
226  vec[l].resize ( num_scalars, 0. );
227  }
228  }
229 
230  assemble_multiple_scalar_impl ( space, local_asm, num_scalars, vec, q_select_ );
231  }
virtual void assemble_multiple_scalar_impl(const VectorSpace< DataType > &space, MultipleScalarAssemblyFunction local_asm, const int num_scalars, std::vector< std::vector< DataType > > &vec, QuadratureSelectionFunction q_select) const =0
bool should_reset_assembly_target_
Definition: assembly.h:448
QuadratureSelectionFunction q_select_
Definition: assembly.h:444

◆ assemble_multiple_scalar_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_multiple_scalar_impl ( const VectorSpace< DataType > &  space,
MultipleScalarAssemblyFunction  local_asm,
const int  num_scalars,
std::vector< std::vector< DataType > > &  vec,
QuadratureSelectionFunction  q_select 
) const
privatepure virtual

◆ assemble_scalar()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_scalar ( const VectorSpace< DataType > &  space,
ScalarAssemblyFunction  local_asm,
std::vector< DataType > &  vec 
) const

Compute element-wise integral for a VectorSpace.

Computes an integral $\int_{K}{f(x)dx}$ over the cells $K$ in the mesh associated to a VectorSpace. The integrand is defined through the ScalarAssemblyFunction, which should return the value of the integral for each element.

Parameters
[in]spacethe VectorSpace to integrate over
[in]local_asmfunction or functor that performs local integration
[out]vecthe value of the integral for each cell in the mesh
See also
Concept for assembly and integration

Definition at line 200 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_scalar_impl(), hiflow::VectorSpace< DataType >::mesh(), hiflow::GlobalAssembler< DataType >::q_select_, and hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_.

Referenced by hiflow::HpFemAssembler< DataType >::assemble_scalar_impl().

203  {
205  {
206  vec.clear ( );
207  const size_t num_cells = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) );
208  vec.resize ( num_cells, 0. );
209  }
210 
211  assemble_scalar_impl ( space, local_asm, vec, q_select_ );
212  }
virtual void assemble_scalar_impl(const VectorSpace< DataType > &space, ScalarAssemblyFunction local_asm, std::vector< DataType > &vec, QuadratureSelectionFunction q_select) const =0
bool should_reset_assembly_target_
Definition: assembly.h:448
QuadratureSelectionFunction q_select_
Definition: assembly.h:444

◆ assemble_scalar_boundary()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_scalar_boundary ( const VectorSpace< DataType > &  space,
BoundaryScalarAssemblyFunction  local_asm,
std::vector< DataType > &  vec 
) const

Compute facet-wise boundary integral for a VectorSpace.

Computes a boundary integral $\int_{\partial K}{f(x)dx}$ over the cells in the mesh associated to a VectorSpace. The integrand is defined through the BoundaryScalarAssemblyFunction, which should return the value of the integral for each boundary facet.

Parameters
[in]spacethe VectorSpace to integrate over
[in]local_asmfunction or functor that performs local integration
[out]vecthe value of the integral for each facet on the boundary
See also
Concept for assembly and integration

Definition at line 286 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_scalar_boundary_impl(), hiflow::GlobalAssembler< DataType >::fq_select_, hiflow::VectorSpace< DataType >::mesh(), and hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_.

289  {
291  {
292  vec.clear ( );
293  const size_t num_cells = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) - 1 );
294  vec.resize ( num_cells, 0. );
295  }
296 
297  assemble_scalar_boundary_impl ( space, local_asm, vec, fq_select_ );
298  }
bool should_reset_assembly_target_
Definition: assembly.h:448
virtual void assemble_scalar_boundary_impl(const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, std::vector< DataType > &vec, FacetQuadratureSelectionFunction fq_select) const =0
FacetQuadratureSelectionFunction fq_select_
Definition: assembly.h:445

◆ assemble_scalar_boundary_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_scalar_boundary_impl ( const VectorSpace< DataType > &  space,
BoundaryScalarAssemblyFunction  local_asm,
std::vector< DataType > &  vec,
FacetQuadratureSelectionFunction  fq_select 
) const
privatepure virtual

◆ assemble_scalar_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_scalar_impl ( const VectorSpace< DataType > &  space,
ScalarAssemblyFunction  local_asm,
std::vector< DataType > &  vec,
QuadratureSelectionFunction  q_select 
) const
privatepure virtual

◆ assemble_vector()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_vector ( const VectorSpace< DataType > &  space,
VectorAssemblyFunction  local_asm,
GlobalVector vec 
) const

Assemble global vector for a VectorSpace.

Assembles a vector $b_i = \int_{\Omega}{f(x, \varphi_i)dx}$ over the domain defined by the mesh associated to a VectorSpace. The integrand is defined through a VectorAssemblyFunction, which should return the locally assembled vector for each element.

Parameters
[in]spacethe VectorSpace for which the assembly is performed
[in]local_asmfunction or functor that performs local vector assembly
[out]global_vectorthe assembled vector $b_i$
See also
Concept for assembly and integration

Definition at line 234 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_vector_impl(), hiflow::GlobalAssembler< DataType >::q_select_, hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_, and hiflow::la::Vector< DataType >::Zeros().

237  {
239  {
240  vec.Zeros ( );
241  }
242 
243  assemble_vector_impl ( space, local_asm, vec, q_select_ );
244  }
bool should_reset_assembly_target_
Definition: assembly.h:448
QuadratureSelectionFunction q_select_
Definition: assembly.h:444
virtual void assemble_vector_impl(const VectorSpace< DataType > &space, VectorAssemblyFunction local_asm, GlobalVector &vec, QuadratureSelectionFunction q_select) const =0

◆ assemble_vector_boundary()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::assemble_vector_boundary ( const VectorSpace< DataType > &  space,
BoundaryVectorAssemblyFunction  local_asm,
GlobalVector vec 
) const

Assemble global vector for a VectorSpace, defined by a boundary integral.

Assembles a vector $b_i = \int_{\partial\Omega}{f(x, \varphi_i)ds}$ over the boundary of the domain defined by the mesh associated to a VectorSpace. The integrand is defined through a BoundaryVectorAssemblyFunction, which should return the locally assembled vector for each boundary facet.

Parameters
[in]spacethe VectorSpace for which the assembly is performed
[in]local_asmfunction or functor that performs local vector assembly
[out]global_vectorthe assembled vector $b_i$
See also
Concept for assembly and integration

Definition at line 301 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_vector_boundary_impl(), hiflow::GlobalAssembler< DataType >::fq_select_, hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_, and hiflow::la::Vector< DataType >::Zeros().

304  {
306  {
307  vec.Zeros ( );
308  }
309 
310  assemble_vector_boundary_impl ( space, local_asm, vec, fq_select_ );
311  }
virtual void assemble_vector_boundary_impl(const VectorSpace< DataType > &space, BoundaryVectorAssemblyFunction local_asm, GlobalVector &vec, FacetQuadratureSelectionFunction fq_select) const =0
bool should_reset_assembly_target_
Definition: assembly.h:448
FacetQuadratureSelectionFunction fq_select_
Definition: assembly.h:445

◆ assemble_vector_boundary_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_vector_boundary_impl ( const VectorSpace< DataType > &  space,
BoundaryVectorAssemblyFunction  local_asm,
GlobalVector vec,
FacetQuadratureSelectionFunction  fq_select 
) const
privatepure virtual

◆ assemble_vector_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::assemble_vector_impl ( const VectorSpace< DataType > &  space,
VectorAssemblyFunction  local_asm,
GlobalVector vec,
QuadratureSelectionFunction  q_select 
) const
privatepure virtual

◆ compute_sparsity_structure()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::compute_sparsity_structure ( const VectorSpace< DataType > &  space,
SparsityStructure sparsity,
std::vector< std::vector< bool > > *  coupling_vars = new std::vector<std::vector<bool> >( 0 ) 
) const

Compute the matrix graph for the assembly.

The matrix graph is a set of pairs (i,j) of global indices which are cannot be guaranteed to give a zero in the matrix assembly. Typically, these will correspond to all global basis functions with overlapping support.

Parameters
[in]spacethe VectorSpace to assemble over
[out]sparsitythe sparsity object containing arrays that describe the matrix graph
[in]coupling_vars2D array indicating the coupling of vars. Rows (first index) belong to test variables, columns (second index) belong to trial variables. If entry (i, j) is set to true, test variable i couples with trial variable j, and the corresponding block is contained in the sparsity structure. Otherwise, the block is skipped, resulting in a sparser structure. If this argument is not passed or is empty, full coupling of all variables is assumed. All rows and columns need to have the size of space.get_nb_var().

Definition at line 141 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::compute_sparsity_structure_impl(), and hiflow::VectorSpace< DataType >::get_nb_var().

Referenced by hiflow::initialize_linear_algebra_objects().

144  {
145  if ( coupling_vars->empty ( ) )
146  {
147  coupling_vars->resize ( space.get_nb_var ( ) );
148  for ( size_t i = 0, i_e = space.get_nb_var ( ); i != i_e; ++i )
149  {
150  ( *coupling_vars )[i].resize ( space.get_nb_var ( ), true );
151  }
152  }
153 
154  // Assert correct size of coupling_vars
155 
156  assert ( coupling_vars->size ( ) == space.get_nb_var ( ) );
157  for ( size_t i = 0, i_e = space.get_nb_var ( ); i != i_e; ++i )
158  {
159  assert ( ( *coupling_vars )[i].size ( ) == space.get_nb_var ( ) );
160  }
161 
162  compute_sparsity_structure_impl ( space, sparsity, coupling_vars );
163  }
virtual void compute_sparsity_structure_impl(const VectorSpace< DataType > &space, SparsityStructure &sparsity, std::vector< std::vector< bool > > *coupling_vars) const =0

◆ compute_sparsity_structure_impl()

template<class DataType>
virtual void hiflow::GlobalAssembler< DataType >::compute_sparsity_structure_impl ( const VectorSpace< DataType > &  space,
SparsityStructure sparsity,
std::vector< std::vector< bool > > *  coupling_vars 
) const
privatepure virtual

Interface to be implemented by concrete assembly classes. These are called from the corresponding functions in the public interface. The integrate_scalar_* functions call assemble_scalar_impl and sum the values in the vector. Note that the implementations should not reset the global object themselves, as this is handled by the public functions.

Implemented in hiflow::HpFemAssembler< DataType >, hiflow::StandardGlobalAssembler< DataType >, and hiflow::DGGlobalAssembler< DataType >.

Referenced by hiflow::GlobalAssembler< DataType >::compute_sparsity_structure().

◆ default_facet_select_() [1/2]

template<>
const GlobalAssembler< double >::FacetQuadratureSelectionFunction hiflow::GlobalAssembler< double >::default_facet_select_ ( )
private

Definition at line 500 of file assembly.cc.

◆ default_facet_select_() [2/2]

template<>
const GlobalAssembler< float >::FacetQuadratureSelectionFunction hiflow::GlobalAssembler< float >::default_facet_select_ ( )
private

Definition at line 507 of file assembly.cc.

◆ default_select_() [1/2]

template<>
const GlobalAssembler< double >::QuadratureSelectionFunction hiflow::GlobalAssembler< double >::default_select_ ( )
private

◆ default_select_() [2/2]

template<>
const GlobalAssembler< float >::QuadratureSelectionFunction hiflow::GlobalAssembler< float >::default_select_ ( )
private

Definition at line 504 of file assembly.cc.

◆ integrate_multiple_scalar()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::integrate_multiple_scalar ( const VectorSpace< DataType > &  space,
MultipleScalarAssemblyFunction  local_asm,
const int  num_scalars,
std::vector< DataType > &  integral 
) const

Compute integral for a VectorSpace.

Computes an integral $\int_{\Omega}{f(x)dx}$ over the domain defined by the mesh associated to a VectorSpace. The vector valued integrand is defined through the MultipleScalarAssemblyFunction, which should return the value of the integral for each element.

Parameters
[in]spacethe VectorSpace to integrate over
[in]local_asmfunction or functor that performs local integration
[in]num_scalarsdimension of vector valued integrand
[out]valuethe value of the integral
See also
Concept for assembly and integration

Definition at line 178 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_multiple_scalar_impl(), hiflow::VectorSpace< DataType >::mesh(), and hiflow::GlobalAssembler< DataType >::q_select_.

181  {
182  const size_t num_cells = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) );
183  std::vector< std::vector<DataType> > cell_values ( num_cells );
184  for ( int l = 0; l < num_cells; ++l )
185  cell_values[l].resize ( num_scalars, 0. );
186 
187  assemble_multiple_scalar_impl ( space, local_asm, num_scalars, cell_values, q_select_ );
188  integral.resize ( num_scalars, 0. );
189 
190  for ( int i = 0; i < num_cells; ++i )
191  {
192  for ( int l = 0; l < num_scalars; ++l )
193  {
194  integral[l] += cell_values[i][l];
195  }
196  }
197  }
virtual void assemble_multiple_scalar_impl(const VectorSpace< DataType > &space, MultipleScalarAssemblyFunction local_asm, const int num_scalars, std::vector< std::vector< DataType > > &vec, QuadratureSelectionFunction q_select) const =0
QuadratureSelectionFunction q_select_
Definition: assembly.h:444

◆ integrate_scalar()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::integrate_scalar ( const VectorSpace< DataType > &  space,
ScalarAssemblyFunction  local_asm,
DataType &  integral 
) const

Compute integral for a VectorSpace.

Computes an integral $\int_{\Omega}{f(x)dx}$ over the domain defined by the mesh associated to a VectorSpace. The integrand is defined through the ScalarAssemblyFunction, which should return the value of the integral for each element.

Parameters
[in]spacethe VectorSpace to integrate over
[in]local_asmfunction or functor that performs local integration
[out]valuethe value of the integral
See also
Concept for assembly and integration

Definition at line 166 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_scalar_impl(), hiflow::VectorSpace< DataType >::mesh(), and hiflow::GlobalAssembler< DataType >::q_select_.

169  {
170  const size_t num_cells = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) );
171  std::vector<DataType> cell_values ( num_cells, 0. );
172 
173  assemble_scalar_impl ( space, local_asm, cell_values, q_select_ );
174  integral = std::accumulate ( cell_values.begin ( ), cell_values.end ( ), 0. );
175  }
virtual void assemble_scalar_impl(const VectorSpace< DataType > &space, ScalarAssemblyFunction local_asm, std::vector< DataType > &vec, QuadratureSelectionFunction q_select) const =0
QuadratureSelectionFunction q_select_
Definition: assembly.h:444

◆ integrate_scalar_boundary()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::integrate_scalar_boundary ( const VectorSpace< DataType > &  space,
BoundaryScalarAssemblyFunction  local_asm,
DataType &  integral 
) const

Compute boundary integral for a VectorSpace.

Computes a boundary integral $\int_{\partial\Omega}{f(x)dx}$ over the boundary of the domain defined by the mesh associated to a VectorSpace. The integrand is defined through the BoundaryScalarAssemblyFunction, which should return the value of the integral for each element.

Parameters
[in]spacethe VectorSpace to integrate over
[in]local_asmfunction or functor that performs local integration
[out]valuethe value of the integral
See also
Concept for assembly and integration

Definition at line 260 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_scalar_boundary_impl(), hiflow::GlobalAssembler< DataType >::fq_select_, and hiflow::VectorSpace< DataType >::mesh().

263  {
264  // TODO: actually the number of boundary facets is needed
265  const size_t num_facets = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) - 1 );
266  std::vector<DataType> cell_values ( num_facets, 0. );
267 
268  assemble_scalar_boundary_impl ( space, local_asm, cell_values, fq_select_ );
269  integral = std::accumulate ( cell_values.begin ( ), cell_values.end ( ), 0. );
270  }
virtual void assemble_scalar_boundary_impl(const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, std::vector< DataType > &vec, FacetQuadratureSelectionFunction fq_select) const =0
FacetQuadratureSelectionFunction fq_select_
Definition: assembly.h:445

◆ maximize_scalar_boundary()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::maximize_scalar_boundary ( const VectorSpace< DataType > &  space,
BoundaryScalarAssemblyFunction  local_asm,
DataType &  maximum 
) const

Compute boundary maximum for a VectorSpace.

Determines a maximum value $\max_{\partial\Omega}{f(x)}$ at the boundary of the domain defined by the mesh associated to a VectorSpace. The cell maxima are defined through the BoundaryScalarAssemblyFunction, which should return the maximal value for each element.

Parameters
[in]spacethe VectorSpace to maximize over
[in]local_asmfunction or functor that performs local maximization
[out]maximumthe maximal value
See also
Concept for assembly and integration

Definition at line 273 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::assemble_scalar_boundary_impl(), hiflow::GlobalAssembler< DataType >::fq_select_, and hiflow::VectorSpace< DataType >::mesh().

276  {
277  // TODO: actually the number of boundary facets is needed
278  const size_t num_facets = space.mesh ( ).num_entities ( space.mesh ( ).tdim ( ) - 1 );
279  std::vector<DataType> cell_values ( num_facets, 0. );
280 
281  assemble_scalar_boundary_impl ( space, local_asm, cell_values, fq_select_ );
282  maximum = *std::max_element ( cell_values.begin ( ), cell_values.end ( ) );
283  }
virtual void assemble_scalar_boundary_impl(const VectorSpace< DataType > &space, BoundaryScalarAssemblyFunction local_asm, std::vector< DataType > &vec, FacetQuadratureSelectionFunction fq_select) const =0
FacetQuadratureSelectionFunction fq_select_
Definition: assembly.h:445

◆ set_quadrature_selection_function()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::set_quadrature_selection_function ( QuadratureSelectionFunction  q_select)

Set the function used to determine which quadrature rule should be used.

The choice of quadrature rules can be controlled by providing a QuadratureSelectionFunction. This function or functor will be called before the local assembly is performed on each element. By default, the DefaultQuadratureSelection function is used.

Parameters
[in]q_selectnew quadrature selection function

Definition at line 327 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::default_select_(), and hiflow::GlobalAssembler< DataType >::q_select_.

Referenced by hiflow::HpFemAssembler< DataType >::assemble_multiple_scalar_impl(), and hiflow::HpFemAssembler< DataType >::assemble_scalar_impl().

328  {
329  if ( q_select != 0 )
330  {
331  q_select_ = q_select;
332  }
333  else
334  {
336  }
337  }
QuadratureSelectionFunction q_select_
Definition: assembly.h:444
const GlobalAssembler< double >::QuadratureSelectionFunction default_select_
Definition: assembly.cc:497

◆ should_reset_assembly_target()

template<class DataType >
void hiflow::GlobalAssembler< DataType >::should_reset_assembly_target ( bool  should_reset)

Change whether the assembled object should be reset prior to assembly.

This function can be used to decide whether the target object of the assembly (scalar for scalar assembly, vector for vector assembly, etc) in the various assembly functions should be reset to zero before the assembly. Setting this value to false can be used to perform several assembly steps with the same object, e.g. for adding a boundary term to an assembly. By default, this is set to true.

Parameters
[in]should_resetwhether or not assembly object should be reset to zero.

Definition at line 340 of file assembly.cc.

References hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_.

Referenced by hiflow::DGGlobalAssembler< DataType >::DGGlobalAssembler().

341  {
342  should_reset_assembly_target_ = should_reset;
343  }
bool should_reset_assembly_target_
Definition: assembly.h:448

Member Data Documentation

◆ default_facet_select_

template<class DataType>
const FacetQuadratureSelectionFunction hiflow::GlobalAssembler< DataType >::default_facet_select_
staticprivate

Definition at line 443 of file assembly.h.

◆ default_select_

template<class DataType>
const QuadratureSelectionFunction hiflow::GlobalAssembler< DataType >::default_select_
staticprivate

Definition at line 442 of file assembly.h.

◆ fq_select_

template<class DataType>
FacetQuadratureSelectionFunction hiflow::GlobalAssembler< DataType >::fq_select_
private

◆ q_select_

template<class DataType>
QuadratureSelectionFunction hiflow::GlobalAssembler< DataType >::q_select_
private

◆ should_reset_assembly_target_

template<class DataType>
bool hiflow::GlobalAssembler< DataType >::should_reset_assembly_target_
protected

The documentation for this class was generated from the following files: