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