/[escript]/trunk/finley/src/Mesh_line2.c
ViewVC logotype

Diff of /trunk/finley/src/Mesh_line2.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 750 by bcumming, Mon May 15 04:03:49 2006 UTC revision 751 by bcumming, Mon Jun 26 01:46:34 2006 UTC
# Line 30  Line 30 
30    
31  /**************************************************************/  /**************************************************************/
32    
   
33  /* get the number of nodes/elements for domain with rank=rank, of size processors  /* get the number of nodes/elements for domain with rank=rank, of size processors
34     where n is the total number of nodes/elements in the global domain */     where n is the total number of nodes/elements in the global domain */
35  static index_t domain_MODdim( index_t rank, index_t size, index_t n )  static index_t domain_MODdim( index_t rank, index_t size, index_t n )
# Line 317  Finley_Mesh* Finley_RectangularMesh_Line Line 316  Finley_Mesh* Finley_RectangularMesh_Line
316    /*  allocate tables: */    /*  allocate tables: */
317        
318    Finley_NodeFile_allocTable(out->Nodes,numNodesLocal+numNodesExternal);    Finley_NodeFile_allocTable(out->Nodes,numNodesLocal+numNodesExternal);
319    Finley_NodeDistibution_allocTable( out->Nodes->degreeOfFreedomDistribution, numNodesLocal, numNodesExternal, 0 );    Finley_NodeDistribution_allocTable( out->Nodes->degreeOfFreedomDistribution, numNodesLocal, numNodesExternal, 0 );
320    Finley_ElementFile_allocTable(out->Elements,numElementsLocal);    Finley_ElementFile_allocTable(out->Elements,numElementsLocal);
321    if( NFaceElements )    if( NFaceElements )
322      Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);      Finley_ElementFile_allocTable(out->FaceElements,NFaceElements);
# Line 354  Finley_Mesh* Finley_RectangularMesh_Line Line 353  Finley_Mesh* Finley_RectangularMesh_Line
353          k--;          k--;
354          out->Nodes->Coordinates[INDEX2(0,k,1)]=Length[0];          out->Nodes->Coordinates[INDEX2(0,k,1)]=Length[0];
355          out->Nodes->Id[k]=k;          out->Nodes->Id[k]=k;
356          out->Nodes->Tag[k]=2;          out->Nodes->Tag[k]=0;
357          out->Nodes->degreeOfFreedom[k]=0;          out->Nodes->degreeOfFreedom[k]=0;
358          DOFcount--;          DOFcount--;
359          k++;          k++;
# Line 382  Finley_Mesh* Finley_RectangularMesh_Line Line 381  Finley_Mesh* Finley_RectangularMesh_Line
381        {        {
382          out->Nodes->Coordinates[INDEX2(0,k,1)]=Length[0];          out->Nodes->Coordinates[INDEX2(0,k,1)]=Length[0];
383          out->Nodes->Id[k]=k;          out->Nodes->Id[k]=k;
384          out->Nodes->Tag[k]=2;          out->Nodes->Tag[k]=0;
385          out->Nodes->degreeOfFreedom[k]=k;          out->Nodes->degreeOfFreedom[k]=k;
386          k++;          k++;
387        }        }
# Line 396  Finley_Mesh* Finley_RectangularMesh_Line Line 395  Finley_Mesh* Finley_RectangularMesh_Line
395          out->Nodes->degreeOfFreedom[k]=DOFcount;          out->Nodes->degreeOfFreedom[k]=DOFcount;
396          k++;          k++;
397        }        }
398        }
399        /* setup boundary DOF data */      /* setup boundary DOF data */
400        if( domInternal )      if( domInternal )
401        {
402          targetDomain = mpi_info->rank-1;
403          forwardDOF[0] = 0;
404          backwardDOF[0] = numNodesLocal;
405          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );
406          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );
407    
408          targetDomain = mpi_info->rank+1;
409          forwardDOF[0] = numNodesLocal-1;
410          backwardDOF[0] = numNodesLocal+1;
411          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );
412          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );
413        }
414        else if( domLeft )
415        {
416          if( periodicLocal[0] )
417        {        {
418          targetDomain = mpi_info->rank-1;          targetDomain = mpi_info->size-1;
419          forwardDOF[0] = 0;          forwardDOF[0] = 0;
420          backwardDOF[0] = numNodesLocal;          backwardDOF[0] = numNodesLocal;          
421          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );
422          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );
423          }
424          targetDomain = mpi_info->rank+1;
425          forwardDOF[0] = numNodesLocal-1-periodicLocal[0];
426          backwardDOF[0] = numNodesLocal + periodicLocal[0];
427          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );
428          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );
429        }
430        else
431        {
432          targetDomain = mpi_info->rank-1;
433          forwardDOF[0] = 0;
434          backwardDOF[0] = numNodesLocal;
435          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );
436          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );
437    
438          targetDomain = mpi_info->rank+1;        if( periodicLocal[1] )
439          forwardDOF[0] = numNodesLocal-1;        {
440            targetDomain = 0;
441            forwardDOF[0] = numNodesLocal-1;          
442          backwardDOF[0] = numNodesLocal+1;          backwardDOF[0] = numNodesLocal+1;
443          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );          Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );
444          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );          Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );
445        }        }
446        else if( domLeft )      }      
447        {        
         if( periodicLocal[0] )  
         {  
           targetDomain = mpi_info->size-1;  
           forwardDOF[0] = 0;  
           backwardDOF[0] = numNodesLocal;            
           Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );  
           Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );  
         }  
         targetDomain = mpi_info->rank+1;  
         forwardDOF[0] = numNodesLocal-1-periodicLocal[0];  
         backwardDOF[0] = numNodesLocal + periodicLocal[0];  
         Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );  
         Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );  
       }  
       else  
       {  
         targetDomain = mpi_info->rank-1;  
         forwardDOF[0] = 0;  
         backwardDOF[0] = numNodesLocal;  
         Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );  
         Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );  
   
         if( periodicLocal[1] )  
         {  
           targetDomain = 0;  
           forwardDOF[0] = numNodesLocal-1;            
           backwardDOF[0] = numNodesLocal+1;  
           Finley_NodeDistribution_addForward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, forwardDOF );  
           Finley_NodeDistribution_addBackward( out->Nodes->degreeOfFreedomDistribution, targetDomain, 1, backwardDOF );  
         }  
       }        
         
     }  
448      if (! Finley_MPI_noError(mpi_info)) {      if (! Finley_MPI_noError(mpi_info)) {
449        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);
450        return NULL;        return NULL;
451      }      }
452    
     printf( "\n============NODES=============\n" );  
     for( k=0; k<numNodesLocal; k++ )  
       printf( "\tI\tId %d\tDOF %d\tcoord [%g]\n", out->Nodes->Id[k], out->Nodes->degreeOfFreedom[k] , out->Nodes->Coordinates[INDEX2(0,k,1)] );  
     for( k=numNodesLocal; k<numNodesLocal+numNodesExternal; k++ )  
       printf( "\tE\tId %d\tDOF %d\tcoord [%g]\n", out->Nodes->Id[k], out->Nodes->degreeOfFreedom[k] , out->Nodes->Coordinates[INDEX2(0,k,1)] );  
     
     for( k=0; k<out->Nodes->degreeOfFreedomDistribution->numNeighbours; k++ )  
     {  
       if( out->Nodes->degreeOfFreedomDistribution->neighbours[k]>=0 )  
       {  
         printf( "\t%d boundary DOF { ", out->Nodes->degreeOfFreedomDistribution->edges[k]->numForward );  
         for( i0=0; i0<out->Nodes->degreeOfFreedomDistribution->edges[k]->numForward; i0++ )  
           printf( "%d ", out->Nodes->degreeOfFreedomDistribution->edges[k]->indexForward[i0] );  
         printf("} to %d\n", out->Nodes->degreeOfFreedomDistribution->neighbours[k] );  
         printf( "\t%d boundary DOF { ", out->Nodes->degreeOfFreedomDistribution->edges[k]->numBackward );  
         for( i0=0; i0<out->Nodes->degreeOfFreedomDistribution->edges[k]->numBackward; i0++ )  
           printf( "%d ", out->Nodes->degreeOfFreedomDistribution->edges[k]->indexBackward[i0] );  
         printf("} from %d\n", out->Nodes->degreeOfFreedomDistribution->neighbours[k] );  
       }  
     }      
   }  
   else  
   {  
     printf( "\n============NODES=============\n" );  
     for( k=0; k<numNodesLocal; k++ )  
       printf( "\tI\tId %d\tDOF %d\tcoord [%g]\n", out->Nodes->Id[k], out->Nodes->degreeOfFreedom[k] , out->Nodes->Coordinates[INDEX2(0,k,1)] );  
453    }    }
454    
455    /*   set the elements: */    /*   set the elements: */
# Line 591  Finley_Mesh* Finley_RectangularMesh_Line Line 563  Finley_Mesh* Finley_RectangularMesh_Line
563    if( domLeft || domRight && !periodic[0] )    if( domLeft || domRight && !periodic[0] )
564      out->FaceElements->elementDistribution->numLocal = out->FaceElements->elementDistribution->numInternal = domLeft + domRight;      out->FaceElements->elementDistribution->numLocal = out->FaceElements->elementDistribution->numInternal = domLeft + domRight;
565    
566    printf( "\n============ELEMENTS (%d)=============\n", out->Elements->numElements );    
   for( k=0; k<out->Elements->elementDistribution->numInternal; k++ )  
   {  
     printf( "I\tId %d : nodes [%d %d]->DOF [%d %d]\n", out->Elements->Id[k], out->Elements->Nodes[INDEX2(0,k,2)], out->Elements->Nodes[INDEX2(1,k,2)], out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(0,k,2)]], out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(1,k,2)]] );  
   }  
   for( k=out->Elements->elementDistribution->numInternal; k<out->Elements->elementDistribution->numLocal; k++ )  
   {  
     printf( "E\tId %d : nodes [%d %d]->DOF [%d %d]\n", out->Elements->Id[k], out->Elements->Nodes[INDEX2(0,k,2)], out->Elements->Nodes[INDEX2(1,k,2)], out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(0,k,2)]], out->Nodes->degreeOfFreedom[out->Elements->Nodes[INDEX2(1,k,2)]] );  
   }  
   for( k=0; k<out->FaceElements->numElements; k++ )  
   {  
     if( NUMNODES==2 )  
       printf( "F\tId %d : nodes [%d %d]->DOF [%d %d]\n", out->FaceElements->Id[k], out->FaceElements->Nodes[INDEX2(0,k,2)], out->FaceElements->Nodes[INDEX2(1,k,2)], out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(0,k,2)]], out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(1,k,2)]] );  
     else  
       printf( "F\tId %d : nodes [%d]->DOF [%d]\n", out->FaceElements->Id[k], out->FaceElements->Nodes[INDEX2(0,k,1)], out->Nodes->degreeOfFreedom[out->FaceElements->Nodes[INDEX2(0,k,1)]] );  
   }  
567    /*  face elements done: */    /*  face elements done: */
568        
569    /*   condense the nodes: */    /*   condense the nodes: */
# Line 614  Finley_Mesh* Finley_RectangularMesh_Line Line 571  Finley_Mesh* Finley_RectangularMesh_Line
571    
572    /* prepare mesh for further calculatuions:*/    /* prepare mesh for further calculatuions:*/
573    
   /* TEMPFIX */  
574    /* this isn't needed for a mesh generated this way */    /* this isn't needed for a mesh generated this way */
575    //Finley_Mesh_prepare(out);    Finley_Mesh_prepare(out);
576      
577      /* setup the CommBuffer */
578      {
579        index_t *numForward=NULL, *numBackward=NULL;
580        index_t i;
581    
582        numForward  = MEMALLOC( out->Nodes->degreeOfFreedomDistribution->numNeighbours, index_t );
583        numBackward = MEMALLOC( out->Nodes->degreeOfFreedomDistribution->numNeighbours, index_t );
584    
585        for( i=0; i<out->Nodes->degreeOfFreedomDistribution->numNeighbours; i++ )
586        {
587          numForward[i] = out->Nodes->degreeOfFreedomDistribution->edges[i]->numForward;
588          numBackward[i] = out->Nodes->degreeOfFreedomDistribution->edges[i]->numBackward;
589        }
590    
591        Paso_CommBuffer_allocTable( out->Nodes->CommBuffer, FINLEY_INIT_ITEMSIZE, numForward, numBackward, out->Nodes->degreeOfFreedomDistribution->numNeighbours, out->Nodes->degreeOfFreedomDistribution->neighbours );
592    
593        MEMFREE( numForward );
594        MEMFREE( numBackward );
595      }
596    if (! Finley_MPI_noError( mpi_info )) {    if (! Finley_MPI_noError( mpi_info )) {
597        Paso_MPIInfo_dealloc( mpi_info );        Paso_MPIInfo_dealloc( mpi_info );
598        Finley_Mesh_dealloc(out);        Finley_Mesh_dealloc(out);

Legend:
Removed from v.750  
changed lines
  Added in v.751

  ViewVC Help
Powered by ViewVC 1.1.26