/*!Add a field*/ void addvector(const string& nameoffield, Fem2D::Mesh* mesh, const KN<double>&val, const KN<double>&val2) { _ofdata.flags(std::ios_base::scientific); _ofdata.precision(15); _ofdata << "<DataArray type=\"Float32\" Name=\""; _ofdata << nameoffield<<"\" NumberOfComponents=\"3\" format=\"ascii\">"; _ofdata << std::endl; for(int i=0;i<val.size();++i) _ofdata<<checkprecision(val[i])<< " " << checkprecision(val2[i]) << " " << 0.0 << std::endl; _ofdata << "</DataArray>" << std::endl; _ofdata.flush(); }
SolveSuperLU (const MatriceMorse<R> &AA, int strategy, double ttgv, double epsilon, double pivot, double pivot_sym, string ¶m_char, KN<long> pperm_r, KN<long> pperm_c): eps(epsilon), epsr(0), tgv(ttgv), etree(0), string_option(param_char), perm_r(pperm_r), perm_c(pperm_c), RR(0), CC(0), tol_pivot_sym(pivot_sym), tol_pivot(pivot) { SuperMatrix B, X; SuperLUStat_t stat; void *work = 0; int info, lwork = 0/*, nrhs = 1*/; int i; double ferr[1]; double berr[1]; double rpg, rcond; R *bb; R *xx; A.Store = 0; B.Store = 0; X.Store = 0; L.Store = 0; U.Store = 0; int status; n = AA.n; m = AA.m; nnz = AA.nbcoef; arow = AA.a; asubrow = AA.cl; xarow = AA.lg; /* FreeFem++ use Morse Format */ // FFCS - "this->" required by g++ 4.7 this->CompRow_to_CompCol(m, n, nnz, arow, asubrow, xarow, &a, &asub, &xa); /* Defaults */ lwork = 0; // nrhs = 0; /* Set the default values for options argument: * options.Fact = DOFACT; * options.Equil = YES; * options.ColPerm = COLAMD; * options.DiagPivotThresh = 1.0; * options.Trans = NOTRANS; * options.IterRefine = NOREFINE; * options.SymmetricMode = NO; * options.PivotGrowth = NO; * options.ConditionNumber = NO; * options.PrintStat = YES; */ set_default_options(&options); printf(".. default options:\n"); printf("\tFact\t %8d\n", options.Fact); printf("\tEquil\t %8d\n", options.Equil); printf("\tColPerm\t %8d\n", options.ColPerm); printf("\tDiagPivotThresh %8.4f\n", options.DiagPivotThresh); printf("\tTrans\t %8d\n", options.Trans); printf("\tIterRefine\t%4d\n", options.IterRefine); printf("\tSymmetricMode\t%4d\n", options.SymmetricMode); printf("\tPivotGrowth\t%4d\n", options.PivotGrowth); printf("\tConditionNumber\t%4d\n", options.ConditionNumber); printf("..\n"); if (!string_option.empty()) {read_options_freefem(string_option, &options);} printf(".. options:\n"); printf("\tFact\t %8d\n", options.Fact); printf("\tEquil\t %8d\n", options.Equil); printf("\tColPerm\t %8d\n", options.ColPerm); printf("\tDiagPivotThresh %8.4f\n", options.DiagPivotThresh); printf("\tTrans\t %8d\n", options.Trans); printf("\tIterRefine\t%4d\n", options.IterRefine); printf("\tSymmetricMode\t%4d\n", options.SymmetricMode); printf("\tPivotGrowth\t%4d\n", options.PivotGrowth); printf("\tConditionNumber\t%4d\n", options.ConditionNumber); printf("..\n"); Dtype_t R_SLU = SuperLUDriver<R>::R_SLU_T(); // FFCS - "this->" required by g++ 4.7 this->Create_CompCol_Matrix(&A, m, n, nnz, a, asub, xa, SLU_NC, R_SLU, SLU_GE); this->Create_Dense_Matrix(&B, m, 0, (R *)0, m, SLU_DN, R_SLU, SLU_GE); this->Create_Dense_Matrix(&X, m, 0, (R *)0, m, SLU_DN, R_SLU, SLU_GE); if (etree.size() == 0) {etree.resize(n);} if (perm_r.size() == 0) {perm_r.resize(n);} if (perm_c.size() == 0) {perm_c.resize(n);} if (!(RR = new double[n])) { ABORT("SUPERLU_MALLOC fails for R[]."); } for (int ii = 0; ii < n; ii++) { RR[ii] = 1.; } if (!(CC = new double[m])) { ABORT("SUPERLU_MALLOC fails for C[]."); } for (int ii = 0; ii < n; ii++) { CC[ii] = 1.; } ferr[0] = 0; berr[0] = 0; /* Initialize the statistics variables. */ StatInit(&stat); /* ONLY PERFORM THE LU DECOMPOSITION */ B.ncol = 0; /* Indicate not to solve the system */ SuperLUDriver<R>::gssvx(&options, &A, perm_c, perm_r, etree, equed, RR, CC, &L, &U, work, lwork, &B, &X, &rpg, &rcond, ferr, berr, &Glu, &mem_usage, &stat, &info); if (verbosity > 2) { printf("LU factorization: dgssvx() returns info %d\n", info); } if (verbosity > 3) { if (info == 0 || info == n + 1) { if (options.PivotGrowth) {printf("Recip. pivot growth = %e\n", rpg);} if (options.ConditionNumber) { printf("Recip. condition number = %e\n", rcond); } Lstore = (SCformat *)L.Store; Ustore = (NCformat *)U.Store; printf("No of nonzeros in factor L = %d\n", Lstore->nnz); printf("No of nonzeros in factor U = %d\n", Ustore->nnz); printf("No of nonzeros in L+U = %d\n", Lstore->nnz + Ustore->nnz - n); printf("L\\U MB %.3f\ttotal MB needed %.3f\texpansions %d\n", mem_usage.for_lu / 1e6, mem_usage.total_needed / 1e6, stat.expansions ); fflush(stdout); } else if (info > 0 && lwork == -1) { printf("** Estimated memory: %d bytes\n", info - n); } } if (verbosity > 5) {StatPrint(&stat);} StatFree(&stat); if (B.Store) {Destroy_SuperMatrix_Store(&B);} if (X.Store) {Destroy_SuperMatrix_Store(&X);} options.Fact = FACTORED;/* Indicate the factored form of A is supplied. */ }
STL(const KN<T>& v) : _it(v), _size(v.size()) { };