Ignore:
Timestamp:
08/11/10 11:47:52 (15 years ago)
Author:
seroussi
Message:

Bamg: put some functions in .ccp

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Bamg/BamgVertex.cpp

    r5143 r5150  
    99
    1010        /*Methods*/
     11        /*FUNCTION BamgVertex::Echo {{{1*/
     12
     13        void BamgVertex::Echo(void){
     14
     15                printf("Vertex:\n");
     16                printf("  integer   coordinates i.x: %i, i.y: %i\n",i.x,i.y);
     17                printf("  Euclidean coordinates r.x: %g, r.y: %g\n",r.x,r.y);
     18                printf("  ReferenceNumber = %i\n",ReferenceNumber);
     19                m.Echo();
     20
     21                return;
     22        }
     23        /*}}}*/
     24        /*FUNCTION BamgVertex::GetReferenceNumber{{{1*/
     25        int  BamgVertex::GetReferenceNumber() const {
     26                return ReferenceNumber;
     27        }
     28        /*}}}*/
     29        /*FUNCTION BamgVertex::MetricFromHessian{{{1*/
     30        void BamgVertex::MetricFromHessian(const double Hxx,const double Hyx, const double Hyy,const double smin,const double smax,const double s,double err,BamgOpts* bamgopts){
     31                /*Compute Metric from Hessian*/
     32
     33                /*get options*/
     34                double power=(bamgopts->power);
     35                double anisomax=(bamgopts->anisomax);
     36                double CutOff=bamgopts->cutoff;
     37                double hmin=(bamgopts->hmin);
     38                double hmax=(bamgopts->hmax);
     39                double coef=bamgopts->coeff;
     40                int    Metrictype=(bamgopts->Metrictype);
     41
     42                /*Intermediary*/
     43                double ci;
     44
     45                /*compute multiplicative coefficient depending on Metric Type (2/9 because it is 2d)*/
     46
     47                //Absolute Error
     48                /*
     49                 *            2         1       
     50                 *Metric M = ---  ------------   Abs(Hessian)
     51                 *            9   err * coeff^2 
     52                 */
     53                if (Metrictype==0){
     54                        ci= 2.0/9.0 * 1/(err*coef*coef);
     55                }
     56
     57                //Relative Error
     58                /*
     59                 *            2         1            Abs(Hessian)
     60                 *Metric M = ---  ------------  ----------------------
     61                 *            9   err * coeff^2  max( |s| , cutoff*max(|s|) )
     62                 *
     63                 */
     64                else if (Metrictype==1){
     65                        ci= 2.0/9.0 * 1/(err*coef*coef) * 1/Max( Abs(s), CutOff*(Max(Abs(smin),Abs(smax))));
     66                }
     67
     68                //Rescaled absolute error
     69                /*
     70                 *            2         1            Abs(Hessian)
     71                 *Metric M = ---  ------------  ----------------------
     72                 *            9   err * coeff^2       (smax-smin)
     73                 */
     74                else if (Metrictype==2){
     75                        ci= 2.0/9.0 * 1/(err*coef*coef) * 1/(smax-smin);
     76                }
     77                else{
     78                        ISSMERROR("Metrictype %i not supported yet (use 0,1 or 2(default))",Metrictype);
     79                }
     80
     81                //initialize metric Miv with ci*H
     82                Metric Miv(Hxx*ci,Hyx*ci,Hyy*ci);
     83
     84                //Get eigen values and vectors of Miv
     85                MatVVP2x2 Vp(Miv);
     86
     87                //move eigen valuse to their absolute values
     88                Vp.Abs();
     89
     90                //Apply a power if requested by user
     91                if(power!=1.0) Vp.pow(power);
     92
     93                //modify eigen values according to hmin and hmax
     94                Vp.Maxh(hmax);
     95                Vp.Minh(hmin);
     96
     97                //Bound anisotropy by 1/(anisomax)^2
     98                Vp.BoundAniso2(1/(anisomax*anisomax));
     99
     100                //rebuild Metric from Vp
     101                Metric MVp(Vp);
     102
     103                //Apply Metric to vertex
     104                m.IntersectWith(MVp);
     105
     106        }
     107        /*}}}1*/
     108        /*FUNCTION BamgVertex::Optim {{{1*/
     109        long BamgVertex::Optim(int i,int koption){
     110                long ret=0;
     111                if ( t && (vint >= 0 ) && (vint <3) ){
     112                        ret = t->Optim(vint,koption);
     113                        if(!i){
     114                                t =0; // for no future optime
     115                                vint= 0;
     116                        }
     117                }
     118                return ret;
     119        }
     120        /*}}}*/
    11121        /*FUNCTION BamgVertex::Smoothing{{{1*/
    12122        double  BamgVertex::Smoothing(Mesh &Th,const Mesh &BTh,Triangle* &tstart ,double omega){
     
    113223        }
    114224        /*}}}1*/
    115         /*FUNCTION BamgVertex::MetricFromHessian{{{1*/
    116         void BamgVertex::MetricFromHessian(const double Hxx,const double Hyx, const double Hyy,const double smin,const double smax,const double s,double err,BamgOpts* bamgopts){
    117                 /*Compute Metric from Hessian*/
    118 
    119                 /*get options*/
    120                 double power=(bamgopts->power);
    121                 double anisomax=(bamgopts->anisomax);
    122                 double CutOff=bamgopts->cutoff;
    123                 double hmin=(bamgopts->hmin);
    124                 double hmax=(bamgopts->hmax);
    125                 double coef=bamgopts->coeff;
    126                 int    Metrictype=(bamgopts->Metrictype);
    127 
    128                 /*Intermediary*/
    129                 double ci;
    130 
    131                 /*compute multiplicative coefficient depending on Metric Type (2/9 because it is 2d)*/
    132 
    133                 //Absolute Error
    134                 /*
    135                  *            2         1       
    136                  *Metric M = ---  ------------   Abs(Hessian)
    137                  *            9   err * coeff^2 
    138                  */
    139                 if (Metrictype==0){
    140                         ci= 2.0/9.0 * 1/(err*coef*coef);
    141                 }
    142 
    143                 //Relative Error
    144                 /*
    145                  *            2         1            Abs(Hessian)
    146                  *Metric M = ---  ------------  ----------------------
    147                  *            9   err * coeff^2  max( |s| , cutoff*max(|s|) )
    148                  *
    149                  */
    150                 else if (Metrictype==1){
    151                         ci= 2.0/9.0 * 1/(err*coef*coef) * 1/Max( Abs(s), CutOff*(Max(Abs(smin),Abs(smax))));
    152                 }
    153 
    154                 //Rescaled absolute error
    155                 /*
    156                  *            2         1            Abs(Hessian)
    157                  *Metric M = ---  ------------  ----------------------
    158                  *            9   err * coeff^2       (smax-smin)
    159                  */
    160                 else if (Metrictype==2){
    161                         ci= 2.0/9.0 * 1/(err*coef*coef) * 1/(smax-smin);
    162                 }
    163                 else{
    164                         ISSMERROR("Metrictype %i not supported yet (use 0,1 or 2(default))",Metrictype);
    165                 }
    166 
    167                 //initialize metric Miv with ci*H
    168                 Metric Miv(Hxx*ci,Hyx*ci,Hyy*ci);
    169 
    170                 //Get eigen values and vectors of Miv
    171                 MatVVP2x2 Vp(Miv);
    172 
    173                 //move eigen valuse to their absolute values
    174                 Vp.Abs();
    175 
    176                 //Apply a power if requested by user
    177                 if(power!=1.0) Vp.pow(power);
    178 
    179                 //modify eigen values according to hmin and hmax
    180                 Vp.Maxh(hmax);
    181                 Vp.Minh(hmin);
    182 
    183                 //Bound anisotropy by 1/(anisomax)^2
    184                 Vp.BoundAniso2(1/(anisomax*anisomax));
    185 
    186                 //rebuild Metric from Vp
    187                 Metric MVp(Vp);
    188 
    189                 //Apply Metric to vertex
    190                 m.IntersectWith(MVp);
    191 
    192         }
    193         /*}}}1*/
    194         /*FUNCTION BamgVertex::Echo {{{1*/
    195 
    196         void BamgVertex::Echo(void){
    197 
    198                 printf("Vertex:\n");
    199                 printf("  integer   coordinates i.x: %i, i.y: %i\n",i.x,i.y);
    200                 printf("  Euclidean coordinates r.x: %g, r.y: %g\n",r.x,r.y);
    201                 printf("  ReferenceNumber = %i\n",ReferenceNumber);
    202                 m.Echo();
    203 
    204                 return;
    205         }
    206         /*}}}*/
    207         /*FUNCTION BamgVertex::Optim {{{1*/
    208         long BamgVertex::Optim(int i,int koption){
    209                 long ret=0;
    210                 if ( t && (vint >= 0 ) && (vint <3) ){
    211                         ret = t->Optim(vint,koption);
    212                         if(!i){
    213                                 t =0; // for no future optime
    214                                 vint= 0;
    215                         }
    216                 }
    217                 return ret;
    218         }
    219         /*}}}*/
    220225
    221226        /*Intermediary*/
Note: See TracChangeset for help on using the changeset viewer.