calcbbox.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: calcbbox.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 "util.h"
00028 
00029 int calcbbox(int n_ele,int *elevert,int *eleprop,PetscReal *vertxyz2,int n_pids,int *slice_id,PetscReal *bbox)
00030 {
00031   int i,j,k,l;
00032   PetscReal bbox2[2*ND]={PETSC_MAX,PETSC_MAX,PETSC_MAX,PETSC_MIN,PETSC_MIN,PETSC_MIN};
00033 
00034   MagparFunctionLogBegin;
00035 
00036 
00037   assert(n_pids>=1);
00038 
00039   PetscPrintf(PETSC_COMM_WORLD,
00040     "Searching bbox for %i volumes, pid[0]=%i\n",
00041     n_pids,slice_id[0]+1
00042   );
00043 
00044   /* find bbox of cut slice in x-y plane */
00045   for (i=0; i<n_ele; i++) {
00046     for (l=0;l<n_pids;l++) {
00047       if (slice_id[l]<0 || eleprop[i] == slice_id[l]) {
00048         for (j=0; j<NV; j++) {
00049           for (k=0;k<ND;k++) {
00050             bbox2[k]   =PetscMin(bbox2[k],   vertxyz2[ND*elevert[NV*i+j]+k]);
00051             bbox2[ND+k]=PetscMax(bbox2[ND+k],vertxyz2[ND*elevert[NV*i+j]+k]);
00052           }
00053         }
00054       }
00055     }
00056   }
00057 
00058   PetscPrintf(PETSC_COMM_WORLD,
00059     "bbox of volume with pid %i (0=any):\n"
00060     "%14s %14s   %s\n",
00061     slice_id[0]+1,"min","max","width"
00062   );
00063 
00064   for (k=0;k<ND;k++) {
00065     ierr = PetscGlobalMin(&bbox2[k],   &bbox[k],   PETSC_COMM_WORLD);CHKERRQ(ierr);
00066     ierr = PetscGlobalMax(&bbox2[ND+k],&bbox[ND+k],PETSC_COMM_WORLD);CHKERRQ(ierr);
00067 
00068     PetscPrintf(PETSC_COMM_WORLD,
00069       "%14e %14e   %g\n",
00070       bbox[k],bbox[ND+k],bbox[ND+k]-bbox[k]
00071     );
00072     assert(bbox[ND+k]-bbox[k]>0);
00073   }
00074 
00075   MagparFunctionLogReturn(0);
00076 }
00077 

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