readmesh.c

Go to the documentation of this file.
00001 /*
00002     This file is part of magpar.
00003 
00004     Copyright (C) 2002-2010 Werner Scholz
00005 
00006     www:   http://www.magpar.net/
00007     email: magpar(at)magpar.net
00008 
00009     magpar is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     magpar is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with magpar; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 
00024 static char const Id[] = "$Id: readmesh.c 2962 2010-02-04 19:50:44Z scholz $\n\n";
00025 static char const Td[] = "$Today: " __FILE__ "  " __DATE__ "  "  __TIME__  " $\n\n";
00026 
00027 #include "magpario.h"
00028 
00029 int ReadMesh(GridData *gdata)
00030 {
00031   MagparFunctionLogBegin;
00032 
00033   PetscTruth flg;
00034   ierr = PetscOptionsGetString(PETSC_NULL,"-simName",gdata->simname,255,&flg);CHKERRQ(ierr);
00035   if (flg!=PETSC_TRUE)
00036     SETERRQ(PETSC_ERR_ARG_CORRUPT,"Option -simName not found!\n");
00037 
00038   int meshtype;
00039   ierr = PetscOptionsGetInt(PETSC_NULL,"-meshtype",(PetscInt*)&meshtype,&flg);CHKERRQ(ierr);
00040   if (flg!=PETSC_TRUE) {
00041     meshtype=1;
00042     PetscPrintf(PETSC_COMM_WORLD,
00043       "Option -meshtype not found, using default value: %i\n",
00044       meshtype
00045     );
00046   }
00047 
00048   ierr = PetscOptionsGetInt(PETSC_NULL,"-inp",(PetscInt*)&gdata->inp,&flg);CHKERRQ(ierr);
00049   if (flg!=PETSC_TRUE) {
00050     gdata->inp=1;
00051     PetscPrintf(PETSC_COMM_WORLD,
00052       "Option -inp not found, using default value: %i\n",
00053       gdata->inp
00054     );
00055   }
00056   ierr = MPI_Bcast(&gdata->inp,1,MPIU_SCALAR,0,PETSC_COMM_WORLD);CHKERRQ(ierr);
00057 
00058   /* indicate, that we have no FE mesh yet */
00059   gdata->vertxyz=NULL;
00060   gdata->elevert=NULL;
00061 
00062   if (meshtype==0){
00063     ierr = ReadPatran(gdata);CHKERRQ(ierr);
00064   }
00065   else if (meshtype==1){
00066     /* TODO: read filename directly from option */
00067     char fmesh[256];
00068     ierr = PetscSNPrintf(fmesh,255,"%s.inp",gdata->simname);CHKERRQ(ierr);
00069     ierr = ReadINP(gdata,fmesh,PETSC_NULL,0);CHKERRQ(ierr);
00070   }
00071   else {
00072     SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"-meshtype has illegal value!\n");
00073   }
00074 
00075   MagparFunctionLogReturn(0);
00076 }
00077 

magpar - Parallel Finite Element Micromagnetics Package
Copyright (C) 2002-2010 Werner Scholz