Reference documentation for deal.II version 8.5.1
tensor_deprecated.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__tensor_deprecated_h
17 #define dealii__tensor_deprecated_h
18 
19 #include <deal.II/base/tensor.h>
20 
21 
22 /* --------- Deprecated non-member functions operating on tensors. ---------- */
23 
24 DEAL_II_NAMESPACE_OPEN
25 
30 
37  int,
38  << "You have requested contraction of tensors over index "
39  << arg1
40  << ", but this is not possible for tensors of the current type.");
41 
42 
51 template <int dim, typename Number>
52 inline
53 Number double_contract (const Tensor<2, dim, Number> &src1,
54  const Tensor<2, dim, Number> &src2) DEAL_II_DEPRECATED;
55 
56 
66 template <int dim, typename Number>
67 inline
69  const Tensor<4,dim,Number> &src1,
70  const Tensor<2,dim,Number> &src2) DEAL_II_DEPRECATED;
71 
82 template <int dim, typename Number>
83 inline
84 void contract (Tensor<2,dim,Number> &dest,
85  const Tensor<2,dim,Number> &src1,
86  const unsigned int index1,
87  const Tensor<2,dim,Number> &src2,
88  const unsigned int index3) DEAL_II_DEPRECATED;
89 
99 template <int dim, typename Number>
100 inline
101 void contract (Tensor<2,dim,Number> &dest,
102  const Tensor<3,dim,Number> &src1,
103  const unsigned int index1,
104  const Tensor<1,dim,Number> &src2) DEAL_II_DEPRECATED;
105 
116 template <int dim, typename Number>
117 inline
118 void contract (Tensor<3,dim,Number> &dest,
119  const Tensor<3,dim,Number> &src1,
120  const unsigned int index1,
121  const Tensor<2,dim,Number> &src2,
122  const unsigned int index2) DEAL_II_DEPRECATED;
123 
132 template <int rank_1, int rank_2, int dim, typename Number>
133 inline
135  const Tensor<rank_1 ,dim, Number> &src1,
136  const Tensor<rank_2 ,dim, Number> &src2) DEAL_II_DEPRECATED;
137 
144 template <int dim, typename Number, typename OtherNumber>
145 inline
147 contract (const Tensor<1,dim,Number> &src1,
148  const Tensor<1,dim,OtherNumber> &src2) DEAL_II_DEPRECATED;
149 
150 
158 template <int dim, typename Number>
159 inline
160 void
162  const Tensor<1,dim,Number> &src) DEAL_II_DEPRECATED;
163 
170 template <int dim, typename Number>
171 inline
172 void
174  const Tensor<1,dim,Number> &src1,
175  const Tensor<1,dim,Number> &src2) DEAL_II_DEPRECATED;
176 
183 template <int rank_1, int rank_2, int dim, typename Number>
184 inline
186  const Tensor<rank_1, dim, Number> &src1,
187  const Tensor<rank_2, dim, Number> &src2) DEAL_II_DEPRECATED;
188 
195 template <int dim, typename Number>
196 inline
198  const Number src1,
199  const Tensor<1,dim,Number> &src2) DEAL_II_DEPRECATED;
200 
207 template <int dim, typename Number>
208 inline
210  const Tensor<1,dim,Number> src1,
211  const Number src2) DEAL_II_DEPRECATED;
212 
217 template <int rank, typename Number>
218 inline
219 Number determinant (const Tensor<rank,1,Number> &t) DEAL_II_DEPRECATED;
220 
221 
226 template <typename Number>
227 inline
228 Number determinant (const Tensor<1,1,Number> &t) DEAL_II_DEPRECATED;
229 
231 
232 /* ----------------------------- Definitions: ------------------------------- */
233 
234 template <int dim, typename Number>
235 inline
237  const Tensor<2, dim, Number> &src2)
238 {
239  Number res = 0.;
240  for (unsigned int i=0; i<dim; ++i)
241  res += src1[i] * src2[i];
242 
243  return res;
244 }
245 
246 template <int dim, typename Number>
247 inline
249  const Tensor<4,dim,Number> &src1,
250  const Tensor<2,dim,Number> &src2)
251 {
252  dest.clear ();
253  for (unsigned int i=0; i<dim; ++i)
254  for (unsigned int j=0; j<dim; ++j)
255  for (unsigned int k=0; k<dim; ++k)
256  for (unsigned int l=0; l<dim; ++l)
257  dest[i][j] += src1[i][j][k][l] * src2[k][l];
258 }
259 
260 template <int dim, typename Number>
261 inline
263  const Tensor<2,dim,Number> &src1, const unsigned int index1,
264  const Tensor<2,dim,Number> &src2, const unsigned int index2)
265 {
266  dest.clear ();
267 
268  switch (index1)
269  {
270  case 1:
271  switch (index2)
272  {
273  case 1:
274  for (unsigned int i=0; i<dim; ++i)
275  for (unsigned int j=0; j<dim; ++j)
276  for (unsigned int k=0; k<dim; ++k)
277  dest[i][j] += src1[k][i] * src2[k][j];
278  break;
279  case 2:
280  for (unsigned int i=0; i<dim; ++i)
281  for (unsigned int j=0; j<dim; ++j)
282  for (unsigned int k=0; k<dim; ++k)
283  dest[i][j] += src1[k][i] * src2[j][k];
284  break;
285 
286  default:
287  Assert (false, (ExcInvalidTensorContractionIndex (index2)));
288  };
289  break;
290  case 2:
291  switch (index2)
292  {
293  case 1:
294  for (unsigned int i=0; i<dim; ++i)
295  for (unsigned int j=0; j<dim; ++j)
296  for (unsigned int k=0; k<dim; ++k)
297  dest[i][j] += src1[i][k] * src2[k][j];
298  break;
299  case 2:
300  for (unsigned int i=0; i<dim; ++i)
301  for (unsigned int j=0; j<dim; ++j)
302  for (unsigned int k=0; k<dim; ++k)
303  dest[i][j] += src1[i][k] * src2[j][k];
304  break;
305 
306  default:
307  Assert (false, (ExcInvalidTensorContractionIndex (index2)));
308  };
309  break;
310 
311  default:
312  Assert (false, (ExcInvalidTensorContractionIndex (index1)));
313  };
314 }
315 
316 template <int dim, typename Number>
317 inline
319  const Tensor<3,dim,Number> &src1, const unsigned int index1,
320  const Tensor<1,dim,Number> &src2)
321 {
322  dest.clear ();
323 
324  switch (index1)
325  {
326  case 1:
327  for (unsigned int i=0; i<dim; ++i)
328  for (unsigned int j=0; j<dim; ++j)
329  for (unsigned int k=0; k<dim; ++k)
330  dest[i][j] += src1[k][i][j] * src2[k];
331  break;
332 
333  case 2:
334  for (unsigned int i=0; i<dim; ++i)
335  for (unsigned int j=0; j<dim; ++j)
336  for (unsigned int k=0; k<dim; ++k)
337  dest[i][j] += src1[i][k][j] * src2[k];
338  break;
339 
340  case 3:
341  for (unsigned int i=0; i<dim; ++i)
342  for (unsigned int j=0; j<dim; ++j)
343  for (unsigned int k=0; k<dim; ++k)
344  dest[i][j] += src1[i][j][k] * src2[k];
345  break;
346 
347  default:
348  Assert (false, (ExcInvalidTensorContractionIndex (index1)));
349  };
350 }
351 
352 template <int dim, typename Number>
353 inline
355  const Tensor<3,dim,Number> &src1, const unsigned int index1,
356  const Tensor<2,dim,Number> &src2, const unsigned int index2)
357 {
358  dest.clear ();
359 
360  switch (index1)
361  {
362  case 1:
363  switch (index2)
364  {
365  case 1:
366  for (unsigned int i=0; i<dim; ++i)
367  for (unsigned int j=0; j<dim; ++j)
368  for (unsigned int k=0; k<dim; ++k)
369  for (unsigned int l=0; l<dim; ++l)
370  dest[i][j][k] += src1[l][i][j] * src2[l][k];
371  break;
372  case 2:
373  for (unsigned int i=0; i<dim; ++i)
374  for (unsigned int j=0; j<dim; ++j)
375  for (unsigned int k=0; k<dim; ++k)
376  for (unsigned int l=0; l<dim; ++l)
377  dest[i][j][k] += src1[l][i][j] * src2[k][l];
378  break;
379  default:
380  Assert (false, (ExcInvalidTensorContractionIndex (index2)));
381  }
382 
383  break;
384  case 2:
385  switch (index2)
386  {
387  case 1:
388  for (unsigned int i=0; i<dim; ++i)
389  for (unsigned int j=0; j<dim; ++j)
390  for (unsigned int k=0; k<dim; ++k)
391  for (unsigned int l=0; l<dim; ++l)
392  dest[i][j][k] += src1[i][l][j] * src2[l][k];
393  break;
394  case 2:
395  for (unsigned int i=0; i<dim; ++i)
396  for (unsigned int j=0; j<dim; ++j)
397  for (unsigned int k=0; k<dim; ++k)
398  for (unsigned int l=0; l<dim; ++l)
399  dest[i][j][k] += src1[i][l][j] * src2[k][l];
400  break;
401  default:
402  Assert (false, (ExcInvalidTensorContractionIndex (index2)));
403  }
404 
405  break;
406  case 3:
407  switch (index2)
408  {
409  case 1:
410  for (unsigned int i=0; i<dim; ++i)
411  for (unsigned int j=0; j<dim; ++j)
412  for (unsigned int k=0; k<dim; ++k)
413  for (unsigned int l=0; l<dim; ++l)
414  dest[i][j][k] += src1[i][j][l] * src2[l][k];
415  break;
416  case 2:
417  for (unsigned int i=0; i<dim; ++i)
418  for (unsigned int j=0; j<dim; ++j)
419  for (unsigned int k=0; k<dim; ++k)
420  for (unsigned int l=0; l<dim; ++l)
421  dest[i][j][k] += src1[i][j][l] * src2[k][l];
422  break;
423  default:
424  Assert (false, (ExcInvalidTensorContractionIndex (index2)));
425  }
426 
427  break;
428  default:
429  Assert (false, (ExcInvalidTensorContractionIndex (index1)));
430  }
431 }
432 
433 template <int rank_1, int rank_2, int dim, typename Number>
434 inline
436  const Tensor<rank_1 ,dim, Number> &src1,
437  const Tensor<rank_2 ,dim, Number> &src2)
438 {
439  TensorAccessors::internal::ReorderedIndexView<0, rank_2, const Tensor<rank_2, dim, Number> >
440  reordered = TensorAccessors::reordered_index_view<0, rank_2>(src2);
441  TensorAccessors::contract<1, rank_1, rank_2, dim>(dest, src1, reordered);
442 }
443 
444 template <int dim, typename Number, typename OtherNumber>
445 inline
448  const Tensor<1,dim,OtherNumber> &src2)
449 {
452  for (unsigned int i=0; i<dim; ++i)
453  res += src1[i] * src2[i];
454 
455  return res;
456 }
457 
458 template <int dim, typename Number>
459 inline
460 void
462  const Tensor<1,dim,Number> &src)
463 {
464  dst = cross_product_2d(src);
465 }
466 
467 template <int dim, typename Number>
468 inline
469 void
471  const Tensor<1,dim,Number> &src1,
472  const Tensor<1,dim,Number> &src2)
473 {
474  dst = cross_product_3d(src1, src2);
475 }
476 
477 template <int rank_1, int rank_2, int dim, typename Number>
478 inline
480  const Tensor<rank_1, dim, Number> &src1,
481  const Tensor<rank_2, dim, Number> &src2)
482 {
483  TensorAccessors::contract<0, rank_1, rank_2, dim>(dst, src1, src2);
484 }
485 
486 template <int dim, typename Number>
487 inline
489  const Number src1,
490  const Tensor<1,dim,Number> &src2)
491 {
492  for (unsigned int i=0; i<dim; ++i)
493  dst[i] = src1 * src2[i];
494 }
495 
496 template <int dim, typename Number>
497 inline
499  const Tensor<1,dim,Number> src1,
500  const Number src2)
501 {
502  for (unsigned int i=0; i<dim; ++i)
503  dst[i] = src1[i] * src2;
504 }
505 
506 template <int rank, typename Number>
507 inline
509 {
510  return determinant(t[0]);
511 }
512 
513 template <typename Number>
514 inline
516 {
517  return t[0];
518 }
519 
520 DEAL_II_NAMESPACE_CLOSE
521 
522 #endif
void double_contract(SymmetricTensor< 2, 1, Number > &tmp, const SymmetricTensor< 4, 1, Number > &t, const SymmetricTensor< 2, 1, Number > &s)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:564
Tensor< 1, dim, Number > cross_product_2d(const Tensor< 1, dim, Number > &src)
Definition: tensor.h:1672
#define Assert(cond, exc)
Definition: exceptions.h:313
SymmetricTensor< 4, dim, Number > outer_product(const SymmetricTensor< 2, dim, Number > &t1, const SymmetricTensor< 2, dim, Number > &t2)
Tensor< 1, dim, Number > cross_product_3d(const Tensor< 1, dim, Number > &src1, const Tensor< 1, dim, Number > &src2)
Definition: tensor.h:1698
void cross_product(Tensor< 1, dim, Number > &dst, const Tensor< 1, dim, Number > &src) 1
Number determinant(const SymmetricTensor< 2, dim, Number > &t)
Definition: mpi.h:41
Tensor< rank_1+rank_2 - 2, dim, typename ProductType< Number, OtherNumber >::type >::tensor_type contract(const Tensor< rank_1, dim, Number > &src1, const Tensor< rank_2, dim, OtherNumber > &src2)
Definition: tensor.h:1459
void clear()
Definition: tensor.h:1072
static ::ExceptionBase & ExcInvalidTensorContractionIndex(int arg1)