Skip to content

Instantly share code, notes, and snippets.

@miklos1

miklos1/kernel.c Secret

Created October 21, 2016 15:14
Show Gist options
  • Save miklos1/af96b65ed1a24335560d352cf5a011dc to your computer and use it in GitHub Desktop.
Save miklos1/af96b65ed1a24335560d352cf5a011dc to your computer and use it in GitHub Desktop.
v*ds on Q7 elements in 2D
static inline void form_exterior_facet_integral_otherwise (double A[64] , const double *const restrict *restrict coords , const unsigned int facet[1] )
{
static const double t0[4][4][8] = {{{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
{{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
{{0.221137963127625, 0.0164996153238121, 1.46377499571231, -1.49080224180464, 1.49632790286375, -1.07050614469824, 0.50001149659949, -0.136443587124107},
{0.00437442722015047, 0.00215466099507914, -0.0539946086792379, 0.684400487401667, 0.512632769204898, -0.209287860703739, 0.0788902578034804, -0.0191701332422974},
{0.00215466099507912, 0.00437442722015036, -0.0191701332422973, 0.0788902578034797, -0.209287860703738, 0.512632769204897, 0.684400487401668, -0.0539946086792376},
{0.016499615323812, 0.221137963127625, -0.136443587124107, 0.500011496599491, -1.07050614469824, 1.49632790286375, -1.49080224180464, 1.46377499571231}},
{{0.221137963127625, 0.0164996153238121, 1.46377499571231, -1.49080224180464, 1.49632790286375, -1.07050614469824, 0.50001149659949, -0.136443587124107},
{0.00437442722015047, 0.00215466099507914, -0.0539946086792379, 0.684400487401667, 0.512632769204898, -0.209287860703739, 0.0788902578034804, -0.0191701332422974},
{0.00215466099507912, 0.00437442722015036, -0.0191701332422973, 0.0788902578034797, -0.209287860703738, 0.512632769204897, 0.684400487401668, -0.0539946086792376},
{0.016499615323812, 0.221137963127625, -0.136443587124107, 0.500011496599491, -1.07050614469824, 1.49632790286375, -1.49080224180464, 1.46377499571231}}};
static const double t1[4][2][1] = {{{0.0},
{1.0}},
{{0.0},
{1.0}},
{{1.0},
{0.0}},
{{1.0},
{0.0}}};
static const double t2[4][4][2] = {{{1.0, 0.0},
{1.0, 0.0},
{1.0, 0.0},
{1.0, 0.0}},
{{0.0, 1.0},
{0.0, 1.0},
{0.0, 1.0},
{0.0, 1.0}},
{{0.930568155797026, 0.0694318442029737},
{0.669990521792428, 0.330009478207572},
{0.330009478207572, 0.669990521792428},
{0.0694318442029737, 0.930568155797026}},
{{0.930568155797026, 0.0694318442029737},
{0.669990521792428, 0.330009478207572},
{0.330009478207572, 0.669990521792428},
{0.0694318442029737, 0.930568155797026}}};
static const double t3[4][4][2] = {{{0.930568155797026, 0.0694318442029737},
{0.669990521792428, 0.330009478207572},
{0.330009478207572, 0.669990521792428},
{0.0694318442029737, 0.930568155797026}},
{{0.930568155797026, 0.0694318442029737},
{0.669990521792428, 0.330009478207572},
{0.330009478207572, 0.669990521792428},
{0.0694318442029737, 0.930568155797026}},
{{1.0, 0.0},
{1.0, 0.0},
{1.0, 0.0},
{1.0, 0.0}},
{{0.0, 1.0},
{0.0, 1.0},
{0.0, 1.0},
{0.0, 1.0}}};
static const double t4[4] = {0.173927422568727, 0.326072577431273, 0.326072577431273, 0.173927422568727};
static const double t5[4][4][8] = {{{0.221137963127625, 0.0164996153238121, 1.46377499571231, -1.49080224180464, 1.49632790286375, -1.07050614469824, 0.50001149659949, -0.136443587124107},
{0.00437442722015047, 0.00215466099507914, -0.0539946086792379, 0.684400487401667, 0.512632769204898, -0.209287860703739, 0.0788902578034804, -0.0191701332422974},
{0.00215466099507912, 0.00437442722015036, -0.0191701332422973, 0.0788902578034797, -0.209287860703738, 0.512632769204897, 0.684400487401668, -0.0539946086792376},
{0.016499615323812, 0.221137963127625, -0.136443587124107, 0.500011496599491, -1.07050614469824, 1.49632790286375, -1.49080224180464, 1.46377499571231}},
{{0.221137963127625, 0.0164996153238121, 1.46377499571231, -1.49080224180464, 1.49632790286375, -1.07050614469824, 0.50001149659949, -0.136443587124107},
{0.00437442722015047, 0.00215466099507914, -0.0539946086792379, 0.684400487401667, 0.512632769204898, -0.209287860703739, 0.0788902578034804, -0.0191701332422974},
{0.00215466099507912, 0.00437442722015036, -0.0191701332422973, 0.0788902578034797, -0.209287860703738, 0.512632769204897, 0.684400487401668, -0.0539946086792376},
{0.016499615323812, 0.221137963127625, -0.136443587124107, 0.500011496599491, -1.07050614469824, 1.49632790286375, -1.49080224180464, 1.46377499571231}},
{{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
{{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
{0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
for (int ip = 0; ip < 4; ip += 1)
{
double t6 = (1 * (-1 * t3[facet[0]][ip][0]));
double t7 = (1 * (1 * t3[facet[0]][ip][0]));
double t8 = (1 * (-1 * t3[facet[0]][ip][1]));
double t9 = (1 * (1 * t3[facet[0]][ip][1]));
double t10 = (1 * (t2[facet[0]][ip][0] * -1));
double t11 = (1 * (t2[facet[0]][ip][1] * -1));
double t12 = (1 * (t2[facet[0]][ip][0] * 1));
double t13 = (1 * (t2[facet[0]][ip][1] * 1));
double t14 = ((t1[facet[0]][0][0] * (((t6 * coords[0][0]) + (t7 * coords[2][0])) + ((t8 * coords[1][0]) + (t9 * coords[3][0])))) + (t1[facet[0]][1][0] * (((t10 * coords[0][0]) + (t11 * coords[2][0])) + ((t12 * coords[1][0]) + (t13 * coords[3][0])))));
double t15 = ((t1[facet[0]][0][0] * (((t6 * coords[0][1]) + (t7 * coords[2][1])) + ((t8 * coords[1][1]) + (t9 * coords[3][1])))) + (t1[facet[0]][1][0] * (((t10 * coords[0][1]) + (t11 * coords[2][1])) + ((t12 * coords[1][1]) + (t13 * coords[3][1])))));
double t16 = (t4[ip] * sqrt((t14 * t14) + (t15 * t15)));
for (int j0 = 0; j0 < 8; j0 += 1)
{
for (int j1 = 0; j1 < 8; j1 += 1)
{
#pragma coffee expression
A[(0 + (j0 * 8)) + (j1 * 1)] += t16 * (t0[facet[0]][ip][j0] * t5[facet[0]][ip][j1]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment