FEniCS / ffcx

Next generation FEniCS Form Compiler for finite element forms
https://fenicsproject.org
Other
140 stars 39 forks source link

Optimize partitions #683

Closed jorgensd closed 2 months ago

jorgensd commented 2 months ago

Changes the optimized code in #682 from

// ------------------------ 
// Section: Jacobian
// Inputs: coordinate_dofs, FE2_C0_D10_Q39d
// Outputs: J_c0
double J_c0 = 0.0;
{
  for (int ic = 0; ic < 3; ++ic)
  {
    J_c0 += coordinate_dofs[(ic) * 3] * FE2_C0_D10_Q39d[0][0][0][ic];
  }
}
// ------------------------ 
// ------------------------ 
// Section: Jacobian
// Inputs: coordinate_dofs, FE2_C1_D01_Q39d
// Outputs: J_c3
double J_c3 = 0.0;
{
  for (int ic = 0; ic < 3; ++ic)
  {
    J_c3 += coordinate_dofs[(ic) * 3 + 1] * FE2_C1_D01_Q39d[0][0][0][ic];
  }
}
// ------------------------ 
// ------------------------ 
// Section: Jacobian
// Inputs: coordinate_dofs, FE2_C1_D01_Q39d
// Outputs: J_c1
double J_c1 = 0.0;
{
  for (int ic = 0; ic < 3; ++ic)
  {
    J_c1 += coordinate_dofs[(ic) * 3] * FE2_C1_D01_Q39d[0][0][0][ic];
  }
}
// ------------------------ 
// ------------------------ 
// Section: Jacobian
// Inputs: coordinate_dofs, FE2_C0_D10_Q39d
// Outputs: J_c2
double J_c2 = 0.0;
{
  for (int ic = 0; ic < 3; ++ic)
  {
    J_c2 += coordinate_dofs[(ic) * 3 + 1] * FE2_C0_D10_Q39d[0][0][0][ic];
  }
}

to

/ ------------------------ 
// Section: Jacobian
// Inputs: coordinate_dofs, FE2_C1_D01_Q39d, FE2_C0_D10_Q39d
// Outputs: J_c1, J_c3, J_c2, J_c0
double J_c0 = 0.0;
double J_c3 = 0.0;
double J_c1 = 0.0;
double J_c2 = 0.0;
{
  for (int ic = 0; ic < 3; ++ic)
  {
    J_c0 += coordinate_dofs[(ic) * 3] * FE2_C0_D10_Q39d[0][0][0][ic];
    J_c3 += coordinate_dofs[(ic) * 3 + 1] * FE2_C1_D01_Q39d[0][0][0][ic];
    J_c1 += coordinate_dofs[(ic) * 3] * FE2_C1_D01_Q39d[0][0][0][ic];
    J_c2 += coordinate_dofs[(ic) * 3 + 1] * FE2_C0_D10_Q39d[0][0][0][ic];
  }
}