void run_Zmatrices_calculation_scattered_field(Zmatrices& Z_matrices, UINT Lagrange_degree, MATRIX M, MATRIX J, GRID& rho, double material_param, const char* result_file) { // Simulation parameters int N_T = Z_matrices.z_N_T; double dt = Z_matrices.z_dt; double c = Z_matrices.z_c; UINT inner_points = 1; printf("\nSimulation parameters for scattered field:" "\n\tNumber of grid vertices = %i" "\n\tMaterial parameter = %e" "\n\tc = %e" "\n\tdt = %e" "\n\tN_T = %i" "\n\tinner_points = %i" "\n\tLagrange_degree = %i\n\n", (int)rho.size(), material_param, c, dt, N_T, inner_points, Lagrange_degree); // Lagrange interpolators (temporal basis functions) CLagrange_interp timeBasis = CLagrange_interp(dt, Lagrange_degree); Z_matrices.timeBasis_D = timeBasis; CLagrange_interp timeBasis_Ns = timeBasis; timeBasis_Ns.diff(); Z_matrices.timeBasis_Ns = timeBasis_Ns; Z_matrices.z_inner_points = inner_points; // do main computation cube S, D; #ifdef OS_WIN clock_t t; #else struct timeval * t = new struct timeval; #endif start_timing(t); Z_matrices.compute_fields(S, D, rho); S *= material_param; finish_timing(t); start_timing(t); MATRIX rhs(D.n_rows, N_T, fill::zeros); VECTOR rhs_(D.n_rows, fill::zeros); printf("%s\n\n", "Marching on in time..."); int j(0), k(0); //#pragma omp parallel default(shared) private(j,k) for (j = 0; j < N_T; j++) { //#pragma omp for for (k = 0; k < j+1; k++) { rhs_ += D.slice(k)*M.col(j - k) - S.slice(k)*J.col(j - k); } rhs.col(j) = rhs_; rhs_.zeros(); //Status printf("\r%i ", j + 1); fflush(stdout); } finish_timing(t); // Output MAT file that stores the operators printf("Compressing matrices into Matlab form..."); mat_t *matfpZ = NULL; matvar_t *matvar = NULL; // Save matrices as separate matlab variables if (CreateMatFile(&matfpZ, result_file) == -1) { return; } else { double NT = (double)N_T; InsertVar(&matfpZ, "N_T", &NT); InsertMatrix(&matfpZ, "E", rhs); FinishMatFile(&matfpZ); // free memory S.clear(), D.clear(); printf("\t- done.\nOutput file location: %s\n\n", result_file); } }
int CmXMLFile(SOCKET ClientSocket, TMemoryStream *ms) { ms->SaveToFile("matr.xml"); InsertMatrix(ms); }