Skip to content
Snippets Groups Projects
Commit a90ccfa8 authored by Ling Wu's avatar Ling Wu
Browse files

bug

parent b8b7bd54
No related branches found
No related tags found
No related merge requests found
......@@ -48,11 +48,11 @@ Yarn_class::~Yarn_class(){};
//**************** Gaussian Point in Yarn ? **************************
double Yarn_class::WireFunc(const double x, const double b, const double L) const{
double tmp;
if( _WirGeo == "Logistic"){
if( strcmp(_WirGeo, "Logistic")==0){
tmp = 1.0/(1.0+exp(-L*x));
return 2.0*b*tmp-b;
}
else if(_WirGeo == "Cos"){
else if(strcmp(_WirGeo, "Cos")==0){
tmp = 2.0*PI/L;
return b*cos(tmp*x);
}
......@@ -60,11 +60,11 @@ double Yarn_class::WireFunc(const double x, const double b, const double L) cons
double Yarn_class::WireFunc_Tang(const double x, const double b, const double L)const {
double tmp;
if( _WirGeo == "Logistic"){
if( strcmp(_WirGeo, "Logistic")==0){
tmp = 1.0/(1.0+exp(-L*x));
return 2.0*b*tmp*(1.0-tmp)*L;
}
else if(_WirGeo == "Cos"){
else if(strcmp(_WirGeo, "Cos")==0){
tmp = 2.0*PI/L;
return -b*sin(tmp*x)*tmp;
}
......@@ -82,17 +82,17 @@ void Yarn_class::Inside_Yarn(const SVector3 &GaussP, double& k, double* V_Rand)c
y = GaussP(1) - _OrigY;
z = GaussP(2);
if( _WirGeo == "Logistic"){
if( strcmp(_WirGeo, "Logistic")==0){
L=_l;
b = -_OrigZ;
if(_Warp_Weft == "Weft") {
if(strcmp(_Warp_Weft, "Weft")==0) {
if( x <= _L/2.0) x = x-_L/4.0;
else{
x = x-3.0*_L/4.0;
b = -b;
}
}
else if(_Warp_Weft == "Warp"){
else if(strcmp(_Warp_Weft,"Warp")==0){
if( y <= _L/2.0) y = y -_L/4.0;
else{
y = y-3.0*_L/4.0;
......@@ -100,12 +100,12 @@ void Yarn_class::Inside_Yarn(const SVector3 &GaussP, double& k, double* V_Rand)c
}
}
}
else if(_WirGeo == "Cos"){
else if(strcmp(_WirGeo, "Cos")==0){
b = _OrigZ;
L=_L;
}
if(_Warp_Weft == "Weft"){
if(strcmp(_Warp_Weft,"Weft")==0){
x0 = x;
x0 = gradient_descent(x0, error, gamma, max_iters, x, z, b, L);
z0 = WireFunc(x0, b, L);
......@@ -118,7 +118,7 @@ void Yarn_class::Inside_Yarn(const SVector3 &GaussP, double& k, double* V_Rand)c
}
}
else if(_Warp_Weft == "Warp"){
else if(strcmp(_Warp_Weft,"Warp")==0){
y0 = y;
y0 = gradient_descent(y0, error, gamma, max_iters, y, z, b, L);
z0 = WireFunc(y0, b, L);
......@@ -137,13 +137,13 @@ void Yarn_class::Inside_Yarn(const SVector3 &GaussP, double& k, double* V_Rand)c
//******************************
double Yarn_class::dfx(const double x, const double xG, const double yG, const double b, const double L) const {
if(_WirGeo == "Cos"){
if(strcmp(_WirGeo, "Cos")==0){
double tmp = 2.0*PI/L;
return 2.0*(x-xG) - 2.0*tmp*b*(b*cos(tmp*x)-yG)*sin(tmp*x);
}
else if(_WirGeo == "Logistic"){
else if(strcmp(_WirGeo,"Logistic")==0){
double tmp = 1.0/(1.0+exp(-L*x));
return 2.0*(x-xG) - 2.0*(2.0*b*tmp-b-yG)*2.0*b*tmp*(1.0-tmp)*L;
return 2.0*(x-xG) + 2.0*(2.0*b*tmp-b-yG)*2.0*b*tmp*(1.0-tmp)*L;
}
else{
printf("The center line function is not implemented! \n");
......@@ -220,26 +220,27 @@ Random_Feul::Random_Feul(const double* mean, const SVector3& Ldomain, const doub
_Eul_mean[1] = mean[1];
_Eul_mean[2] = mean[2];
if (Geo!= NULL ) _Geo = Geo;
if(_Geo == "Cos" or _Geo == "Logistic"){
if(strcmp(_Geo,"Cos")==0 or strcmp(_Geo,"Logistic")==0){
double a = dx;
double b = dy;
double L = _Ldomain.x();
double l = dz;
double tmpX, tmpY;
double tmpX, tmpY,tmpZ;
char* weft = "Weft";
char* warp = "Warp";
tmpY = _OrigY - L/2.0;
Weft1 = init_Yarn(_OrigX, tmpY, _OrigZ, a, b, L, l, _Geo, weft);
Weft2 = init_Yarn(_OrigX, _OrigY, _OrigZ, a, b, L, l, _Geo, weft);
tmpZ = b;
Weft1 = init_Yarn(_OrigX, tmpY, -tmpZ, a, b, L, l, _Geo, weft);
Weft2 = init_Yarn(_OrigX, _OrigY, tmpZ, a, b, L, l, _Geo, weft);
tmpY = _OrigY + L/2.0;
Weft3 = init_Yarn(_OrigX, tmpY, _OrigZ, a, b, L, l, _Geo, weft);
Weft3 = init_Yarn(_OrigX, tmpY, -tmpZ, a, b, L, l, _Geo, weft);
tmpY = _OrigY - L/2.0;
Warp1 = init_Yarn(_OrigX, tmpY, _OrigZ, a, b, L, l, _Geo, warp);
Warp1 = init_Yarn(_OrigX, tmpY, tmpZ, a, b, L, l, _Geo, warp);
tmpX = _OrigX + L/2.0;
Warp2 = init_Yarn(tmpX, tmpY, _OrigZ, a, b, L, l, _Geo, warp);
Warp2 = init_Yarn(tmpX, tmpY, -tmpZ, a, b, L, l, _Geo, warp);
tmpX = _OrigX + L;
Warp3 = init_Yarn(tmpX, tmpY, _OrigZ, a, b, L, l, _Geo, warp);
Warp3 = init_Yarn(tmpX, tmpY, tmpZ, a, b, L, l, _Geo, warp);
}
malloctens4(&_RF_eul,_nx,_ny,_nz,3);
......@@ -339,7 +340,7 @@ Random_Feul::~Random_Feul(){
void Random_Feul::RandomGen(const SVector3 &GaussP, double* V_Rand){
if(strcmp(_Geo,"Cylinder")==1)
if(strcmp(_Geo,"Cylinder")==0)
{
if(_Eul_mean[0] == 0.0){
V_Rand[0] = 0.0;
......@@ -357,7 +358,7 @@ void Random_Feul::RandomGen(const SVector3 &GaussP, double* V_Rand){
V_Rand[2] = 0.0;
}
}
else if(strcmp(_Geo,"Cos")==1 or strcmp(_Geo,"Logistic")==1){
else if(strcmp(_Geo,"Cos")==0 or strcmp(_Geo,"Logistic")==0){
double x, y;
double L = _Ldomain.x();
const Yarn_class* TWeft, *TWarp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment