waves
Basic FE playground
ElementVectors.hpp
Go to the documentation of this file.
1 
14 template <typename scalar, int element_type, int element_size>
16  size_t _numPrimalDPN,
17  size_t pool_size) : domain(_domain), numPrimalDPN(_numPrimalDPN)
18 {
19  N = Kokkos::View<scalar ***, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>("A", pool_size, element_size, element_size);
20 }
21 
30 template <typename scalar, int element_type, int element_size>
32 {
33  tbox::Cache *cache;
34 
35  std::vector<Eigen::Vector3d> gauss_p;
36  std::vector<double> gauss_w;
37 
38  /* @todo could probably be refactored into cache = element->getVCache(); */
39  if (element_type == static_cast<int>(tbox::ELTYPE::HEX8))
40  {
41  tbox::CacheHex8 &cachehex8 = this->trilinosHex8GetCache();
42  cache = &cachehex8;
43  }
44  else if (element_type == static_cast<int>(tbox::ELTYPE::TETRA4))
45  {
46  tbox::CacheTetra4 &cachetetra4 = this->trilinosTetra4GetCache();
47  cache = &cachetetra4;
48  }
49  else if (element_type == static_cast<int>(tbox::ELTYPE::TRI3))
50  {
51  tbox::CacheTri3 &cachetri3 = this->trilinosTri3GetCache();
52  cache = &cachetri3;
53  }
54  else if (element_type == static_cast<int>(tbox::ELTYPE::QUAD4))
55  {
56  tbox::CacheQuad4 &cachequad4 = this->trilinosQuad4GetCache();
57  cache = &cachequad4;
58  }
59 
60  for (size_t a = 0; a < cache->getVGauss().getN(); ++a)
61  {
62  gauss_p.push_back(cache->getVGauss().getP(a));
63  gauss_w.push_back(cache->getVGauss().getW(a));
64  }
65 
68 
69  auto N_current = subview(N, i_thread, Kokkos::ALL(), Kokkos::ALL());
70 
71  Kokkos::deep_copy(N_current, 0);
72 
73  // Looping on gauss points
74  for (auto a = 0; a < gauss_p.size(); ++a)
75  {
76  for (auto j = 0; j < element_size; ++j)
77  if (element_type == static_cast<int>(tbox::ELTYPE::HEX8))
78  ff(j) = (static_cast<tbox::CacheHex8 *>(cache)->getSf(a))(j);
79  else if (element_type == static_cast<int>(tbox::ELTYPE::TETRA4))
80  ff(j) = (static_cast<tbox::CacheTetra4 *>(cache)->getSf(a))(j);
81  else if (element_type == static_cast<int>(tbox::ELTYPE::TRI3))
82  ff(j) = (static_cast<tbox::CacheTri3 *>(cache)->getSf(a))(j);
83  else if (element_type == static_cast<int>(tbox::ELTYPE::QUAD4))
84  ff(j) = (static_cast<tbox::CacheQuad4 *>(cache)->getSf(a))(j);
85 
86  double detJ = this->buildJ(a, J, e, *(domain->elementsList), *(domain->nodesList));
87 
88  for (auto i = 0; i < element_size; ++i)
89  for (auto j = 0; j < element_size; ++j)
90  N_current(i, j) += ff(i) * ff(j) * gauss_w[a] * detJ;
91  }
92 }
93 
102 template <typename scalar, int element_type, int element_size>
103 Kokkos::View<scalar **, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace> ElementVectors<scalar, element_type, element_size>::getN(size_t i_thread) const
104 {
105  Kokkos::View<scalar **, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace> N_current =
106  subview(N, i_thread, Kokkos::ALL(), Kokkos::ALL());
107  return N_current;
108 }
ElementVectors::N
Kokkos::View< scalar ***, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace > N
Definition: ElementVectors.h:30
katoptron::Domain
Class which is used to store all the information related to the discretized domain:
Definition: Domain.h:26
ElementVectors::ElementVectors
ElementVectors(Teuchos::RCP< katoptron::Domain< scalar >> domain, size_t numPrimalDPN, size_t pool_size)
ElementVectors constructor.
Definition: ElementVectors.hpp:15
tVector
Definition: tMatrix.h:7
tMatrix
Definition: tMatrix.h:10
ElementVectors::compute
void compute(int e, int i_thread)
Compute the matrix. Arguments:
Definition: ElementVectors.hpp:31
ElementVectors::getN
Kokkos::View< scalar **, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace > getN(size_t i_thread) const
Return the .
Definition: ElementVectors.hpp:103