Loading...
Searching...
No Matches
ElementDofLayout.h
// Copyright (C) 2019 Chris Richardson and Garth N. Wells
//
// This file is part of DOLFINx (https://www.fenicsproject.org)
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include <array>
#include <cstdint>
#include <span>
#include <vector>
namespace dolfinx::mesh
{
enum class CellType : std::int8_t;
}
namespace dolfinx::fem
{
// TODO: For this class/concept to be robust, the topology of the
// reference cell needs to be defined.
//
// TODO: Handle block dofmaps properly
class ElementDofLayout
{
public:
ElementDofLayout(
int block_size,
const std::vector<std::vector<std::vector<int>>>& entity_dofs,
const std::vector<std::vector<std::vector<int>>>& entity_closure_dofs,
const std::vector<int>& parent_map,
const std::vector<ElementDofLayout>& sub_layouts);
ElementDofLayout copy() const;
ElementDofLayout(const ElementDofLayout& dofmap) = default;
ElementDofLayout(ElementDofLayout&& dofmap) = default;
~ElementDofLayout() = default;
ElementDofLayout& operator=(const ElementDofLayout& dofmap) = default;
ElementDofLayout& operator=(ElementDofLayout&& dofmap) = default;
bool operator==(const ElementDofLayout& layout) const;
int num_dofs() const;
int num_entity_dofs(int dim) const;
int num_entity_closure_dofs(int dim) const;
const std::vector<int>& entity_dofs(int dim, int entity_index) const;
const std::vector<int>& entity_closure_dofs(int dim, int entity_index) const;
const std::vector<std::vector<std::vector<int>>>& entity_dofs_all() const;
const std::vector<std::vector<std::vector<int>>>&
entity_closure_dofs_all() const;
int num_sub_dofmaps() const;
const ElementDofLayout& sub_layout(std::span<const int> component) const;
std::vector<int> sub_view(std::span<const int> component) const;
int block_size() const;
bool is_view() const;
private:
// Block size
int _block_size;
// Mapping of dofs to this ElementDofLayout's immediate parent
std::vector<int> _parent_map;
// Total number of dofs on this element dofmap
int _num_dofs;
// The number of dofs associated with each entity type
std::array<int, 4> _num_entity_dofs;
// The number of dofs associated with each entity type, including all
// connected entities of lower dimension.
std::array<int, 4> _num_entity_closure_dofs;
// List of dofs per entity, ordered by dimension.
// dof = _entity_dofs[dim][entity][i]
std::vector<std::vector<std::vector<int>>> _entity_dofs;
// List of dofs with connected entities of lower dimension
std::vector<std::vector<std::vector<int>>> _entity_closure_dofs;
// List of sub dofmaps
// std::vector<std::shared_ptr<const ElementDofLayout>> _sub_dofmaps;
std::vector<ElementDofLayout> _sub_dofmaps;
};
} // namespace dolfinx::fem
dolfinx::fem::ElementDofLayout::entity_closure_dofs
const std::vector< int > & entity_closure_dofs(int dim, int entity_index) const
Definition ElementDofLayout.cpp:80
dolfinx::fem::ElementDofLayout::copy
ElementDofLayout copy() const
Copy the DOF layout, discarding any parent information.
Definition ElementDofLayout.cpp:45
dolfinx::fem::ElementDofLayout::num_entity_dofs
int num_entity_dofs(int dim) const
Definition ElementDofLayout.cpp:63
dolfinx::fem::ElementDofLayout::entity_dofs
const std::vector< int > & entity_dofs(int dim, int entity_index) const
Definition ElementDofLayout.cpp:73
dolfinx::fem::ElementDofLayout::sub_view
std::vector< int > sub_view(std::span< const int > component) const
Definition ElementDofLayout.cpp:113
dolfinx::fem::ElementDofLayout::entity_closure_dofs_all
const std::vector< std::vector< std::vector< int > > > & entity_closure_dofs_all() const
Definition ElementDofLayout.cpp:92
dolfinx::fem::ElementDofLayout::ElementDofLayout
ElementDofLayout(ElementDofLayout &&dofmap)=default
Move constructor.
dolfinx::fem::ElementDofLayout::is_view
bool is_view() const
Definition ElementDofLayout.cpp:140
dolfinx::fem::ElementDofLayout::ElementDofLayout
ElementDofLayout(int block_size, const std::vector< std::vector< std::vector< int > > > &entity_dofs, const std::vector< std::vector< std::vector< int > > > &entity_closure_dofs, const std::vector< int > &parent_map, const std::vector< ElementDofLayout > &sub_layouts)
Definition ElementDofLayout.cpp:18
dolfinx::fem::ElementDofLayout::num_entity_closure_dofs
int num_entity_closure_dofs(int dim) const
Definition ElementDofLayout.cpp:68
dolfinx::fem::ElementDofLayout::~ElementDofLayout
~ElementDofLayout()=default
Destructor.
dolfinx::fem::ElementDofLayout::operator=
ElementDofLayout & operator=(ElementDofLayout &&dofmap)=default
Move assignment.
dolfinx::fem::ElementDofLayout::block_size
int block_size() const
Block size.
Definition ElementDofLayout.cpp:138
dolfinx::fem::ElementDofLayout::ElementDofLayout
ElementDofLayout(const ElementDofLayout &dofmap)=default
Copy constructor.
dolfinx::fem::ElementDofLayout::operator=
ElementDofLayout & operator=(const ElementDofLayout &dofmap)=default
Copy assignment.
dolfinx::fem::ElementDofLayout::operator==
bool operator==(const ElementDofLayout &layout) const
Definition ElementDofLayout.cpp:52
dolfinx::fem::ElementDofLayout::sub_layout
const ElementDofLayout & sub_layout(std::span< const int > component) const
Get sub-dofmap given by list of components, one for each level.
Definition ElementDofLayout.cpp:100
dolfinx::fem::ElementDofLayout::num_dofs
int num_dofs() const
Definition ElementDofLayout.cpp:61
dolfinx::fem::ElementDofLayout::entity_dofs_all
const std::vector< std::vector< std::vector< int > > > & entity_dofs_all() const
Direct access to all entity dofs (dof = _entity_dofs[dim][entity][i]).
Definition ElementDofLayout.cpp:86
dolfinx::fem::ElementDofLayout::num_sub_dofmaps
int num_sub_dofmaps() const
Get number of sub-dofmaps.
Definition ElementDofLayout.cpp:97
dolfinx::fem
Finite element method functionality.
Definition assemble_expression_impl.h:23
dolfinx::mesh
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32
dolfinx::mesh::CellType
CellType
Cell type identifier.
Definition cell_types.h:22