waves
Basic FE playground
NeumannList.h
Go to the documentation of this file.
1 #ifndef KATOPTRON_NEUMANNLIST_H
2 #define KATOPTRON_NEUMANNLIST_H
3 
4 #include "katoptron.h"
5 
6 #include "Map.h"
7 #include "wNeumann.h"
8 #include "wTag.h"
9 
10 #include <Tpetra_Map.hpp>
11 #include <Tpetra_Vector.hpp>
12 #include <Teuchos_RCP.hpp>
13 #include <Kokkos_ViewFactory.hpp>
14 
15 #include "EnsembleTraits.h"
16 
17 namespace katoptron
18 {
19 
23 template <typename scalar>
25 {
28 
29 private:
30  Kokkos::View<int **, Kokkos::LayoutRight> neumann_elementsList;
31  Kokkos::View<scalar ***, Kokkos::LayoutRight> neumann_values_list;
32 
36 
40 
41 public:
42  NeumannList(Problem &pbl, Teuchos::RCP<Map> map, Teuchos::RCP<ElementsList> elementsList);
43 
48 
59  {
61  }
62 
74  {
75  return neumann_elementsList(i, neumann_elements + e1);
76  }
77 
89  {
90  return neumann_values_list(i, 0, neumann_dofs + j);
91  }
92 
104  {
105  return neumann_values_list(i, 0, neumann_values + j);
106  }
107 };
108 
125 template <typename scalar>
126 NeumannList<scalar>::NeumannList(Problem &pbl, Teuchos::RCP<Map> map, Teuchos::RCP<ElementsList> elementsList)
127 {
130 
131  typedef EnsembleTraits<scalar> ET;
132  const int ensemble_size = ET::size;
133 
134  local_ordinal_type numDPN = map->numPrimalDPN;
135 
136  neumann_number = pbl.nBCs.size();
137  local_ordinal_type maxNumElemsPernBC = 0;
138 
139  std::vector<std::vector<global_ordinal_type>> nbcElems = {};
140 
141  for (auto i = 0; i < neumann_number; ++i)
142  {
143  std::vector<global_ordinal_type> mynBcElems = {};
144  for (auto j = 0; j < pbl.nBCs[i]->tag->elems.size(); ++j)
145  {
146  local_ordinal_type e = map->mapElems->getLocalElement(pbl.nBCs[i]->tag->elems[j]->no - 1);
147 
148  if (elementsList->getElementType(e) == static_cast<int>(tbox::ELTYPE::QUAD4))
149  ;
150  else if (elementsList->getElementType(e) == static_cast<int>(tbox::ELTYPE::TRI3))
151  ;
152  else
153  continue;
154 
155  mynBcElems.push_back(e);
156  }
157  nbcElems.push_back(mynBcElems);
158  if (maxNumElemsPernBC < mynBcElems.size())
159  maxNumElemsPernBC = mynBcElems.size();
160  }
161 
162  neumann_size = 0;
163  neumann_elements = 1;
164  neumann_elementsList = Kokkos::View<int **, Kokkos::LayoutRight>("R", neumann_number, neumann_elements + maxNumElemsPernBC);
165 
166  for (auto i = 0; i < neumann_number; ++i)
167  {
168  neumann_elementsList(i, neumann_size) = nbcElems[i].size();
169 
170  for (auto j = 0; j < nbcElems[i].size(); ++j)
171  neumann_elementsList(i, neumann_elements + j) = nbcElems[i][j];
172  }
173 
174  neumann_time = 0;
175  neumann_dofs = 1;
176  neumann_values = 1 + numDPN;
177  neumann_values_list = Kokkos::View<scalar ***, Kokkos::LayoutRight>("R", neumann_number, 1, 1 + 2 * numDPN);
178  for (auto i = 0; i < neumann_number; ++i)
179  {
180  neumann_values_list(i, 0, neumann_time) = 0.; //to change latter
181  for (auto j = 0; j < numDPN; ++j)
182  if (pbl.nBCs[i]->which_dof[j])
183  neumann_values_list(i, 0, neumann_dofs + j) = 1;
184  else
185  neumann_values_list(i, 0, neumann_dofs + j) = 0;
186 
187  for (auto j = 0; j < numDPN; ++j)
188  for (int s = 0; s < ensemble_size; ++s)
189  {
190  ET::coeff(neumann_values_list(i, 0, neumann_values + j), s) = pbl.nBCs[i]->values[j * ensemble_size + s];
191  }
192  }
193 }
194 }; // namespace katoptron
195 
196 #endif //KATOPTRON_NEUMANNLIST_H
katoptron::Map::local_ordinal_type
int local_ordinal_type
Definition: Map.h:27
katoptron::NeumannList
Class which is used to store the list of the Neumann boundary conditions (BC).
Definition: NeumannList.h:24
katoptron::Map::global_ordinal_type
int global_ordinal_type
Definition: Map.h:28
wNeumann.h
local_ordinal_type
katoptron::Map::local_ordinal_type local_ordinal_type
Definition: ResultsETI.cpp:4
katoptron::NeumannList::getNeumannNumber
local_ordinal_type getNeumannNumber()
Return the number of Neumann BC.
Definition: NeumannList.h:47
katoptron::NeumannList::neumann_size
local_ordinal_type neumann_size
Definition: NeumannList.h:34
katoptron::NeumannList::getNeumannDof
scalar getNeumannDof(local_ordinal_type i, local_ordinal_type j)
Return whether there is a surface load for the given BC for a given DOF index.
Definition: NeumannList.h:88
EnsembleTraits
Definition: EnsembleTraits.h:8
katoptron::NeumannList::neumann_dofs
local_ordinal_type neumann_dofs
Definition: NeumannList.h:38
katoptron::NeumannList::neumann_values_list
Kokkos::View< scalar ***, Kokkos::LayoutRight > neumann_values_list
Definition: NeumannList.h:31
katoptron
katoptron namespace
Definition: Algebraic.h:18
katoptron::NeumannList::neumann_number
local_ordinal_type neumann_number
Definition: NeumannList.h:33
katoptron::NeumannList::neumann_time
local_ordinal_type neumann_time
Definition: NeumannList.h:37
katoptron::NeumannList::global_ordinal_type
Map::global_ordinal_type global_ordinal_type
Definition: NeumannList.h:27
EnsembleTraits.h
katoptron::NeumannList::local_ordinal_type
Map::local_ordinal_type local_ordinal_type
Definition: NeumannList.h:26
katoptron::NeumannList::NeumannList
NeumannList(Problem &pbl, Teuchos::RCP< Map > map, Teuchos::RCP< ElementsList > elementsList)
NeumannList constructor.
Definition: NeumannList.h:126
katoptron::NeumannList::neumann_elements
local_ordinal_type neumann_elements
Definition: NeumannList.h:35
katoptron::NeumannList::getNeumannValue
scalar getNeumannValue(local_ordinal_type i, local_ordinal_type j)
Return the value of the surface load for the given BC for a given DOF index.
Definition: NeumannList.h:103
katoptron::Problem
Class which is used to specify in Python the thermomechanical to solve.
Definition: wProblem.h:19
katoptron.h
katoptron::Problem::nBCs
std::vector< Neumann * > nBCs
Definition: wProblem.h:28
katoptron::NeumannList::getNeumannSize
local_ordinal_type getNeumannSize(local_ordinal_type i)
Return the number of elements for a given Neumann BC.
Definition: NeumannList.h:58
Map.h
global_ordinal_type
katoptron::Map::global_ordinal_type global_ordinal_type
Definition: ResultsETI.cpp:5
katoptron::NeumannList::getNeumannElement
local_ordinal_type getNeumannElement(local_ordinal_type i, local_ordinal_type e1)
Return the local ID of the element e1 of a given BC.
Definition: NeumannList.h:73
katoptron::NeumannList::neumann_values
local_ordinal_type neumann_values
Definition: NeumannList.h:39
katoptron::NeumannList::neumann_elementsList
Kokkos::View< int **, Kokkos::LayoutRight > neumann_elementsList
Definition: NeumannList.h:30