41 template<
class FV,
unsigned int spacedim>
43 : dim_(-1), n_points_(0), n_dofs_(0)
48 template<
class FV,
unsigned int spacedim>
58 template<
class FV,
unsigned int spacedim>
61 unsigned int first_component_idx,
65 for (
unsigned int ip=0; ip<
n_points; ip++)
66 for (
unsigned int id=0;
id<dof_indices.size();
id++)
75 template<
class FV,
unsigned int spacedim>
76 template<
unsigned int DIM>
96 ASSERT(fe_sys !=
nullptr).error(
"Mixed system must be represented by FESystem.");
101 unsigned int comp_offset = 0;
102 for (
auto fe : fe_sys->
fe())
118 ASSERT(
false).error(
"Not implemented.");
130 template<
class FV,
unsigned int spacedim>
131 template<
unsigned int DIM>
147 ASSERT(fe !=
nullptr).error(
"Mixed system must be represented by FESystem.");
151 for (
unsigned int f=0; f<fe->
fe().size(); f++)
156 if ( q.
dim() == DIM )
160 else if ( q.
dim() + 1 == DIM )
163 for (
unsigned int sid = 0; sid < RefElement<DIM>::n_sides; sid++)
169 ASSERT(
false)(q.
dim())(DIM).error(
"Dimension mismatch in FEValues::initialize().");
174 template<
class FV,
unsigned int spacedim>
175 template<
unsigned int DIM>
184 ASSERT(_fe.
n_components() == spacedim).error(
"FEVector must have spacedim components.");
186 ASSERT(_fe.
n_components() == spacedim*spacedim).error(
"FETensor must have spacedim*spacedim components.");
199 if (fe_sys !=
nullptr)
201 for (
unsigned int f=0; f<fe_sys->
fe().size(); f++)
219 template<
class FV,
unsigned int spacedim>
220 template<
unsigned int DIM>
225 std::shared_ptr<FEInternalData> data = std::make_shared<FEInternalData>(q.
size(),
n_dofs_);
228 for (
unsigned int i=0; i<q.
size(); i++)
230 for (
unsigned int j=0; j<
n_dofs_; j++)
235 data->ref_shape_values[i][j] = trans(shape_values.row(j));
240 for (
unsigned int i=0; i<q.
size(); i++)
242 for (
unsigned int j=0; j<
n_dofs_; j++)
248 data->ref_shape_grads[i][j] = grad;
256 template<
class FV,
unsigned int spacedim>
261 this->fill_data_specialized<MapScalar<FV, spacedim>>(elm_values, fe_data);
264 this->fill_data_specialized<MapVector<FV, spacedim>>(elm_values, fe_data);
267 this->fill_data_specialized<MapContravariant<FV, spacedim>>(elm_values, fe_data);
270 this->fill_data_specialized<MapPiola<FV, spacedim>>(elm_values, fe_data);
273 this->fill_data_specialized<MapTensor<FV, spacedim>>(elm_values, fe_data);
276 this->fill_data_specialized<MapSystem<FV, spacedim>>(elm_values, fe_data);
285 template<
class FV,
unsigned int spacedim>
286 template<
class MapType>
289 map_type.fill_values_vec(*this->
fv_, elm_values, fe_data);
291 map_type.update_values(*this->
fv_, elm_values, fe_data);
293 map_type.update_gradients(*this->
fv_, elm_values, fe_data);
311 template<
unsigned int spacedim>
316 template<
unsigned int spacedim>
321 template<
unsigned int spacedim>
326 elm_values_ = std::make_shared<ElementValues<spacedim> >(q, this->update_flags, dim);
331 template<
unsigned int spacedim>
335 shape_values_.resize(this->n_points_,
vector<double>(this->n_dofs_*this->n_components_));
338 shape_gradients_.resize(this->n_points_,
vector<arma::vec::fixed<spacedim> >(this->n_dofs_*this->n_components_));
345 template<
unsigned int spacedim>
347 const unsigned int point_no,
348 const unsigned int comp)
const
353 return shape_gradients_[point_no][function_no*this->n_components_+comp];
562 template<
unsigned int spacedim>
567 if (!elm_values_->cell().is_valid() ||
568 elm_values_->cell() != cell)
570 elm_values_->reinit(cell);
573 this->fill_data(*elm_values_, *this->fe_data_);
577 template<
unsigned int spacedim>
582 if (!elm_values_->side().is_valid() ||
583 elm_values_->side() != cell_side)
585 elm_values_->reinit(cell_side);
591 this->fill_data(*elm_values_, *(this->side_fe_data_[sid]) );
596 template<
unsigned int spacedim>
599 patch_data_idx_(-1), used_size_(0), max_n_elem_(max_size) {}
602 template<
unsigned int spacedim>
612 for (
auto it=patch_elements.begin();
it!=patch_elements.end(); ++
it, ++i) {
620 for (
unsigned int sid=0; sid<this->
dim_+1; ++sid) {
631 template<
unsigned int spacedim>
636 if ( q_dim == this->
dim_ ) {
639 }
else if ( q_dim+1 == this->
dim_ ) {
643 ASSERT(
false)(q_dim)(this->
dim_).error(
"Invalid dimension of quadrature!");
657 template<
unsigned int spacedim>
667 template<
unsigned int spacedim>
675 template<
unsigned int spacedim>
677 const unsigned int point_no,
678 const unsigned int comp)
const
694 fv[0].initialize(quadrature[0], *fe[0_d], flags);
695 fv[1].initialize(quadrature[1], *fe[1_d], flags);
696 fv[2].initialize(quadrature[2], *fe[2_d], flags);
697 fv[3].initialize(quadrature[3], *fe[3_d], flags);
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
#define ASSERT_PERMANENT_GT(a, b)
Definition of comparative assert macro (Greater Than)
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
#define ASSERT_LE(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
Class for computation of data on cell and side.
Compound finite element on dim dimensional simplex.
const std::vector< std::shared_ptr< FiniteElement< dim > > > & fe() const
std::vector< unsigned int > fe_dofs(unsigned int fe_index)
Return dof indices belonging to given sub-FE.
Structure for storing the precomputed finite element data.
FEInternalData(unsigned int np, unsigned int nd)
unsigned int n_points
Number of quadrature points.
std::vector< std::vector< arma::vec > > ref_shape_values
Precomputed values of basis functions at the quadrature points.
std::vector< std::vector< arma::mat > > ref_shape_grads
Precomputed gradients of basis functions at the quadrature points.
UpdateFlags update_flags
Flags that indicate which finite element quantities are to be computed.
void allocate(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags flags)
Allocates space for computed data.
unsigned int n_points_
Number of integration points.
FV * fv_
Helper object, we need its for ViewsCache initialization.
std::vector< shared_ptr< FEInternalData > > side_fe_data_
Precomputed FE data (shape functions on reference element) for all side quadrature points.
std::vector< unsigned int > fe_sys_n_space_components_
Numbers of components of FESystem sub-elements in real space.
FEType fe_type_
Type of finite element (scalar, vector, tensor).
unsigned int n_dofs_
Number of finite element dofs.
unsigned int n_points() const
Returns the number of quadrature points.
virtual void init_fe_val_vec()=0
Initialize fe_values_vec only in PatchFEValues.
ViewsCache views_cache_
Auxiliary storage of FEValuesViews accessors.
virtual void allocate_in(unsigned int)=0
Initialize vectors declared separately in descendants.
void fill_data(const ElementValues< spacedim > &elm_values, const FEInternalData &fe_data)
Computes the shape function values and gradients on the actual cell and fills the FEValues structure.
std::vector< FV > fe_values_vec
Vector of FEValues for sub-elements of FESystem.
std::vector< unsigned int > fe_sys_n_components_
Numbers of components of FESystem sub-elements in reference space.
std::vector< std::vector< unsigned int > > fe_sys_dofs_
Dof indices of FESystem sub-elements.
std::shared_ptr< typename FEValuesBase< FV, spacedim >::FEInternalData > init_fe_data(const FiniteElement< DIM > &fe, const Quadrature &q)
Precompute finite element data on reference element.
unsigned int n_components_
Number of components of the FE.
FEValuesBase()
Default constructor with postponed initialization.
void fill_data_specialized(const ElementValues< spacedim > &elm_values, const FEInternalData &fe_data)
Computes the shape function values and gradients on the actual cell and fills the FEValues structure....
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
virtual void initialize_in(Quadrature &, unsigned int)=0
Initialize ElementValues separately in descendants.
std::shared_ptr< FEInternalData > fe_data_
Precomputed finite element data.
unsigned int dim_
Dimension of reference space.
Calculates finite element data on the actual cell.
~FEValues()
Correct deallocation of objects created by 'initialize' methods.
FEValues()
Default constructor with postponed initialization.
arma::vec::fixed< spacedim > shape_grad_component(const unsigned int function_no, const unsigned int point_no, const unsigned int comp) const
Return the gradient of the function_no-th shape function at the point_no-th quadrature point.
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
void initialize_in(Quadrature &q, unsigned int dim) override
Implement FEValuesBase::initialize_in.
void allocate_in(unsigned int q_dim) override
Implement FEValuesBase::allocate_in.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
unsigned int n_space_components(unsigned int spacedim)
Number of components of FE in a mapped space with dimension spacedim.
virtual UpdateFlags update_each(UpdateFlags flags)
Decides which additional quantities have to be computed for each cell.
unsigned int n_dofs() const
Returns the number of degrees of freedom needed by the finite element.
FEType type_
Type of FiniteElement.
double shape_value(const unsigned int i, const arma::vec::fixed< dim > &p, const unsigned int comp=0) const
Calculates the value of the comp-th component of the i-th shape function at the point p on the refere...
arma::vec::fixed< dim > shape_grad(const unsigned int i, const arma::vec::fixed< dim > &p, const unsigned int comp=0) const
Calculates the comp-th component of the gradient of the i-th shape function at the point p on the ref...
unsigned int n_components() const
Returns numer of components of the basis function.
static UpdateFlags update_each(UpdateFlags flags)
Determines which additional quantities have to be computed.
unsigned int patch_data_idx_
Patch index of processed element / side.
unsigned int max_size() const
void reinit(PatchElementsList patch_elements)
Reinit data.
PatchFEValues(unsigned int max_size=0)
Constructor, set maximal number of elements on patch.
unsigned int max_n_elem_
Maximal number of elements on patch.
std::vector< ElementFEData > element_data_
Data of elements / sides on patch.
unsigned int used_size_
Number of elements / sides on patch. Must be less or equal to size of element_data vector.
void init_fe_val_vec() override
Implement FEValuesBase::initialize_in.
MeshObjectType object_type_
Distinguishes using of PatchFEValues for storing data of elements or sides.
arma::vec::fixed< spacedim > shape_grad_component(const unsigned int function_no, const unsigned int point_no, const unsigned int comp) const
Return the gradient of the function_no-th shape function at the point_no-th quadrature point.
void allocate_in(unsigned int q_dim) override
Implement FEValuesBase::allocate_in.
void initialize_in(Quadrature &q, unsigned int dim) override
Implement FEValuesBase::initialize_in.
std::map< unsigned int, unsigned int > element_patch_map_
Map of element patch indexes to element_data_.
void resize(unsigned int max_size)
Set size of ElementFEData. Important: Use only during the initialization of FESystem !
std::array< QGauss, 4 > array
Base class for quadrature rules on simplices in arbitrary dimensions.
Quadrature make_from_side(unsigned int sid) const
unsigned int size() const
Returns number of quadrature points.
Armor::ArmaVec< double, point_dim > point(unsigned int i) const
Returns the ith quadrature point.
unsigned int side_idx() const
Returns local index of the side on the element.
unsigned int dim() const
Returns dimension of the side, that is dimension of the element minus one.
Class ElementValues calculates data related to transformation of reference cell to actual cell (Jacob...
Class FESystem for compound finite elements.
std::vector< FEValues< 3 > > mixed_fe_values(QGauss::array &quadrature, MixedPtr< FiniteElement > fe, UpdateFlags flags)
Class FEValues calculates finite element data on the actual cells such as shape function values,...
Abstract class for description of finite elements.
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell.
ArmaMat< double, N, M > mat
Class FEValues calculates finite element data on the actual cells such as shape function values,...
Basic definitions of numerical quadrature rules.
void initialize(const FV &fv, const FiniteElement< DIM > &fe)
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell.
@ update_values
Shape function values.
@ update_gradients
Shape function gradients.