Changeset 419
- Timestamp:
- 05/14/09 08:50:30 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Tria.cpp
r418 r419 1577 1577 1578 1578 /* parameters: */ 1579 double velocity_x,velocity_y,velocity_mag; 1580 double obs_velocity_x,obs_velocity_y,obs_velocity_mag; 1579 double obs_velocity_mag,velocity_mag; 1581 1580 double absolutex,absolutey,relativex,relativey,logarithmicx,logarithmicy; 1582 1581 … … 2095 2094 #define __FUNCT__ "Tria::Misfit" 2096 2095 double Tria::Misfit(double* velocity,double* obs_velocity,void* vinputs,int analysis_type){ 2096 2097 2097 int i; 2098 2098 … … 2113 2113 double obs_vx_list[numgrids]; 2114 2114 double obs_vy_list[numgrids]; 2115 double absolute_list[numgrids]; 2116 double relative_list[numgrids]; 2117 double logarithmic_list[numgrids]; 2115 2118 2116 2119 /* gaussian points: */ … … 2124 2127 2125 2128 /* parameters: */ 2126 double velocity_ x,velocity_y,velocity_mag;2127 double obs_velocity_x,obs_velocity_y,obs_velocity_mag;2129 double velocity_mag,obs_velocity_mag; 2130 double absolute,relative,logarithmic; 2128 2131 2129 2132 /* Jacobian: */ … … 2155 2158 } 2156 2159 2160 /*Compute Misfit at the 3 nodes (integration of the linearized function)*/ 2161 if(fit==0){ 2162 /*We are using an absolute misfit: */ 2163 for (i=0;i<numgrids;i++){ 2164 absolute_list[i]=0.5*(pow((vx_list[i]-obs_vx_list[i]),2)+pow((vy_list[i]-obs_vy_list[i]),2)); 2165 } 2166 } 2167 else if(fit==1){ 2168 /*We are using a relative misfit: */ 2169 for (i=0;i<numgrids;i++){ 2170 scalex=pow(meanvel/(obs_vx_list[i]+epsvel),2); 2171 scaley=pow(meanvel/(obs_vy_list[i]+epsvel),2); 2172 if(obs_vx_list[i]==0)scalex=0; 2173 if(obs_vy_list[i]==0)scaley=0; 2174 relative_list[i]=0.5*(scalex*pow((vx_list[i]-obs_vx_list[i]),2)+scaley*pow((vy_list[i]-obs_vy_list[i]),2))*Jdet*gauss_weight; 2175 } 2176 } 2177 else if(fit==2){ 2178 /*We are using a logarithmic misfit: */ 2179 for (i=0;i<numgrids;i++){ 2180 velocity_mag=sqrt(pow(vx_list[i],2)+pow(vy_list[i],2))+epsvel; //epsvel to avoid velocity being nil. 2181 obs_velocity_mag=sqrt(pow(obs_vx_list[i],2)+pow(obs_vy_list[i],2))+epsvel; //epsvel to avoid observed velocity being nil. 2182 logarithmic_list[i]=4*pow(meanvel,2)*pow(log(velocity_mag/obs_velocity_mag),2); 2183 } 2184 } 2185 else{ 2186 /*Not supported yet! : */ 2187 throw ErrorException(__FUNCT__,exprintf("%s%g","unsupported type of fit: ",fit)); 2188 } 2189 2157 2190 /* Get gaussian points and weights (make this a statically initialized list of points? fstd): */ 2158 2191 GaussTria( &num_gauss, &first_gauss_area_coord, &second_gauss_area_coord, &third_gauss_area_coord, &gauss_weights, 2); … … 2172 2205 gauss_l1l2l3[2]=*(third_gauss_area_coord+ig); 2173 2206 2174 /*Compute velocities at gaussian point: */2175 GetParameterValue(&velocity_x, &vx_list[0],gauss_l1l2l3);2176 GetParameterValue(&velocity_y, &vy_list[0],gauss_l1l2l3);2177 #ifdef _DEBUG_2178 printf("Velocity: %g %g\n", velocity_x,velocity_y);2179 #endif2180 2181 /*Compute obs_velocities at gaussian point: */2182 GetParameterValue(&obs_velocity_x, &obs_vx_list[0],gauss_l1l2l3);2183 GetParameterValue(&obs_velocity_y, &obs_vy_list[0],gauss_l1l2l3);2184 #ifdef _DEBUG_2185 printf("Observed velocity: %g %g\n", obs_velocity_x,obs_velocity_y);2186 #endif2187 2188 2207 /* Get Jacobian determinant: */ 2189 2208 GetJacobianDeterminant2d(&Jdet, &xyz_list[0][0],gauss_l1l2l3); … … 2194 2213 /*Differents misfits are allowed: */ 2195 2214 if(fit==0){ 2196 /*Absolute misfit: */ 2197 Jelem+=.5*(pow((velocity_x-obs_velocity_x),2)+pow((velocity_y-obs_velocity_y),2))*Jdet*gauss_weight; 2215 /*Compute absolute misfit at gaussian point: */ 2216 GetParameterValue(&absolute, &absolute_list[0],gauss_l1l2l3); 2217 2218 /*compute Misfit*/ 2219 Jelem+=absolute*Jdet*gauss_weight; 2198 2220 } 2199 2221 else if(fit==1){ 2200 /*Relative misfit: */ 2201 scalex=pow(meanvel/(obs_velocity_x+epsvel),2); 2202 scaley=pow(meanvel/(obs_velocity_y+epsvel),2); 2203 if(obs_velocity_x==0)scalex=0; 2204 if(obs_velocity_y==0)scaley=0; 2205 Jelem+=.5*(scalex*pow((velocity_x-obs_velocity_x),2)+scaley*pow((velocity_y-obs_velocity_y),2))*Jdet*gauss_weight; 2222 /*Compute relative misfit at gaussian point: */ 2223 GetParameterValue(&relative, &relative_list[0],gauss_l1l2l3); 2224 2225 /*compute Misfit*/ 2226 Jelem+=relative*Jdet*gauss_weight; 2206 2227 } 2207 2228 else if(fit==2){ 2208 /*Logarithmic misfit: */ 2209 velocity_mag=sqrt(pow(velocity_x,2)+pow(velocity_y,2))+epsvel; //epsvel to avoid velocity being nil. 2210 obs_velocity_mag=sqrt(pow(obs_velocity_x,2)+pow(obs_velocity_y,2))+epsvel; //epsvel to avoid observed velocity being nil. 2211 Jelem+=4*pow(meanvel,2)*pow(log(velocity_mag/obs_velocity_mag),2)*Jdet*gauss_weight; 2229 /*Compute logarithmic misfit at gaussian point: */ 2230 GetParameterValue(&logarithmic, &logarithmic_list[0],gauss_l1l2l3); 2231 2232 /*compute Misfit*/ 2233 Jelem+=logarithmic*Jdet*gauss_weight; 2212 2234 } 2213 2235 else throw ErrorException(__FUNCT__,exprintf("%s%i%s","fit type",fit," not supported yet!"));
Note:
See TracChangeset
for help on using the changeset viewer.