10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
14 #include "../classes.h"
27 #define AEPS 2.2204460492503131E-015
45 this->
sid=channel_id-1;
53 this->
S = channelarea;
54 this->
Sold = channelarea;
57 int i1 = iomodel->
faces[4*index+0];
58 int i2 = iomodel->
faces[4*index+1];
59 int e1 = iomodel->
faces[4*index+2];
60 int e2 = iomodel->
faces[4*index+3];
73 int channel_vertex_ids[2];
74 channel_vertex_ids[0]=i1;
75 channel_vertex_ids[1]=i2;
79 int channel_node_ids[2];
80 channel_node_ids[0]=i1;
81 channel_node_ids[1]=i2;
100 channel->
id=this->
id;
148 void Channel::Marshall(
char** pmarshalled_data,
int* pmarshalled_data_size,
int marshall_direction){
163 this->
hnodes->
Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
164 this->
helement->
Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
165 this->
hvertices->
Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction);
203 switch(analysis_type){
208 _error_(
"Don't know why we should be here");
226 switch(analysis_type){
231 _error_(
"Don't know why we should be here");
307 if(!flags[this->
nodes[i]->Lid()]){
313 while(flagsindices[counter]>=0) counter++;
314 flagsindices[counter]=this->nodes[i]->Lid();
320 if(this->nodes[i]->IsClone())
328 if(this->nodes[i]->IsClone())
336 if(this->nodes[i]->IsClone())
342 default:
_error_(
"not supported");
364 IssmDouble Jdet,v1,qc,fFactor,Afactor,Bfactor,Xifactor;
365 IssmDouble A,B,n,phi_old,phi,phi_0,dPw,ks,Ngrad;
366 IssmDouble H,h,b,dphi[2],dphids,dphimds,db[2],dbds;
398 IssmDouble tx = xyz_list_tria[index2][0] - xyz_list_tria[index1][0];
399 IssmDouble ty = xyz_list_tria[index2][1] - xyz_list_tria[index1][1];
406 for(
int ig=gauss->
begin();ig<gauss->end();ig++){
412 dbasisds[0] = dbasisdx[0*2+0]*tx + dbasisdx[0*2+1]*ty;
413 dbasisds[1] = dbasisdx[1*2+0]*tx + dbasisdx[1*2+1]*ty;
427 phi_0 = rho_water*g*b + rho_ice*g*H;
428 dphids = dphi[0]*tx + dphi[1]*ty;
429 dphimds = rho_water*g*(db[0]*tx + db[1]*ty);
430 Ngrad = fabs(dphids);
441 dPw = dphids - dphimds;
445 if(this->
S>0. || qc*dPw>0.){
450 Afactor =
C_W*c_t*rho_water;
451 Bfactor = 1./L * (1./rho_ice - 1./rho_water);
453 Xifactor = + Bfactor * (fabs(-Kc*dphids) + fabs(lc*qc));
456 Xifactor = - Bfactor * (fabs(-Kc*dphids) + fabs(lc*qc));
460 for(
int i=0;i<numnodes;i++){
461 for(
int j=0;j<numnodes;j++){
464 +Kc*dbasisds[i]*dbasisds[j]
465 - Afactor * Bfactor* Kc * dPw * basis[i] * dbasisds[j]
466 + Afactor * fFactor * Bfactor * basis[i] * dbasisds[j]
467 + Xifactor* basis[i] * dbasisds[j]
474 v1 = 2./pow(n,n)*A*
S*(pow(fabs(phi_0 - phi),n-1.)*( - n));
475 for(
int i=0;i<numnodes;i++){
476 for(
int j=0;j<numnodes;j++){
477 Ke->
values[i*numnodes+j] += gauss->
weight*Jdet*(-v1)*basis[i]*basis[j];
498 IssmDouble A,B,n,phi_old,phi,phi_0,dphimds,dphi[2];
499 IssmDouble H,h,b,db[2],dphids,qc,dPw,ks,Ngrad;
529 IssmDouble tx = xyz_list_tria[index2][0] - xyz_list_tria[index1][0];
530 IssmDouble ty = xyz_list_tria[index2][1] - xyz_list_tria[index1][1];
537 for(
int ig=gauss->
begin();ig<gauss->end();ig++){
555 phi_0 = rho_water*g*b + rho_ice*g*H;
556 dphids = dphi[0]*tx + dphi[1]*ty;
557 dphimds = rho_water*g*(db[0]*tx + db[1]*ty);
558 Ngrad = fabs(dphids);
568 dPw = dphids - dphimds;
572 if(this->
S>0. || qc*dPw>0.){
577 Afactor =
C_W*c_t*rho_water;
578 Bfactor = 1./L * (1./rho_ice - 1./rho_water);
583 v2 = 2./pow(n,n)*A*this->
S*(pow(fabs(phi_0 - phi),n-1.)*(phi_0 +(n-1.)*phi));
585 for(
int i=0;i<numnodes;i++){
587 pe->
values[i]+= + Jdet*gauss->
weight*Afactor*Bfactor*fFactor*dphimds*basis[i];
598 this->
Sold = this->
S;
615 IssmDouble H,h,b,dphi[2],dphids,dphimds,db[2],dbds;
641 IssmDouble tx = xyz_list_tria[index2][0] - xyz_list_tria[index1][0];
642 IssmDouble ty = xyz_list_tria[index2][1] - xyz_list_tria[index1][1];
663 phi_0 = rho_water*g*b + rho_ice*g*H;
664 dphids = dphi[0]*tx + dphi[1]*ty;
665 dphimds = rho_water*g*(db[0]*tx + db[1]*ty);
666 Ngrad = fabs(dphids);
682 bool converged =
false;
691 if(this->
S>0. || qc*dPw>0.){
696 fabs(Qprime*pow(Snew,
ALPHA_C-1.)*dphids)
697 + C*Qprime*pow(Snew,
ALPHA_C-1.)*dPw
698 ) - 2./pow(n,n)*A*pow(fabs(N),n-1.)*N;
700 IssmDouble beta = 1./(rho_ice*L)*( fabs(lc*qc*dphids) + C*fFactor*dPw );
703 this->
S =
ODE1(alpha,beta,this->
Sold,dt,2);
704 if(this->
S<0.) this->
S = 0.;
709 if(fabs((this->
S - Snew)/(Snew+
AEPS))<1e-8 || count>=10) converged =
true;
719 values[this->
sid] = reCast<IssmPDouble>(this->
S);