v0.16.3
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
MoFEM::GetFTensor4FromMatImpl< Tensor_Dim0, Tensor_Dim1, Tensor_Dim2, Tensor_Dim3, 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_Dim0, int Tensor_Dim1, int Tensor_Dim2, int Tensor_Dim3, int S, class DL, class M>
struct MoFEM::GetFTensor4FromMatImpl< Tensor_Dim0, Tensor_Dim1, Tensor_Dim2, Tensor_Dim3, S, DL, M >

Definition at line 1263 of file Templates.hpp.

Member Function Documentation

◆ get()

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

Definition at line 1264 of file Templates.hpp.

1264 {
1265 using T = std::remove_cv_t<std::remove_reference_t<decltype(data(0, 0))>>;
1266 constexpr int tensor_size =
1267 Tensor_Dim0 * Tensor_Dim1 * Tensor_Dim2 * Tensor_Dim3;
1268 constexpr int stride =
1269 S == -1 ? (DL::isGaussByCoeffs ? tensor_size : 1) : S;
1270 if constexpr (DL::isGaussByCoeffs) {
1271 static_assert(
1272 stride % tensor_size == 0,
1273 "getFTensor4FromMat: stride should be a multiple of tensor_size");
1274
1275#ifndef NDEBUG
1276 if (data.size2() != tensor_size) {
1277 THROW_MESSAGE("getFTensor4FromMat<" +
1278 boost::lexical_cast<std::string>(Tensor_Dim0) + "," +
1279 boost::lexical_cast<std::string>(Tensor_Dim1) + "," +
1280 boost::lexical_cast<std::string>(Tensor_Dim2) + "," +
1281 boost::lexical_cast<std::string>(Tensor_Dim3) +
1282 ">: wrong size of columns in data matrix, should be " +
1283 boost::lexical_cast<std::string>(tensor_size) +
1284 " but is " +
1285 boost::lexical_cast<std::string>(data.size2()));
1286 }
1287 auto *first = &data(rr + 0, cc + 0);
1288 auto *last = &data(rr + 0, cc + 0 + tensor_size - 1);
1289 if (last - first != tensor_size - 1) {
1290 THROW_MESSAGE("getFTensor4FromMat<" +
1291 boost::lexical_cast<std::string>(Tensor_Dim0) + "," +
1292 boost::lexical_cast<std::string>(Tensor_Dim1) + "," +
1293 boost::lexical_cast<std::string>(Tensor_Dim2) + "," +
1294 boost::lexical_cast<std::string>(Tensor_Dim3) +
1295 ">: row slice is not contiguous");
1296 }
1297#endif
1299 Tensor_Dim1, Tensor_Dim2, Tensor_Dim3>{
1300 &data(rr + 0, cc + 0)};
1301 } else if constexpr (DL::isCoeffsByGauss) {
1302 std::array<T *, tensor_size> ptrs;
1303#ifndef NDEBUG
1304 if (data.size1() != tensor_size) {
1305 THROW_MESSAGE("getFTensor4FromMat<" +
1306 boost::lexical_cast<std::string>(Tensor_Dim0) + "," +
1307 boost::lexical_cast<std::string>(Tensor_Dim1) + "," +
1308 boost::lexical_cast<std::string>(Tensor_Dim2) + "," +
1309 boost::lexical_cast<std::string>(Tensor_Dim3) +
1310 ">: wrong size of rows in data matrix, should be " +
1311 boost::lexical_cast<std::string>(tensor_size) +
1312 " but is " +
1313 boost::lexical_cast<std::string>(data.size1()));
1314 }
1315#endif
1316 for (auto i = 0; i != tensor_size; ++i)
1317 ptrs[i] = &data(rr + i, cc + 0);
1318 return makeFTensor4FromPtrArray<T, Tensor_Dim0, Tensor_Dim1, Tensor_Dim2,
1319 Tensor_Dim3, stride>(
1320 ptrs, std::make_index_sequence<tensor_size>{});
1321 } else {
1322 static_assert(!std::is_same<M, M>::value,
1323 "Unsupported data layout for getFTensor4FromMatImpl");
1324 }
1325 }
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
FTensor::Index< 'i', SPACE_DIM > i
static auto makeFTensor4FromPtrArray(const std::array< T *, Tensor_Dim0 *Tensor_Dim1 *Tensor_Dim2 *Tensor_Dim3 > &ptrs, std::index_sequence< Is... >)

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