MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / sub_view

Method sub_view

cpp/dolfinx/fem/ElementDofLayout.cpp:97–121  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

95}
96//-----------------------------------------------------------------------------
97std::vector<int>
98ElementDofLayout::sub_view(std::span<const int> component) const
99{
100 // Fill up a list of parent dofs, from which subdofmap will select
101 std::vector<int> dof_list(_num_dofs * _block_size);
102 std::iota(dof_list.begin(), dof_list.end(), 0);
103
104 const ElementDofLayout* element_dofmap_current = this;
105 for (int i : component)
106 {
107 // Switch to sub-dofmap
108 assert(element_dofmap_current);
109 if (i >= (int)element_dofmap_current->_sub_dofmaps.size())
110 throw std::runtime_error("Invalid component");
111 element_dofmap_current = &_sub_dofmaps.at(i);
112
113 std::vector<int> dof_list_new(element_dofmap_current->_num_dofs
114 * element_dofmap_current->_block_size);
115 for (std::size_t j = 0; j < dof_list_new.size(); ++j)
116 dof_list_new[j] = dof_list[element_dofmap_current->_parent_map[j]];
117 dof_list = dof_list_new;
118 }
119
120 return dof_list;
121}
122//-----------------------------------------------------------------------------
123int ElementDofLayout::block_size() const { return _block_size; }
124//-----------------------------------------------------------------------------

Callers 1

extract_sub_dofmapMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected