Exemple #1
0
int foo()
{
  int mat[2][2];
  mat[0][0] = 1;
  mat[0][1] = 2;
  mat[1][0] = 4;
  mat[1][1] = 8;
  return inv_J(mat);
}
    void TestComputeTransformedBasisFunctionDerivatives()
    {
        // 1D
        ChastePoint<1> one(1);

        c_matrix<double, 1, 1> inv_J;
        inv_J(0,0) = 0.5;

        c_matrix<double, 1, 2> trans_deriv;
        LinearBasisFunction<1>::ComputeTransformedBasisFunctionDerivatives(one, inv_J, trans_deriv);

        TS_ASSERT_DELTA(trans_deriv(0,0), -0.5, 1e-12);
        TS_ASSERT_DELTA(trans_deriv(0,1),  0.5, 1e-12);

        // 2D
        ChastePoint<2> oneone(1,1);

        c_matrix<double, 2, 2> inv_J2 = 0.5 * identity_matrix<double>(2);

        c_matrix<double, 2, 3> trans_deriv2;
        LinearBasisFunction<2>::ComputeTransformedBasisFunctionDerivatives(oneone, inv_J2, trans_deriv2);

        TS_ASSERT_DELTA(trans_deriv2(0,0), -0.5, 1e-12);
        TS_ASSERT_DELTA(trans_deriv2(0,1),  0.5, 1e-12);
        TS_ASSERT_DELTA(trans_deriv2(0,2),    0, 1e-12);

        // 3D
        ChastePoint<3> oneoneone(1,1,1);

        c_matrix<double, 3, 3> inv_J3 = 0.5 * identity_matrix<double>(3);

        c_matrix<double, 3, 4> trans_deriv3;
        LinearBasisFunction<3>::ComputeTransformedBasisFunctionDerivatives(oneoneone, inv_J3, trans_deriv3);

        TS_ASSERT_DELTA(trans_deriv3(0,0), -0.5, 1e-12);
        TS_ASSERT_DELTA(trans_deriv3(0,1),  0.5, 1e-12);
        TS_ASSERT_DELTA(trans_deriv3(0,2),    0, 1e-12);
        TS_ASSERT_DELTA(trans_deriv3(0,3),    0, 1e-12);
    }