dune-pdelab  2.0.0
jacobiantocurl.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=8 sw=2 sts=2:
3 #ifndef DUNE_PDELAB_COMMON_JACOBIANTOCURL_HH
4 #define DUNE_PDELAB_COMMON_JACOBIANTOCURL_HH
5 
6 #include <cstddef>
7 
8 #include <dune/common/fvector.hh>
9 #include <dune/common/static_assert.hh>
10 
11 namespace Dune {
12  namespace PDELab {
13 
15 
26  template<typename Jacobian, std::size_t dimR = Jacobian::rows,
27  std::size_t dimD = Jacobian::cols>
29 
32 
56  template<typename Jacobian>
57  class JacobianToCurl<Jacobian, 1, 2> {
58  dune_static_assert
59  ( Jacobian::rows == 1 && Jacobian::cols == 2, "This specialization "
60  "works only for dimRange == 1 and dimDomain == 2");
61 
62  public:
63  typedef typename Jacobian::block_type CurlField;
64  static const std::size_t dimCurl = 2;
65  typedef FieldVector<CurlField, dimCurl> Curl;
66 
67  void operator()(const Jacobian& jacobian, Curl& curl) const {
68  curl[0] = jacobian[0][1];
69  curl[1] = -jacobian[0][0];
70  }
71  };
72 
75 
97  template<typename Jacobian>
98  class JacobianToCurl<Jacobian, 2, 2> {
99  dune_static_assert
100  ( Jacobian::rows == 2 && Jacobian::cols == 2, "This specialization "
101  "works only for dimRange == 2 and dimDomain == 2");
102 
103  public:
104  typedef typename Jacobian::block_type CurlField;
105  static const std::size_t dimCurl = 1;
106  typedef FieldVector<CurlField, dimCurl> Curl;
107 
108  void operator()(const Jacobian& jacobian, Curl& curl) const {
109  curl[0] = jacobian[1][0]-jacobian[0][1];
110  }
111  };
112 
115 
132  template<typename Jacobian>
133  class JacobianToCurl<Jacobian, 3, 3> {
134  dune_static_assert
135  ( Jacobian::rows == 3 && Jacobian::cols == 3, "This specialization "
136  "works only for dimRange == 3 and dimDomain == 3");
137 
138  public:
139  typedef typename Jacobian::block_type CurlField;
140  static const std::size_t dimCurl = 3;
141  typedef FieldVector<CurlField, dimCurl> Curl;
142 
143  void operator()(const Jacobian& jacobian, Curl& curl) const {
144  for(std::size_t alpha = 0; alpha < 3; ++alpha) {
145  std::size_t beta = (alpha+1)%3;
146  std::size_t gamma = (alpha+2)%3;
147  curl[alpha] = jacobian[gamma][beta]-jacobian[beta][gamma];
148  }
149  }
150  };
151 
152  } // namespace PDELab
153 } //namespace Dune
154 
155 #endif // DUNE_PDELAB_COMMON_JACOBIANTOCURL_HH
156 
Jacobian::block_type CurlField
Definition: jacobiantocurl.hh:63
void operator()(const Jacobian &jacobian, Curl &curl) const
Definition: jacobiantocurl.hh:143
void operator()(const Jacobian &jacobian, Curl &curl) const
Definition: jacobiantocurl.hh:67
FieldVector< CurlField, dimCurl > Curl
Definition: jacobiantocurl.hh:141
extract the curl of a function from the jacobian of that function
Definition: jacobiantocurl.hh:28
FieldVector< CurlField, dimCurl > Curl
Definition: jacobiantocurl.hh:106
Jacobian::block_type CurlField
Definition: jacobiantocurl.hh:139
FieldVector< CurlField, dimCurl > Curl
Definition: jacobiantocurl.hh:65
Jacobian::block_type CurlField
Definition: jacobiantocurl.hh:104
void operator()(const Jacobian &jacobian, Curl &curl) const
Definition: jacobiantocurl.hh:108