Manicore
Library to implement schemes on n-dimensionnal manifolds.
exporter.hpp
Go to the documentation of this file.
1 #ifndef EXPORTED_HPP
2 #define EXPORTED_HPP
3 
4 #include <Eigen/Dense>
5 #include <vector>
6 
7 #include "exterior_dimension.hpp"
8 #include "mesh.hpp"
9 
18 namespace Manicore {
21 
23 
27  template<size_t dimension>
28  class Exporter {
29  public:
31 
38  Exporter(Mesh<dimension> const * mesh ,
39  int r ,
40  int acc
41  );
42 
44 
51  int save(size_t k ,
52  std::function<Eigen::VectorXd(size_t iT)> Fu_h ,
53  const char *filename ,
54  bool star=false ) const;
56 
59  int saveSq(size_t k ,
60  std::function<Eigen::VectorXd(size_t iT)> Fu_h ,
61  const char *filename ) const;
62 
63  private:
64  std::vector<Eigen::Vector3d> _locations;
65  std::vector<size_t> _cellIndices;
66  std::vector<Eigen::Matrix<double,dimension,dimension>> _metricInv;
67  std::vector<double> _volume;
68  std::vector<Eigen::VectorXd> _polyEval;
69  // TODO Make it works in arbitrary dimension. What to do with forms not match a scalar or a vector?
70  std::vector<Eigen::Matrix<double,Dimension::ExtDim(1,3),Dimension::ExtDim(1,dimension)>> _pushforward;
71  std::vector<Eigen::Matrix<double,Dimension::ExtDim(1,3),Dimension::ExtDim(dimension-1,dimension)>> _pushforwardStar;
72  /* // Structure to store various size of pullback matrices
73  template<size_t _k> struct PullbackHolder {
74  std::vector<Eigen::Matrix<double,Dimension::ExtDim(_k,3),Dimension::ExtDim(_k,dimension)>> _pullback;
75  PullbackHolder<_k-1> _next;
76  template<size_t k> std::vector<Eigen::Matrix<double,Dimension::ExtDim(k,3),Dimension::ExtDim(k,dimension)>> & pullback() {
77  if constexpr (k==_k) return _pullback;
78  else return _next.template pullback<k>();
79  }
80  template<size_t k> std::vector<Eigen::Matrix<double,Dimension::ExtDim(k,3),Dimension::ExtDim(k,dimension)>> pullback() const {
81  if constexpr (k==_k) return _pullback;
82  else return _next.template pullback<k>();
83  }
84  };
85  template<> struct PullbackHolder<0> {
86  std::vector<Eigen::Matrix<double,1,1>> _pullback;
87  template<size_t k> std::vector<Eigen::Matrix<double,1,1>> & pullback() {
88  static_assert(k == 0);
89  return _pullback;
90  }
91  template<size_t k> std::vector<Eigen::Matrix<double,1,1>> pullback() const {
92  static_assert(k == 0);
93  return _pullback;
94  }
95  };
96  PullbackHolder<dimension> _pullbackEval;
97  */
98  };
100 }
101 #endif
Evaluate vector of discrete unknowns and store them in files.
Definition: exporter.hpp:28
int save(size_t k, std::function< Eigen::VectorXd(size_t iT)> Fu_h, const char *filename, bool star=false) const
Write a csv file with the point-wise value of the discrete function.
Definition: exporter.cpp:71
int saveSq(size_t k, std::function< Eigen::VectorXd(size_t iT)> Fu_h, const char *filename) const
Write a csv file with the point-wise value of the contraction of the function with itself.
Definition: exporter.cpp:112
Exporter(Mesh< dimension > const *mesh, int r, int acc)
Constructor.
Definition: exporter.cpp:28
Main data structure for the mesh.
Definition: mesh.hpp:54
constexpr functions to compute the dimension of various polynomial spaces
constexpr size_t ExtDim(size_t l, size_t d)
Dimension of the exterior algebra .
Definition: exterior_dimension.hpp:37
Compute and store the topological and geometrical data of the mesh.
Definition: maxwell.hpp:21