Ignore:
Timestamp:
11/04/16 17:42:57 (8 years ago)
Author:
adhikari
Message:

CHG: rotational feedback works fine now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/FemModel.cpp

    r21295 r21344  
    24592459        /*Go through elements, and add contribution from each element to the deflection vector wg:*/
    24602460        ns = elements->Size();
    2461        
     2461
    24622462        /*First, figure out the area of the ocean, which is needed to compute the eustatic component: */
    24632463        for(int i=0;i<ns;i++){
     
    24652465                eartharea_cpu += element->GetAreaSpherical();
    24662466        }
     2467       
    24672468        ISSM_MPI_Reduce (&eartharea_cpu,&eartharea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
    24682469        ISSM_MPI_Bcast(&eartharea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
     
    24752476        for(int i=0;i<nsmax;i++){
    24762477                if(i<ns){
    2477 
    24782478                        if(verboseconvolution)if(VerboseConvergence())if(i%100==0)_printf_("\r" << "      convolution progress: " << (double)i/(double)ns*100 << "%   ");
    2479 
    24802479                        Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
    2481                         element->SealevelriseNonEustatic(pSgo, Sg_old,latitude,longitude,radius,eartharea);
     2480                        element->SealevelriseNonEustatic(pSgo,Sg_old,latitude,longitude,radius,eartharea);
    24822481                }
    24832482                if(i%100==0)pSgo->Assemble();
    24842483        }
    24852484        if(verboseconvolution)if(VerboseConvergence())_printf_("\n");
    2486 
     2485       
    24872486        /*Free ressources:*/
    24882487        xDelete<IssmDouble>(Sg_old);
     2488}
     2489/*}}}*/
     2490void FemModel::SealevelriseRotationalFeedback(Vector<IssmDouble>* pSgo_rot, Vector<IssmDouble>* pSg_old, IssmDouble* latitude, IssmDouble* longitude, IssmDouble* radius){/*{{{*/
     2491
     2492        /*serialized vectors:*/
     2493        IssmDouble* Sg_old=NULL;
     2494        IssmDouble  eartharea=0;
     2495        IssmDouble  eartharea_cpu=0;
     2496        IssmDouble      tide_love_h, tide_love_k, fluid_love, moi_e, moi_p, omega, g;
     2497        IssmDouble      load_love_k2 = -0.30922675; //degree 2 load Love number
     2498        IssmDouble      m1, m2, m3;
     2499        IssmDouble      lati, longi, value;
     2500
     2501        /*Serialize vectors from previous iteration:*/
     2502        Sg_old=pSg_old->ToMPISerial();
     2503
     2504        /*First, figure out the area of the ocean, which is needed to compute the eustatic component: */
     2505        for(int i=0;i<elements->Size();i++){
     2506                Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
     2507                eartharea_cpu += element->GetAreaSpherical();
     2508        }
     2509        ISSM_MPI_Reduce (&eartharea_cpu,&eartharea,1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
     2510        ISSM_MPI_Bcast(&eartharea,1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
     2511
     2512        IssmDouble moi_list[3]={0,0,0};
     2513        IssmDouble moi_list_cpu[3]={0,0,0};
     2514        for(int i=0;i<elements->Size();i++){
     2515                Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
     2516                element->SealevelriseMomentOfInertia(&moi_list[0],Sg_old,eartharea);
     2517                moi_list_cpu[0] += moi_list[0];
     2518                moi_list_cpu[1] += moi_list[1];
     2519                moi_list_cpu[2] += moi_list[2];
     2520        }
     2521        ISSM_MPI_Reduce (&moi_list_cpu[0],&moi_list[0],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
     2522        ISSM_MPI_Bcast(&moi_list[0],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
     2523        //     
     2524        ISSM_MPI_Reduce (&moi_list_cpu[1],&moi_list[1],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
     2525        ISSM_MPI_Bcast(&moi_list[1],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
     2526        //     
     2527        ISSM_MPI_Reduce (&moi_list_cpu[2],&moi_list[2],1,ISSM_MPI_DOUBLE,ISSM_MPI_SUM,0,IssmComm::GetComm() );
     2528        ISSM_MPI_Bcast(&moi_list[2],1,ISSM_MPI_DOUBLE,0,IssmComm::GetComm());
     2529       
     2530        /*pull out some useful parameters: */
     2531        parameters->FindParam(&tide_love_h,SealevelriseTidalLoveHEnum);
     2532        parameters->FindParam(&tide_love_k,SealevelriseTidalLoveKEnum);
     2533        parameters->FindParam(&fluid_love,SealevelriseFluidLoveEnum);
     2534        parameters->FindParam(&moi_e,SealevelriseEquatorialMoiEnum);
     2535        parameters->FindParam(&moi_p,SealevelrisePolarMoiEnum);
     2536        parameters->FindParam(&omega,SealevelriseAngularVelocityEnum);
     2537
     2538        /*compute perturbation terms for angular velocity vector: */
     2539        m1 = 1/(1-tide_love_k/fluid_love) * (1+load_love_k2)/(moi_p-moi_e) * moi_list[0];
     2540        m2 = 1/(1-tide_love_k/fluid_love) * (1+load_love_k2)/(moi_p-moi_e) * moi_list[1];
     2541        m3 = -(1+load_love_k2)/moi_p * moi_list[2];
     2542
     2543        for(int i=0;i<vertices->Size();i++){
     2544                //Vertex* vertex=(Vertex*)vertices->GetObjectByOffset(i);
     2545                Vertex* vertex=xDynamicCast<Vertex*>(vertices->GetObjectByOffset(i));
     2546               
     2547                lati=latitude[i]/180*PI;        longi=longitude[i]/180*PI;
     2548
     2549                /*only first order terms are considered now: */
     2550                value=((1.0+tide_love_k-tide_love_h)/9.81)*pow(omega*radius[i],2.0)*
     2551                                                (-m3/6.0 - m3*cos(2.0*lati)/2.0 - sin(lati)*cos(lati)*(m1*cos(longi)+m2*sin(longi)));
     2552       
     2553                pSgo_rot->SetValue(vertex->Sid(),value,INS_VAL); //INS_VAL ensures that you don't add several times
     2554        }
     2555
     2556        /*Assemble mesh velocity*/
     2557        pSgo_rot->Assemble();
     2558       
     2559        /*Free ressources:*/
     2560        xDelete<IssmDouble>(Sg_old);
     2561       
    24892562}
    24902563/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.