1
/* Copyright 2004,2007 ENSEIRB, INRIA & CNRS
3
** This file is part of the Scotch software package for static mapping,
4
** graph partitioning and sparse matrix ordering.
6
** This software is governed by the CeCILL-C license under French law
7
** and abiding by the rules of distribution of free software. You can
8
** use, modify and/or redistribute the software under the terms of the
9
** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
10
** URL: "http://www.cecill.info".
12
** As a counterpart to the access to the source code and rights to copy,
13
** modify and redistribute granted by the license, users are provided
14
** only with a limited warranty and the software's author, the holder of
15
** the economic rights, and the successive licensors have only limited
18
** In this respect, the user's attention is drawn to the risks associated
19
** with loading, using, modifying and/or developing or reproducing the
20
** software by the user in light of its specific status of free software,
21
** that may mean that it is complicated to manipulate, and that also
22
** therefore means that it is reserved for developers and experienced
23
** professionals having in-depth computer knowledge. Users are therefore
24
** encouraged to load and test the software's suitability as regards
25
** their requirements in conditions enabling the security of their
26
** systems and/or data to be ensured and, more generally, to use and
27
** operate it in the same conditions as regards security.
29
** The fact that you are presently reading this means that you have had
30
** knowledge of the CeCILL-C license and that you accept its terms.
32
/************************************************************/
34
/** NAME : mesh_check.c **/
36
/** AUTHOR : Francois PELLEGRINI **/
38
/** FUNCTION : This module handles the source mesh **/
41
/** DATES : # Version 4.0 : from : 29 dec 2001 **/
42
/** to 11 may 2004 **/
44
/************************************************************/
47
** The defines and includes.
57
/****************************************/
59
/* These routines handle source meshes. */
61
/****************************************/
63
/* This routine checks the consistency
66
** - 0 : if mesh data are consistent.
72
const Mesh * const meshptr)
74
Gnum vertnnd; /* Maximum vertex index */
75
Gnum vertnum; /* Number of current vertex */
76
Gnum veisnbr; /* Number of isolated element vertices */
77
Gnum velosum; /* Vertex element load sum */
78
Gnum vnlosum; /* Vertex node load sum */
79
Gnum degrmax; /* Maximum degree */
81
if ((meshptr->velmbas > meshptr->velmnnd) ||
82
(meshptr->vnodbas > meshptr->vnodnnd) ||
83
((meshptr->velmnnd != meshptr->vnodbas) &&
84
(meshptr->vnodnnd != meshptr->velmbas))) {
85
errorPrint ("meshCheck: invalid node and element numbers");
89
vertnnd = meshptr->velmnbr + meshptr->vnodnbr + meshptr->baseval;
92
for (vertnum = meshptr->velmbas; vertnum < meshptr->velmnnd; vertnum ++) { /* For all element vertices */
96
if ((meshptr->verttax[vertnum] < meshptr->baseval) ||
97
(meshptr->vendtax[vertnum] < meshptr->verttax[vertnum])) {
98
errorPrint ("meshCheck: invalid vertex arrays (1)");
102
degrval = meshptr->vendtax[vertnum] - meshptr->verttax[vertnum];
103
if (degrval > degrmax)
105
else if (degrval == 0)
108
for (edgenum = meshptr->verttax[vertnum]; edgenum < meshptr->vendtax[vertnum]; edgenum ++) {
109
Gnum vertend; /* Number of end vertex */
110
Gnum edgeend; /* Number of end vertex edge */
112
vertend = meshptr->edgetax[edgenum];
114
if ((vertend < meshptr->baseval) || (vertend >= vertnnd)) { /* If invalid edge end */
115
errorPrint ("meshCheck: invalid edge array (1)");
118
if ((vertend >= meshptr->velmbas) &&
119
(vertend < meshptr->velmnnd)) {
120
errorPrint ("meshCheck: element vertices must not be connected together");
124
for (edgeend = meshptr->verttax[vertend]; /* Search for matching arc */
125
(edgeend < meshptr->vendtax[vertend]) && (meshptr->edgetax[edgeend] != vertnum);
127
if (edgeend >= meshptr->vendtax[vertend]) {
128
errorPrint ("meshCheck: arc data do not match (1)");
131
for (edgeend ++; /* Search for duplicate arcs */
132
(edgeend < meshptr->vendtax[vertend]) && (meshptr->edgetax[edgeend] != vertnum);
134
if (edgeend < meshptr->vendtax[vertend]) {
135
errorPrint ("meshCheck: duplicate arc (1)");
140
if (veisnbr != meshptr->veisnbr) {
141
errorPrint ("meshCheck: invalid number of isolated element vertices (1)");
145
for (vertnum = meshptr->vnodbas; vertnum < meshptr->vnodnnd; vertnum ++) { /* For all node vertices */
148
if ((meshptr->verttax[vertnum] < meshptr->baseval) ||
149
(meshptr->vendtax[vertnum] < meshptr->verttax[vertnum])) {
150
errorPrint ("meshCheck: invalid vertex arrays (2)");
153
if ((meshptr->vendtax[vertnum] - meshptr->verttax[vertnum]) > degrmax)
154
degrmax = meshptr->vendtax[vertnum] - meshptr->verttax[vertnum];
156
for (edgenum = meshptr->verttax[vertnum]; edgenum < meshptr->vendtax[vertnum]; edgenum ++) {
157
Gnum vertend; /* Number of end vertex */
158
Gnum edgeend; /* Number of end vertex edge */
160
vertend = meshptr->edgetax[edgenum];
162
if ((vertend < meshptr->baseval) || (vertend >= vertnnd)) { /* If invalid edge end */
163
errorPrint ("meshCheck: invalid edge array (2)");
166
if ((vertend >= meshptr->vnodbas) &&
167
(vertend < meshptr->vnodnnd)) {
168
errorPrint ("meshCheck: node vertices must not be connected together");
172
for (edgeend = meshptr->verttax[vertend]; /* Search for matching arc */
173
(edgeend < meshptr->vendtax[vertend]) && (meshptr->edgetax[edgeend] != vertnum);
175
if (edgeend >= meshptr->vendtax[vertend]) {
176
errorPrint ("meshCheck: arc data do not match (2)");
179
for (edgeend ++; /* Search for duplicate arcs */
180
(edgeend < meshptr->vendtax[vertend]) && (meshptr->edgetax[edgeend] != vertnum);
182
if (edgeend < meshptr->vendtax[vertend]) {
183
errorPrint ("meshCheck: duplicate arc (2)");
189
if (meshptr->velotax == NULL) /* Recompute node vertex load sum */
190
velosum = meshptr->velmnnd - meshptr->velmbas;
192
for (vertnum = meshptr->velmbas, velosum = 0;
193
vertnum < meshptr->velmnnd; vertnum ++) {
194
if (meshptr->velotax[vertnum] < 1) {
195
errorPrint ("meshCheck: invalid element vertex load");
198
velosum += meshptr->velotax[vertnum];
201
if (velosum != meshptr->velosum) {
202
errorPrint ("meshCheck: invalid element vertex load sum");
206
if (meshptr->vnlotax == NULL) /* Recompute node vertex load sum */
207
vnlosum = meshptr->vnodnnd - meshptr->vnodbas;
209
for (vertnum = meshptr->vnodbas, vnlosum = 0;
210
vertnum < meshptr->vnodnnd; vertnum ++) {
211
if (meshptr->vnlotax[vertnum] < 1) {
212
errorPrint ("meshCheck: invalid node vertex load");
215
vnlosum += meshptr->vnlotax[vertnum];
218
if (vnlosum != meshptr->vnlosum) {
219
errorPrint ("meshCheck: invalid node vertex load sum");
223
if (meshptr->degrmax < degrmax) {
224
errorPrint ("meshCheck: invalid maximum degree");