v0.16.0
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 1268 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 1269 of file Templates.hpp.

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