|
@@ -50,28 +50,50 @@ namespace Kernel{
|
|
|
|
|
|
void
|
|
|
Richards::run(){
|
|
|
- if(Debug::level>0 and Debug::ix==ix) cout<<" [Richards::run] start"<<endl;
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix) cout<<" [Richards::run] start"<<endl;
|
|
|
+ #endif
|
|
|
norm_previous_P=norm2(previous_P,nZ);
|
|
|
has_converged=weighted_run(1);
|
|
|
if(!has_converged) has_converged=weighted_run(0.5);
|
|
|
- if(Debug::level>0 and Debug::ix==ix) cout<<" [Richards::run] stop"<<endl;
|
|
|
+
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix) cout<<" [Richards::run] stop"<<endl;
|
|
|
+ #endif
|
|
|
|
|
|
}
|
|
|
|
|
|
bool
|
|
|
Richards::weighted_run(double w){
|
|
|
- if(Debug::level>0 and Debug::ix==ix) cout<<" [Richards::weighted_run] start"<<endl;
|
|
|
- if(Debug::level>0 and Debug::ix==ix) cout<<" [Richards::weighted_run] w = "<<w<<endl;
|
|
|
+ Debug::debug_Thomas=(Debug::ix==ix);
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix){
|
|
|
+ cout<<" [Richards::weighted_run] start"<<endl;
|
|
|
+ cout<<" [Richards::weighted_run] w = "<<w<<endl;
|
|
|
+ }
|
|
|
+ #endif
|
|
|
double error=numeric_limits<double>::infinity();
|
|
|
size_t count=0;
|
|
|
in_P=near_P;
|
|
|
out_P=temp_P[1];
|
|
|
while(error>=tolerence_Richards and count<max_iterations_Richards){
|
|
|
++count;
|
|
|
+
|
|
|
+ #ifdef MYDEBUG
|
|
|
if(Debug::level>1 and Debug::ix==ix) cout<<" [Richards::weighted_run] count = "<<count<<endl;
|
|
|
+ #endif
|
|
|
+
|
|
|
solve_system();
|
|
|
|
|
|
+ if(w<1){
|
|
|
+ for(size_t i=0;i<nZ;++i){
|
|
|
+ out_P[i]=w*out_P[i]+(1-w)*in_P[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
//Computed P is in out_P=temp_P[count%2]
|
|
|
+ /*if(Debug::ix==ix) Debug::display("in_P",in_P,0,nZ);
|
|
|
+ if(Debug::ix==ix) Debug::display("out_P",out_P,0,nZ);*/
|
|
|
+
|
|
|
error=error2(in_P,out_P,nZ)/norm_previous_P;
|
|
|
if(count==1){
|
|
|
in_P=temp_P[1];
|
|
@@ -80,29 +102,39 @@ namespace Kernel{
|
|
|
else{
|
|
|
swap(in_P,out_P);
|
|
|
}
|
|
|
- }
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix){
|
|
|
+ cout<<" [Richards::weighted_run] error = "<<error<<endl;;
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+ }
|
|
|
if(error<tolerence_Richards){
|
|
|
//Last computed P is in temp_P[count%2] which is now also in_P
|
|
|
assert(in_P==temp_P[count%2]);
|
|
|
swap(P,temp_P[count%2]);
|
|
|
+ #ifdef MYDEBUG
|
|
|
if(Debug::ix==ix){
|
|
|
if(Debug::level>1) cout<<" [Richards::weighted_run] converge"<<endl;
|
|
|
- if(Debug::level>0) cout<<" [Richards::weighted_run] stop"<<endl;
|
|
|
+ cout<<" [Richards::weighted_run] stop"<<endl;
|
|
|
}
|
|
|
+ #endif
|
|
|
return true;
|
|
|
}
|
|
|
- if(Debug::level>0 and Debug::ix==ix){
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix){
|
|
|
cout<<" [Richards::weighted_run] not converge"<<endl;
|
|
|
cout<<" [Richards::weighted_run] stop"<<endl;
|
|
|
}
|
|
|
+ #endif
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
void
|
|
|
Richards::solve_system(){
|
|
|
- if(Debug::level>0 and Debug::ix==ix) cout<<" [Richards::solve_system] start"<<endl;
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix) cout<<" [Richards::solve_system] start"<<endl;
|
|
|
assert(nZ>=3);
|
|
|
-
|
|
|
+ #endif
|
|
|
//Compute A
|
|
|
diag_A[0]=(Physics::phi*dZ*Physics::ds(in_P[0]))/(2*dt);
|
|
|
for(size_t i=1;i<nZ-1;++i){
|
|
@@ -167,7 +199,7 @@ namespace Kernel{
|
|
|
//TODO : Add BB computation from fpump
|
|
|
|
|
|
//Compute F
|
|
|
- F[0]=div_w[0]*dZ+R[0]-G[0]-I[0]-S[0]-H[0]+(diag_A[0]+diag_C[0])*in_P[0]+sup_C[0]*in_P[1];
|
|
|
+ F[0]=R[0]-G[0]-I[0]-S[0]-H[0]+(diag_A[0]+diag_C[0])*in_P[0]+sup_C[0]*in_P[1];
|
|
|
for(size_t i=1;i<nZ-2;++i){
|
|
|
F[i]=div_w[i]*dZ+R[i]-G[i]-I[i]-S[i]-H[i]+(diag_A[i]+diag_C[i])*in_P[i]+sub_C[i-1]*in_P[i-1]+sup_C[i]*in_P[i+1];
|
|
|
}
|
|
@@ -182,13 +214,15 @@ namespace Kernel{
|
|
|
sup_A[i]=(sup_B[i]+sup_C[i]);
|
|
|
}
|
|
|
diag_A[nZ-2]+=(diag_B[nZ-2]+diag_C[nZ-2]);
|
|
|
-
|
|
|
+ //Debug::display("sup_A",sup_A,0,nZ-2);
|
|
|
Thomas(nZ-1,sub_A,diag_A,sup_A,F,out_P);
|
|
|
out_P[nZ-1]=in_P[nZ-1];
|
|
|
- if(Debug::level>0 and Debug::ix==ix){
|
|
|
+ #ifdef MYDEBUG
|
|
|
+ if(Debug::ix==ix){
|
|
|
cout<<" [Richards::solve_system] out = "<<out_P<<endl;
|
|
|
cout<<" [Richards::solve_system] stop"<<endl;
|
|
|
}
|
|
|
+ #endif
|
|
|
|
|
|
}
|
|
|
}
|