⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 projection.h

📁 利用C
💻 H
📖 第 1 页 / 共 5 页
字号:
    {      combinations[j] = new unsigned int [n];      for (unsigned int k = 0; k < n; k++)        combinations[j][k] = 0;    }            // Generate combinations of derivatives    for (unsigned int row = 1; row < num_derivatives; row++)    {      for (unsigned int num = 0; num < row; num++)      {        for (unsigned int col = n-1; col+1 > 0; col--)        {          if (combinations[row][col] + 1 > 2)            combinations[row][col] = 0;          else          {            combinations[row][col] += 1;            break;          }        }      }    }        // Compute inverse of Jacobian    const double Jinv[3][3] ={{d00 / detJ, d10 / detJ, d20 / detJ}, {d01 / detJ, d11 / detJ, d21 / detJ}, {d02 / detJ, d12 / detJ, d22 / detJ}};        // Declare transformation matrix    // Declare pointer to two dimensional array and initialise    double **transform = new double *[num_derivatives];            for (unsigned int j = 0; j < num_derivatives; j++)    {      transform[j] = new double [num_derivatives];      for (unsigned int k = 0; k < num_derivatives; k++)        transform[j][k] = 1;    }        // Construct transformation matrix    for (unsigned int row = 0; row < num_derivatives; row++)    {      for (unsigned int col = 0; col < num_derivatives; col++)      {        for (unsigned int k = 0; k < n; k++)          transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];      }    }        // Reset values    for (unsigned int j = 0; j < 1*num_derivatives; j++)      values[j] = 0;        // Map degree of freedom to element degree of freedom    const unsigned int dof = i;        // Generate scalings    const double scalings_y_0 = 1;    const double scalings_y_1 = scalings_y_0*(0.5 - 0.5*y);    const double scalings_y_2 = scalings_y_1*(0.5 - 0.5*y);    const double scalings_z_0 = 1;    const double scalings_z_1 = scalings_z_0*(0.5 - 0.5*z);    const double scalings_z_2 = scalings_z_1*(0.5 - 0.5*z);        // Compute psitilde_a    const double psitilde_a_0 = 1;    const double psitilde_a_1 = x;    const double psitilde_a_2 = 1.5*x*psitilde_a_1 - 0.5*psitilde_a_0;        // Compute psitilde_bs    const double psitilde_bs_0_0 = 1;    const double psitilde_bs_0_1 = 1.5*y + 0.5;    const double psitilde_bs_0_2 = 0.111111111111111*psitilde_bs_0_1 + 1.66666666666667*y*psitilde_bs_0_1 - 0.555555555555556*psitilde_bs_0_0;    const double psitilde_bs_1_0 = 1;    const double psitilde_bs_1_1 = 2.5*y + 1.5;    const double psitilde_bs_2_0 = 1;        // Compute psitilde_cs    const double psitilde_cs_00_0 = 1;    const double psitilde_cs_00_1 = 2*z + 1;    const double psitilde_cs_00_2 = 0.3125*psitilde_cs_00_1 + 1.875*z*psitilde_cs_00_1 - 0.5625*psitilde_cs_00_0;    const double psitilde_cs_01_0 = 1;    const double psitilde_cs_01_1 = 3*z + 2;    const double psitilde_cs_02_0 = 1;    const double psitilde_cs_10_0 = 1;    const double psitilde_cs_10_1 = 3*z + 2;    const double psitilde_cs_11_0 = 1;    const double psitilde_cs_20_0 = 1;        // Compute basisvalues    const double basisvalue0 = 0.866025403784439*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_0;    const double basisvalue1 = 2.73861278752583*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_0;    const double basisvalue2 = 1.58113883008419*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_0;    const double basisvalue3 = 1.11803398874989*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_1;    const double basisvalue4 = 5.1234753829798*psitilde_a_2*scalings_y_2*psitilde_bs_2_0*scalings_z_2*psitilde_cs_20_0;    const double basisvalue5 = 3.96862696659689*psitilde_a_1*scalings_y_1*psitilde_bs_1_1*scalings_z_2*psitilde_cs_11_0;    const double basisvalue6 = 2.29128784747792*psitilde_a_0*scalings_y_0*psitilde_bs_0_2*scalings_z_2*psitilde_cs_02_0;    const double basisvalue7 = 3.24037034920393*psitilde_a_1*scalings_y_1*psitilde_bs_1_0*scalings_z_1*psitilde_cs_10_1;    const double basisvalue8 = 1.87082869338697*psitilde_a_0*scalings_y_0*psitilde_bs_0_1*scalings_z_1*psitilde_cs_01_1;    const double basisvalue9 = 1.3228756555323*psitilde_a_0*scalings_y_0*psitilde_bs_0_0*scalings_z_0*psitilde_cs_00_2;        // Table(s) of coefficients    const static double coefficients0[10][10] = \    {{-0.0577350269189625, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323},    {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499976, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323},    {-0.0577350269189626, 0, 0.0702728368926306, -0.0248451997499976, 0, 0, 0.087287156094397, 0, -0.0475131096733199, 0.0167984210226323},    {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794},    {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293},    {0.23094010767585, 0.121716123890037, -0.0702728368926306, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293},    {0.23094010767585, 0.121716123890037, 0.0702728368926307, -0.0993807989999907, 0, 0.100790526135794, -0.087287156094397, -0.0205737799949456, -0.01187827741833, 0.0167984210226323},    {0.23094010767585, -0.121716123890037, -0.0702728368926307, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293},    {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323},    {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}};        // Interesting (new) part    // Tables of derivatives of the polynomial base (transpose)    const static double dmats0[10][10] = \    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {6.32455532033676, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {0, 11.2249721603218, 0, 0, 0, 0, 0, 0, 0, 0},    {4.58257569495584, 0, 8.36660026534076, -1.18321595661992, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {3.74165738677394, 0, 0, 8.69482604771366, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};        const static double dmats1[10][10] = \    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {5.47722557505166, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},    {2.29128784747792, 7.24568837309472, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},    {-2.64575131106459, 0, 9.66091783079296, 0.683130051063974, 0, 0, 0, 0, 0, 0},    {1.87082869338697, 0, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},    {3.24037034920393, 0, 0, 7.52994023880668, 0, 0, 0, 0, 0, 0},    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};        const static double dmats2[10][10] = \    {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {3.16227766016838, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {1.82574185835055, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {5.16397779494322, 0, 0, 0, 0, 0, 0, 0, 0, 0},    {2.95803989154981, 5.61248608016091, -1.08012344973464, -0.763762615825973, 0, 0, 0, 0, 0, 0},    {2.29128784747792, 1.44913767461894, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0},    {1.32287565553229, 0, 3.86436713231718, -0.341565025531986, 0, 0, 0, 0, 0, 0},    {1.87082869338697, 7.09929573971954, 0, 4.34741302385683, 0, 0, 0, 0, 0, 0},    {1.08012344973464, 0, 7.09929573971954, 2.50998007960223, 0, 0, 0, 0, 0, 0},    {-3.81881307912986, 0, 0, 8.87411967464942, 0, 0, 0, 0, 0, 0}};        // Compute reference derivatives    // Declare pointer to array of derivatives on FIAT element    double *derivatives = new double [num_derivatives];        // Declare coefficients    double coeff0_0 = 0;    double coeff0_1 = 0;    double coeff0_2 = 0;    double coeff0_3 = 0;    double coeff0_4 = 0;    double coeff0_5 = 0;    double coeff0_6 = 0;    double coeff0_7 = 0;    double coeff0_8 = 0;    double coeff0_9 = 0;        // Declare new coefficients    double new_coeff0_0 = 0;    double new_coeff0_1 = 0;    double new_coeff0_2 = 0;    double new_coeff0_3 = 0;    double new_coeff0_4 = 0;    double new_coeff0_5 = 0;    double new_coeff0_6 = 0;    double new_coeff0_7 = 0;    double new_coeff0_8 = 0;    double new_coeff0_9 = 0;        // Loop possible derivatives    for (unsigned int deriv_num = 0; deriv_num < num_derivatives; deriv_num++)    {      // Get values from coefficients array      new_coeff0_0 = coefficients0[dof][0];      new_coeff0_1 = coefficients0[dof][1];      new_coeff0_2 = coefficients0[dof][2];      new_coeff0_3 = coefficients0[dof][3];      new_coeff0_4 = coefficients0[dof][4];      new_coeff0_5 = coefficients0[dof][5];      new_coeff0_6 = coefficients0[dof][6];      new_coeff0_7 = coefficients0[dof][7];      new_coeff0_8 = coefficients0[dof][8];      new_coeff0_9 = coefficients0[dof][9];          // Loop derivative order      for (unsigned int j = 0; j < n; j++)      {        // Update old coefficients        coeff0_0 = new_coeff0_0;        coeff0_1 = new_coeff0_1;        coeff0_2 = new_coeff0_2;        coeff0_3 = new_coeff0_3;        coeff0_4 = new_coeff0_4;        coeff0_5 = new_coeff0_5;        coeff0_6 = new_coeff0_6;        coeff0_7 = new_coeff0_7;        coeff0_8 = new_coeff0_8;        coeff0_9 = new_coeff0_9;            if(combinations[deriv_num][j] == 0)        {          new_coeff0_0 = coeff0_0*dmats0[0][0] + coeff0_1*dmats0[1][0] + coeff0_2*dmats0[2][0] + coeff0_3*dmats0[3][0] + coeff0_4*dmats0[4][0] + coeff0_5*dmats0[5][0] + coeff0_6*dmats0[6][0] + coeff0_7*dmats0[7][0] + coeff0_8*dmats0[8][0] + coeff0_9*dmats0[9][0];          new_coeff0_1 = coeff0_0*dmats0[0][1] + coeff0_1*dmats0[1][1] + coeff0_2*dmats0[2][1] + coeff0_3*dmats0[3][1] + coeff0_4*dmats0[4][1] + coeff0_5*dmats0[5][1] + coeff0_6*dmats0[6][1] + coeff0_7*dmats0[7][1] + coeff0_8*dmats0[8][1] + coeff0_9*dmats0[9][1];          new_coeff0_2 = coeff0_0*dmats0[0][2] + coeff0_1*dmats0[1][2] + coeff0_2*dmats0[2][2] + coeff0_3*dmats0[3][2] + coeff0_4*dmats0[4][2] + coeff0_5*dmats0[5][2] + coeff0_6*dmats0[6][2] + coeff0_7*dmats0[7][2] + coeff0_8*dmats0[8][2] + coeff0_9*dmats0[9][2];          new_coeff0_3 = coeff0_0*dmats0[0][3] + coeff0_1*dmats0[1][3] + coeff0_2*dmats0[2][3] + coeff0_3*dmats0[3][3] + coeff0_4*dmats0[4][3] + coeff0_5*dmats0[5][3] + coeff0_6*dmats0[6][3] + coeff0_7*dmats0[7][3] + coeff0_8*dmats0[8][3] + coeff0_9*dmats0[9][3];          new_coeff0_4 = coeff0_0*dmats0[0][4] + coeff0_1*dmats0[1][4] + coeff0_2*dmats0[2][4] + coeff0_3*dmats0[3][4] + coeff0_4*dmats0[4][4] + coeff0_5*dmats0[5][4] + coeff0_6*dmats0[6][4] + coeff0_7*dmats0[7][4] + coeff0_8*dmats0[8][4] + coeff0_9*dmats0[9][4];          new_coeff0_5 = coeff0_0*dmats0[0][5] + coeff0_1*dmats0[1][5] + coeff0_2*dmats0[2][5] + coeff0_3*dmats0[3][5] + coeff0_4*dmats0[4][5] + coeff0_5*dmats0[5][5] + coeff0_6*dmats0[6][5] + coeff0_7*dmats0[7][5] + coeff0_8*dmats0[8][5] + coeff0_9*dmats0[9][5];          new_coeff0_6 = coeff0_0*dmats0[0][6] + coeff0_1*dmats0[1][6] + coeff0_2*dmats0[2][6] + coeff0_3*dmats0[3][6] + coeff0_4*dmats0[4][6] + coeff0_5*dmats0[5][6] + coeff0_6*dmats0[6][6] + coeff0_7*dmats0[7][6] + coeff0_8*dmats0[8][6] + coeff0_9*dmats0[9][6];          new_coeff0_7 = coeff0_0*dmats0[0][7] + coeff0_1*dmats0[1][7] + coeff0_2*dmats0[2][7] + coeff0_3*dmats0[3][7] + coeff0_4*dmats0[4][7] + coeff0_5*dmats0[5][7] + coeff0_6*dmats0[6][7] + coeff0_7*dmats0[7][7] + coeff0_8*dmats0[8][7] + coeff0_9*dmats0[9][7];          new_coeff0_8 = coeff0_0*dmats0[0][8] + coeff0_1*dmats0[1][8] + coeff0_2*dmats0[2][8] + coeff0_3*dmats0[3][8] + coeff0_4*dmats0[4][8] + coeff0_5*dmats0[5][8] + coeff0_6*dmats0[6][8] + coeff0_7*dmats0[7][8] + coeff0_8*dmats0[8][8] + coeff0_9*dmats0[9][8];          new_coeff0_9 = coeff0_0*dmats0[0][9] + coeff0_1*dmats0[1][9] + coeff0_2*dmats0[2][9] + coeff0_3*dmats0[3][9] + coeff0_4*dmats0[4][9] + coeff0_5*dmats0[5][9] + coeff0_6*dmats0[6][9] + coeff0_7*dmats0[7][9] + coeff0_8*dmats0[8][9] + coeff0_9*dmats0[9][9];        }        if(combinations[deriv_num][j] == 1)        {          new_coeff0_0 = coeff0_0*dmats1[0][0] + coeff0_1*dmats1[1][0] + coeff0_2*dmats1[2][0] + coeff0_3*dmats1[3][0] + coeff0_4*dmats1[4][0] + coeff0_5*dmats1[5][0] + coeff0_6*dmats1[6][0] + coeff0_7*dmats1[7][0] + coeff0_8*dmats1[8][0] + coeff0_9*dmats1[9][0];          new_coeff0_1 = coeff0_0*dmats1[0][1] + coeff0_1*dmats1[1][1] + coeff0_2*dmats1[2][1] + coeff0_3*dmats1[3][1] + coeff0_4*dmats1[4][1] + coeff0_5*dmats1[5][1] + coeff0_6*dmats1[6][1] + coeff0_7*dmats1[7][1] + coeff0_8*dmats1[8][1] + coeff0_9*dmats1[9][1];          new_coeff0_2 = coeff0_0*dmats1[0][2] + coeff0_1*dmats1[1][2] + coeff0_2*dmats1[2][2] + coeff0_3*dmats1[3][2] + coeff0_4*dmats1[4][2] + coeff0_5*dmats1[5][2] + coeff0_6*dmats1[6][2] + coeff0_7*dmats1[7][2] + coeff0_8*dmats1[8][2] + coeff0_9*dmats1[9][2];          new_coeff0_3 = coeff0_0*dmats1[0][3] + coeff0_1*dmats1[1][3] + coeff0_2*dmats1[2][3] + coeff0_3*dmats1[3][3] + coeff0_4*dmats1[4][3] + coeff0_5*dmats1[5][3] + coeff0_6*dmats1[6][3] + coeff0_7*dmats1[7][3] + coeff0_8*dmats1[8][3] + coeff0_9*dmats1[9][3];          new_coeff0_4 = coeff0_0*dmats1[0][4] + coeff0_1*dmats1[1][4] + coeff0_2*dmats1[2][4] + coeff0_3*dmats1[3][4] + coeff0_4*dmats1[4][4] + coeff0_5*dmats1[5][4] + coeff0_6*dmats1[6][4] + coeff0_7*dmats1[7][4] + coeff0_8*dmats1[8][4] + coeff0_9*dmats1[9][4];          new_coeff0_5 = coeff0_0*dmats1[0][5] + coeff0_1*dmats1[1][5] + coeff0_2*dmats1[2][5] + coeff0_3*dmats1[3][5] + coeff0_4*dmats1[4][5] + coeff0_5*dmats1[5][5] + coeff0_6*dmats1[6][5] + coeff0_7*dmats1[7][5] + coeff0_8*dmats1[8][5] + coeff0_9*dmats1[9][5];          new_coeff0_6 = coeff0_0*dmats1[0][6] + coeff0_1*dmats1[1][6] + coeff0_2*dmats1[2][6] + coeff0_3*dmats1[3][6] + coeff0_4*dmats1[4][6] + coeff0_5*dmats1[5][6] + coeff0_6*dmats1[6][6] + coeff0_7*dmats1[7][6] + coeff0_8*dmats1[8][6] + coeff0_9*dmats1[9][6];          new_coeff0_7 = coeff0_0*dmats1[0][7] + coeff0_1*dmats1[1][7] + coeff0_2*dmats1[2][7] + coeff0_3*dmats1[3][7] + coeff0_4*dmats1[4][7] + coeff0_5*dmats1[5][7] + coeff0_6*dmats1[6][7] + coeff0_7*dmats1[7][7] + coeff0_8*dmats1[8][7] + coeff0_9*dmats1[9][7];          new_coeff0_8 = coeff0_0*dmats1[0][8] + coeff0_1*dmats1[1][8] + coeff0_2*dmats1[2][8] + coeff0_3*dmats1[3][8] + coeff0_4*dmats1[4][8] + coeff0_5*dmats1[5][8] + coeff0_6*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -