v0.16.3
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
MoFEM::GetFTensor2FromMatImpl< Tensor_Dim1, Tensor_Dim2, S, DL, M > Struct Template Reference

#include "include/Templates.hpp"

Static Public Member Functions

static auto get (M &data, int rr=0, int cc=0)
 

Detailed Description

template<int Tensor_Dim1, int Tensor_Dim2, int S, class DL, class M>
struct MoFEM::GetFTensor2FromMatImpl< Tensor_Dim1, Tensor_Dim2, S, DL, M >

Definition at line 482 of file Templates.hpp.

Member Function Documentation

◆ get()

template<int Tensor_Dim1, int Tensor_Dim2, int S, class DL , class M >
static auto MoFEM::GetFTensor2FromMatImpl< Tensor_Dim1, Tensor_Dim2, S, DL, M >::get ( M &  data,
int  rr = 0,
int  cc = 0 
)
inlinestatic

Definition at line 483 of file Templates.hpp.

483 {
484 // Preserve const matrix elements in the non-owning tensor view.
485 using T = std::remove_reference_t<decltype(data(0, 0))>;
486 constexpr int stride =
487 S == -1 ? (DL::isGaussByCoeffs ? Tensor_Dim1 * Tensor_Dim2 : 1) : S;
488 if constexpr (DL::isGaussByCoeffs) {
489 static_assert(stride % (Tensor_Dim1 * Tensor_Dim2) == 0,
490 "getFTensor2FromMat: stride should be a multiple of "
491 "Tensor_Dim1 * Tensor_Dim2");
492
493#ifndef NDEBUG
494 if (data.size2() != Tensor_Dim1 * Tensor_Dim2) {
496 "getFTensor2FromMat<" +
497 boost::lexical_cast<std::string>(Tensor_Dim1) + "," +
498 boost::lexical_cast<std::string>(Tensor_Dim2) +
499 ">: wrong size of columns in data matrix, should be " +
500 boost::lexical_cast<std::string>(Tensor_Dim1 * Tensor_Dim2) +
501 " but is " + boost::lexical_cast<std::string>(data.size2()));
502 }
503 auto *first = &data(rr + 0, cc + 0);
504 auto *last = &data(rr + 0, cc + 0 + Tensor_Dim1 * Tensor_Dim2 - 1);
505 if (last - first != Tensor_Dim1 * Tensor_Dim2 - 1) {
506 THROW_MESSAGE("getFTensor2FromMat<" +
507 boost::lexical_cast<std::string>(Tensor_Dim1) + "," +
508 boost::lexical_cast<std::string>(Tensor_Dim2) +
509 ">: row slice is not contiguous");
510 }
511#endif
513 Tensor_Dim2>(&data(rr + 0, cc + 0));
514 } else if constexpr (DL::isCoeffsByGauss) {
515 std::array<T *, Tensor_Dim1 * Tensor_Dim2> ptrs;
516#ifndef NDEBUG
517 if (data.size1() != Tensor_Dim1 * Tensor_Dim2) {
519 "getFTensor2FromMat<" +
520 boost::lexical_cast<std::string>(Tensor_Dim1) + "," +
521 boost::lexical_cast<std::string>(Tensor_Dim2) +
522 ">: wrong size of rows in data matrix, should be " +
523 boost::lexical_cast<std::string>(Tensor_Dim1 * Tensor_Dim2) +
524 " but is " + boost::lexical_cast<std::string>(data.size1()));
525 }
526#endif
527 for (auto i = 0; i != Tensor_Dim1 * Tensor_Dim2; ++i)
528 ptrs[i] = &data(rr + i, cc + 0);
530 Tensor_Dim2>(ptrs);
531 } else {
532 static_assert(!std::is_same<M, M>::value,
533 "Unsupported data layout for getFTensor2FromMatImpl");
534 }
535 }
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
FTensor::Index< 'i', SPACE_DIM > i

The documentation for this struct was generated from the following file: