"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/tools/cgnscheck.c" between
CGNS-4.1.2.tar.gz and CGNS-4.2.0.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.

cgnscheck.c  (CGNS-4.1.2):cgnscheck.c  (CGNS-4.2.0)
skipping to change at line 23 skipping to change at line 23
# define access _access # define access _access
# define unlink _unlink # define unlink _unlink
#else #else
# include <unistd.h> # include <unistd.h>
#endif #endif
#include "getargs.h" #include "getargs.h"
#include "hash.h" #include "hash.h"
#include "cgnslib.h" #include "cgnslib.h"
#include "cgns_header.h" #include "cgns_header.h"
#include "cgnames.h" #include "cgnames.h"
#include "cgns_io.h"
#if !defined(CGNS_VERSION) || CGNS_VERSION < 3100 #if !defined(CGNS_VERSION) || CGNS_VERSION < 3100
# error You need at least CGNS Version 3.1 # error You need at least CGNS Version 3.1
#endif #endif
#define USE_MID_NODES #define USE_MID_NODES
#if CG_SIZEOF_SIZE == 32 #if CG_SIZEOF_SIZE == 32
#define CG_ABS abs #define CG_ABS abs
#else #else
skipping to change at line 664 skipping to change at line 665
nodes = z->sets[ns].elements; nodes = z->sets[ns].elements;
offsets = z->sets[ns].offsets; offsets = z->sets[ns].offsets;
type = z->sets[ns].type; type = z->sets[ns].type;
if (type == CGNS_ENUMV(NGON_n)) { if (type == CGNS_ENUMV(NGON_n)) {
*nnodes = (int)(offsets[ne+1] - offsets[ne]); *nnodes = (int)(offsets[ne+1] - offsets[ne]);
nodes += (offsets[ne] - offsets[0]); nodes += (offsets[ne] - offsets[0]);
*dim = 2; *dim = 2;
return nodes; return nodes;
} }
if (type == CGNS_ENUMV(NFACE_n)) { if (type == CGNS_ENUMV(NFACE_n)) {
*nnodes = offsets[ne+1] - offsets[ne]; *nnodes = (int)(offsets[ne+1] - offsets[ne]);
nodes += (offsets[ne] - offsets[0]); nodes += (offsets[ne] - offsets[0]);
*dim = 3; *dim = 3;
return nodes; return nodes;
} }
if (type == CGNS_ENUMV(MIXED)) { if (type == CGNS_ENUMV(MIXED)) {
type = (CGNS_ENUMT(ElementType_t))*nodes++; type = (CGNS_ENUMT(ElementType_t))*nodes++;
if (FileVersion < 3200 &&
type >= CGNS_ENUMV(NGON_n)) {
nn = (int)(type - CGNS_ENUMV(NGON_n));
}
else {
if (cg_npe (type, &nn) || nn <= 0)
return NULL;
}
while (ne-- > 0) { while (ne-- > 0) {
nodes += nn;
type = (CGNS_ENUMT(ElementType_t))*nodes++;
if (FileVersion < 3200 && if (FileVersion < 3200 &&
type >= CGNS_ENUMV(NGON_n)) { type >= CGNS_ENUMV(NGON_n)) {
nn = (int)(type - CGNS_ENUMV(NGON_n)); nn = (int)(type - CGNS_ENUMV(NGON_n));
} }
else { else {
if (cg_npe (type, &nn) || nn <= 0) if (cg_npe (type, &nn) || nn <= 0)
return NULL; return NULL;
} }
nodes += nn;
type = (CGNS_ENUMT(ElementType_t))*nodes++;
} }
} }
else { else {
cg_npe (type, &nn); cg_npe (type, &nn);
if (nn <= 0) return NULL; if (nn <= 0) return NULL;
nodes += (nn * ne); nodes += (nn * ne);
} }
switch (type) { switch (type) {
case CGNS_ENUMV(NODE): case CGNS_ENUMV(NODE):
*dim = 0; *dim = 0;
skipping to change at line 1934 skipping to change at line 1943
if (cg_array_info (na, name, &datatype, &ndim, dims)) if (cg_array_info (na, name, &datatype, &ndim, dims))
error_exit ("cg_array_info"); error_exit ("cg_array_info");
print_indent (indent); print_indent (indent);
printf ("checking quantity \"%s\"\n", name); printf ("checking quantity \"%s\"\n", name);
fflush (stdout); fflush (stdout);
for (size = 1, n = 0; n < ndim; n++) for (size = 1, n = 0; n < ndim; n++)
size *= dims[n]; size *= dims[n];
if (ndim < 1 || size < 1) if (ndim < 1 || size < 1)
error ("invalid dimensions"); error ("invalid dimensions");
if (length < 0 && size != 1 && size != -length) if (length < 0 && size != 1 && size != -length)
error ("array size not 1 or %d", -length); error ("array size not 1 or %ld", -length);
if (length > 0 && size != length) if (length > 0 && size != length)
error ("array size not %d", length); error ("array size not %ld", length);
check_quantity (na, name, dataclass, punits, isref, indent+2); check_quantity (na, name, dataclass, punits, isref, indent+2);
} }
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static void check_user_data (int parclass, int *parunits, int indent) static void check_user_data (int parclass, int *parunits, int indent)
{ {
int n, nd, nu, nuser, na, ndim; int n, nd, nu, nuser, na, ndim;
cgsize_t dims[12]; cgsize_t dims[12];
skipping to change at line 3408 skipping to change at line 3417
} }
ierr = cg_famname_read (name); ierr = cg_famname_read (name);
if (ierr && ierr != CG_NODE_NOT_FOUND) error_exit("cg_famname_read"); if (ierr && ierr != CG_NODE_NOT_FOUND) error_exit("cg_famname_read");
if (ierr == CG_NODE_NOT_FOUND) { if (ierr == CG_NODE_NOT_FOUND) {
if (bctype == CGNS_ENUMV(FamilySpecified)) if (bctype == CGNS_ENUMV(FamilySpecified))
warning (1, warning (1,
"BC Type is FamilySpecified but no family name is given"); "BC Type is FamilySpecified but no family name is given");
} }
else { else {
if (bctype != CGNS_ENUMV(FamilySpecified)) {
warning(2, "BC Type is not FamilySpecified but a family name is defi
ned.\n");
}
if (verbose) printf (" Family=\"%s\"\n", name); if (verbose) printf (" Family=\"%s\"\n", name);
for (n = 0; n < NumFamily; n++) { for (n = 0; n < NumFamily; n++) {
if (0 == strcmp (name, Family[n])) break; if (0 == strcmp (name, Family[n])) break;
} }
if (n == NumFamily && if (n == NumFamily &&
(FileVersion >= 1200 || strcmp(name, "ORPHAN"))) (FileVersion >= 1200 || strcmp(name, "ORPHAN")))
warning (bctype == CGNS_ENUMV(FamilySpecified) ? 1 : 2, warning (bctype == CGNS_ENUMV(FamilySpecified) ? 1 : 2,
"family name \"%s\" not found", name); "family name \"%s\" not found", name);
} }
skipping to change at line 3564 skipping to change at line 3576
} }
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
static void check_zoneBC (void) static void check_zoneBC (void)
{ {
char name[33], *desc; char name[33], *desc;
int n, nb, ierr; int n, nb, ierr;
int *punits, units[9], dataclass; int *punits, units[9], dataclass;
ZONE *z = &Zones[cgnszone-1];
if (cg_nbocos (cgnsfn, cgnsbase, cgnszone, &nb)) if (cg_nbocos (cgnsfn, cgnsbase, cgnszone, &nb))
error_exit("cg_nbocos"); error_exit("cg_nbocos");
if (nb < 1) return; if (nb < 1) {
if (z->ns > 0 && CellDim == 3) {
warning(2, "Surface elements exists in the 3D zone but no ZoneBC_t is
declared. If the surface elements are meant to define boundaries ZoneBC_t is req
uired.");
}
return;
}
puts (" checking boundary conditions"); puts (" checking boundary conditions");
fflush (stdout); fflush (stdout);
go_absolute ("Zone_t", cgnszone, "ZoneBC_t", 1, NULL); go_absolute ("Zone_t", cgnszone, "ZoneBC_t", 1, NULL);
if (verbose > 1) { if (verbose > 1) {
int nd; int nd;
if (cg_ndescriptors (&nd)) error_exit("cg_ndescriptors"); if (cg_ndescriptors (&nd)) error_exit("cg_ndescriptors");
for (n = 1; n <= nd; n++) { for (n = 1; n <= nd; n++) {
if (cg_descriptor_read (n, name, &desc)) if (cg_descriptor_read (n, name, &desc))
error_exit("cg_descriptor_read"); error_exit("cg_descriptor_read");
skipping to change at line 5202 skipping to change at line 5220
printf ("\nchecking zone \"%s\"\n", z->name); printf ("\nchecking zone \"%s\"\n", z->name);
fflush (stdout); fflush (stdout);
if (z->type == CGNS_ENUMV(Structured)) { if (z->type == CGNS_ENUMV(Structured)) {
for (n = 0; n < CellDim; n++) { for (n = 0; n < CellDim; n++) {
if (z->dims[0][n] < 2) { if (z->dims[0][n] < 2) {
error ("number of points in %c-direction < 2", indexname[n]); error ("number of points in %c-direction < 2", indexname[n]);
z->idim = 0; z->idim = 0;
} }
if (z->dims[1][n] != z->dims[0][n] - 1) { if (z->dims[1][n] != z->dims[0][n] - 1) {
error ("number of cells in %c-direction is %d instead of %d", error ("number of cells in %c-direction is %ld instead of %ld",
indexname[n], z->dims[1][n], z->dims[0][n] - 1); indexname[n], z->dims[1][n], z->dims[0][n] - 1);
z->dims[1][n] = z->dims[0][n] - 1; z->dims[1][n] = z->dims[0][n] - 1;
} }
if (z->dims[2][n] != 0) if (z->dims[2][n] != 0)
warning (1, "VertexSizeBoundary in %c-direction should be 0" warning (1, "VertexSizeBoundary in %c-direction should be 0"
" for structured grid", indexname[n]); " for structured grid", indexname[n]);
} }
} }
else if (z->type == CGNS_ENUMV(Unstructured)) { else if (z->type == CGNS_ENUMV(Unstructured)) {
if (z->dims[0][0] < CellDim + 1) { if (z->dims[0][0] < CellDim + 1) {
skipping to change at line 5275 skipping to change at line 5293
if (ierr && ierr != CG_NODE_NOT_FOUND) error_exit("cg_famname_read"); if (ierr && ierr != CG_NODE_NOT_FOUND) error_exit("cg_famname_read");
if (ierr == CG_OK) { if (ierr == CG_OK) {
if (verbose) printf (" Family=%s\n", name); if (verbose) printf (" Family=%s\n", name);
for (n = 0; n < NumFamily; n++) { for (n = 0; n < NumFamily; n++) {
if (0 == strcmp (name, Family[n])) break; if (0 == strcmp (name, Family[n])) break;
} }
if (n >= NumFamily && if (n >= NumFamily &&
(FileVersion >= 1200 || strcmp(name, "ORPHAN"))) (FileVersion >= 1200 || strcmp(name, "ORPHAN")))
warning (2, "zone family name \"%s\" not found", name); warning (2, "zone family name \"%s\" not found", name);
} }
else if (ierr == CG_NODE_NOT_FOUND) {
warning(2, "No family name declared for zone \"%s\"."
"It is a recommended practice to associate one.", z->name);
}
/*----- ReferenceState -----*/ /*----- ReferenceState -----*/
ierr = cg_state_read (&desc); ierr = cg_state_read (&desc);
if (ierr && ierr != CG_NODE_NOT_FOUND) error_exit("cg_state_read"); if (ierr && ierr != CG_NODE_NOT_FOUND) error_exit("cg_state_read");
if (ierr == CG_OK) { if (ierr == CG_OK) {
puts (" checking reference state"); puts (" checking reference state");
if (desc != NULL) { if (desc != NULL) {
if (verbose > 1) if (verbose > 1)
printf (" Descriptor:%s\n", desc); printf (" Descriptor:%s\n", desc);
skipping to change at line 6130 skipping to change at line 6152
warning (1, "no zones defined"); warning (1, "no zones defined");
return; return;
} }
for (cgnszone = 1; cgnszone <= NumZones; cgnszone++) for (cgnszone = 1; cgnszone <= NumZones; cgnszone++)
check_zone (); check_zone ();
} }
/*=======================================================================*/ /*=======================================================================*/
void check_node_name_recursive(int cgio_num, double nodeid)
{
int nchildren, child;
int len;
char_33 name;
double *childids;
char *slash_ptr = NULL;
if (cgio_get_name(cgio_num, nodeid, name) != CG_OK) {
return;
}
if (strlen(name) < 1) {
return;
}
if (name[0] == '.') {
error ("Invalid CGNS node name: node should not start with a dot");
}
slash_ptr = strchr(name, '/');
if (slash_ptr != NULL) {
error("Invalid CGNS node name: node should not have a slash");
}
cgio_number_children(cgio_num, nodeid, &nchildren);
if (nchildren == 0) {
return;
}
childids = (double *) malloc(nchildren*sizeof(double));
cgio_children_ids(cgio_num, nodeid, 1, nchildren, &len, childids);
if (len != nchildren) {
free(childids);
return;
}
for (child = 0; child < nchildren; child++) {
check_node_name_recursive(cgio_num, childids[child]);
}
free(childids);
}
void check_node_names(void)
{
int cgio_num;
int nchildren, child, len;
double rootid;
double *childids;
printf ("\nchecking node names\n");
cg_get_cgio(cgnsfn, &cgio_num);
cg_root_id(cgnsfn, &rootid);
cgio_number_children(cgio_num, rootid, &nchildren);
childids = (double *) malloc(nchildren*sizeof(double));
cgio_children_ids(cgio_num, rootid, 1, nchildren, &len, childids);
if (len != nchildren) {
free(childids);
return;
}
for (child = 0; child < nchildren; child++) {
check_node_name_recursive(cgio_num, childids[child]);
}
free(childids);
}
/*=======================================================================*/
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
char *cgnsfile; char *cgnsfile;
int n, nbases, update = 0; int n, nbases, update = 0;
float file_version; float file_version;
if (argc < 2) if (argc < 2)
print_usage (usgmsg, NULL); print_usage (usgmsg, NULL);
while ((n = getargs (argc, argv, options)) > 0) { while ((n = getargs (argc, argv, options)) > 0) {
skipping to change at line 6197 skipping to change at line 6291
if (precision) printf ("File Precision=%d\n", precision); if (precision) printf ("File Precision=%d\n", precision);
} }
/* get number of bases */ /* get number of bases */
if (cg_nbases (cgnsfn, &nbases)) error_exit("cg_nbases"); if (cg_nbases (cgnsfn, &nbases)) error_exit("cg_nbases");
if (nbases < 1) warning (1, "no bases defined in CGNS file"); if (nbases < 1) warning (1, "no bases defined in CGNS file");
for (cgnsbase = 1; cgnsbase <= nbases; cgnsbase++) for (cgnsbase = 1; cgnsbase <= nbases; cgnsbase++)
check_base (); check_base ();
/* check node name validity according to SIDS */
check_node_names();
/* close CGNS file and exit */ /* close CGNS file and exit */
if (cg_close (cgnsfn)) error_exit("cg_close"); if (cg_close (cgnsfn)) error_exit("cg_close");
puts ("\nchecking complete"); puts ("\nchecking complete");
if (totwarn) printf ("%d warnings (%d shown)\n", totwarn, nwarn); if (totwarn) printf ("%d warnings (%d shown)\n", totwarn, nwarn);
if (nerr) printf ("%d errors\n", nerr); if (nerr) printf ("%d errors\n", nerr);
return 0; return 0;
} }
 End of changes. 14 change blocks. 
7 lines changed or deleted 107 lines changed or added

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