waves
Basic FE playground
Algebraic.hpp
Go to the documentation of this file.
1 namespace katoptron
2 {
3 
18 template <typename scalar>
19 Algebraic<scalar>::Algebraic(Teuchos::RCP<Map> _map, Teuchos::RCP<Domain<scalar>> domain)
20 {
21  map = _map;
22 
23  LinearSolver::getTimers()["graph"].start();
24  graph = Teuchos::rcp(new Graph(_map, domain->elementsList));
25  LinearSolver::getTimers()["graph"].stop();
26  matrices = Teuchos::rcp(new Matrices<scalar>(graph));
27  vectors = Teuchos::rcp(new Vectors<scalar>(map));
28 }
29 
39 template <typename scalar>
40 Teuchos::RCP<Tpetra::Vector<scalar, Map::local_ordinal_type, Map::global_ordinal_type>>
41 Algebraic<scalar>::readVectorFromFile(std::string &name, size_t myRank)
42 {
43  using Teuchos::RCP;
44  using Teuchos::rcp;
45 
46  std::ifstream inputfile;
47  if (myRank == 0)
48  inputfile.open(name);
49 
50  RCP<Tpetra::Vector<scalar, Map::local_ordinal_type, Map::global_ordinal_type>> x_0 =
51  rcp(new Tpetra::Vector<scalar, Map::local_ordinal_type, Map::global_ordinal_type>(map->mapOutput, true));
52  RCP<Tpetra::Vector<scalar, Map::local_ordinal_type, Map::global_ordinal_type>> x =
53  rcp(new Tpetra::Vector<scalar, Map::local_ordinal_type, Map::global_ordinal_type>(map->mapDofs, true));
54 
55  if (myRank == 0)
56  {
57  auto line_size = map->mapOutput->getGlobalNumElements();
58 
59  typedef EnsembleTraits<scalar> ET;
60  const int ensemble_size = ET::size;
61 
62  for (Map::global_ordinal_type global_index = 0; global_index < line_size; ++global_index)
63  {
64  scalar tmp;
65  for (auto j = 0; j < ensemble_size; ++j)
66  inputfile >> ET::coeff(tmp, j);
67 
68  x_0->replaceGlobalValue(global_index, tmp);
69  }
70  inputfile.close();
71  }
72 
73  Tpetra::Export<> exportDof(map->mapOutput, map->mapDofs);
74 
75  x->doExport(*x_0, exportDof, Tpetra::ADD);
76  return x;
77 }
78 
79 }; // namespace katoptron
katoptron::Domain
Class which is used to store all the information related to the discretized domain:
Definition: Domain.h:26
katoptron::Map::global_ordinal_type
int global_ordinal_type
Definition: Map.h:28
katoptron::Matrices
Class which includes all the Trilinos matrices (Tpetra matrices and Xpetra matrices) used in the simu...
Definition: Matrices.h:32
katoptron::Graph
Class used to compute and store the graph of the primal matrices with and without overlaps.
Definition: Graph.h:21
katoptron::Algebraic::readVectorFromFile
Teuchos::RCP< Tpetra::Vector< scalar, local_ordinal_type, global_ordinal_type > > readVectorFromFile(std::string &name, size_t myRank)
Function to read a vector from file and distribute it to the MPI processes.
Definition: Algebraic.hpp:41
EnsembleTraits
Definition: EnsembleTraits.h:8
katoptron
katoptron namespace
Definition: Algebraic.h:18
katoptron::Vectors
Class which includes all the Trilinos vectors (Tpetra vectors and Xpetra vectors) used in the simulat...
Definition: Vectors.h:22
katoptron::LinearSolver::getTimers
static fwk::Timers & getTimers()
Manage timers.
Definition: LinearSolver.h:119
katoptron::Algebraic::Algebraic
Algebraic(Teuchos::RCP< Map > map, Teuchos::RCP< Domain< scalar >> domain)
Algebraic constructor.
Definition: Algebraic.hpp:19