void ModuleBasic::create_mesh_space_forms() { /* SANITY CHECKS */ // Consistency check of boundary conditions. this->bc_types.check_consistency(); // Sanity check of material markers and material constants. this->materials_sanity_check(); /* BEGIN THE COMPUTATION */ // Load the mesh. H2DReader mloader; mloader.load_str(this->get_mesh_string(), this->mesh); // Clear the mesh string. this->clear_mesh_string(); // Debug. /* MeshView m("", 0, 0, 400, 400); m.show(this->mesh); View::wait(); */ // Perform initial uniform mesh refinements. for (int i = 0; i < this->init_ref_num; i++) this->mesh->refine_all_elements(); // Create an H1 space with default shapeset. this->space = new H1Space(this->mesh, &(this->bc_types), &(this->bc_values), this->init_p); int ndof = Space::get_num_dofs(this->space); info("ndof = %d", ndof); // Debug. /* BaseView b("", new WinGeom(0, 0, 400, 400)); b.show(this->space); View::wait(); */ // Initialize the weak formulation. this->wf = new WeakForm(); this->wf->add_matrix_form(callback(bilinear_form_vol)); this->wf->add_vector_form(callback(linear_form_vol)); for (unsigned int i=0; i < this->bdy_values_neumann.size(); i++) { this->wf->add_vector_form_surf(callback(linear_form_surf_neumann), this->bdy_markers_neumann[i]); } for (unsigned int i=0; i < this->bdy_values_newton.size(); i++) { this->wf->add_matrix_form_surf(callback(bilinear_form_surf_newton), this->bdy_markers_newton[i]); this->wf->add_vector_form_surf(callback(linear_form_surf_newton), this->bdy_markers_newton[i]); } }
int main(int argc, char* argv[]) { int ret = ERROR_FAILURE; if (argc < 2) { printf("please input as this format: <mesh type> <meshfile> [meshfiledump] \n"); return ERROR_FAILURE; } char *mtype = argv[1]; char *file_name = argv[2]; char *file_name_dump = NULL; if (argc > 2) file_name_dump = argv[3]; // load the mesh file Mesh mesh; MeshLoader *mloader = NULL; if (strcmp(mtype, "exII") == 0) mloader = new ExodusIIReader(); else if (strcmp(mtype, "h2d") == 0) mloader = new H2DReader(); else if (strcmp(mtype, "h2d-str") == 0) { // load the file into a string FILE *file = fopen(file_name , "rb"); error_if(file == NULL, "unable to open file '%s'", file_name); // obtain file size: fseek(file, 0, SEEK_END); long size = ftell(file); rewind(file); // allocate memory to contain the whole file: char *buffer = (char *) malloc (sizeof(char) * size); error_if(buffer == NULL, "memory error"); // copy the file into the buffer: size_t result = fread(buffer, 1, size, file); error_if(result != size, "reading error"); fclose(file); // H2DReader *hloader = new H2DReader(); hloader->load_str(buffer, &mesh); ret = dump_compare(mesh, file_name_dump); delete hloader; free(buffer); return ret; } else if (strcmp(mtype, "h2d-old") == 0) { H2DReader *hloader = new H2DReader(); hloader->load_old(file_name, &mesh); ret = dump_compare(mesh, file_name_dump); delete hloader; return ret; } else { error("unknown mesh loader type"); } if (mloader->load(file_name, &mesh)) { ret = dump_compare(mesh, file_name_dump); } else { error("failed"); ret = ERROR_FAILURE; } delete mloader; return ret; }