F_BiotSavart.cpp (getdp-3.4.0-source.tgz) | : | F_BiotSavart.cpp (getdp-3.5.0-source.tgz) | ||
---|---|---|---|---|
// GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege | // GetDP - Copyright (C) 1997-2022 P. Dular and C. Geuzaine, University of Liege | |||
// | // | |||
// See the LICENSE.txt file for license information. Please report all | // See the LICENSE.txt file for license information. Please report all | |||
// issues on https://gitlab.onelab.info/getdp/getdp/issues. | // issues on https://gitlab.onelab.info/getdp/getdp/issues. | |||
// | // | |||
// Contributor(s): | // Contributor(s): | |||
// Ruth Sabariego | // Ruth Sabariego | |||
// | // | |||
#include <math.h> | #include <math.h> | |||
#include "ProData.h" | #include "ProData.h" | |||
#include "F.h" | #include "F.h" | |||
#include "Message.h" | #include "Message.h" | |||
#define ONE_OVER_TWO_PI 1.5915494309189534E-01 | #define ONE_OVER_TWO_PI 1.5915494309189534E-01 | |||
#define ONE_OVER_FOUR_PI 7.9577471545947668E-02 | #define ONE_OVER_FOUR_PI 7.9577471545947668E-02 | |||
#define SQU(a) ((a)*(a)) | #define SQU(a) ((a) * (a)) | |||
#define CUB(a) ((a)*(a)*(a)) | #define CUB(a) ((a) * (a) * (a)) | |||
extern struct CurrentData Current ; | extern struct CurrentData Current; | |||
/* ------------------------------------------------------------------------ */ | /* ------------------------------------------------------------------------ */ | |||
/* F _ B i o t S a v a r t */ | /* F _ B i o t S a v a r t */ | |||
/* ------------------------------------------------------------------------ */ | /* ------------------------------------------------------------------------ */ | |||
void F_BiotSavart(F_ARG) | void F_BiotSavart(F_ARG) | |||
{ | { | |||
double r, xxs, yys, zzs ; | double r, xxs, yys, zzs; | |||
V->Type = VECTOR ; | V->Type = VECTOR; | |||
switch((int)Fct->Para[0]){ | switch((int)Fct->Para[0]) { | |||
case DIM_2D : | case DIM_2D: | |||
xxs = Current.x-Current.xs ; | xxs = Current.x - Current.xs; | |||
yys = Current.y-Current.ys ; | yys = Current.y - Current.ys; | |||
r = SQU(xxs)+SQU(yys) ; | r = SQU(xxs) + SQU(yys); | |||
if(!r) Message::Error("1/0 in 'F_BiotSavart'") ; | if(!r) Message::Error("1/0 in 'F_BiotSavart'"); | |||
V->Val[0] = ONE_OVER_TWO_PI * xxs / r ; | V->Val[0] = ONE_OVER_TWO_PI * xxs / r; | |||
V->Val[1] = ONE_OVER_TWO_PI * yys / r ; | V->Val[1] = ONE_OVER_TWO_PI * yys / r; | |||
V->Val[2] = 0. ; | V->Val[2] = 0.; | |||
V->Val[MAX_DIM ] = V->Val[MAX_DIM + 1] = V->Val[MAX_DIM + 2] = 0. ; | V->Val[MAX_DIM] = V->Val[MAX_DIM + 1] = V->Val[MAX_DIM + 2] = 0.; | |||
break; | break; | |||
case DIM_3D : | case DIM_3D: | |||
xxs = Current.x-Current.xs ; | xxs = Current.x - Current.xs; | |||
yys = Current.y-Current.ys ; | yys = Current.y - Current.ys; | |||
zzs = Current.z-Current.zs ; | zzs = Current.z - Current.zs; | |||
r = sqrt(SQU(xxs)+SQU(yys)+SQU(zzs)) ; | r = sqrt(SQU(xxs) + SQU(yys) + SQU(zzs)); | |||
if(!r) Message::Error("1/0 in 'F_BiotSavart'") ; | if(!r) Message::Error("1/0 in 'F_BiotSavart'"); | |||
V->Val[0] = ONE_OVER_FOUR_PI * xxs/ CUB(r) ; | V->Val[0] = ONE_OVER_FOUR_PI * xxs / CUB(r); | |||
V->Val[1] = ONE_OVER_FOUR_PI * yys/ CUB(r) ; | V->Val[1] = ONE_OVER_FOUR_PI * yys / CUB(r); | |||
V->Val[2] = ONE_OVER_FOUR_PI * zzs/ CUB(r) ; | V->Val[2] = ONE_OVER_FOUR_PI * zzs / CUB(r); | |||
V->Val[MAX_DIM] = V->Val[MAX_DIM + 1 ] = V->Val[MAX_DIM + 2 ] =0. ; | V->Val[MAX_DIM] = V->Val[MAX_DIM + 1] = V->Val[MAX_DIM + 2] = 0.; | |||
break; | ||||
default: | ||||
Message::Error("Bad dimension for BiotSavart"); | ||||
break; | break; | |||
default: Message::Error("Bad dimension for BiotSavart"); break; | ||||
} | } | |||
} | } | |||
void F_Pocklington(F_ARG) | void F_Pocklington(F_ARG) | |||
{ | { | |||
double r, xxs, yys, zzs ; | double r, xxs, yys, zzs; | |||
double k , kr, cte, a, re, im ; | double k, kr, cte, a, re, im; | |||
V->Type = SCALAR ; | V->Type = SCALAR; | |||
k = Fct->Para[0] ; | k = Fct->Para[0]; | |||
a = Fct->Para[1] ; | a = Fct->Para[1]; | |||
xxs = Current.x-Current.xs ; | xxs = Current.x - Current.xs; | |||
yys = Current.y-Current.ys ; | yys = Current.y - Current.ys; | |||
zzs = Current.z-Current.zs ; | zzs = Current.z - Current.zs; | |||
r = sqrt(SQU(xxs)+SQU(yys)+SQU(zzs)+ a*a ) ; | r = sqrt(SQU(xxs) + SQU(yys) + SQU(zzs) + a * a); | |||
if(!r) Message::Error("1/0 in 'F_Pocklington'") ; | if(!r) Message::Error("1/0 in 'F_Pocklington'"); | |||
kr = k*r ; | kr = k * r; | |||
cte = ONE_OVER_FOUR_PI/(r*r*r*r*r); | cte = ONE_OVER_FOUR_PI / (r * r * r * r * r); | |||
re = 2*SQU(r)-3*SQU(a) + SQU(kr*a); | re = 2 * SQU(r) - 3 * SQU(a) + SQU(kr * a); | |||
im = kr * (2*SQU(r)-3*SQU(a)) ; | im = kr * (2 * SQU(r) - 3 * SQU(a)); | |||
V->Val[0] = cte * (cos(kr)* re + sin(kr)*im) ; | V->Val[0] = cte * (cos(kr) * re + sin(kr) * im); | |||
V->Val[MAX_DIM] = cte * (-sin(kr) * re + cos(kr)*im) ; | V->Val[MAX_DIM] = cte * (-sin(kr) * re + cos(kr) * im); | |||
} | } | |||
#undef F_ARG | #undef F_ARG | |||
End of changes. 16 change blocks. | ||||
52 lines changed or deleted | 50 lines changed or added |