00001 /****************************************************************************** 00002 File uth_intf.h - interface to utility procedures (and macros) 00003 1. general purpose utilities (implementation in uts_util.c) 00004 2. time measurments (implementation system dependent !!!) 00005 00006 Contains declarations of constants and interface routines: 00007 00008 General purpose utilities: 00009 00010 utr_ctrl_c_signal_handler(int param) - to catch kill signals 00011 utr_set_interactive - to set up names for interactive input and output 00012 that control the run (possibly stdin and/or stdout for on-line control) 00013 utr_initialize_mesh - to initialize mesh of a specified type 00014 utr_initialize_field - to initialize field of a specified type 00015 utr_write_paraview_std_lin - to dump data in Paraview format (for std_lin only) 00016 utr_write_paraview_partmesh - to dump mesh in Paraview format with partition info 00017 !utr_export_mesh - to export mesh of a specified type in a specified format 00018 !utr_export_field - to export field of a specified type in a specified format 00019 00020 utr_get_ent_dofs - to read geometry or solution DOFs for a given DOF entity 00021 from suitable (approximation or mesh) data structures 00022 00023 in uts_adapt.c 00024 utr_create_patches - to create patches of elements containing a given node 00025 (uses only mesh data - can be the same for all fields) 00026 utr_create_patches_small - the same as above but uses lists of elements nodes 00027 instead of lists of elements dof entities 00028 utr_recover_derivatives - to recover deirvatives using patches of elements 00029 (can be called separately for each field on the same mesh) 00030 utr_recover_derivatives_small-to recover derivatives using patches of elements 00031 (does not use apr_get_stiff_mat_data for getting lists of element nodes) 00032 utr_adapt - to enforce default adaptation strategy for SINGLE problem/field 00033 utr_test_refinements - to perform sequence of random refinements/unrefinements 00034 utr_manual_refinement - to perform manual refinement/unrefinement 00035 00036 in uts_ls_intf.c 00037 utr_get_list_ent - to return the list of: 00038 1. integration entities - entities 00039 for which stiffness matrices and load vectors are 00040 provided by the FEM code to the solver module, 00041 2. DOF entities - entities with which there are dofs 00042 associated by the given approximation 00043 utr_get_list_dof_ent - to return the list DOF entities 00044 - entities with which there are dofs 00045 associated by the given approximation 00046 given the list of integration entities - entities 00047 for which stiffness matrices and load vectors are 00048 provided by the FEM code to the solver module 00049 (not for DG approximation!!!) 00050 utr_get_list_int_ent - to return the list of integration entities - entities 00051 for which stiffness matrices and load vectors are 00052 provided by the FEM code to the solver module 00053 (not for DG approximation!!!) 00054 utr_get_list_ent_coarse - to return the list of integration entities - entities 00055 for which stiffness matrices and load vectors are 00056 provided by the FEM code to the solver module, 00057 and DOF entities - entities with which there are dofs 00058 associated by the given approximation for COARSE level 00059 given the corresponding lists from the fine level 00060 (it calls separate implementations for dg and std?) 00061 utr_get_max_num_grid_levels - for limiting nr_levels in multigrid 00062 based on mesh and field data 00063 utr_dof_ent_sons - to return info whether the entity is owned 00064 and a list of dof entity sons for owned entity 00065 utr_comp_stiff_mat - to create a stiffness matrix 00066 and a load vector corresponding to the specified 00067 mesh entity, together with information on how to 00068 assemble entries into the global stiffness matrix 00069 and the global load vector 00070 utr_create_assemble_stiff_mat - to create element stiffness matrices 00071 and assemble them to the global SM 00072 utr_renumber - to renumber (permute) graph vertices (used for bandwidth reduction) 00073 utr_color_int_ent_for_assembly_with_graph_creation - coloring elements for lock free 00074 assembly (with creation of neighbourhood graphs) 00075 utr_color_int_ent_for_assembly - coloring elements for lock free assembly 00076 utr_rewr_sol - to rewrite solution from one vector to another 00077 00078 in uts_util: 00079 utr_average_sol_el - to compute the average of solution over element 00080 00081 utr_dvector - to allocate a double vector: name[0..ncom-1]: 00082 name=ut_dvector(ncom,error_text) 00083 utr_ivector - to allocate an integer vector: name[0..ncom-1]: 00084 name=ut_ivector(ncom,error_text) 00085 utr_d_zero - to zero a double vector of length Num 00086 utr_chk_list - to check whether Num is on the list List 00087 with length Ll 00088 utr_put_list - to put Num on the list List with length Ll 00089 (filled with numbers and zeros at the end) 00090 utr_mat3_inv - to invert a 3x3 matrix (stored as a vector!) 00091 utr_vec3_add - to compute vector product of 3D vectors 00092 utr_vec3_subst - to compute sum of 3D vectors 00093 utr_vec3_prod - to compute difference of 3D vectors 00094 utr_vec3_mxpr - to compute mixed vector product of 3D vectors 00095 utr_vec3_length - to compute length of a 3D vector 00096 utr_mat3vec - to compute matrix vector product in 3D space 00097 utr_mat3mat - to compute matrix matrix product in 3D space 00098 (all matrices are stored by rows as vectors!) 00099 utr_mat_det - to compute determinant of a matrix 00100 utr_skip_rest_of_line - to allow for comments in input files 00101 utr_fprintf_double - to write double number to file with specified accuracy 00102 (in the number of significant digits) 00103 utr_insert_sort - to sort an array by insertion (for small integer arrays) 00104 utr_heap_sort - to heap-sort an array (for large double precision arrays) 00105 00106 Input Output routines (IO): 00107 utr_io_read_mesh - to read mesh from given filename(s) 00108 00109 00110 ------------------------------ 00111 History: 00112 02.2002 - Krzysztof Banas, kbanas@pk.edu.pl 00113 10.2012 - Kazimierz.Michalik@agh.edu.pl 00114 08.2012 - Kamil Wachala, kamil.wachala@gmail.com 00115 2011 - Kazimierz Michalik, kamich@agh.edu.pl 00116 2016 - Aleksander Siwek (Aleksander.Siwek@agh.edu.pl) 00117 ******************************************************************************/ 00118 00119 #ifndef _uth_intf_ 00120 #define _uth_intf_ 00121 00123 #define utm_max(x,y) ((x)>(y)?(x):(y)) 00124 #define utm_min(x,y) ((x)<(y)?(x):(y)) 00125 #define utm_abs(x) ((x)<0?-(x):(x)) 00126 00127 #ifndef UTM_SAFE_FREE_PTR 00128 # define UTM_SAFE_FREE_PTR(ptr) if((ptr)!=NULL) { free((ptr));(ptr)=NULL; }; 00129 #endif 00130 00131 #ifndef UTM_SAFE_FREE_PTR_ARRAY 00132 # define UTM_SAFE_FREE_PTR_ARRAY(p_ar,n) if((p_ar)!=NULL){int i=0; for(;i<n;++i){UTM_SAFE_FREE_PTR(p_ar[i]);}}; 00133 #endif 00134 00135 #ifdef __cplusplus 00136 extern "C" 00137 { 00138 #endif 00139 00140 00146 typedef enum 00147 { 00148 UTE_POINT_DATA=0, 00149 UTE_CELL_DATA, 00150 UTE_SCALARS, 00151 UTE_VECTORS, 00152 UTE_TENSORS, 00153 UTE_DOUBLE, 00154 UTE_INT, 00155 UTE_VTK_LEGACY_FORMAT, 00156 UTE_VTK_XML, 00157 UTE_LAST 00158 } ute_paraview_flags; 00159 00160 #define UTC_LIST_END_MARK -1 00161 00163 #define UTC_MAXEL_PATCH 100 // maximal number of elements in the patch 00164 #define UTC_MAXNO_PATCH 200 // maximal number of nodes in the patch 00165 00166 #define UTC_MAX_INT_ENT_NEIG 300 // maximal number of neighbours for int ent 00167 // i.e. maximal number of faces and elements that share some DOFS with 00168 // a given integration entity (face or element) 00169 00170 /*struct for patches - e.g. to recover derivatives by uts_recover_derivatives*/ 00171 typedef struct { 00172 int nr_elems; 00173 int elems[UTC_MAXEL_PATCH]; 00174 int nr_nodes; 00175 int nodes[UTC_MAXNO_PATCH]; 00176 double *deriv; 00177 } utt_patches; 00178 00179 typedef struct { 00180 // practically every utr_ routine can have its own time counter 00181 double initialize_mesh; 00182 double initialize_field; 00183 double decompress_files; 00184 double problem_initialization; 00185 00186 double create_int_ent_list; 00187 double create_dof_ent_list; 00188 double renumber_dofs; 00189 double total_coloring; 00190 double color_elements; 00191 double color_faces; 00192 double handle_solver_interface_data_structures; 00193 double handle_solver_interface_GPU_data_structures; 00194 double create_solver_data_structures; 00195 double total_sir_create; 00196 00197 double read_initial_guess; 00198 double read_geo_dofs_vector; 00199 double read_single_sol_dofs_vector; 00200 double read_all_sol_dofs_vectors; 00201 double CPU_integration_elems; 00202 double CPU_assembly_elems; 00203 double CPU_integration_faces; 00204 double CPU_assembly_faces; 00205 double GPU_integration_and_assembly; 00206 double CPU_GPU_solver_ds_merging; 00207 double create_sm_uncon; 00208 double adding_constraints_info; 00209 double total_integration_and_assembly; 00210 double solve; 00211 double write_solution; 00212 double total_sir_solve; 00213 00214 double export_mesh; 00215 double export_field; 00216 double compress_files; 00217 double create_patches; 00218 double recover_derivatives; 00219 double calculate_error; 00220 double refine_mesh; 00221 double project_field; 00222 double manual_refinemts; 00223 double total_outside_solver; 00224 00225 double total; 00226 } utt_time_measurement; 00227 00228 extern utt_time_measurement utv_time; 00229 00233 extern int utv_SIGINT_not_caught; 00234 extern void utr_ctrl_c_signal_handler(int param); 00235 00239 extern void utr_reset_time_counters( int Control); 00240 00244 extern void utr_display_time_counters( int Control); 00245 00246 00251 extern int utr_set_interactive( 00252 char* Workdir, // working directory 00253 int Argc, // passed from maine 00254 char **Argv, 00255 FILE **Interactive_input, 00256 FILE **Interactive_output 00257 ); 00258 00262 extern int utr_initialize_mesh( 00263 FILE *Interactive_output, 00264 const char* Work_dir, // path to working directory 00265 char Mesh_type, 00266 const char* Mesh_file 00267 ); 00268 00272 extern int utr_initialize_field( 00273 FILE *Interactive_output, 00274 char Field_type, 00275 char Control, 00280 int Mesh_id, 00281 int Nreq, 00282 int Nr_sol, 00283 int Pdeg, 00284 char *Filename, 00285 double (*Fun_p)(int, double*, int) 00287 ); 00288 00292 extern int utr_write_paraview_std_lin( 00293 int Mesh_id, 00294 int Field_id, 00295 const char* Workdir, 00296 const char *Filename, 00297 ute_paraview_flags VTK_file_version 00298 ); 00299 00302 00303 extern int utr_write_paraview_mesh(int Mesh_id, 00304 const char* Work_dir, 00305 const char *Filename, 00306 ute_paraview_flags VTK_file_version); 00307 00310 00311 extern void utr_write_paraview_partmesh( 00312 int Mesh_id, 00313 const char* Work_dir, 00314 const char *Filename, 00315 int *Parts, 00316 ute_paraview_flags VTK_file_version 00317 ); 00318 00319 typedef struct { 00320 int field_id; 00321 int dofs_write[20]; // dofs to write: dofs_write[0] - number of dofs 00322 // dofs_write[i] - IDs of dofs to write 00323 ute_paraview_flags entity_type; 00324 ute_paraview_flags quantity_type; 00325 ute_paraview_flags value_type; 00326 char const *field_name; 00327 } utt_paraview_field_descriptor; 00328 00331 00332 extern int utr_write_paraview_fields(const char* Work_dir, 00333 const char* Filename, 00334 double Current_time, 00335 const int N_descriptors, 00336 utt_paraview_field_descriptor* Field_descriptors, 00337 ute_paraview_flags VTK_file_version 00338 ); 00341 00342 extern int utr_write_paraview_tensor( 00343 int Field_id, 00344 FILE *File, 00345 int* Dofs_write, // dofs to write: dofs_write[0] - number of dofs 00346 // dofs_write[i] - IDs of dofs to write 00347 double dt 00348 ); 00351 00352 extern int utr_write_paraview_bc( 00353 int Mesh_id, 00354 const char* Work_dir, 00355 const char *Filename, 00356 ute_paraview_flags VTK_file_version 00357 ); 00358 00359 /*--------------------------------------------------------- 00360 utr_get_ent_dofs - to read geometry or solution DOFs for a given DOF entity 00361 from suitable (approximation or mesh) data structures 00362 ----------------------------------------------------------*/ 00363 int utr_get_ent_dofs( 00364 int Problem_id, 00365 int Dof_ent_type, 00366 int Dof_ent_id, 00367 int Nrdofs, 00368 int Vect_id, 00369 /* or geometrical DOFs */ 00370 double* Vect_dofs 00371 ); 00372 00373 00378 extern int utr_create_patches( 00379 int Problem_id, 00380 utt_patches **patches_p 00381 ); 00382 00387 extern int utr_create_patches_small( 00388 int Problem_id, 00389 utt_patches **patches_p 00390 ); 00391 00396 extern int utr_recover_derivatives( 00397 int Field_id, 00398 int Sol_vec_id, /*in: which solution vector to take into account */ 00399 int Nr_patches, 00400 utt_patches *patches 00402 ); 00403 00409 extern int utr_recover_derivatives_small( 00410 int Field_id, 00411 int Sol_vec_id, /*in: which solution vector to take into account */ 00412 int Nr_patches, 00413 utt_patches *patches 00415 ); 00416 00420 extern int utr_adapt( 00421 int Problem_id, 00422 char* Work_dir, 00423 FILE *Interactive_input, 00424 FILE *Interactive_output 00425 ); 00426 00430 extern int utr_test_refinements( 00431 int Problem_id, 00432 char* Work_dir, 00433 FILE *Interactive_input, 00434 FILE *Interactive_output 00435 ); 00436 00440 extern int utr_manual_refinement( 00441 int Problem_id, 00442 char* Work_dir, 00443 FILE *Interactive_input, 00444 FILE *Interactive_output 00445 ); 00446 00454 extern int utr_get_list_ent( 00455 int Problem_id, 00456 int* Nr_int_ent, 00458 int** List_int_ent_type, 00459 int** List_int_ent_id, 00461 int* Nr_dof_ent, 00463 int** List_dof_ent_type, 00464 int** List_dof_ent_id, 00465 int** List_dof_ent_nrdofs, 00466 int* Nrdofs_glob, 00467 int* Max_dofs_per_dof_ent 00468 ); 00469 00470 00471 00472 /*------------------------------------------------------------ 00473 utr_get_list_dof_ent - to return the list DOF entities 00474 - entities with which there are dofs 00475 associated by the given approximation 00476 given the list of integration entities - entities 00477 for which stiffness matrices and load vectors are 00478 provided by the FEM code to the solver module 00479 (not for DG approximation!!!) 00480 ------------------------------------------------------------*/ 00481 extern int utr_get_list_dof_ent( /* returns: >=0 - success code, <0 - error code */ 00482 int Problem_id, /* in: problem (and solver) identification */ 00483 int* Nr_int_ent, /* in: number of integration entitites */ 00484 int** List_int_ent_type,/* in: list of types of integration entitites */ 00485 int** List_int_ent_id, /* in: list of IDs of integration entitites */ 00486 /* GHOST DOF ENTITIES HAVE NEGATIVE TYPE !!! */ 00487 int* Nr_dof_ent, /* out: number of dof entities (entities with which there 00488 are dofs associated by the given approximation) */ 00489 int** List_dof_ent_type,/* out: list of types of integration entitites */ 00490 int** List_dof_ent_id, /* out: list of IDs of integration entitites */ 00491 int** List_dof_ent_nrdofs,/* out: list of no of dofs for 'dof' entity */ 00492 int* Nrdofs_glob, /* out: global number of degrees of freedom (unknowns) */ 00493 int* Max_dofs_per_dof_ent/* out: maximal number of dofs per dof entity */ 00494 ); 00495 00496 /*------------------------------------------------------------ 00497 utr_get_list_int_ent - to return the list of integration entities - entities 00498 for which stiffness matrices and load vectors are 00499 provided by the FEM code to the solver module 00500 (not for DG approximation!!!) 00501 ------------------------------------------------------------*/ 00502 extern int utr_get_list_int_ent( /* returns: >=0 - success code, <0 - error code */ 00503 int Problem_id, /* in: problem (and solver) identification */ 00504 int* Nr_int_ent, /* out: number of integration entitites */ 00505 int** List_int_ent_type,/* out: list of types of integration entitites */ 00506 int** List_int_ent_id /* out: list of IDs of integration entitites */ 00507 ); 00508 00518 extern int utr_get_list_ent_coarse( /* returns: >=0 - success code, <0 - error code */ 00519 int Problem_id, /* in: problem (and solver) identification */ 00520 int Nr_int_ent_fine, /* in: number of integration entitites */ 00521 int *List_int_ent_type_fine, /* in: list of types of integration entitites */ 00522 int *List_int_ent_id_fine, /* in: list of IDs of integration entitites */ 00523 int Nr_dof_ent_fine, /* in: number of dof entities (entities with which there 00524 are dofs associated by the given approximation) */ 00525 int *List_dof_ent_type_fine, /* in: list of types of integration entitites */ 00526 int *List_dof_ent_id_fine, /* in: list of IDs of integration entitites */ 00527 int *List_dof_ent_nrdof_fine, /* in: list of no of dofs for 'dof' entity */ 00528 int Nrdof_glob_fine, /* in: global number of degrees of freedom (unknowns) */ 00529 int Max_dof_per_ent_fine, /* in: maximal number of dofs per dof entity */ 00530 int *Pdeg_coarse_p, /* in: degree of approximation for coarse space */ 00531 int *Nr_int_ent_p, /* out: number of integration entitites */ 00532 int **List_int_ent_type, /* out: list of types of integration entitites */ 00533 int **List_int_ent_id, /* out: list of IDs of integration entitites */ 00534 int *Nr_dof_ent_p, /* out: number of dof entities (entities with which there 00535 are dofs associated by the given approximation) */ 00536 int **List_dof_ent_type, /* out: list of types of integration entitites */ 00537 int **List_dof_ent_id, /* out: list of IDs of integration entitites */ 00538 int **List_dof_ent_nrdofs, /* out: list of no of dofs for 'dof' entity */ 00539 int* Nrdofs_glob_p, /* out: global number of degrees of freedom (unknowns) */ 00540 int* Max_dofs_per_dof_ent_p /* out: maximal number of dofs per dof entity */ 00541 ); 00542 00543 00544 /*------------------------------------------------------------ 00545 utr_get_max_num_grid_levels - for limiting nr_levels in multigrid 00546 based on mesh and field data 00547 ------------------------------------------------------------*/ 00548 extern int utr_get_max_num_grid_levels( 00549 int Problem_id 00550 ); 00551 00552 00553 /*--------------------------------------------------------- 00554 utr_dof_ent_sons - to return info whether the entity is owned 00555 and a list of dof entity sons for owned entity 00556 ---------------------------------------------------------*/ 00557 extern int utr_dof_ent_sons( /* returns: info whether the entity is owned */ 00558 int Problem_id, /* in: problem ID */ 00559 int Ent_type, /* in: type of mesh entity */ 00560 int Ent_id, /* in: mesh entity ID */ 00561 int *Ent_sons /* out: list of dof entity sons (for owned entities) */ 00562 /* Ent_sons[0] - number of sons */ 00563 ); 00564 00565 /*------------------------------------------------------------ 00566 utr_comp_stiff_mat - to create a stiffness matrix 00567 and a load vector corresponding to the specified 00568 mesh entity, together with information on how to 00569 assemble entries into the global stiffness matrix 00570 and the global load vector 00571 ------------------------------------------------------------*/ 00572 extern int utr_comp_stiff_mat( /* returns: >=0 - success code, <0 - error code */ 00573 int Problem_id, /* in: approximation field ID */ 00574 int Int_ent_type, /* in: unique identifier of the integration entity */ 00575 int Int_ent_id, /* in: unique identifier of the integration entity */ 00576 int Comp_sm, /* in: indicator for the scope of computations: */ 00577 /* PDC_NO_COMP - do not compute anything */ 00578 /* PDC_COMP_SM - compute entries to stiff matrix only */ 00579 /* PDC_COMP_RHS - compute entries to rhs vector only */ 00580 /* PDC_COMP_BOTH - compute entries for sm and rhsv */ 00581 int *Pdeg_vec, /* in: enforced degree of polynomial (if > 0 ) */ 00582 int *Nr_dof_ent, /* in: size of arrays, */ 00583 /* out: number of mesh entities with which dofs and */ 00584 /* stiffness matrix blocks are associated */ 00585 int *List_dof_ent_type, /* out: list of types for 'dof' entities */ 00586 int *List_dof_ent_id, /* out: list of ids for 'dof' entities */ 00587 int *List_dof_ent_nrdofs, /* out: list of no of dofs for 'dof' entity */ 00588 int *Nrdofs_loc, /* in(optional): size of Stiff_mat and Rhs_vect */ 00589 /* out(optional): actual number of dofs per integration entity */ 00590 double *Stiff_mat, /* out(optional): stiffness matrix stored columnwise */ 00591 double *Rhs_vect, /* outpds_elast_ls_std_intf.c(optional): rhs vector */ 00592 char *Rewr_dofs /* out(optional): flag to rewrite or sum up entries */ 00593 /* 'T' - true, rewrite entries when assembling */ 00594 /* 'F' - false, sum up entries when assembling */ 00595 ); 00596 00602 extern int utr_create_assemble_stiff_mat( 00603 int Problem_id, 00604 int Level_id, 00605 int Comp_type, 00606 //extern const int PDC_NO_COMP ; /** do not compute stiff matrix and rhs vector */ 00607 //extern const int PDC_COMP_SM ; /** compute entries to stiff matrix only */ 00608 //extern const int PDC_COMP_RHS ; /** compute entries to rhs vector only */ 00609 //extern const int PDC_COMP_BOTH; /** compute entries for sm and rhsv */ 00610 int* Pdeg_coarse_p, // indicator or value for pdeg on coarse meshes 00611 int Nr_int_ent, 00612 int* L_int_ent_type, 00613 int* L_int_ent_id, 00614 int Nr_colors_elems, 00615 int* L_color_index_elems, 00616 int Nr_colors_faces, 00617 int* L_color_index_faces, 00618 int* Asse_pos_first_dof_int_ent, 00619 int* Assembly_table, 00620 int* Pos_first_dof_int_ent, 00621 int* Local_to_global, 00622 int Max_dofs_int_ent 00623 ); 00624 00625 00629 extern int utr_rewr_sol( 00630 int Field_id, 00631 int Sol_from, 00632 int Sol_to 00633 ); 00634 00635 /*------------------------------------------------------------ 00636 utr_renumber - to renumber (permute) graph vertices 00637 ------------------------------------------------------------*/ 00638 extern void utr_renumber( 00639 int Nr_vertices, /* in: number of graph vertices */ 00640 int * Nrneig, /* in: list of numbers of neighbors */ 00641 int ** L_neig, /* in: adjacency list */ 00642 int *Permutation_array /* out: permutation vector */ 00643 ); 00644 00645 00649 extern double utr_average_sol_el( 00650 int Field_id, 00651 int El 00652 ); 00653 00658 extern double *utr_dvector( 00659 int ncom, 00660 char error_text[] 00661 ); 00662 00667 extern int *utr_ivector( 00668 int ncom, 00669 char error_text[] 00670 ); 00671 00672 00676 extern void utr_d_zero( 00677 double* Vec, 00678 int Num 00679 ); 00680 00685 extern int utr_chk_list( 00688 int Num, 00689 int* List, 00690 int Ll 00691 ); 00692 00697 extern int utr_put_list( 00701 int Num, 00702 int* List, 00703 int Ll 00704 ); 00705 00709 extern double utr_mat3_inv( 00711 const double *mat, 00712 double *mat_inv 00713 ); 00714 00715 //---------------------------------------------------------- 00716 //utr_vec3_add - to compute sum of 3D vectors 00717 //---------------------------------------------------------- 00718 00719 extern void utr_vec3_add( 00720 const double vec_a[3], //IN 00721 const double vec_b[3], //IN 00722 double vec_c[3]); //OUT 00723 00724 //---------------------------------------------------------- 00725 //utr_vec3_subst - to compute the difference of 3D vectors 00726 //---------------------------------------------------------- 00727 00728 extern void utr_vec3_subst( 00729 const double vec_a[3], //IN 00730 const double vec_b[3], // IN 00731 double vec_c[3]); // OUT 00732 00736 extern void utr_vec3_prod( 00737 const double* vec_a, 00738 const double* vec_b, 00739 double* vec_c 00740 ); 00741 00745 extern double utr_vec3_mxpr( 00746 const double* vec_a, 00747 const double* vec_b, 00748 const double* vec_c 00749 ); 00750 00754 extern double utr_vec3_length( 00755 const double* vec 00756 ); 00757 00761 extern void utr_mat3vec( 00762 const double* m1, 00763 const double* v1, 00764 double* v2 00765 ); 00766 00771 extern void utr_mat3mat( 00772 const double* m1, 00773 const double* m2, 00774 double* m3 00775 ); 00776 00777 00778 //---------------------------------------------------------- 00779 //utr_vec3_dot - to compute vector dot product of 3D vectors 00780 //---------------------------------------------------------- 00781 extern double utr_vec3_dot( 00782 const double vec_a[3], 00783 const double vec_b[3]); 00784 00785 //---------------------------------------------------------- 00786 //utr_vec3_angle - to compute vector dot product of 3D vectors 00787 //---------------------------------------------------------- 00788 extern double utr_vec3_angle( 00789 const double vec_a[3], 00790 const double vec_b[3]); 00791 00792 00796 extern double utr_mat_det(const double *m, int n,char store, double * det); 00797 00801 extern void utr_skip_rest_of_line( 00802 FILE *Fp 00803 ); 00804 00805 00810 extern int utr_fprintf_double( 00811 FILE* stream, // output stream 00812 int sdigits, // number of significant digits to write - put 0 for 00813 // full accuracy (.12) written in "%g" fashion 00814 double value // double to write 00815 ); 00816 00820 extern void utr_heap_sort( 00821 int *Ind_array, 00823 double *Val_array 00824 ); 00825 00829 extern int utr_insert_sort( 00830 int* A, // array 00831 int p, //first index 00832 int k // last index 00833 ); 00834 00835 00836 //-------------------------------------------------------- 00837 // utr_io_read_mesh - to read mesh with given filename(s) 00838 // Reads all mesh files from current working directory 00839 // that matches with passed regular expression Mesh_files_regex. 00840 // All files HAVE TO be the same type (ex. nas,dat,in etc.). 00841 // NOTE: single filename ex. "mesh.dat" is also a valid regular expression. 00842 //-------------------------------------------------------- 00843 extern int utr_io_read_mesh( 00844 // returns: > 0 - number of files correctly read; <=0 - error 00845 const int Mesh_id, // IN: id of mesh to read to 00846 const char * Working_dir, // IN: directory with mesh file(s) 00847 const char * Mesh_files_regex, // IN: regular expression pattern 00848 // NOTE: using regex 'POSIX grep' standard 00849 const char Mesh_type // IN: type of mesh 00850 ); 00851 00852 00856 extern int utr_export_field( 00857 int Field_id, /* in: field ID */ 00858 int Nreq, /* in: number of equations (scalar dofs) */ 00859 int Select, /* in: parameter to select written vectors */ 00860 int Accuracy, /* in: parameter specyfying accuracy - significant digits */ 00861 /* (put 0 for full accuracy in "%g" format) */ 00862 char *Filename /* in: name of the file to write field data */ 00863 ); 00864 00868 extern int utr_io_export_mesh( 00869 FILE *Interactive_output, 00870 const int Mesh_id, // id of mesh to export 00871 char Mesh_type, 00872 char* Mesh_file 00873 ); 00874 00875 00879 extern int utr_menu_export_mesh( 00880 FILE *Interactive_output, 00881 FILE *Interactive_input, 00882 const int Mesh_id, 00883 const char *Work_dir, 00884 char* Mesh_file 00885 ); 00886 00887 00888 00889 extern int utr_io_write_img_to_pbm(// returns 0 if all ok. 00890 const char * Work_dir, // Directory to write in. 00891 const char * Filename, // without extension 00892 const char * Comment, // written into img file header, can be NULL if no comment. 00893 const int Width, // >0 00894 const int Height, // >0 00895 const int Max_color_component_value, 00896 const int Magic_number, // {4,5,6} 00897 const unsigned char* Img_data, // pointer to the array with image data 00898 FILE* Interactive_output 00899 ); 00900 00901 00902 00903 00904 00905 00906 int utr_io_write_mesh_info_to_PAM(int Mesh_id 00907 , const char *Work_dir, const char *Filename, const char *Comment, FILE *Interactive_output); 00908 00909 // utr_io_write_img_to_pam - to write data into PAM image file. 00910 // http://en.wikipedia.org/wiki/Netpbm 00911 // Allowed combinations of parameters: 00912 // ----------------------------------------------------------- 00913 // TUPLTYPE |MAXVAL |DEPTH |comment 00914 // ----------------------------------------------------------- 00915 // BLACKANDWHITE 1 1 special case of GRAYSCALE 00916 // GRAYSCALE 2…65535 1 2 bytes per pixel for MAXVAL > 255 00917 // RGB 1…65535 3 6 bytes per pixel for MAXVAL > 255 00918 // BLACKANDWHITE_ALPHA 1 2 2 bytes per pixel 00919 // GRAYSCALE_ALPHA 2…65535 2 4 bytes per pixel for MAXVAL > 255 00920 // RGB_ALPHA 1…65535 4 8 bytes per pixel for MAXVAL > 255s of parameters: 00921 // ----------------------------------------------------------- 00922 int utr_io_write_img_to_pam( // returns 0 if all ok. 00923 const char * Work_dir, // Directory to write in. 00924 const char * Filename, // without extension 00925 const int Width, // >0 00926 const int Height, // >0 00927 const int Depth, // <1:4> 00928 const int Maxval, // <1:65535>, 00929 const char* TUPLTYPE, 00930 const char* Img_data, // pointer to the array with image data 00931 FILE* Interactive_output 00932 ); 00933 00934 // utr_io_write_img_to_pnm - to write data into PNM image file. 00935 // The Portable Bit/Grey/PixMap formats PBM, PGM, PPM. 00936 // They are collectively referred to as PNM (Portable aNy Map). 00937 // http://en.wikipedia.org/wiki/Netpbm_format 00938 // Allowed combinations: 00939 // ----------------------------------------------------------- 00940 // Type Magic number Extension Colors 00941 // ----------------------------------------------------------- 00942 // Portable BitMap P4 binary .pbm 0–1 (black & white) 00943 // Portable GrayMap P5 binary .pgm 0–255 (gray scale) 00944 // Portable PixMap P6 binary .ppm 0–255 (RGB) 00945 // ----------------------------------------------------------- 00946 int utr_io_write_img_to_pnm(// returns 0 if all ok. 00947 const char * Work_dir, // Directory to write in. 00948 const char * Filename, // without extension 00949 const char * Comment, // written into img file header, can be NULL if no comment. 00950 const int Width, // >0 00951 const int Height, // >0 00952 const int Max_color_component_value, // see Colors above 00953 const int Magic_number, // {4,5,6} 00954 const char* Img_data, // pointer to the array with image data 00955 FILE* Interactive_output 00956 ); 00957 00958 00959 int utr_color_int_ent_for_assembly( 00960 int Problem_id, /* in: Problem id */ 00961 int Level_id, /* in: Level id */ 00962 int nr_elems, /* in: number of elements */ 00963 int nr_faces, /* in: number of faces */ 00964 int* L_int_ent_type, /* in: integration entities type, 00965 out: coloured */ 00966 int* L_int_ent_id, /* in: integration entities id, 00967 out: coloured */ 00968 int nr_dof_ent, /* number of dof entities dof_ents */ 00969 int* nr_int_ent_loc, /* number of int_ents for each dof_ent */ 00970 int** l_int_ent_index, /* list of indices in int_ent table for each dof_ent */ 00971 int* Nr_colors_elems, /* out: number of colours for elements */ 00972 int** L_color_index_elems,/* out: crs table with index of L_int_ent.. where colour starts and ends */ 00973 int* Nr_colors_faces, /* out: number of colours for faces */ 00974 int** L_color_index_faces /* out: crs table with index of L_int_ent.. where colour starts and ends */ 00975 ); 00976 00977 00978 // UTR_IO_RESULT (file with infomrations) should not be here! 00979 // It is in uth_io_files.h 00980 00992 int utr_ctrl_pts_init(const char* Work_dir, const char* Filename, const int N_solutions, 00993 const char* Target_ctrl_pts_filename); 01004 int utr_ctrl_pts_add_values(const int Field_id); 01005 01006 int utr_generate_int_ent_coloring( // return number of colors 01007 const int nr_int_ent, // IN: mesh id to color 01008 int ** elem2elem, // IN: array entity neighborhood 01009 int *Elem_colors); // OUT: array of size number of active elems containing colors (numbers) 01010 01011 01013 01014 // end of group 01016 01017 01018 #ifdef __cplusplus 01019 } 01020 #endif 01021 01022 #endif