"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cgnstools/utilities/update_ngon.c" between
CGNS-4.1.0.tar.gz and CGNS-4.1.1.tar.gz

About: The CGNS (CFD General Notation System) provides a standard for recording and recovering computer data associated with the numerical solution of fluid dynamics equations.

update_ngon.c  (CGNS-4.1.0):update_ngon.c  (CGNS-4.1.1)
skipping to change at line 63 skipping to change at line 63
/* allocate data */ /* allocate data */
for (n = 0; n < ndim; n++) { for (n = 0; n < ndim; n++) {
size *= dim_vals[n]; size *= dim_vals[n];
} }
if (size <= 0) { if (size <= 0) {
return 1; return 1;
} }
data = malloc((size_t) size*sizeof(int)); data = malloc((size_t) size*sizeof(int));
/* read elem type */ /* read elem type */
if (cgio_read_all_data(cgio_num, elem_id, data) != CG_OK) { if (cgio_read_all_data_type(cgio_num, elem_id, "I4", data) != CG_OK) {
free(data); free(data);
return 1; return 1;
} }
int elem_type = data[0]; int elem_type = data[0];
free(data); free(data);
/* Handle NGON_n and NFAce_n in the same way but MIXED is a bit different */ /* Handle NGON_n and NFAce_n in the same way but MIXED is a bit different */
if (elem_type == CGNS_ENUMV(NGON_n) || if (elem_type == CGNS_ENUMV(NGON_n) ||
elem_type == CGNS_ENUMV(NFACE_n)) { elem_type == CGNS_ENUMV(NFACE_n)) {
double connect_id; double connect_id;
double offset_id; double offset_id;
skipping to change at line 103 skipping to change at line 103
int * connectivity = NULL; int * connectivity = NULL;
int *new_connectivity = NULL; int *new_connectivity = NULL;
int * new_offset = NULL; int * new_offset = NULL;
cgsize_t num_elem = 0; cgsize_t num_elem = 0;
cgsize_t idx = 0; cgsize_t idx = 0;
cgsize_t cur_idx = 0; cgsize_t cur_idx = 0;
cgsize_t cur_elem = 0; cgsize_t cur_elem = 0;
cgsize_t local_idx; cgsize_t local_idx;
connectivity = malloc((size_t)sizeof(int)*elem_size); connectivity = malloc((size_t)sizeof(int)*elem_size);
cgio_read_all_data(cgio_num, connect_id, (void *)connectivity); cgio_read_all_data_type(cgio_num, connect_id, datatype, (void *)conn ectivity);
/* first count number of elements */ /* first count number of elements */
idx = 0; idx = 0;
while (idx < elem_size) { while (idx < elem_size) {
num_elem += 1; num_elem += 1;
idx += connectivity[idx] + 1; idx += connectivity[idx] + 1;
} }
new_connectivity = malloc((size_t)(elem_size - num_elem)*sizeof(int) ); new_connectivity = malloc((size_t)(elem_size - num_elem)*sizeof(int) );
new_offset = malloc((size_t)(num_elem + 1)*sizeof(int)); new_offset = malloc((size_t)(num_elem + 1)*sizeof(int));
skipping to change at line 153 skipping to change at line 153
else if (strcmp(datatype, "I8") == 0) { else if (strcmp(datatype, "I8") == 0) {
cglong_t * connectivity = NULL; cglong_t * connectivity = NULL;
cglong_t * new_connectivity = NULL; cglong_t * new_connectivity = NULL;
cglong_t * new_offset = NULL; cglong_t * new_offset = NULL;
cgsize_t num_elem = 0; cgsize_t num_elem = 0;
cgsize_t idx = 0; cgsize_t idx = 0;
cgsize_t cur_idx = 0; cgsize_t cur_idx = 0;
cgsize_t cur_elem = 0; cgsize_t cur_elem = 0;
cgsize_t local_idx; cgsize_t local_idx;
connectivity = malloc((size_t)sizeof(cglong_t)*elem_size); connectivity = malloc((size_t)sizeof(cglong_t)*elem_size);
cgio_read_all_data(cgio_num, connect_id, (void *)connectivity); cgio_read_all_data_type(cgio_num, connect_id, datatype, (void *)conn ectivity);
/* first count number of elements */ /* first count number of elements */
while (idx < elem_size) { while (idx < elem_size) {
idx += connectivity[idx] +1; idx += connectivity[idx] +1;
num_elem += 1; num_elem += 1;
} }
new_connectivity = malloc((size_t)(elem_size - num_elem) * sizeof(cg long_t)); new_connectivity = malloc((size_t)(elem_size - num_elem) * sizeof(cg long_t));
new_offset = malloc((size_t)(num_elem + 1) * sizeof(cglong_t)); new_offset = malloc((size_t)(num_elem + 1) * sizeof(cglong_t));
idx = 0; idx = 0;
skipping to change at line 236 skipping to change at line 236
if (strcmp(datatype, "I4") == 0) { if (strcmp(datatype, "I4") == 0) {
int * connectivity = NULL; int * connectivity = NULL;
int * new_offset = NULL; int * new_offset = NULL;
int nparts_in_elem; int nparts_in_elem;
cgsize_t num_elem = 0; cgsize_t num_elem = 0;
cgsize_t idx = 0; cgsize_t idx = 0;
cgsize_t cur_idx = 0; cgsize_t cur_idx = 0;
cgsize_t cur_elem = 0; cgsize_t cur_elem = 0;
connectivity = malloc((size_t)sizeof(int)*elem_size); connectivity = malloc((size_t)sizeof(int)*elem_size);
cgio_read_all_data(cgio_num, connect_id, (void *)connectivity); cgio_read_all_data_type(cgio_num, connect_id, datatype, (void *)conn ectivity);
/* first count number of elements */ /* first count number of elements */
while (idx < elem_size) { while (idx < elem_size) {
int celltype = connectivity[idx]; int celltype = connectivity[idx];
int npe; int npe;
cg_npe(celltype, &npe); cg_npe(celltype, &npe);
idx += npe + 1; idx += npe + 1;
num_elem += 1; num_elem += 1;
} }
new_offset = malloc((size_t)(num_elem + 1) * sizeof(int)); new_offset = malloc((size_t)(num_elem + 1) * sizeof(int));
skipping to change at line 278 skipping to change at line 278
else if (strcmp(datatype, "I8") == 0) { else if (strcmp(datatype, "I8") == 0) {
cglong_t * connectivity = NULL; cglong_t * connectivity = NULL;
cglong_t * new_offset = NULL; cglong_t * new_offset = NULL;
cgsize_t num_elem = 0; cgsize_t num_elem = 0;
cgsize_t idx = 0; cgsize_t idx = 0;
cgsize_t cur_idx = 0; cgsize_t cur_idx = 0;
cgsize_t cur_elem = 0; cgsize_t cur_elem = 0;
int nparts_in_elem; int nparts_in_elem;
connectivity = malloc((size_t)sizeof(cglong_t)*elem_size); connectivity = malloc((size_t)sizeof(cglong_t)*elem_size);
cgio_read_all_data(cgio_num, connect_id, (void *)connectivity); cgio_read_all_data_type(cgio_num, connect_id, datatype, (void *)conn ectivity);
/* first count number of elements */ /* first count number of elements */
while (idx < elem_size) { while (idx < elem_size) {
cglong_t celltype = connectivity[idx]; cglong_t celltype = connectivity[idx];
int npe; int npe;
cg_npe(celltype, &npe); cg_npe(celltype, &npe);
idx += npe + 1; idx += npe + 1;
num_elem += 1; num_elem += 1;
} }
new_offset = malloc((size_t)(num_elem + 1) * sizeof(cglong_t)); new_offset = malloc((size_t)(num_elem + 1) * sizeof(cglong_t));
skipping to change at line 369 skipping to change at line 369
/* allocate data */ /* allocate data */
for (n = 0; n < ndim; n++) { for (n = 0; n < ndim; n++) {
size *= dim_vals[n]; size *= dim_vals[n];
} }
if (size <= 0) { if (size <= 0) {
free(node_ids); free(node_ids);
return 1; return 1;
} }
data = malloc((size_t)sizeof(char)*(size + 1)); data = malloc((size_t)sizeof(char)*(size + 1));
/* read data zonetype */ /* read data zonetype */
if (cgio_read_all_data(cgio_num, childid, (void*)data) != CG_OK) { if (cgio_read_all_data_type(cgio_num, childid, "C1", (void*)data) != CG_OK) {
data[0] = '\0'; data[0] = '\0';
} }
else { else {
data[size] = '\0'; data[size] = '\0';
} }
/* define CGNS zone type */ /* define CGNS zone type */
if (strcmp(data, "Structured") == 0) { if (strcmp(data, "Structured") == 0) {
zt = CGNS_ENUMV(Structured); zt = CGNS_ENUMV(Structured);
} }
else if (strcmp(data, "Unstructured") == 0) { else if (strcmp(data, "Unstructured") == 0) {
skipping to change at line 480 skipping to change at line 480
if (cgio_get_file_type(inpcg, &inptype)) { if (cgio_get_file_type(inpcg, &inptype)) {
cgio_error_exit("cgio_get_file_type"); cgio_error_exit("cgio_get_file_type");
} }
if (cgio_file_version (inpcg, version, created, modified)) { if (cgio_file_version (inpcg, version, created, modified)) {
cgio_error_exit ("cgio_file_version"); cgio_error_exit ("cgio_file_version");
} }
if (0 == cgio_get_node_id (inpcg, root_id, if (0 == cgio_get_node_id (inpcg, root_id,
"CGNSLibraryVersion",&node_id) && "CGNSLibraryVersion",&node_id) &&
0 == cgio_read_all_data (inpcg, node_id, &cgns_version)) { 0 == cgio_read_all_data_type(inpcg, node_id, "R4", &cgns_version)) {
printf ("CGNS version : %4.2f\n", cgns_version); printf ("CGNS version : %4.2f\n", cgns_version);
if (cgns_version < 4.0) { if (cgns_version < 4.0) {
status = 1; status = 1;
} }
else { else {
status = 0; status = 0;
} }
} }
else { else {
printf ("CGNS version : not defined\n"); printf ("CGNS version : not defined\n");
status = 1; status = 1;
} }
if (cgio_close_file (inpcg)) { if (cgio_close_file (inpcg)) {
cgio_error_exit ("cgio_close_file"); cgio_error_exit ("cgio_close_file");
} }
return status; return status;
} }
int update_cgns_version(double cgio_num, double root_id) void update_cgns_version(double cgio_num, double root_id)
{ {
double node_id; double node_id;
float cgns_version = 4.00; float cgns_version = 4.00;
cgsize_t dim_vals[12]; cgsize_t dim_vals[12];
if (0 == cgio_get_node_id (cgio_num, root_id, "CGNSLibraryVersion", &node_id )) { if (0 == cgio_get_node_id (cgio_num, root_id, "CGNSLibraryVersion", &node_id )) {
cgio_write_all_data(cgio_num, node_id, &cgns_version); cgio_write_all_data(cgio_num, node_id, &cgns_version);
} }
else { else {
cgio_create_node(cgio_num, root_id, "CGNSLibraryVersion", &node_id); cgio_create_node(cgio_num, root_id, "CGNSLibraryVersion", &node_id);
 End of changes. 8 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)