v0.16.0
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 481 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 482 of file Templates.hpp.

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

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