FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
dof_mapping_renderer.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/adjacency/graph.hpp>
10
11namespace FEAT
12{
13 namespace Space
14 {
21 {
22 public:
32 template<typename Space_>
33 static Adjacency::Graph render(const Space_& space)
34 {
35 // fetch the number of cells and dofs
36 const Index num_cells(space.get_mesh().get_num_entities(Space_::shape_dim));
37 const Index num_dofs(space.get_num_dofs());
38
39 // allocate domain pointer vector
40 std::vector<Index> dom_ptr(num_cells+1u);
41 dom_ptr[0u] = Index(0);
42
43#ifdef FEAT_HAVE_OMP
44 FEAT_PRAGMA_OMP(parallel)
45 {
46 typename Space_::DofMappingType dof_map(space);
47
48 FEAT_PRAGMA_OMP(for)
49 for(Index i = 0; i < num_cells; ++i)
50 {
51 dof_map.prepare(i);
52 dom_ptr[i+1u] = Index(dof_map.get_num_local_dofs());
53 dof_map.finish();
54 }
55 }
56 feat_omp_in_scan(dom_ptr.size(), dom_ptr.data(), dom_ptr.data());
57#else // no FEAT_HAVE_OMP
58 {
59 typename Space_::DofMappingType dof_map(space);
60 for(Index i = 0; i < num_cells; ++i)
61 {
62 dof_map.prepare(i);
63 dom_ptr[i+1u] = dom_ptr[i] + Index(dof_map.get_num_local_dofs());
64 dof_map.finish();
65 }
66 }
67#endif // FEAT_HAVE_OMP
68
69 // allocate image index vector
70 std::vector<Index> img_idx(dom_ptr[num_cells]);
71
72 FEAT_PRAGMA_OMP(parallel)
73 {
74 typename Space_::DofMappingType dof_map(space);
75
76 FEAT_PRAGMA_OMP(for)
77 for(Index i = 0; i < num_cells; ++i)
78 {
79 Index l(dom_ptr[i]);
80 dof_map.prepare(i);
81 for(int j(0); j < dof_map.get_num_local_dofs(); ++j, ++l)
82 {
83 img_idx[l] = dof_map.get_index(j);
84 }
85 dof_map.finish();
86 }
87 }
88
89 // create an adjacency graph
90 return Adjacency::Graph(num_dofs, std::move(dom_ptr), std::move(img_idx));
91 }
92 }; // class DofMappingRenderer
93 } // namespace Space
94} // namespace FEAT
Adjacency Graph implementation.
Definition: graph.hpp:34
Dof-Mapping renderer class.
static Adjacency::Graph render(const Space_ &space)
Renders the dof-mapping of a space into an adjacency graph.
FEAT namespace.
Definition: adjactor.hpp:12
void feat_omp_in_scan(std::size_t n, const T_ x[], T_ y[])
Computes an OpenMP-parallel inclusive scan a.k.a. a prefix sum of an array, i.e.
Definition: omp_util.hpp:35
std::uint64_t Index
Index data type.