int main() { // Create coarse mesh, set Dirichlet BC, enumerate // basis functions Mesh *mesh = new Mesh(A, B, N_elem, P_init, N_eq); printf("N_dof = %d\n", mesh->assign_dofs()); // Register weak forms DiscreteProblem *dp = new DiscreteProblem(); dp->add_matrix_form(0, 0, jacobian_vol); dp->add_vector_form(0, residual_vol); dp->add_matrix_form_surf(0, 0, jacobian_surf_left, BOUNDARY_LEFT); dp->add_vector_form_surf(0, residual_surf_left, BOUNDARY_LEFT); dp->add_matrix_form_surf(0, 0, jacobian_surf_right, BOUNDARY_RIGHT); dp->add_vector_form_surf(0, residual_surf_right, BOUNDARY_RIGHT); // Newton's loop newton(dp, mesh, NULL, NEWTON_TOL, NEWTON_MAXITER); // Plot the solution Linearizer l(mesh); l.plot_solution("solution.gp"); printf("Done.\n"); return 1; }
int main() { // Create coarse mesh MeshData *md = new MeshData(); // transform input data to the format used by the "Mesh" constructor Mesh *mesh = new Mesh(md->N_macroel, md->interfaces, md->poly_orders, md->material_markers, md->subdivisions, N_GRP, N_SLN); delete md; printf("N_dof = %d\n", mesh->assign_dofs()); mesh->plot("mesh.gp"); for (int g = 0; g < N_GRP; g++) { mesh->set_bc_right_dirichlet(g, flux_right_surf[g]); } // Register weak forms DiscreteProblem *dp = new DiscreteProblem(); dp->add_matrix_form(0, 0, jacobian_fuel_0_0, fuel); dp->add_matrix_form(0, 1, jacobian_fuel_0_1, fuel); dp->add_matrix_form(1, 0, jacobian_fuel_1_0, fuel); dp->add_matrix_form(1, 1, jacobian_fuel_1_1, fuel); dp->add_vector_form(0, residual_fuel_0, fuel); dp->add_vector_form(1, residual_fuel_1, fuel); dp->add_vector_form_surf(0, residual_surf_left_0, BOUNDARY_LEFT); dp->add_vector_form_surf(1, residual_surf_left_1, BOUNDARY_LEFT); // Newton's loop newton(dp, mesh, NULL, NEWTON_TOL, NEWTON_MAXITER, verbose); // Plot the resulting neutron flux Linearizer l(mesh); l.plot_solution("solution.gp"); // Calculate flux integral for comparison with the reference value double I = calc_integrated_flux(mesh, 1, 60., 80.); double Iref = 134.9238787715397; printf("I = %.13f, err = %.13f%%\n", I, 100.*(I - Iref)/Iref ); printf("Done.\n"); return 1; }