14 Assembly<AssemblyType::PETSC>::OpBase;
16struct OpCheckBlocks : FormBase {
17 OpCheckBlocks() : FormBase(
"row",
"col", OPROWCOL) {}
23 constexpr int row_offset = 1;
24 constexpr int block_count = 3;
25 locMat.resize(row_offset + 2 * RowDim + 1, block_count * ColDim + 1,
false);
27 for (
int row = 0; row != 2; ++row) {
28 auto t_block = getLocMat<RowDim, ColDim>(row_offset + row * RowDim);
29 for (
int col = 0; col != block_count; ++col, ++t_block)
30 t_block(
i,
j) = 10. * (row + 1) + col;
33 for (std::size_t row = 0; row != locMat.size1(); ++row) {
34 for (std::size_t col = 0; col != locMat.size2(); ++col) {
35 const double expected =
36 row < row_offset || row >= row_offset + 2 * RowDim ||
37 col >= block_count * ColDim
39 : 10. * (1 + (row - row_offset) / RowDim) + col / ColDim;
40 if (locMat(row, col) != expected)
42 "Incorrect %dx%d form block or cursor stride at (%zu,%zu)",
43 RowDim, ColDim, row, col);
58 static_assert(std::is_same_v<
61 static_assert(std::is_same_v<
64 static_assert(std::is_same_v<SymmetricView,
68 constexpr int count = 3;
69 MatrixDouble vector_values(count, 3), tensor_values(count, 9),
70 symmetric_values(count, 6);
72 for (
int gg = 0; gg != count; ++gg) {
73 for (
int col = 0; col != 3; ++col)
74 vector_values(gg, col) = 100. * gg + col + 1;
75 for (
int col = 0; col != 9; ++col)
76 tensor_values(gg, col) = 100. * gg + col + 11;
77 for (
int col = 0; col != 6; ++col)
78 symmetric_values(gg, col) = 100. * gg + col + 21;
80 const auto &vectors = vector_values;
81 const auto &tensors = tensor_values;
82 const auto &symmetric = symmetric_values;
87 static_assert(!std::is_assignable_v<
decltype(t_vector(0)),
double>);
88 static_assert(!std::is_assignable_v<
decltype(t_tensor(0, 0)),
double>);
89 static_assert(!std::is_assignable_v<
decltype(t_symmetric(0, 0)),
double>);
91 auto t_vector_mutable = getFTensor1FromMat<3>(vector_values);
92 auto t_tensor_mutable = getFTensor2FromMat<3, 3>(tensor_values);
93 auto t_symmetric_mutable = getFTensor2SymmetricFromMat<3>(symmetric_values);
94 static_assert(std::is_assignable_v<
decltype(t_vector_mutable(0)),
double>);
95 static_assert(std::is_assignable_v<
decltype(t_tensor_mutable(0, 0)),
double>);
97 std::is_assignable_v<
decltype(t_symmetric_mutable(0, 0)),
double>);
99 t_vector_mutable(0) = -31.;
100 t_tensor_mutable(0, 0) = -41.;
101 t_symmetric_mutable(0, 0) = -51.;
102 for (
int gg = 0; gg != count; ++gg) {
103 for (
int row = 0; row != 3; ++row) {
104 if (t_vector(row) != vector_values(gg, row))
106 "Incorrect const vector view or Gauss stride");
107 for (
int col = 0; col != 3; ++col)
108 if (t_tensor(row, col) != tensor_values(gg, 3 * row + col))
110 "Incorrect const tensor view or Gauss stride");
111 for (
int col = row; col != 3; ++col) {
112 const int packed = 3 * row - row * (row - 1) / 2 + col - row;
113 if (t_symmetric(row, col) != symmetric_values(gg, packed) ||
114 t_symmetric(col, row) != symmetric_values(gg, packed))
116 "Incorrect const symmetric view or Gauss stride");
128int main(
int argc,
char *argv[]) {
130 "Check FTensor form matrix block views\n");
132 CHKERR checkConstMatrixViews();
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
decltype(GetFTensor2SymmetricFromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2SymmetricFromMatType
decltype(GetFTensor1FromMatImpl< Tensor_Dim, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor1FromMatType
decltype(GetFTensor2FromMatImpl< Tensor_Dim0, Tensor_Dim1, S, DL, M >::get(std::declval< M & >(), 0, 0)) GetFTensor2FromMatType
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.