00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "Euclid_dh.h"
00031 #include "Mat_dh.h"
00032 #include "Factor_dh.h"
00033 #include "Parser_dh.h"
00034 #include "TimeLog_dh.h"
00035 #include "SubdomainGraph_dh.h"
00036
00037
00038 static void scale_rhs_private (Euclid_dh ctx, double *rhs);
00039 static void permute_vec_n2o_private (Euclid_dh ctx, double *xIN,
00040 double *xOUT);
00041 static void permute_vec_o2n_private (Euclid_dh ctx, double *xIN,
00042 double *xOUT);
00043
00044 #undef __FUNC__
00045 #define __FUNC__ "Euclid_dhApply"
00046 void
00047 Euclid_dhApply (Euclid_dh ctx, double *rhs, double *lhs)
00048 {
00049 START_FUNC_DH double *rhs_, *lhs_;
00050 double t1, t2;
00051
00052 t1 = MPI_Wtime ();
00053
00054
00055 ctx->from = 0;
00056 ctx->to = ctx->m;
00057
00058
00059 if (!strcmp (ctx->algo_ilu, "none") || !strcmp (ctx->algo_par, "none"))
00060 {
00061 int i, m = ctx->m;
00062 for (i = 0; i < m; ++i)
00063 lhs[i] = rhs[i];
00064 goto END_OF_FUNCTION;
00065 }
00066
00067
00068
00069
00070
00071 if (ctx->sg != NULL)
00072 {
00073
00074 permute_vec_n2o_private (ctx, rhs, lhs);
00075 CHECK_V_ERROR;
00076 rhs_ = lhs;
00077 lhs_ = ctx->work2;
00078 }
00079 else
00080 {
00081 rhs_ = rhs;
00082 lhs_ = lhs;
00083 }
00084
00085
00086 if (ctx->isScaled)
00087 {
00088
00089 scale_rhs_private (ctx, rhs_);
00090 CHECK_V_ERROR;
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 if (np_dh == 1 || !strcmp (ctx->algo_par, "bj"))
00103 {
00104 Factor_dhSolveSeq (rhs_, lhs_, ctx);
00105 CHECK_V_ERROR;
00106 }
00107
00108
00109
00110 else
00111 {
00112 Factor_dhSolve (rhs_, lhs_, ctx);
00113 CHECK_V_ERROR;
00114 }
00115
00116
00117
00118
00119
00120 if (ctx->sg != NULL)
00121 {
00122 permute_vec_o2n_private (ctx, lhs_, lhs);
00123 CHECK_V_ERROR;
00124 }
00125
00126 END_OF_FUNCTION:;
00127
00128 t2 = MPI_Wtime ();
00129
00130 ctx->timing[TRI_SOLVE_T] += (t2 - t1);
00131
00132
00133
00134
00135
00136 ctx->timing[TOTAL_SOLVE_TEMP_T] = t2 - ctx->timing[SOLVE_START_T];
00137
00138
00139 ctx->its += 1;
00140 ctx->itsTotal += 1;
00141
00142 END_FUNC_DH}
00143
00144
00145 #undef __FUNC__
00146 #define __FUNC__ "scale_rhs_private"
00147 void
00148 scale_rhs_private (Euclid_dh ctx, double *rhs)
00149 {
00150 START_FUNC_DH int i, m = ctx->m;
00151 REAL_DH *scale = ctx->scale;
00152
00153
00154 if (scale != NULL)
00155 {
00156 for (i = 0; i < m; ++i)
00157 {
00158 rhs[i] *= scale[i];
00159 }
00160 }
00161 END_FUNC_DH}
00162
00163
00164 #undef __FUNC__
00165 #define __FUNC__ "permute_vec_o2n_private"
00166 void
00167 permute_vec_o2n_private (Euclid_dh ctx, double *xIN, double *xOUT)
00168 {
00169 START_FUNC_DH int i, m = ctx->m;
00170 int *o2n = ctx->sg->o2n_col;
00171 for (i = 0; i < m; ++i)
00172 xOUT[i] = xIN[o2n[i]];
00173 END_FUNC_DH}
00174
00175
00176 #undef __FUNC__
00177 #define __FUNC__ "permute_vec_n2o_private"
00178 void
00179 permute_vec_n2o_private (Euclid_dh ctx, double *xIN, double *xOUT)
00180 {
00181 START_FUNC_DH int i, m = ctx->m;
00182 int *n2o = ctx->sg->n2o_row;
00183 for (i = 0; i < m; ++i)
00184 xOUT[i] = xIN[n2o[i]];
00185 END_FUNC_DH}