| 1 |
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 2 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 |
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 4 |
// vi: set et ts=4 sw=2 sts=2: |
| 5 |
/****************************************************************************/ |
| 6 |
/* */ |
| 7 |
/* File: mgio.c */ |
| 8 |
/* */ |
| 9 |
/* Purpose: input/output of loc ref mg */ |
| 10 |
/* */ |
| 11 |
/* Author: Klaus Johannsen */ |
| 12 |
/* Institut fuer Computeranwendungen III */ |
| 13 |
/* Universitaet Stuttgart */ |
| 14 |
/* Pfaffenwaldring 27 */ |
| 15 |
/* 70550 Stuttgart */ |
| 16 |
/* email: [email protected] */ |
| 17 |
/* */ |
| 18 |
/* History: 18.11.96 begin, */ |
| 19 |
/* */ |
| 20 |
/* Remarks: */ |
| 21 |
/* */ |
| 22 |
/****************************************************************************/ |
| 23 |
|
| 24 |
/****************************************************************************/ |
| 25 |
/* */ |
| 26 |
/* include files */ |
| 27 |
/* system include files */ |
| 28 |
/* application include files */ |
| 29 |
/* */ |
| 30 |
/****************************************************************************/ |
| 31 |
|
| 32 |
#include <config.h> |
| 33 |
|
| 34 |
#include <array> |
| 35 |
#include <cstdio> |
| 36 |
#include <cstdlib> |
| 37 |
#include <cstring> |
| 38 |
#include <cassert> |
| 39 |
|
| 40 |
#include <dune/uggrid/low/bio.h> |
| 41 |
#include "mgio.h" |
| 42 |
|
| 43 |
#ifdef __MGIO_USE_IN_UG__ |
| 44 |
|
| 45 |
#include <dune/uggrid/low/debug.h> |
| 46 |
#include <dune/uggrid/low/fileopen.h> |
| 47 |
|
| 48 |
#endif |
| 49 |
|
| 50 |
|
| 51 |
USING_UG_NAMESPACE |
| 52 |
USING_UGDIM_NAMESPACE |
| 53 |
|
| 54 |
/****************************************************************************/ |
| 55 |
/* */ |
| 56 |
/* defines in the following order */ |
| 57 |
/* */ |
| 58 |
/* compile time constants defining static data size (i.e. arrays) */ |
| 59 |
/* other constants */ |
| 60 |
/* macros */ |
| 61 |
/* */ |
| 62 |
/****************************************************************************/ |
| 63 |
|
| 64 |
#define MGIO_TITLE_LINE "####.sparse.mg.storage.format.####" |
| 65 |
|
| 66 |
#define MGIO_INTSIZE 1000 /* minimal 497 !!! */ |
| 67 |
#define MGIO_DOUBLESIZE 200 |
| 68 |
#define MGIO_BUFFERSIZE 1024 |
| 69 |
|
| 70 |
#define MGIO_CHECK_INTSIZE(n) if ((n)>MGIO_INTSIZE) assert(0) /*return (1)*/ |
| 71 |
#define MGIO_CHECK_DOUBLESIZE(n) if ((n)>MGIO_DOUBLESIZE) return (1) |
| 72 |
#define MGIO_CHECK_BUFFERIZE(s) if (strlen(s)>MGIO_BUFFERSIZE) return (1) |
| 73 |
|
| 74 |
#define MGIO_ECTRL_NF_LEN 5 |
| 75 |
#define MGIO_ECTRL_NM_LEN 5 |
| 76 |
#define MGIO_ECTRL_RF_LEN 18 |
| 77 |
#define MGIO_ECTRL_RC_LEN 3 |
| 78 |
#define MGIO_ECTRL_ON_LEN 1 |
| 79 |
|
| 80 |
#define MGIO_ECTRL_NF_SHIFT 0 |
| 81 |
#define MGIO_ECTRL_NM_SHIFT (MGIO_ECTRL_NF_SHIFT + MGIO_ECTRL_NF_LEN) |
| 82 |
#define MGIO_ECTRL_RF_SHIFT (MGIO_ECTRL_NM_SHIFT + MGIO_ECTRL_NM_LEN) |
| 83 |
#define MGIO_ECTRL_RC_SHIFT (MGIO_ECTRL_RF_SHIFT + MGIO_ECTRL_RF_LEN) |
| 84 |
#define MGIO_ECTRL_ON_SHIFT (MGIO_ECTRL_RC_SHIFT + MGIO_ECTRL_RC_LEN) |
| 85 |
|
| 86 |
#define MGIO_ECTRL(rf,nf,nm,rc,on) ((((nf)&((1<<MGIO_ECTRL_NF_LEN)-1))<<MGIO_ECTRL_NF_SHIFT) | \ |
| 87 |
(((nm)&((1<<MGIO_ECTRL_NM_LEN)-1))<<MGIO_ECTRL_NM_SHIFT) | \ |
| 88 |
(((rf)&((1<<MGIO_ECTRL_RF_LEN)-1))<<MGIO_ECTRL_RF_SHIFT) | \ |
| 89 |
(((rc)&((1<<MGIO_ECTRL_RC_LEN)-1))<<MGIO_ECTRL_RC_SHIFT) | \ |
| 90 |
(((on)&((1<<MGIO_ECTRL_ON_LEN)-1))<<MGIO_ECTRL_ON_SHIFT)) |
| 91 |
|
| 92 |
#define MGIO_ECTRL_NF(ctrl) (((ctrl)>>MGIO_ECTRL_NF_SHIFT)&((1<<MGIO_ECTRL_NF_LEN)-1)) |
| 93 |
#define MGIO_ECTRL_NM(ctrl) (((ctrl)>>MGIO_ECTRL_NM_SHIFT)&((1<<MGIO_ECTRL_NM_LEN)-1)) |
| 94 |
#define MGIO_ECTRL_RF(ctrl) (((ctrl)>>MGIO_ECTRL_RF_SHIFT)&((1<<MGIO_ECTRL_RF_LEN)-1)) |
| 95 |
#define MGIO_ECTRL_RC(ctrl) (((ctrl)>>MGIO_ECTRL_RC_SHIFT)&((1<<MGIO_ECTRL_RC_LEN)-1)) |
| 96 |
#define MGIO_ECTRL_ON(ctrl) (((ctrl)>>MGIO_ECTRL_ON_SHIFT)&((1<<MGIO_ECTRL_ON_LEN)-1)) |
| 97 |
|
| 98 |
/****************************************************************************/ |
| 99 |
/* */ |
| 100 |
/* data structures used in this source file (exported data structures are */ |
| 101 |
/* in the corresponding include file!) */ |
| 102 |
/* */ |
| 103 |
/****************************************************************************/ |
| 104 |
|
| 105 |
/****************************************************************************/ |
| 106 |
/* */ |
| 107 |
/* definition of exported global variables */ |
| 108 |
/* */ |
| 109 |
/****************************************************************************/ |
| 110 |
|
| 111 |
int NS_DIM_PREFIX mgpathes_set; /* paths used in ug */ |
| 112 |
|
| 113 |
|
| 114 |
/****************************************************************************/ |
| 115 |
/* */ |
| 116 |
/* definition of variables global to this source file only (static!) */ |
| 117 |
/* */ |
| 118 |
/****************************************************************************/ |
| 119 |
|
| 120 |
static FILE *stream; /* file */ |
| 121 |
static char buffer[MGIO_BUFFERSIZE]; /* general purpose buffer */ |
| 122 |
static int intList[MGIO_INTSIZE]; /* general purpose integer list */ |
| 123 |
static double doubleList[MGIO_DOUBLESIZE]; /* general purpose double list*/ |
| 124 |
static int nparfiles; /* nb of parallel files */ |
| 125 |
|
| 126 |
/* local storage of general elements */ |
| 127 |
static std::array<MGIO_GE_ELEMENT, MGIO_TAGS> lge; |
| 128 |
|
| 129 |
|
| 130 |
/****************************************************************************/ |
| 131 |
/* */ |
| 132 |
/* forward declarations of functions used before they are defined */ |
| 133 |
/* */ |
| 134 |
/****************************************************************************/ |
| 135 |
|
| 136 |
/****************************************************************************/ |
| 137 |
/*D |
| 138 |
MGIO_dircreate - create a directory for multigrid files |
| 139 |
|
| 140 |
SYNOPSIS: |
| 141 |
int MGIO_dircreate (char *filename, int rename); |
| 142 |
|
| 143 |
PARAMETERS: |
| 144 |
. filename - name of directory |
| 145 |
. rename - renaming option |
| 146 |
|
| 147 |
DESCRIPTION: |
| 148 |
Create a directory with specified name incl. renaming option. |
| 149 |
The considered path entry is "mgpaths". |
| 150 |
|
| 151 |
RETURN VALUE: |
| 152 |
int |
| 153 |
.n 0 if ok |
| 154 |
.n 1 when error occurred. |
| 155 |
|
| 156 |
SEE ALSO: |
| 157 |
D*/ |
| 158 |
/****************************************************************************/ |
| 159 |
|
| 160 |
#ifdef __MGIO_USE_IN_UG__ |
| 161 |
int NS_DIM_PREFIX MGIO_dircreate (char *filename, int rename) |
| 162 |
{ |
| 163 |
|
| 164 |
if (mgpathes_set) return(DirCreateUsingSearchPaths_r(filename,"mgpaths",rename)); |
| 165 |
else return(DirCreateUsingSearchPaths_r(filename,NULL,rename)); |
| 166 |
} |
| 167 |
#endif |
| 168 |
|
| 169 |
/****************************************************************************/ |
| 170 |
/*D |
| 171 |
MGIO_filetype - test for type of multigrid file |
| 172 |
|
| 173 |
SYNOPSIS: |
| 174 |
INT MGIO_filetype (char *filename); |
| 175 |
|
| 176 |
PARAMETERS: |
| 177 |
. filename - name of file |
| 178 |
|
| 179 |
DESCRIPTION: |
| 180 |
Test for type of multigrid file with name filename in searching paths if exist. |
| 181 |
The considered path entry is "mgpaths". |
| 182 |
|
| 183 |
RETURN VALUE: |
| 184 |
int |
| 185 |
.n FT_FILE if regular file |
| 186 |
.n FT_DIR if directory |
| 187 |
.n FT_LINK if link and #define S_IFLNK |
| 188 |
.n FT_UNKNOWN else |
| 189 |
|
| 190 |
SEE ALSO: |
| 191 |
D*/ |
| 192 |
/****************************************************************************/ |
| 193 |
|
| 194 |
#ifdef __MGIO_USE_IN_UG__ |
| 195 |
int NS_DIM_PREFIX MGIO_filetype (char *filename) |
| 196 |
{ |
| 197 |
|
| 198 |
if (mgpathes_set) return(FileTypeUsingSearchPaths(filename,"mgpaths")); |
| 199 |
else return(filetype(filename)); |
| 200 |
} |
| 201 |
#endif |
| 202 |
|
| 203 |
/****************************************************************************/ |
| 204 |
/*D |
| 205 |
Read_OpenMGFile - opens multigrid file for reading |
| 206 |
|
| 207 |
SYNOPSIS: |
| 208 |
int Read_OpenMGFile (char *filename); |
| 209 |
|
| 210 |
PARAMETERS: |
| 211 |
. filename - name of file |
| 212 |
|
| 213 |
DESCRIPTION: |
| 214 |
Opens a multigrid file with specified name for reading. |
| 215 |
The considered path entry is "mgpaths". |
| 216 |
|
| 217 |
RETURN VALUE: |
| 218 |
int |
| 219 |
.n 0 if ok |
| 220 |
.n 1 when error occurred. |
| 221 |
|
| 222 |
SEE ALSO: |
| 223 |
D*/ |
| 224 |
/****************************************************************************/ |
| 225 |
|
| 226 |
int NS_DIM_PREFIX Read_OpenMGFile (char *filename) |
| 227 |
{ |
| 228 |
|
| 229 |
#ifdef __MGIO_USE_IN_UG__ |
| 230 |
if (mgpathes_set) stream = FileOpenUsingSearchPaths(filename,"r","mgpaths"); |
| 231 |
else stream = fileopen(filename,"r"); |
| 232 |
#else |
| 233 |
stream = fopen(filename,"r"); |
| 234 |
#endif |
| 235 |
|
| 236 |
if (stream==NULL) return (1); |
| 237 |
|
| 238 |
return (0); |
| 239 |
} |
| 240 |
|
| 241 |
/****************************************************************************/ |
| 242 |
/*D |
| 243 |
Write_OpenMGFile - opens multigrid file for writing |
| 244 |
|
| 245 |
SYNOPSIS: |
| 246 |
int Write_OpenMGFile (char *filename, int rename); |
| 247 |
|
| 248 |
PARAMETERS: |
| 249 |
. filename - name of file |
| 250 |
. rename - renaming option |
| 251 |
|
| 252 |
DESCRIPTION: |
| 253 |
Opens a multigrid file with specified name for writing incl. renaming option. |
| 254 |
The considered path entry is "mgpaths". |
| 255 |
|
| 256 |
RETURN VALUE: |
| 257 |
int |
| 258 |
.n 0 if ok |
| 259 |
.n 1 when error occurred. |
| 260 |
|
| 261 |
SEE ALSO: |
| 262 |
D*/ |
| 263 |
/****************************************************************************/ |
| 264 |
|
| 265 |
int NS_DIM_PREFIX Write_OpenMGFile (char *filename, int rename) |
| 266 |
{ |
| 267 |
|
| 268 |
#ifdef __MGIO_USE_IN_UG__ |
| 269 |
if (mgpathes_set) stream = FileOpenUsingSearchPaths_r(filename,"w","mgpaths",rename); |
| 270 |
else stream = fileopen_r(filename,"w",rename); |
| 271 |
#else |
| 272 |
stream = fopen(filename,"w"); |
| 273 |
#endif |
| 274 |
|
| 275 |
if (stream==NULL) return (1); |
| 276 |
return (0); |
| 277 |
} |
| 278 |
|
| 279 |
/****************************************************************************/ |
| 280 |
/* |
| 281 |
Read_MG_General - reads general information about mg |
| 282 |
|
| 283 |
SYNOPSIS: |
| 284 |
int Read_MG_General (MGIO_MG_GENERAL *mg_general); |
| 285 |
|
| 286 |
PARAMETERS: |
| 287 |
. mg_general - general information about mg |
| 288 |
|
| 289 |
DESCRIPTION: |
| 290 |
function reads general information about the mg |
| 291 |
|
| 292 |
RETURN VALUE: |
| 293 |
INT |
| 294 |
.n 0 if ok |
| 295 |
.n 1 if read error. |
| 296 |
|
| 297 |
SEE ALSO: |
| 298 |
*/ |
| 299 |
/****************************************************************************/ |
| 300 |
|
| 301 |
int NS_DIM_PREFIX Read_MG_General (MGIO_MG_GENERAL *mg_general) |
| 302 |
{ |
| 303 |
/* initialize basic i/o */ |
| 304 |
if (Bio_Initialize(stream,BIO_ASCII,'r')) return (1); |
| 305 |
|
| 306 |
/* head always in ACSII */ |
| 307 |
if (Bio_Read_string(buffer)) return (1); |
| 308 |
if (strcmp(buffer,MGIO_TITLE_LINE)!=0) return (1); |
| 309 |
if (Bio_Read_mint(1,intList)) return (1); |
| 310 |
mg_general->mode = intList[0]; |
| 311 |
|
| 312 |
/* re-initialize basic i/o */ |
| 313 |
if (Bio_Initialize(stream,mg_general->mode,'r')) return (1); |
| 314 |
|
| 315 |
/* now special mode */ |
| 316 |
if (Bio_Read_string(mg_general->version)) return (1); |
| 317 |
if (strcmp(mg_general->version,"UG_IO_2.2")==0) |
| 318 |
{ |
| 319 |
strcpy(mg_general->version,"UG_IO_2.3"); |
| 320 |
} |
| 321 |
if (Bio_Read_string(mg_general->ident)) return (1); |
| 322 |
if (Bio_Read_string(mg_general->DomainName)) return (1); |
| 323 |
if (Bio_Read_string(mg_general->MultiGridName)) return (1); |
| 324 |
if (Bio_Read_string(mg_general->Formatname)) return (1); |
| 325 |
if (Bio_Read_mint(11,intList)) return (1); |
| 326 |
mg_general->dim = intList[0]; |
| 327 |
mg_general->magic_cookie= intList[1]; |
| 328 |
mg_general->heapsize = intList[2]; |
| 329 |
mg_general->nLevel = intList[3]; |
| 330 |
mg_general->nNode = intList[4]; |
| 331 |
mg_general->nPoint = intList[5]; |
| 332 |
mg_general->nElement = intList[6]; |
| 333 |
mg_general->VectorTypes = intList[7]; |
| 334 |
mg_general->me = intList[8]; |
| 335 |
mg_general->nparfiles = intList[9]; |
| 336 |
if (intList[10]!=MGIO_DEBUG) |
| 337 |
RETURN (1); /* check debug-level of file: 0: no debug information */ |
| 338 |
|
| 339 |
/* init global parameters */ |
| 340 |
nparfiles = mg_general->nparfiles; |
| 341 |
|
| 342 |
return (0); |
| 343 |
} |
| 344 |
|
| 345 |
/****************************************************************************/ |
| 346 |
/* |
| 347 |
Write_MG_General - writes general information about mg |
| 348 |
|
| 349 |
SYNOPSIS: |
| 350 |
int Write_MG_General (MGIO_MG_GENERAL *mg_general); |
| 351 |
|
| 352 |
PARAMETERS: |
| 353 |
. mg_general - general information about mg |
| 354 |
|
| 355 |
DESCRIPTION: |
| 356 |
function writes general information about the mg |
| 357 |
|
| 358 |
RETURN VALUE: |
| 359 |
INT |
| 360 |
.n 0 if ok |
| 361 |
.n 1 if read error. |
| 362 |
|
| 363 |
SEE ALSO: |
| 364 |
*/ |
| 365 |
/****************************************************************************/ |
| 366 |
|
| 367 |
int NS_DIM_PREFIX Write_MG_General (MGIO_MG_GENERAL *mg_general) |
| 368 |
{ |
| 369 |
/* initialize basic i/o */ |
| 370 |
if (Bio_Initialize(stream,BIO_ASCII,'w')) return (1); |
| 371 |
|
| 372 |
/* head always in ACSII */ |
| 373 |
if (Bio_Write_string(MGIO_TITLE_LINE)) return (1); |
| 374 |
intList[0] = mg_general->mode; |
| 375 |
if (Bio_Write_mint(1,intList)) return (1); |
| 376 |
|
| 377 |
/* initialize basic i/o */ |
| 378 |
if (Bio_Initialize(stream,mg_general->mode,'w')) return (1); |
| 379 |
|
| 380 |
/* now special mode */ |
| 381 |
if (Bio_Write_string(mg_general->version)) return (1); |
| 382 |
if (Bio_Write_string(mg_general->ident)) return (1); |
| 383 |
if (Bio_Write_string(mg_general->DomainName)) return (1); |
| 384 |
if (Bio_Write_string(mg_general->MultiGridName)) return (1); |
| 385 |
if (Bio_Write_string(mg_general->Formatname)) return (1); |
| 386 |
intList[0] = mg_general->dim; |
| 387 |
intList[1] = mg_general->magic_cookie; |
| 388 |
intList[2] = mg_general->heapsize; |
| 389 |
intList[3] = mg_general->nLevel; |
| 390 |
intList[4] = mg_general->nNode; |
| 391 |
intList[5] = mg_general->nPoint; |
| 392 |
intList[6] = mg_general->nElement; |
| 393 |
intList[7] = mg_general->VectorTypes; |
| 394 |
intList[8] = mg_general->me; |
| 395 |
intList[9] = mg_general->nparfiles; |
| 396 |
intList[10]= MGIO_DEBUG; |
| 397 |
if (Bio_Write_mint(11,intList)) return (1); |
| 398 |
|
| 399 |
/* init global parameters */ |
| 400 |
nparfiles = mg_general->nparfiles; |
| 401 |
|
| 402 |
return (0); |
| 403 |
} |
| 404 |
|
| 405 |
/****************************************************************************/ |
| 406 |
/* |
| 407 |
Read_GE_General - reads general information about general elements |
| 408 |
|
| 409 |
SYNOPSIS: |
| 410 |
int Read_GE_General (MGIO_GE_GENERAL *ge_general); |
| 411 |
|
| 412 |
PARAMETERS: |
| 413 |
. ge_general - general information about general elements |
| 414 |
|
| 415 |
DESCRIPTION: |
| 416 |
function reads general information about general elements |
| 417 |
|
| 418 |
RETURN VALUE: |
| 419 |
INT |
| 420 |
.n 0 if ok |
| 421 |
.n 1 if read error. |
| 422 |
|
| 423 |
SEE ALSO: |
| 424 |
*/ |
| 425 |
/****************************************************************************/ |
| 426 |
|
| 427 |
int NS_DIM_PREFIX Read_GE_General (MGIO_GE_GENERAL *ge_general) |
| 428 |
{ |
| 429 |
if (Bio_Read_mint(1,intList)) return (1); |
| 430 |
ge_general->nGenElement = intList[0]; |
| 431 |
|
| 432 |
return (0); |
| 433 |
} |
| 434 |
|
| 435 |
/****************************************************************************/ |
| 436 |
/* |
| 437 |
Write_GE_General - writes general information about general elements |
| 438 |
|
| 439 |
SYNOPSIS: |
| 440 |
int Write_GE_General (MGIO_GE_GENERAL *ge_general); |
| 441 |
|
| 442 |
PARAMETERS: |
| 443 |
. ge_general - general information about general elements |
| 444 |
|
| 445 |
DESCRIPTION: |
| 446 |
function writes general information about general elements |
| 447 |
|
| 448 |
RETURN VALUE: |
| 449 |
INT |
| 450 |
.n 0 if ok |
| 451 |
.n 1 if read error. |
| 452 |
|
| 453 |
SEE ALSO: |
| 454 |
*/ |
| 455 |
/****************************************************************************/ |
| 456 |
|
| 457 |
int NS_DIM_PREFIX Write_GE_General (MGIO_GE_GENERAL *ge_general) |
| 458 |
{ |
| 459 |
intList[0] = ge_general->nGenElement; |
| 460 |
if (Bio_Write_mint(1,intList)) return (1); |
| 461 |
|
| 462 |
return (0); |
| 463 |
} |
| 464 |
|
| 465 |
/****************************************************************************/ |
| 466 |
/* |
| 467 |
Read_GE_Elements - reads general elements |
| 468 |
|
| 469 |
SYNOPSIS: |
| 470 |
int Read_GE_Elements (int n, MGIO_GE_ELEMENT *ge_element); |
| 471 |
|
| 472 |
PARAMETERS: |
| 473 |
. n - nb of general elements to read |
| 474 |
. ge_element - first general elements |
| 475 |
|
| 476 |
DESCRIPTION: |
| 477 |
function reads general elements |
| 478 |
|
| 479 |
RETURN VALUE: |
| 480 |
INT |
| 481 |
.n 0 if ok |
| 482 |
.n 1 if read error. |
| 483 |
|
| 484 |
SEE ALSO: |
| 485 |
*/ |
| 486 |
/****************************************************************************/ |
| 487 |
|
| 488 |
int NS_DIM_PREFIX Read_GE_Elements (int n, MGIO_GE_ELEMENT *ge_element) |
| 489 |
{ |
| 490 |
MGIO_GE_ELEMENT *pge; |
| 491 |
|
| 492 |
pge = ge_element; |
| 493 |
for (int i = 0; i < n; i++) |
| 494 |
{ |
| 495 |
if (Bio_Read_mint(4,intList)) |
| 496 |
return 1; |
| 497 |
|
| 498 |
int s = 0; |
| 499 |
|
| 500 |
pge->tag = lge[i].tag = intList[s++]; |
| 501 |
pge->nCorner = lge[i].nCorner = intList[s++]; |
| 502 |
pge->nEdge = lge[i].nEdge = intList[s++]; |
| 503 |
pge->nSide = lge[i].nSide = intList[s++]; |
| 504 |
if (pge->nEdge>0 || pge->nSide>0) |
| 505 |
{ |
| 506 |
if (Bio_Read_mint(2*pge->nEdge+4*pge->nSide,intList)) |
| 507 |
return 1; |
| 508 |
|
| 509 |
s=0; |
| 510 |
|
| 511 |
for (int j = 0; j < pge->nEdge; j++) |
| 512 |
{ |
| 513 |
pge->CornerOfEdge[j][0] = lge[i].CornerOfEdge[j][0] = intList[s++]; |
| 514 |
pge->CornerOfEdge[j][1] = lge[i].CornerOfEdge[j][1] = intList[s++]; |
| 515 |
} |
| 516 |
for (int j = 0; j < pge->nSide; j++) |
| 517 |
{ |
| 518 |
pge->CornerOfSide[j][0] = lge[i].CornerOfSide[j][0] = intList[s++]; |
| 519 |
pge->CornerOfSide[j][1] = lge[i].CornerOfSide[j][1] = intList[s++]; |
| 520 |
pge->CornerOfSide[j][2] = lge[i].CornerOfSide[j][2] = intList[s++]; |
| 521 |
pge->CornerOfSide[j][3] = lge[i].CornerOfSide[j][3] = intList[s++]; |
| 522 |
} |
| 523 |
} |
| 524 |
pge++; |
| 525 |
} |
| 526 |
|
| 527 |
return 0; |
| 528 |
} |
| 529 |
|
| 530 |
/****************************************************************************/ |
| 531 |
/* |
| 532 |
Write_GE_Elements - writes general elements |
| 533 |
|
| 534 |
SYNOPSIS: |
| 535 |
int Write_GE_Elements (int n, MGIO_GE_ELEMENT *ge_element); |
| 536 |
|
| 537 |
PARAMETERS: |
| 538 |
. n - nb of general elements to write |
| 539 |
. ge_element - first general elements |
| 540 |
|
| 541 |
DESCRIPTION: |
| 542 |
function writes general elements |
| 543 |
|
| 544 |
RETURN VALUE: |
| 545 |
INT |
| 546 |
.n 0 if ok |
| 547 |
.n 1 if read error. |
| 548 |
|
| 549 |
SEE ALSO: |
| 550 |
*/ |
| 551 |
/****************************************************************************/ |
| 552 |
|
| 553 |
int NS_DIM_PREFIX Write_GE_Elements (int n, MGIO_GE_ELEMENT *ge_element) |
| 554 |
{ |
| 555 |
MGIO_GE_ELEMENT *pge = ge_element; |
| 556 |
|
| 557 |
for (int i = 0; i < n; i++) |
| 558 |
{ |
| 559 |
int s = 0; |
| 560 |
intList[s++] = lge[i].tag = pge->tag; |
| 561 |
intList[s++] = lge[i].nCorner = pge->nCorner; |
| 562 |
intList[s++] = lge[i].nEdge = pge->nEdge; |
| 563 |
intList[s++] = lge[i].nSide = pge->nSide; |
| 564 |
for (int j = 0; j < pge->nEdge; j++) |
| 565 |
{ |
| 566 |
intList[s++] = lge[i].CornerOfEdge[j][0] = pge->CornerOfEdge[j][0]; |
| 567 |
intList[s++] = lge[i].CornerOfEdge[j][1] = pge->CornerOfEdge[j][1]; |
| 568 |
} |
| 569 |
for (int j = 0; j < pge->nSide; j++) |
| 570 |
{ |
| 571 |
intList[s++] = lge[i].CornerOfSide[j][0] = pge->CornerOfSide[j][0]; |
| 572 |
intList[s++] = lge[i].CornerOfSide[j][1] = pge->CornerOfSide[j][1]; |
| 573 |
intList[s++] = lge[i].CornerOfSide[j][2] = pge->CornerOfSide[j][2]; |
| 574 |
intList[s++] = lge[i].CornerOfSide[j][3] = pge->CornerOfSide[j][3]; |
| 575 |
} |
| 576 |
MGIO_CHECK_INTSIZE(s); |
| 577 |
if (Bio_Write_mint(s,intList)) return (1); |
| 578 |
pge++; |
| 579 |
} |
| 580 |
|
| 581 |
return (0); |
| 582 |
} |
| 583 |
|
| 584 |
/****************************************************************************/ |
| 585 |
/* |
| 586 |
Read_RR_General - reads general information about refinement rules |
| 587 |
|
| 588 |
SYNOPSIS: |
| 589 |
int Read_RR_General (MGIO_RR_GENERAL *mgio_rr_general); |
| 590 |
|
| 591 |
PARAMETERS: |
| 592 |
. mgio_rr_general - general information about refinement rules |
| 593 |
|
| 594 |
DESCRIPTION: |
| 595 |
function reads general information about refinement rules |
| 596 |
|
| 597 |
RETURN VALUE: |
| 598 |
INT |
| 599 |
.n 0 if ok |
| 600 |
.n 1 if read error. |
| 601 |
|
| 602 |
SEE ALSO: |
| 603 |
*/ |
| 604 |
/****************************************************************************/ |
| 605 |
|
| 606 |
int NS_DIM_PREFIX Read_RR_General (MGIO_RR_GENERAL *mgio_rr_general) |
| 607 |
{ |
| 608 |
if (Bio_Read_mint(1+MGIO_TAGS,intList)) |
| 609 |
return 1; |
| 610 |
|
| 611 |
int s = 0; |
| 612 |
mgio_rr_general->nRules = intList[s++]; |
| 613 |
for (int i = 0; i < MGIO_TAGS; i++) |
| 614 |
mgio_rr_general->RefRuleOffset[i] = intList[s++]; |
| 615 |
|
| 616 |
return (0); |
| 617 |
} |
| 618 |
|
| 619 |
/****************************************************************************/ |
| 620 |
/* |
| 621 |
Write_GE_General - writes general information about refinement rules |
| 622 |
|
| 623 |
SYNOPSIS: |
| 624 |
int Write_RR_General (MGIO_RR_GENERAL *mgio_rr_general); |
| 625 |
|
| 626 |
PARAMETERS: |
| 627 |
. mgio_rr_general - general information about refinement rules |
| 628 |
|
| 629 |
DESCRIPTION: |
| 630 |
function writes general information about refinement rules |
| 631 |
|
| 632 |
RETURN VALUE: |
| 633 |
INT |
| 634 |
.n 0 if ok |
| 635 |
.n 1 if read error. |
| 636 |
|
| 637 |
SEE ALSO: |
| 638 |
*/ |
| 639 |
/****************************************************************************/ |
| 640 |
|
| 641 |
int NS_DIM_PREFIX Write_RR_General (MGIO_RR_GENERAL *mgio_rr_general) |
| 642 |
{ |
| 643 |
int s = 0; |
| 644 |
intList[s++] = mgio_rr_general->nRules; |
| 645 |
for (int i = 0; i < MGIO_TAGS; i++) |
| 646 |
intList[s++] = mgio_rr_general->RefRuleOffset[i]; |
| 647 |
if (Bio_Write_mint(s,intList)) return (1); |
| 648 |
|
| 649 |
return (0); |
| 650 |
} |
| 651 |
|
| 652 |
/****************************************************************************/ |
| 653 |
/* |
| 654 |
Read_RR_Rules - reads refinement rules |
| 655 |
|
| 656 |
SYNOPSIS: |
| 657 |
int Read_RR_Rules (int n, MGIO_RR_RULE *rr_rules); |
| 658 |
|
| 659 |
PARAMETERS: |
| 660 |
. n - nb of refinement rules to read |
| 661 |
. rr_rules - first refinement rule |
| 662 |
|
| 663 |
DESCRIPTION: |
| 664 |
function reads refinement rules |
| 665 |
|
| 666 |
RETURN VALUE: |
| 667 |
INT |
| 668 |
.n 0 if ok |
| 669 |
.n 1 if read error. |
| 670 |
|
| 671 |
SEE ALSO: |
| 672 |
*/ |
| 673 |
/****************************************************************************/ |
| 674 |
|
| 675 |
int NS_DIM_PREFIX Read_RR_Rules (int n, MGIO_RR_RULE *rr_rules) |
| 676 |
{ |
| 677 |
MGIO_RR_RULE *prr; |
| 678 |
|
| 679 |
prr = rr_rules; |
| 680 |
for (int i = 0; i < n; i++) |
| 681 |
{ |
| 682 |
if (Bio_Read_mint(2,intList)) return (1); |
| 683 |
prr->rclass = intList[0]; |
| 684 |
prr->nsons = intList[1]; |
| 685 |
int m = MGIO_MAX_NEW_CORNERS+2*MGIO_MAX_NEW_CORNERS+prr->nsons*(1+MGIO_MAX_CORNERS_OF_ELEM+MGIO_MAX_SIDES_OF_ELEM+1); |
| 686 |
if (Bio_Read_mint(m,intList)) return (1); |
| 687 |
int s = 0; |
| 688 |
for (int j = 0; j < MGIO_MAX_NEW_CORNERS; j++) |
| 689 |
prr->pattern[j] = intList[s++]; |
| 690 |
for (int j = 0; j < MGIO_MAX_NEW_CORNERS; j++) |
| 691 |
{ |
| 692 |
prr->sonandnode[j][0] = intList[s++]; |
| 693 |
prr->sonandnode[j][1] = intList[s++]; |
| 694 |
} |
| 695 |
for (int j = 0; j < prr->nsons; j++) |
| 696 |
{ |
| 697 |
prr->sons[j].tag = intList[s++]; |
| 698 |
for (int k = 0; k < MGIO_MAX_CORNERS_OF_ELEM; k++) |
| 699 |
prr->sons[j].corners[k] = intList[s++]; |
| 700 |
for (int k = 0; k < MGIO_MAX_SIDES_OF_ELEM; k++) |
| 701 |
prr->sons[j].nb[k] = intList[s++]; |
| 702 |
prr->sons[j].path = intList[s++]; |
| 703 |
} |
| 704 |
prr++; |
| 705 |
} |
| 706 |
|
| 707 |
return (0); |
| 708 |
} |
| 709 |
|
| 710 |
/****************************************************************************/ |
| 711 |
/* |
| 712 |
Write_RR_Rules - writes refinement rules |
| 713 |
|
| 714 |
SYNOPSIS: |
| 715 |
int Write_RR_Rules (int n, MGIO_RR_RULE *rr_rules); |
| 716 |
|
| 717 |
PARAMETERS: |
| 718 |
. n - nb of refinement rules to write |
| 719 |
. rr_rules - first refinement rule |
| 720 |
|
| 721 |
DESCRIPTION: |
| 722 |
function writes refinement rules |
| 723 |
|
| 724 |
RETURN VALUE: |
| 725 |
INT |
| 726 |
.n 0 if ok |
| 727 |
.n 1 if read error. |
| 728 |
|
| 729 |
SEE ALSO: |
| 730 |
*/ |
| 731 |
/****************************************************************************/ |
| 732 |
|
| 733 |
int NS_DIM_PREFIX Write_RR_Rules (int n, MGIO_RR_RULE *rr_rules) |
| 734 |
{ |
| 735 |
MGIO_RR_RULE *prr; |
| 736 |
|
| 737 |
prr = rr_rules; |
| 738 |
for (int i = 0; i < n; i++) |
| 739 |
{ |
| 740 |
int s = 0; |
| 741 |
intList[s++] = prr->rclass; |
| 742 |
intList[s++] = prr->nsons; |
| 743 |
for (int j = 0; j < MGIO_MAX_NEW_CORNERS; j++) |
| 744 |
intList[s++] = prr->pattern[j]; |
| 745 |
for (int j = 0; j < MGIO_MAX_NEW_CORNERS; j++) |
| 746 |
{ |
| 747 |
intList[s++] = prr->sonandnode[j][0]; |
| 748 |
intList[s++] = prr->sonandnode[j][1]; |
| 749 |
} |
| 750 |
for (int j = 0; j < prr->nsons; j++) |
| 751 |
{ |
| 752 |
intList[s++] = prr->sons[j].tag; |
| 753 |
for (int k = 0; k < MGIO_MAX_CORNERS_OF_ELEM; k++) |
| 754 |
intList[s++] = prr->sons[j].corners[k]; |
| 755 |
for (int k = 0; k < MGIO_MAX_SIDES_OF_ELEM; k++) |
| 756 |
intList[s++] = prr->sons[j].nb[k]; |
| 757 |
intList[s++] = prr->sons[j].path; |
| 758 |
} |
| 759 |
MGIO_CHECK_INTSIZE(s); |
| 760 |
if (Bio_Write_mint(s,intList)) return (1); |
| 761 |
prr++; |
| 762 |
} |
| 763 |
|
| 764 |
return (0); |
| 765 |
} |
| 766 |
|
| 767 |
/****************************************************************************/ |
| 768 |
/* |
| 769 |
Read_CG_General - reads general information about coarse grid |
| 770 |
|
| 771 |
SYNOPSIS: |
| 772 |
int Read_CG_General (MGIO_CG_GENERAL *cg_general); |
| 773 |
|
| 774 |
PARAMETERS: |
| 775 |
. cg_general - general information about coarse grid |
| 776 |
|
| 777 |
DESCRIPTION: |
| 778 |
function reads general information about coarse grid |
| 779 |
|
| 780 |
RETURN VALUE: |
| 781 |
INT |
| 782 |
.n 0 if ok |
| 783 |
.n 1 if read error. |
| 784 |
|
| 785 |
SEE ALSO: |
| 786 |
*/ |
| 787 |
/****************************************************************************/ |
| 788 |
|
| 789 |
int NS_DIM_PREFIX Read_CG_General (MGIO_CG_GENERAL *cg_general) |
| 790 |
{ |
| 791 |
if (Bio_Read_mint(6,intList)) return (1); |
| 792 |
cg_general->nPoint = intList[0]; |
| 793 |
cg_general->nBndPoint = intList[1]; |
| 794 |
cg_general->nInnerPoint = intList[2]; |
| 795 |
cg_general->nElement = intList[3]; |
| 796 |
cg_general->nBndElement = intList[4]; |
| 797 |
cg_general->nInnerElement = intList[5]; |
| 798 |
|
| 799 |
return (0); |
| 800 |
} |
| 801 |
|
| 802 |
/****************************************************************************/ |
| 803 |
/* |
| 804 |
Write_CG_General - writes general information about coarse grid |
| 805 |
|
| 806 |
SYNOPSIS: |
| 807 |
int Write_CG_General (MGIO_CG_GENERAL *cg_general); |
| 808 |
|
| 809 |
PARAMETERS: |
| 810 |
. cg_general - general information about coarse grid |
| 811 |
|
| 812 |
DESCRIPTION: |
| 813 |
function writes general information about coarse grid |
| 814 |
|
| 815 |
RETURN VALUE: |
| 816 |
INT |
| 817 |
.n 0 if ok |
| 818 |
.n 1 if read error. |
| 819 |
|
| 820 |
SEE ALSO: |
| 821 |
*/ |
| 822 |
/****************************************************************************/ |
| 823 |
|
| 824 |
int NS_DIM_PREFIX Write_CG_General (MGIO_CG_GENERAL *cg_general) |
| 825 |
{ |
| 826 |
intList[0] = cg_general->nPoint; |
| 827 |
intList[1] = cg_general->nBndPoint; |
| 828 |
intList[2] = cg_general->nInnerPoint; |
| 829 |
intList[3] = cg_general->nElement; |
| 830 |
intList[4] = cg_general->nBndElement; |
| 831 |
intList[5] = cg_general->nInnerElement; |
| 832 |
if (Bio_Write_mint(6,intList)) return (1); |
| 833 |
|
| 834 |
return (0); |
| 835 |
} |
| 836 |
|
| 837 |
/****************************************************************************/ |
| 838 |
/* |
| 839 |
Read_CG_Points - reads coarse grid points |
| 840 |
|
| 841 |
SYNOPSIS: |
| 842 |
int Read_CG_Points (MGIO_CG_POINT *cg_point); |
| 843 |
|
| 844 |
PARAMETERS: |
| 845 |
. n - nb of coarse grid points to read |
| 846 |
. cg_point - first coarse grid point |
| 847 |
|
| 848 |
DESCRIPTION: |
| 849 |
function reads coarse grid points |
| 850 |
|
| 851 |
RETURN VALUE: |
| 852 |
INT |
| 853 |
.n 0 if ok |
| 854 |
.n 1 if read error. |
| 855 |
|
| 856 |
SEE ALSO: |
| 857 |
*/ |
| 858 |
/****************************************************************************/ |
| 859 |
|
| 860 |
int NS_DIM_PREFIX Read_CG_Points (int n, MGIO_CG_POINT *cg_point) |
| 861 |
{ |
| 862 |
for (int i = 0; i < n; i++) |
| 863 |
{ |
| 864 |
if (Bio_Read_mdouble(MGIO_DIM,doubleList)) return (1); |
| 865 |
MGIO_CG_POINT *cgp = MGIO_CG_POINT_PS(cg_point,i); |
| 866 |
for (int j = 0; j < MGIO_DIM; j++) |
| 867 |
cgp->position[j] = doubleList[j]; |
| 868 |
if (MGIO_PARFILE) |
| 869 |
{ |
| 870 |
if (Bio_Read_mint(2,intList)) return (1); |
| 871 |
cgp->level = intList[0]; |
| 872 |
cgp->prio = intList[1]; |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
return (0); |
| 877 |
} |
| 878 |
|
| 879 |
/****************************************************************************/ |
| 880 |
/* |
| 881 |
Write_CG_Points - writes coarse grid points |
| 882 |
|
| 883 |
SYNOPSIS: |
| 884 |
int Write_CG_Points (MGIO_CG_POINT *cg_point); |
| 885 |
|
| 886 |
PARAMETERS: |
| 887 |
. n - nb of coarse grid points to write |
| 888 |
. cg_point - first coarse grid point |
| 889 |
|
| 890 |
DESCRIPTION: |
| 891 |
function writes coarse grid points |
| 892 |
|
| 893 |
RETURN VALUE: |
| 894 |
INT |
| 895 |
.n 0 if ok |
| 896 |
.n 1 if read error. |
| 897 |
|
| 898 |
SEE ALSO: |
| 899 |
*/ |
| 900 |
/****************************************************************************/ |
| 901 |
|
| 902 |
int NS_DIM_PREFIX Write_CG_Points (int n, MGIO_CG_POINT *cg_point) |
| 903 |
{ |
| 904 |
for (int i = 0; i < n; i++) |
| 905 |
{ |
| 906 |
MGIO_CG_POINT *cgp = MGIO_CG_POINT_PS(cg_point,i); |
| 907 |
for (int j = 0; j < MGIO_DIM; j++) |
| 908 |
doubleList[j] = cgp->position[j]; |
| 909 |
if (Bio_Write_mdouble(MGIO_DIM,doubleList)) return (1); |
| 910 |
if (MGIO_PARFILE) |
| 911 |
{ |
| 912 |
intList[0] = cgp->level; |
| 913 |
intList[1] = cgp->prio; |
| 914 |
if (Bio_Write_mint(2,intList)) return (1); |
| 915 |
} |
| 916 |
} |
| 917 |
|
| 918 |
return (0); |
| 919 |
} |
| 920 |
|
| 921 |
/****************************************************************************/ |
| 922 |
/* |
| 923 |
Read_pinfo - reads parallel-info for an element |
| 924 |
|
| 925 |
SYNOPSIS: |
| 926 |
static int Read_pinfo (MGIO_CG_ELEMENT *pe); |
| 927 |
*/ |
| 928 |
/****************************************************************************/ |
| 929 |
|
| 930 |
int NS_DIM_PREFIX Read_pinfo (int ge, MGIO_PARINFO *pinfo) |
| 931 |
{ |
| 932 |
#if (MGIO_DEBUG>0) |
| 933 |
char buffer[28]; |
| 934 |
static int nb=0; |
| 935 |
|
| 936 |
if (Bio_Read_string(buffer)) return (1); |
| 937 |
if(strcmp(buffer,"PINFO_BEGIN")!=0) |
| 938 |
{ |
| 939 |
printf("proc=%d, nb=%d\n",me,nb); |
| 940 |
fflush(stdout); |
| 941 |
assert(0); |
| 942 |
} |
| 943 |
nb++; |
| 944 |
#endif |
| 945 |
|
| 946 |
int s = 0; |
| 947 |
int m = 3 + 6 * lge[ge].nCorner; |
| 948 |
if (Bio_Read_mint(m,intList)) return (1); |
| 949 |
pinfo->prio_elem = intList[s++]; |
| 950 |
assert(pinfo->prio_elem<32); |
| 951 |
pinfo->ncopies_elem = intList[s++]; |
| 952 |
int np = pinfo->ncopies_elem; |
| 953 |
pinfo->e_ident = intList[s++]; |
| 954 |
for (int i = 0; i < lge[ge].nCorner; i++) |
| 955 |
{ |
| 956 |
pinfo->prio_node[i] = intList[s++]; |
| 957 |
assert(pinfo->prio_node[i]<32); |
| 958 |
pinfo->ncopies_node[i] = intList[s++]; |
| 959 |
np+= pinfo->ncopies_node[i]; |
| 960 |
pinfo->n_ident[i] = intList[s++]; |
| 961 |
} |
| 962 |
for (int i = 0; i < lge[ge].nCorner; i++) |
| 963 |
{ |
| 964 |
pinfo->prio_vertex[i] = intList[s++]; |
| 965 |
assert(pinfo->prio_vertex[i]<32); |
| 966 |
pinfo->ncopies_vertex[i] = intList[s++]; |
| 967 |
np+= pinfo->ncopies_vertex[i]; |
| 968 |
pinfo->v_ident[i] = intList[s++]; |
| 969 |
} |
| 970 |
s=0; |
| 971 |
m = 3*lge[ge].nEdge; |
| 972 |
if (Bio_Read_mint(m,intList)) return (1); |
| 973 |
for (int i = 0; i < lge[ge].nEdge; i++) |
| 974 |
{ |
| 975 |
pinfo->prio_edge[i] = intList[s++]; |
| 976 |
assert(pinfo->prio_edge[i]<32); |
| 977 |
pinfo->ncopies_edge[i] = intList[s++]; |
| 978 |
np+= pinfo->ncopies_edge[i]; |
| 979 |
pinfo->ed_ident[i] = intList[s++]; |
| 980 |
} |
| 981 |
if ((np > 0) && Bio_Read_mint(np,intList)) |
| 982 |
return 1; |
| 983 |
|
| 984 |
for (int i = 0; i < np; i++) |
| 985 |
{ |
| 986 |
pinfo->proclist[i] = intList[i]; |
| 987 |
ASSERT(pinfo->proclist[i]<nparfiles); |
| 988 |
} |
| 989 |
|
| 990 |
return (0); |
| 991 |
} |
| 992 |
|
| 993 |
/****************************************************************************/ |
| 994 |
/* |
| 995 |
Write_pinfo - writes parallel-info for an element |
| 996 |
|
| 997 |
SYNOPSIS: |
| 998 |
static int Write_pinfo (MGIO_CG_ELEMENT *pe); |
| 999 |
*/ |
| 1000 |
/****************************************************************************/ |
| 1001 |
|
| 1002 |
int NS_DIM_PREFIX Write_pinfo (int ge, MGIO_PARINFO *pinfo) |
| 1003 |
{ |
| 1004 |
int np; |
| 1005 |
|
| 1006 |
#if (MGIO_DEBUG>0) |
| 1007 |
if (Bio_Write_string("PINFO_BEGIN")) return (1); |
| 1008 |
#endif |
| 1009 |
|
| 1010 |
int s = 0; |
| 1011 |
intList[s++] = pinfo->prio_elem; |
| 1012 |
intList[s++] = np = pinfo->ncopies_elem; |
| 1013 |
intList[s++] = pinfo->e_ident; |
| 1014 |
for (int i = 0; i < lge[ge].nCorner; i++) |
| 1015 |
{ |
| 1016 |
intList[s++] = pinfo->prio_node[i]; |
| 1017 |
intList[s++] = pinfo->ncopies_node[i]; |
| 1018 |
np+= pinfo->ncopies_node[i]; |
| 1019 |
intList[s++] = pinfo->n_ident[i]; |
| 1020 |
} |
| 1021 |
for (int i = 0; i < lge[ge].nCorner; i++) |
| 1022 |
{ |
| 1023 |
intList[s++] = pinfo->prio_vertex[i]; |
| 1024 |
intList[s++] = pinfo->ncopies_vertex[i]; |
| 1025 |
np+= pinfo->ncopies_vertex[i]; |
| 1026 |
intList[s++] = pinfo->v_ident[i]; |
| 1027 |
} |
| 1028 |
if (Bio_Write_mint(s,intList)) RETURN (1); |
| 1029 |
s=0; |
| 1030 |
for (int i = 0; i<lge[ge].nEdge; i++) |
| 1031 |
{ |
| 1032 |
intList[s++] = pinfo->prio_edge[i]; |
| 1033 |
intList[s++] = pinfo->ncopies_edge[i]; |
| 1034 |
np+= pinfo->ncopies_edge[i]; |
| 1035 |
intList[s++] = pinfo->ed_ident[i]; |
| 1036 |
} |
| 1037 |
if (Bio_Write_mint(s,intList)) RETURN (1); |
| 1038 |
for (int i = 0; i < np; i++) |
| 1039 |
{ |
| 1040 |
intList[i] = pinfo->proclist[i]; |
| 1041 |
ASSERT(intList[i]<nparfiles); |
| 1042 |
} |
| 1043 |
if ((np > 0) && Bio_Write_mint(np,intList)) |
| 1044 |
return 1; |
| 1045 |
|
| 1046 |
return (0); |
| 1047 |
} |
| 1048 |
|
| 1049 |
/****************************************************************************/ |
| 1050 |
/* |
| 1051 |
Read_CG_Elements - reads coarse grid elements |
| 1052 |
|
| 1053 |
SYNOPSIS: |
| 1054 |
int Read_CG_Elements (int n, MGIO_CG_ELEMENT *cg_element); |
| 1055 |
|
| 1056 |
PARAMETERS: |
| 1057 |
. n - nb of coarse grid elements to read |
| 1058 |
. cg_element - first coarse grid element |
| 1059 |
|
| 1060 |
DESCRIPTION: |
| 1061 |
function reads coarse grid elements |
| 1062 |
|
| 1063 |
RETURN VALUE: |
| 1064 |
INT |
| 1065 |
.n 0 if ok |
| 1066 |
.n 1 if read error. |
| 1067 |
|
| 1068 |
SEE ALSO: |
| 1069 |
*/ |
| 1070 |
/****************************************************************************/ |
| 1071 |
|
| 1072 |
int NS_DIM_PREFIX Read_CG_Elements (int n, MGIO_CG_ELEMENT *cg_element) |
| 1073 |
{ |
| 1074 |
int i,j,m,s; |
| 1075 |
MGIO_CG_ELEMENT *pe; |
| 1076 |
|
| 1077 |
for (i=0; i<n; i++) |
| 1078 |
{ |
| 1079 |
pe = MGIO_CG_ELEMENT_PS(cg_element,i); |
| 1080 |
|
| 1081 |
/* coarse grid part */ |
| 1082 |
if (Bio_Read_mint(1,&pe->ge)) return (1); |
| 1083 |
m=lge[pe->ge].nCorner+lge[pe->ge].nSide+3; |
| 1084 |
if (Bio_Read_mint(m,intList)) return (1); |
| 1085 |
s=0; |
| 1086 |
pe->nref = intList[s++]; |
| 1087 |
for (j=0; j<lge[pe->ge].nCorner; j++) |
| 1088 |
pe->cornerid[j] = intList[s++]; |
| 1089 |
for (j=0; j<lge[pe->ge].nSide; j++) |
| 1090 |
pe->nbid[j] = intList[s++]; |
| 1091 |
pe->se_on_bnd = intList[s++]; |
| 1092 |
pe->subdomain = intList[s++]; |
| 1093 |
|
| 1094 |
if (MGIO_PARFILE) |
| 1095 |
{ |
| 1096 |
if (Bio_Read_mint(1,intList)) return (1); |
| 1097 |
s=0; |
| 1098 |
pe->level = intList[s++]; |
| 1099 |
} |
| 1100 |
|
| 1101 |
#if (MGIO_DEBUG>0) |
| 1102 |
/* read debug extension */ |
| 1103 |
m = 1 + lge[pe->ge].nCorner + lge[pe->ge].nSide; |
| 1104 |
if (Bio_Read_mint(m,intList)) return (1); |
| 1105 |
s=0; |
| 1106 |
pe->mykey = intList[s++]; |
| 1107 |
for (j=0; j<lge[pe->ge].nCorner; j++) |
| 1108 |
pe->nodekey[j] = intList[s++]; |
| 1109 |
for (j=0; j<lge[pe->ge].nSide; j++) |
| 1110 |
pe->neighborkey[j] = intList[s++]; |
| 1111 |
#endif |
| 1112 |
|
| 1113 |
} |
| 1114 |
|
| 1115 |
return (0); |
| 1116 |
} |
| 1117 |
|
| 1118 |
/****************************************************************************/ |
| 1119 |
/* |
| 1120 |
Write_CG_Elements - writes coarse grid elements |
| 1121 |
|
| 1122 |
SYNOPSIS: |
| 1123 |
int Write_CG_Elements (int n, MGIO_CG_ELEMENT *cg_element); |
| 1124 |
|
| 1125 |
PARAMETERS: |
| 1126 |
. n - nb of coarse grid elements to write |
| 1127 |
. rr_rules - first coarse grid element |
| 1128 |
|
| 1129 |
DESCRIPTION: |
| 1130 |
function writes coarse grid elements |
| 1131 |
|
| 1132 |
RETURN VALUE: |
| 1133 |
INT |
| 1134 |
.n 0 if ok |
| 1135 |
.n 1 if read error. |
| 1136 |
|
| 1137 |
SEE ALSO: |
| 1138 |
*/ |
| 1139 |
/****************************************************************************/ |
| 1140 |
|
| 1141 |
int NS_DIM_PREFIX Write_CG_Elements (int n, MGIO_CG_ELEMENT *cg_element) |
| 1142 |
{ |
| 1143 |
for (int i = 0; i < n; i++) |
| 1144 |
{ |
| 1145 |
const MGIO_CG_ELEMENT *pe = MGIO_CG_ELEMENT_PS(cg_element, i); |
| 1146 |
|
| 1147 |
/* coarse grid part */ |
| 1148 |
int s = 0; |
| 1149 |
intList[s++] = pe->ge; |
| 1150 |
intList[s++] = pe->nref; |
| 1151 |
for (int j = 0; j < lge[pe->ge].nCorner; j++) |
| 1152 |
intList[s++] = pe->cornerid[j]; |
| 1153 |
for (int j = 0; j < lge[pe->ge].nSide; j++) |
| 1154 |
intList[s++] = pe->nbid[j]; |
| 1155 |
intList[s++] = pe->se_on_bnd; |
| 1156 |
intList[s++] = pe->subdomain; |
| 1157 |
MGIO_CHECK_INTSIZE(s); |
| 1158 |
if (Bio_Write_mint(s,intList)) return (1); |
| 1159 |
|
| 1160 |
if (MGIO_PARFILE) |
| 1161 |
{ |
| 1162 |
s=0; |
| 1163 |
intList[s++] = pe->level; |
| 1164 |
if (Bio_Write_mint(s,intList)) return (1); |
| 1165 |
} |
| 1166 |
|
| 1167 |
#if (MGIO_DEBUG>0) |
| 1168 |
/* write debug extension */ |
| 1169 |
s=0; |
| 1170 |
intList[s++] = pe->mykey; |
| 1171 |
for (int j = 0; j < lge[pe->ge].nCorner; j++) |
| 1172 |
intList[s++] = pe->nodekey[j]; |
| 1173 |
for (int j = 0; j < lge[pe->ge].nSide; j++) |
| 1174 |
intList[s++] = pe->neighborkey[j]; |
| 1175 |
if (Bio_Write_mint(s,intList)) return (1); |
| 1176 |
#endif |
| 1177 |
|
| 1178 |
} |
| 1179 |
|
| 1180 |
return (0); |
| 1181 |
} |
| 1182 |
|
| 1183 |
/****************************************************************************/ |
| 1184 |
/* |
| 1185 |
Read_HE_Refinement - reads hierarchical elements |
| 1186 |
|
| 1187 |
SYNOPSIS: |
| 1188 |
int Read_HE_Refinement (MGIO_HE_ELEMENT *he_element); |
| 1189 |
|
| 1190 |
PARAMETERS: |
| 1191 |
. n - nb of hierarchical elements to read |
| 1192 |
. he_element - hierarchical element |
| 1193 |
|
| 1194 |
DESCRIPTION: |
| 1195 |
function reads hierarchical elements |
| 1196 |
|
| 1197 |
RETURN VALUE: |
| 1198 |
INT |
| 1199 |
.n 0 if ok |
| 1200 |
.n 1 if read error. |
| 1201 |
|
| 1202 |
SEE ALSO: |
| 1203 |
*/ |
| 1204 |
/****************************************************************************/ |
| 1205 |
|
| 1206 |
int NS_DIM_PREFIX Read_Refinement (MGIO_REFINEMENT *pr, MGIO_RR_RULE *rr_rules) |
| 1207 |
{ |
| 1208 |
#if (MGIO_DEBUG>0) |
| 1209 |
char buffer[128]; |
| 1210 |
if (Bio_Read_string(buffer)) assert(0); /*return (1);*/ |
| 1211 |
if(strcmp(buffer,"REFINEMENT_BEGIN")!=0) assert(0); /*return (1);*/ |
| 1212 |
if (Bio_Read_mint(1,intList)) assert(0); /*return (1);*/ |
| 1213 |
#endif |
| 1214 |
|
| 1215 |
if (Bio_Read_mint(2,intList)) assert(0); /*return (1);*/ |
| 1216 |
unsigned int ctrl = intList[0]; |
| 1217 |
pr->sonref = intList[1]; |
| 1218 |
pr->refrule = MGIO_ECTRL_RF(ctrl)-1; |
| 1219 |
if (pr->refrule>-1) |
| 1220 |
{ |
| 1221 |
pr->nnewcorners = MGIO_ECTRL_NF(ctrl); |
| 1222 |
pr->nmoved = MGIO_ECTRL_NM(ctrl); |
| 1223 |
pr->refclass = MGIO_ECTRL_RC(ctrl); |
| 1224 |
if (pr->nnewcorners+pr->nmoved>0) |
| 1225 |
if (Bio_Read_mint(pr->nnewcorners+pr->nmoved,intList)) assert(0); /*return (1);*/ |
| 1226 |
int s = 0; |
| 1227 |
for (int j = 0; j < pr->nnewcorners; j++) |
| 1228 |
pr->newcornerid[j] = intList[s++]; |
| 1229 |
for (int j = 0; j < pr->nmoved; j++) |
| 1230 |
pr->mvcorner[j].id = intList[s++]; |
| 1231 |
if (pr->nmoved>0) |
| 1232 |
{ |
| 1233 |
if (Bio_Read_mdouble(MGIO_DIM*pr->nmoved,doubleList)) assert(0); /*return (1);*/ |
| 1234 |
s=0; |
| 1235 |
for (int j = 0; j < pr->nmoved; j++) |
| 1236 |
for (int k = 0; k < MGIO_DIM; k++) |
| 1237 |
pr->mvcorner[j].position[k] = doubleList[s++]; |
| 1238 |
} |
| 1239 |
} |
| 1240 |
|
| 1241 |
if (MGIO_PARFILE) |
| 1242 |
{ |
| 1243 |
pr->orphanid_ex = MGIO_ECTRL_ON(ctrl); |
| 1244 |
int s = 2; |
| 1245 |
if (pr->orphanid_ex) |
| 1246 |
s += pr->nnewcorners; |
| 1247 |
if (Bio_Read_mint(s,intList)) assert(0); /*return (1);*/ |
| 1248 |
s=0; |
| 1249 |
pr->sonex = intList[s++]; |
| 1250 |
pr->nbid_ex = intList[s++]; |
| 1251 |
if (pr->orphanid_ex) |
| 1252 |
for (int j = 0; j < pr->nnewcorners; j++) |
| 1253 |
pr->orphanid[j] = intList[s++]; |
| 1254 |
for (int k = 0; k < MGIO_MAX_SONS_OF_ELEM; k++) |
| 1255 |
if ((pr->sonex>>k)&1) |
| 1256 |
{ |
| 1257 |
int tag = rr_rules[pr->refrule].sons[k].tag; |
| 1258 |
if (Read_pinfo(tag,&pr->pinfo[k])) assert(0); /*return (1);*/ |
| 1259 |
if ((pr->nbid_ex>>k)&1) |
| 1260 |
{ |
| 1261 |
if (Bio_Read_mint(lge[tag].nSide,intList)) assert(0); /*return (1);*/ |
| 1262 |
for (int j = 0; j < lge[tag].nSide; j++) |
| 1263 |
pr->nbid[k][j] = intList[j]; |
| 1264 |
} |
| 1265 |
} |
| 1266 |
} |
| 1267 |
|
| 1268 |
#if (MGIO_DEBUG>0) |
| 1269 |
/* read debug extension */ |
| 1270 |
|
| 1271 |
/* read mykey */ |
| 1272 |
if (Bio_Read_mint(1,&(pr->mykey))) assert(0); /*return (1);*/ |
| 1273 |
|
| 1274 |
/* read myfatherkey */ |
| 1275 |
if (Bio_Read_mint(1,&(pr->myfatherkey))) assert(0); /*return (1);*/ |
| 1276 |
|
| 1277 |
/* read nbkey[] */ |
| 1278 |
if (Bio_Read_mint(MGIO_MAX_SIDES_OF_ELEM,pr->nbkey)) assert(0); /*return (1);*/ |
| 1279 |
|
| 1280 |
/* read mycorners */ |
| 1281 |
if (Bio_Read_mint(1,&(pr->mycorners))) assert(0); /*return (1);*/ |
| 1282 |
assert(pr->mycorners>0); |
| 1283 |
|
| 1284 |
if (Bio_Read_mint(3*pr->mycorners,intList)) assert(0); /*return (1);*/ |
| 1285 |
int s = 0; |
| 1286 |
for (int j = 0; j < pr->mycorners; j++) |
| 1287 |
{ |
| 1288 |
pr->mycornerkey[j] = intList[s++]; |
| 1289 |
pr->mycornerfatherkey[j] = intList[s++]; |
| 1290 |
pr->mycornersonkey[j] = intList[s++]; |
| 1291 |
} |
| 1292 |
|
| 1293 |
if (pr->refrule>-1) |
| 1294 |
{ |
| 1295 |
if (MGIO_PARFILE) |
| 1296 |
{ |
| 1297 |
/* read sonskey[], sonsnbkey[][] and nbkey[][] */ |
| 1298 |
for (int k = 0; k < MGIO_MAX_SONS_OF_ELEM; k++) |
| 1299 |
if ((pr->sonex>>k)&1) |
| 1300 |
{ |
| 1301 |
tag = rr_rules[pr->refrule].sons[k].tag; |
| 1302 |
s = 1+lge[tag].nSide; |
| 1303 |
if (Bio_Read_mint(s,intList)) assert(0); /*return (1);*/ |
| 1304 |
|
| 1305 |
s=0; |
| 1306 |
pr->sonskey[k] = intList[s++]; |
| 1307 |
for (int j = 0; j < lge[tag].nSide; j++) |
| 1308 |
pr->sonsnbkey[k][j] = intList[s++]; |
| 1309 |
} |
| 1310 |
else |
| 1311 |
pr->sonskey[k] = -1 ; |
| 1312 |
} |
| 1313 |
|
| 1314 |
} |
| 1315 |
#endif |
| 1316 |
return (0); |
| 1317 |
} |
| 1318 |
|
| 1319 |
/****************************************************************************/ |
| 1320 |
/* |
| 1321 |
Write_HE_Refinement - writes hierarchical elements |
| 1322 |
|
| 1323 |
SYNOPSIS: |
| 1324 |
int Write_HE_Refinement (int n, MGIO_HE_ELEMENT *he_element); |
| 1325 |
|
| 1326 |
PARAMETERS: |
| 1327 |
. n - nb of hierarchical elements to write |
| 1328 |
. he_element - hierarchical element |
| 1329 |
|
| 1330 |
DESCRIPTION: |
| 1331 |
function writes hierarchical elements |
| 1332 |
|
| 1333 |
RETURN VALUE: |
| 1334 |
INT |
| 1335 |
.n 0 if ok |
| 1336 |
.n 1 if read error. |
| 1337 |
|
| 1338 |
SEE ALSO: |
| 1339 |
*/ |
| 1340 |
/****************************************************************************/ |
| 1341 |
|
| 1342 |
int NS_DIM_PREFIX Write_Refinement (MGIO_REFINEMENT *pr, MGIO_RR_RULE *rr_rules) |
| 1343 |
{ |
| 1344 |
int j,k,s,t,tag; |
| 1345 |
|
| 1346 |
#if (MGIO_DEBUG>0) |
| 1347 |
static int g_count; |
| 1348 |
if (Bio_Write_string("REFINEMENT_BEGIN")) return (1); |
| 1349 |
if (Bio_Write_mint(1,&g_count)) return (1); |
| 1350 |
g_count++; |
| 1351 |
#endif |
| 1352 |
|
| 1353 |
s=t=0; |
| 1354 |
if (MGIO_PARFILE) |
| 1355 |
{ |
| 1356 |
intList[s++] = MGIO_ECTRL(pr->refrule+1,pr->nnewcorners,pr->nmoved,pr->refclass,pr->orphanid_ex); |
| 1357 |
} |
| 1358 |
else |
| 1359 |
{ |
| 1360 |
intList[s++] = MGIO_ECTRL(pr->refrule+1,pr->nnewcorners,pr->nmoved,pr->refclass,0); |
| 1361 |
} |
| 1362 |
intList[s++] = pr->sonref; |
| 1363 |
if (pr->refrule>-1) |
| 1364 |
{ |
| 1365 |
for (j=0; j<pr->nnewcorners; j++) |
| 1366 |
intList[s++] = pr->newcornerid[j]; |
| 1367 |
for (j=0; j<pr->nmoved; j++) |
| 1368 |
intList[s++] = pr->mvcorner[j].id; |
| 1369 |
for (j=0; j<pr->nmoved; j++) |
| 1370 |
for (k=0; k<MGIO_DIM; k++) |
| 1371 |
doubleList[t++] = pr->mvcorner[j].position[k]; |
| 1372 |
} |
| 1373 |
|
| 1374 |
MGIO_CHECK_INTSIZE(s); |
| 1375 |
if (Bio_Write_mint(s,intList)) return (1); |
| 1376 |
MGIO_CHECK_DOUBLESIZE(t); |
| 1377 |
if (t>0) if (Bio_Write_mdouble(t,doubleList)) return (1); |
| 1378 |
|
| 1379 |
if (MGIO_PARFILE) |
| 1380 |
{ |
| 1381 |
s=0; |
| 1382 |
intList[s++] = pr->sonex; |
| 1383 |
intList[s++] = pr->nbid_ex; |
| 1384 |
if (pr->orphanid_ex) |
| 1385 |
for (j=0; j<pr->nnewcorners; j++) |
| 1386 |
intList[s++] = pr->orphanid[j]; |
| 1387 |
if (Bio_Write_mint(s,intList)) return (1); |
| 1388 |
for (k=0; k<MGIO_MAX_SONS_OF_ELEM; k++) |
| 1389 |
if ((pr->sonex>>k)&1) |
| 1390 |
{ |
| 1391 |
tag = rr_rules[pr->refrule].sons[k].tag; |
| 1392 |
if (Write_pinfo(tag,&pr->pinfo[k])) return (1); |
| 1393 |
if ((pr->nbid_ex>>k)&1) |
| 1394 |
{ |
| 1395 |
for (j=0; j<lge[tag].nSide; j++) |
| 1396 |
intList[j] = pr->nbid[k][j]; |
| 1397 |
if (Bio_Write_mint(lge[tag].nSide,intList)) return (1); |
| 1398 |
} |
| 1399 |
} |
| 1400 |
} |
| 1401 |
|
| 1402 |
#if (MGIO_DEBUG>0) |
| 1403 |
/* write debug extension */ |
| 1404 |
|
| 1405 |
/* write mykey */ |
| 1406 |
if (Bio_Write_mint(1,&(pr->mykey))) assert(0); /*return (1);*/ |
| 1407 |
|
| 1408 |
/* write myfatherkey */ |
| 1409 |
if (Bio_Write_mint(1,&(pr->myfatherkey))) assert(0); /*return (1);*/ |
| 1410 |
|
| 1411 |
/* write nbkey[] */ |
| 1412 |
MGIO_CHECK_INTSIZE(MGIO_MAX_SIDES_OF_ELEM); |
| 1413 |
if (Bio_Write_mint(MGIO_MAX_SIDES_OF_ELEM,pr->nbkey)) assert(0); /*return (1);*/ |
| 1414 |
|
| 1415 |
/* write mycorners */ |
| 1416 |
if (Bio_Write_mint(1,&(pr->mycorners))) assert(0); /*return (1);*/ |
| 1417 |
assert(pr->mycorners > 0); |
| 1418 |
|
| 1419 |
s=0; |
| 1420 |
for (j=0; j<pr->mycorners; j++) |
| 1421 |
{ |
| 1422 |
intList[s++] = pr->mycornerkey[j]; |
| 1423 |
intList[s++] = pr->mycornerfatherkey[j]; |
| 1424 |
intList[s++] = pr->mycornersonkey[j]; |
| 1425 |
} |
| 1426 |
MGIO_CHECK_INTSIZE(s); |
| 1427 |
if (Bio_Write_mint(s,intList)) assert(0); /*return (1);*/ |
| 1428 |
|
| 1429 |
if (pr->refrule>-1) |
| 1430 |
{ |
| 1431 |
if (MGIO_PARFILE) |
| 1432 |
{ |
| 1433 |
/* write sonskey[], sonsnbkey[][] and nbkey[][] */ |
| 1434 |
for (k=0; k<MGIO_MAX_SONS_OF_ELEM; k++) |
| 1435 |
if ((pr->sonex>>k)&1) |
| 1436 |
{ |
| 1437 |
s=0; |
| 1438 |
tag = rr_rules[pr->refrule].sons[k].tag; |
| 1439 |
intList[s++] = pr->sonskey[k]; |
| 1440 |
|
| 1441 |
for (j=0; j<lge[tag].nSide; j++) |
| 1442 |
intList[s++] = pr->sonsnbkey[k][j]; |
| 1443 |
|
| 1444 |
MGIO_CHECK_INTSIZE(s); |
| 1445 |
if (Bio_Write_mint(s,intList)) assert(0); /*return (1);*/ |
| 1446 |
} |
| 1447 |
} |
| 1448 |
} |
| 1449 |
|
| 1450 |
#endif |
| 1451 |
|
| 1452 |
return (0); |
| 1453 |
} |
| 1454 |
|
| 1455 |
/****************************************************************************/ |
| 1456 |
/* |
| 1457 |
Read_BD_General - reads general information about boundary description |
| 1458 |
|
| 1459 |
SYNOPSIS: |
| 1460 |
int Read_BD_General (MGIO_BD_GENERAL *bd_general); |
| 1461 |
|
| 1462 |
PARAMETERS: |
| 1463 |
. bd_general - information about boundary description |
| 1464 |
|
| 1465 |
DESCRIPTION: |
| 1466 |
function reads general information about boundary description |
| 1467 |
|
| 1468 |
RETURN VALUE: |
| 1469 |
INT |
| 1470 |
.n 0 if ok |
| 1471 |
.n 1 if read error. |
| 1472 |
|
| 1473 |
SEE ALSO: |
| 1474 |
*/ |
| 1475 |
/****************************************************************************/ |
| 1476 |
|
| 1477 |
int NS_DIM_PREFIX Read_BD_General (MGIO_BD_GENERAL *bd_general) |
| 1478 |
{ |
| 1479 |
if (Bio_Read_mint(1,intList)) return (1); |
| 1480 |
bd_general->nBndP = intList[0]; |
| 1481 |
|
| 1482 |
return (0); |
| 1483 |
} |
| 1484 |
|
| 1485 |
/****************************************************************************/ |
| 1486 |
/* |
| 1487 |
Write_BD_General - writes general information about boundary description |
| 1488 |
|
| 1489 |
SYNOPSIS: |
| 1490 |
int Write_BD_General (MGIO_BD_GENERAL *bd_general); |
| 1491 |
|
| 1492 |
PARAMETERS: |
| 1493 |
. bd_general - information about boundary description |
| 1494 |
|
| 1495 |
DESCRIPTION: |
| 1496 |
function writes general information about boundary description |
| 1497 |
|
| 1498 |
RETURN VALUE: |
| 1499 |
INT |
| 1500 |
.n 0 if ok |
| 1501 |
.n 1 if read error. |
| 1502 |
|
| 1503 |
SEE ALSO: |
| 1504 |
*/ |
| 1505 |
/****************************************************************************/ |
| 1506 |
|
| 1507 |
int NS_DIM_PREFIX Write_BD_General (MGIO_BD_GENERAL *bd_general) |
| 1508 |
{ |
| 1509 |
intList[0] = bd_general->nBndP; |
| 1510 |
if (Bio_Write_mint(1,intList)) return (1); |
| 1511 |
|
| 1512 |
return (0); |
| 1513 |
} |
| 1514 |
|
| 1515 |
/****************************************************************************/ |
| 1516 |
/* |
| 1517 |
Read_PBndDesc - reads BNDPs |
| 1518 |
|
| 1519 |
SYNOPSIS: |
| 1520 |
int Read_PBndDesc (MGIO_HEAP *theHeap, int n, BNDP **BndPList); |
| 1521 |
|
| 1522 |
PARAMETERS: |
| 1523 |
. theHeap - heap |
| 1524 |
. n - nb of BndP to read |
| 1525 |
. BndPList - list of ptrs to BndP |
| 1526 |
|
| 1527 |
DESCRIPTION: |
| 1528 |
function reads BNDPs |
| 1529 |
|
| 1530 |
RETURN VALUE: |
| 1531 |
INT |
| 1532 |
.n 0 if ok |
| 1533 |
.n 1 if read error. |
| 1534 |
|
| 1535 |
SEE ALSO: |
| 1536 |
*/ |
| 1537 |
/****************************************************************************/ |
| 1538 |
|
| 1539 |
#ifdef __MGIO_USE_IN_UG__ |
| 1540 |
|
| 1541 |
int NS_DIM_PREFIX Read_PBndDesc (STD_BVP *theBVP, HEAP *theHeap, int n, BNDP **BndPList) |
| 1542 |
{ |
| 1543 |
if (theBVP!=NULL && theHeap==NULL) return (1); |
| 1544 |
if (theBVP!=NULL) |
| 1545 |
{ |
| 1546 |
for (int i = 0; i <n; i++) |
| 1547 |
{ |
| 1548 |
BndPList[i] = BNDP_LoadBndP (theBVP,theHeap); |
| 1549 |
if (BndPList[i]==NULL) return (1); |
| 1550 |
} |
| 1551 |
} |
| 1552 |
else |
| 1553 |
{ |
| 1554 |
for (int i = 0; i < n; i++) |
| 1555 |
{ |
| 1556 |
BndPList[i] = BNDP_LoadBndP_Ext (); |
| 1557 |
if (BndPList[i]==NULL) return (1); |
| 1558 |
} |
| 1559 |
} |
| 1560 |
return (0); |
| 1561 |
} |
| 1562 |
|
| 1563 |
#endif |
| 1564 |
|
| 1565 |
/****************************************************************************/ |
| 1566 |
/* |
| 1567 |
Write_PBndDesc - write BNDPs |
| 1568 |
|
| 1569 |
SYNOPSIS: |
| 1570 |
int Write_PBndDesc (int n, BNDP **BndPList); |
| 1571 |
|
| 1572 |
PARAMETERS: |
| 1573 |
. n - nb of BndP to write |
| 1574 |
. BndPList - list of ptrs to BndP |
| 1575 |
|
| 1576 |
DESCRIPTION: |
| 1577 |
function writes BNDPs |
| 1578 |
|
| 1579 |
RETURN VALUE: |
| 1580 |
INT |
| 1581 |
.n 0 if ok |
| 1582 |
.n 1 if read error. |
| 1583 |
|
| 1584 |
SEE ALSO: |
| 1585 |
*/ |
| 1586 |
/****************************************************************************/ |
| 1587 |
|
| 1588 |
#ifdef __MGIO_USE_IN_UG__ |
| 1589 |
|
| 1590 |
int NS_DIM_PREFIX Write_PBndDesc (int n, BNDP **BndPList) |
| 1591 |
{ |
| 1592 |
if (n>0) |
| 1593 |
{ |
| 1594 |
for (int i = 0; i < n; i++) |
| 1595 |
if (BNDP_SaveBndP (BndPList[i])) return (1); |
| 1596 |
} |
| 1597 |
else |
| 1598 |
{ |
| 1599 |
n=-n; |
| 1600 |
for (int i = 0; i < n; i++) |
| 1601 |
if (BNDP_SaveBndP_Ext (BndPList[i])) return (1); |
| 1602 |
} |
| 1603 |
return (0); |
| 1604 |
} |
| 1605 |
|
| 1606 |
#endif |
| 1607 |
|
| 1608 |
/****************************************************************************/ |
| 1609 |
/* |
| 1610 |
CloseMGFile - close the file |
| 1611 |
|
| 1612 |
SYNOPSIS: |
| 1613 |
int CloseMGFile (); |
| 1614 |
|
| 1615 |
PARAMETERS: |
| 1616 |
|
| 1617 |
DESCRIPTION: |
| 1618 |
close the file |
| 1619 |
|
| 1620 |
RETURN VALUE: |
| 1621 |
INT |
| 1622 |
.n 0 if ok |
| 1623 |
.n 1 if read error. |
| 1624 |
|
| 1625 |
SEE ALSO: |
| 1626 |
*/ |
| 1627 |
/****************************************************************************/ |
| 1628 |
|
| 1629 |
int NS_DIM_PREFIX CloseMGFile (void) |
| 1630 |
{ |
| 1631 |
if (fclose(stream)!=0) return (1); |
| 1632 |
return (0); |
| 1633 |
} |
| 1634 |
|
| 1635 |
/****************************************************************************/ |
| 1636 |
/* |
| 1637 |
MGIO_Init - init input/output for mg |
| 1638 |
|
| 1639 |
SYNOPSIS: |
| 1640 |
int MGIO_Init (void); |
| 1641 |
|
| 1642 |
PARAMETERS: |
| 1643 |
|
| 1644 |
DESCRIPTION: |
| 1645 |
init the i/o of mg |
| 1646 |
|
| 1647 |
RETURN VALUE: |
| 1648 |
INT |
| 1649 |
.n 0 if ok |
| 1650 |
.n 1 if read error. |
| 1651 |
|
| 1652 |
SEE ALSO: |
| 1653 |
*/ |
| 1654 |
/****************************************************************************/ |
| 1655 |
|
| 1656 |
int NS_DIM_PREFIX MGIO_Init () |
| 1657 |
{ |
| 1658 |
|
| 1659 |
#ifdef __MGIO_USE_IN_UG__ |
| 1660 |
|
| 1661 |
/* check consistency with output macros */ |
| 1662 |
MGIO_CHECKEXTMACROS; |
| 1663 |
|
| 1664 |
/* path to grid-dirs */ |
| 1665 |
mgpathes_set = 0; |
| 1666 |
if (ReadSearchingPaths("defaults","mgpaths")==0) |
| 1667 |
mgpathes_set = 1; |
| 1668 |
|
| 1669 |
#endif |
| 1670 |
|
| 1671 |
return (0); |
| 1672 |
} |