void compare(CompareCmd *env, FE_Field *field_a, PointField *field_b) { if (env->verbose) { cout << "Comparing FE_Field against PointField" << endl; } assert(env->quadrature != 0); QuadratureRule *qr = env->quadrature; Residuals *residuals = env->residuals; // dimensions int nel = qr->meshPart->nel; int nq = qr->points->n_points(); int valdim = field_a->n_rank(); assert((nel*nq) == field_b->points->n_points()); assert(valdim == field_b->values->n_dim()); // field values at quadrature points Points phi_a, phi_b; double *values_a = new double[nq * valdim]; double *values_b = new double[nq * valdim]; phi_a.set_data(values_a, nq, valdim); phi_b.set_data(values_b, nq, valdim); residuals->reset_accumulator(); env->start_timer(nel, "elts"); // main loop for (int e = 0; e < nel; e++) { qr->select_cell(e); for (int q = 0; q < nq; q++) { double *globalPoint = (*(qr->points))[q]; bool ca = field_a->eval(globalPoint, &values_a[q*valdim]); //bool cb = field_b->eval(globalPoint, &values_b[q*valdim]); for (int i = 0; i < valdim; i++) { values_b[q*valdim + i] = field_b->values->data[q*valdim + i]; } } double err2 = qr->L2(phi_a, phi_b); double vol = qr->meshPart->cell->volume(); //residuals->update(e, sqrt(err2)/vol); //residuals->update(e, sqrt(err2)); residuals->update(e, sqrt(err2), vol); env->update_timer(e); } env->end_timer(); // clean up delete [] values_a; delete [] values_b; }
void compare(CompareCmd *env, FE_Field *field_a, FE_Field *field_b) { if (env->verbose) { cout << "Comparing FE_Field against FE_Field" << endl; } assert(env->quadrature != 0); QuadratureRule *qr = env->quadrature; Residuals *residuals = env->residuals; // dimensions int nel = qr->meshPart->nel; int nq = qr->points->n_points(); int valdim = field_a->n_rank(); // field values at quadrature points Points phi_a, phi_b; double *values_a = new double[nq * valdim]; double *values_b = new double[nq * valdim]; phi_a.set_data(values_a, nq, valdim); phi_b.set_data(values_b, nq, valdim); field_a->fe->initialize_basis_tab(); residuals->reset_accumulator(); // main loop env->start_timer(nel,"elts"); for (int e = 0; e < nel; e++) { qr->select_cell(e); field_a->tabulate_element(e, phi_a.data); bool cb = field_b->Field::eval(*(qr->points), phi_b); double err2 = qr->L2(phi_a, phi_b); double vol = qr->meshPart->cell->volume(); //residuals->update(e, sqrt(err2)/vol); //residuals->update(e, sqrt(err2)); residuals->update(e, sqrt(err2), vol); env->update_timer(e); } env->end_timer(); // clean up delete [] values_a; delete [] values_b; }
void compare(CompareCmd *env, Field *field_a, Field *field_b) { const bool debug = false; if (env->verbose) { cout << "Comparing Field against Field" << endl; } assert(env->quadrature != 0); QuadratureRule *qr = env->quadrature; Residuals *residuals = env->residuals; // dimensions int nel = qr->meshPart->nel; int nq = qr->points->n_points(); int ndim = field_a->n_dim(); int valdim = field_a->n_rank(); // field values at quadrature points Points phi_a, phi_b; double *values_a = new double[nq * valdim]; double *values_b = new double[nq * valdim]; phi_a.set_data(values_a, nq, valdim); phi_b.set_data(values_b, nq, valdim); residuals->reset_accumulator(); env->start_timer(nel, "elts"); // main loop for (int e = 0; e < nel; e++) { qr->select_cell(e); for (int q = 0; q < nq; q++) { double *globalPoint = (*(qr->points))[q]; field_a->eval(globalPoint, &values_a[q*valdim]); field_b->eval(globalPoint, &values_b[q*valdim]); if (debug) { int j; cerr << e << " " << q << " "; for (j = 0; j < ndim; j++) { cerr << globalPoint[j] << " "; } cerr << "\t"; for (j = 0; j < valdim; j++) { cerr << values_a[valdim*q + j] << " "; } cerr << "\t"; for (j = 0; j < valdim; j++) { cerr << values_b[valdim*q + j] << " "; } cerr << endl; } } double err2 = qr->L2(phi_a, phi_b); double vol = qr->meshPart->cell->volume(); //residuals->update(e, sqrt(err2)/vol); //residuals->update(e, sqrt(err2)); residuals->update(e, sqrt(err2), vol); env->update_timer(e); } env->end_timer(); // clean up delete [] values_a; delete [] values_b; }