Small Fixes / enhancement to project_tool
This commit is contained in:
parent
7a61ad7519
commit
34eac2721a
@ -5,14 +5,14 @@ template<typename T, typename ProdType>
|
|||||||
static T project_tool(T *vertex_value, T *u, T *u0)
|
static T project_tool(T *vertex_value, T *u, T *u0)
|
||||||
{
|
{
|
||||||
T ret0 = 0;
|
T ret0 = 0;
|
||||||
for (int i = 0; i < 8; i++)
|
for (unsigned int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
int c[3] = { i & 1, (i>>1)&1, (i>>2)&1 };
|
unsigned int c[3] = { i & 1, (i>>1)&1, (i>>2)&1 };
|
||||||
int epsilon[3];
|
int epsilon[3];
|
||||||
T ret = 0;
|
T ret = 0;
|
||||||
|
|
||||||
for (int q = 0; q < 3; q++)
|
for (int q = 0; q < 3; q++)
|
||||||
epsilon[q] = (2*c[q]-1);
|
epsilon[q] = 2*c[q]-1;
|
||||||
|
|
||||||
for (int q = 0; q < ProdType::numProducts; q++)
|
for (int q = 0; q < ProdType::numProducts; q++)
|
||||||
ret += ProdType::product(u, u0, epsilon, q);
|
ret += ProdType::product(u, u0, epsilon, q);
|
||||||
@ -27,7 +27,8 @@ static T project_tool(T *vertex_value, T *u, T *u0)
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
static inline T get_u0(const T& u0, int epsilon)
|
static inline T get_u0(const T& u0, int epsilon)
|
||||||
{
|
{
|
||||||
return (epsilon > 0) ? u0 : (1-u0);
|
return (1-epsilon)/2 + epsilon*u0;
|
||||||
|
// return (epsilon > 0) ? u0 : (1-u0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -39,7 +40,7 @@ struct ProductTerm0
|
|||||||
{
|
{
|
||||||
T a = 1;
|
T a = 1;
|
||||||
|
|
||||||
for (int r = 0; r < 3; r++)
|
for (unsigned int r = 0; r < 3; r++)
|
||||||
a *= get_u0(u0[r], epsilon[r]);
|
a *= get_u0(u0[r], epsilon[r]);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@ -54,14 +55,14 @@ struct ProductTerm1
|
|||||||
static T product(T *u, T *u0, int *epsilon, int q)
|
static T product(T *u, T *u0, int *epsilon, int q)
|
||||||
{
|
{
|
||||||
T a = 1;
|
T a = 1;
|
||||||
double G[3];
|
T G[3];
|
||||||
|
|
||||||
for (int r = 0; r < 3; r++)
|
for (unsigned int r = 0; r < 3; r++)
|
||||||
{
|
{
|
||||||
G[r] = get_u0(u0[r], epsilon[r]);
|
G[r] = get_u0(u0[r], epsilon[r]);
|
||||||
}
|
}
|
||||||
|
|
||||||
double F[3] = { G[1]*G[2], G[0]*G[2], G[0]*G[1] };
|
T F[3] = { G[1]*G[2], G[0]*G[2], G[0]*G[1] };
|
||||||
|
|
||||||
return F[q] * u[q] * epsilon[q];
|
return F[q] * u[q] * epsilon[q];
|
||||||
}
|
}
|
||||||
@ -75,14 +76,14 @@ struct ProductTerm2
|
|||||||
static inline T product(T *u, T *u0, int *epsilon, int q)
|
static inline T product(T *u, T *u0, int *epsilon, int q)
|
||||||
{
|
{
|
||||||
T a = 1;
|
T a = 1;
|
||||||
double G[3];
|
T G[3];
|
||||||
|
|
||||||
for (int r = 0; r < 3; r++)
|
for (unsigned int r = 0; r < 3; r++)
|
||||||
{
|
{
|
||||||
G[r] = get_u0(u0[r], epsilon[r]);
|
G[r] = get_u0(u0[r], epsilon[r]);
|
||||||
}
|
}
|
||||||
|
|
||||||
double F[3] = { epsilon[1]*epsilon[2]*u[1]*u[2], epsilon[0]*epsilon[2]*u[0]*u[2], epsilon[0]*epsilon[1]*u[0]*u[1] };
|
T F[3] = { epsilon[1]*epsilon[2]*u[1]*u[2], epsilon[0]*epsilon[2]*u[0]*u[2], epsilon[0]*epsilon[1]*u[0]*u[1] };
|
||||||
|
|
||||||
return F[q] * G[q];
|
return F[q] * G[q];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user