📄 ffc_24.h
字号:
const double d20 = J_01*J_12 - J_02*J_11; const double d21 = J_02*J_10 - J_00*J_12; const double d22 = J_00*J_11 - J_01*J_10; // Compute determinant of Jacobian double detJ = J_00*d00 + J_10*d10 + J_20*d20; // Compute constants const double C0 = element_coordinates[3][0] + element_coordinates[2][0] \ + element_coordinates[1][0] - element_coordinates[0][0]; const double C1 = element_coordinates[3][1] + element_coordinates[2][1] \ + element_coordinates[1][1] - element_coordinates[0][1]; const double C2 = element_coordinates[3][2] + element_coordinates[2][2] \ + element_coordinates[1][2] - element_coordinates[0][2]; // Get coordinates and map to the reference (FIAT) element double x = coordinates[0]; double y = coordinates[1]; double z = coordinates[2]; x = (2.0*d00*x + 2.0*d10*y + 2.0*d20*z - d00*C0 - d10*C1 - d20*C2) / detJ; y = (2.0*d01*x + 2.0*d11*y + 2.0*d21*z - d01*C0 - d11*C1 - d21*C2) / detJ; z = (2.0*d02*x + 2.0*d12*y + 2.0*d22*z - d02*C0 - d12*C1 - d22*C2) / detJ; // Map coordinates to the reference cube if (std::abs(y + z) < 1e-14) x = 1.0; else x = -2.0 * (1.0 + x)/(y + z) - 1.0; if (std::abs(z - 1.0) < 1e-14) y = -1.0; else y = 2.0 * (1.0 + y)/(1.0 - z) - 1.0; // Compute number of derivatives unsigned int num_derivatives = 1; for (unsigned int j = 0; j < n; j++) num_derivatives *= 3; // Declare pointer to two dimensional array that holds combinations of derivatives and initialise unsigned int **combinations = new unsigned int *[num_derivatives]; for (unsigned int j = 0; j < num_derivatives; j++) { 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, components are scaled because of difference in FFC/FIAT reference elements const double Jinv[3][3] ={{2*d00 / detJ, 2*d10 / detJ, 2*d20 / detJ}, {2*d01 / detJ, 2*d11 / detJ, 2*d21 / detJ}, {2*d02 / detJ, 2*d12 / detJ, 2*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.0577350269189626, -0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, 0.050395263067897, 0.0290957186981323, 0.0411475599898912, 0.0237565548366599, 0.0167984210226323}, {0.23094010767585, 0, -0.140545673785261, -0.0993807989999906, -0.130120009726471, 0, 0.0290957186981323, 0, 0.02375655483666, 0.0167984210226323}, {-0.0577350269189625, 0.0608580619450185, -0.0351364184463153, -0.0248451997499977, 0.0650600048632355, -0.050395263067897, 0.0290957186981323, -0.0411475599898912, 0.0237565548366599, 0.0167984210226323}, {0.23094010767585, -0.121716123890037, 0.0702728368926306, -0.0993807989999907, 0, -0.100790526135794, -0.0872871560943969, 0.0205737799949456, -0.01187827741833, 0.0167984210226323}, {0.23094010767585, 0.121716123890037, 0.0702728368926306, -0.0993807989999906, 0, 0.100790526135794, -0.0872871560943969, -0.0205737799949456, -0.01187827741833, 0.0167984210226323}, {-0.0577350269189626, 0, 0.0702728368926307, -0.0248451997499977, 0, 0, 0.0872871560943969, 0, -0.0475131096733199, 0.0167984210226323}, {0.23094010767585, -0.121716123890037, -0.0702728368926306, 0.0993807989999906, 0, 0, 0, -0.102868899974728, -0.0593913870916499, -0.0671936840905293}, {0.23094010767585, 0.121716123890037, -0.0702728368926307, 0.0993807989999907, 0, 0, 0, 0.102868899974728, -0.0593913870916499, -0.0671936840905293}, {0.23094010767585, 0, 0.140545673785261, 0.0993807989999906, 0, 0, 0, 0, 0.1187827741833, -0.0671936840905293}, {-0.0577350269189626, 0, 0, 0.074535599249993, 0, 0, 0, 0, 0, 0.100790526135794}}; // 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}, {3.16227766016838, 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, 5.61248608016091, 0, 0, 0, 0, 0, 0, 0, 0}, {2.29128784747792, 0, 4.18330013267038, -0.591607978309962, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1.87082869338697, 0, 0, 4.34741302385683, 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}, {1.58113883008419, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {2.73861278752583, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1.4790199457749, 2.80624304008046, -0.540061724867322, -0.381881307912987, 0, 0, 0, 0, 0, 0}, {1.14564392373896, 3.62284418654736, 2.09165006633519, -0.295803989154981, 0, 0, 0, 0, 0, 0}, {-1.3228756555323, 0, 4.83045891539648, 0.341565025531987, 0, 0, 0, 0, 0, 0}, {0.935414346693486, 0, 0, 2.17370651192842, 0, 0, 0, 0, 0, 0}, {1.62018517460197, 0, 0, 3.76497011940334, 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}, {1.58113883008419, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0.912870929175277, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {2.58198889747161, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1.4790199457749, 2.80624304008046, -0.540061724867322, -0.381881307912987, 0, 0, 0, 0, 0, 0}, {1.14564392373896, 0.724568837309472, 2.09165006633519, -0.295803989154981, 0, 0, 0, 0, 0, 0}, {0.661437827766147, 0, 1.93218356615859, -0.170782512765993, 0, 0, 0, 0, 0, 0}, {0.935414346693486, 3.54964786985977, 0, 2.17370651192842, 0, 0, 0, 0, 0, 0}, {0.540061724867322, 0, 3.54964786985977, 1.25499003980111, 0, 0, 0, 0, 0, 0}, {-1.90940653956493, 0, 0, 4.43705983732471, 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];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -