/[escript]/branches/trilinos_from_5897/dudley/src/NodeFile_allocTable.cpp
ViewVC logotype

Diff of /branches/trilinos_from_5897/dudley/src/NodeFile_allocTable.cpp

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

revision 964 by gross, Tue Feb 13 05:10:26 2007 UTC revision 1312 by ksteube, Mon Sep 24 06:18:44 2007 UTC
# Line 1  Line 1 
 /*  
  ************************************************************  
  *          Copyright 2006 by ACcESS MNRF                   *  
  *                                                          *  
  *              http://www.access.edu.au                    *  
  *       Primary Business: Queensland, Australia            *  
  *  Licensed under the Open Software License version 3.0    *  
  *     http://www.opensource.org/licenses/osl-3.0.php       *  
  *                                                          *  
  ************************************************************  
 */  
1    
2  /**************************************************************/  /* $Id$ */
3    
4  /*   Finley: Mesh: NodeFile */  /*******************************************************
5     *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16  /**************************************************************/  /**************************************************************/
17    
18  /*   Author: gross@access.edu.au */  /*   Finley: Mesh: NodeFile */
 /*   Version: $Id$ */  
19    
20  /**************************************************************/  /**************************************************************/
21    
# Line 26  Line 24 
24  /**************************************************************/  /**************************************************************/
25    
26  /*  allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */  /*  allocates the node table within an node file to hold numNodes of nodes. The LinearTo mapping, if it exists, */
27  /*  is deallocated. use Finley_Mesh_setLinearMesh to create a new one. */  /*  is frees. use Finley_Mesh_setLinearMesh to create a new one. */
28    
29  void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)  void Finley_NodeFile_allocTable(Finley_NodeFile* in ,dim_t numNodes)
30  {  {
31    index_t *Id2=NULL, *Tag2=NULL, *degreeOfFreedom2=NULL, *reducedDegreeOfFreedom2=NULL, *toReduced2=NULL;    index_t *Id2=NULL, *Tag2=NULL, *globalDegreesOfFreedom2=NULL, *globalReducedDOFIndex2=NULL,
32  #ifdef PASO_MPI            *globalReducedNodesIndex2=NULL, *globalNodesIndex2=NULL, *reducedNodesId2=NULL, *degreesOfFreedomId2=NULL,
33      index_t *Dom2=NULL;            *reducedDegreesOfFreedomId2=NULL;
 #endif  
34    double *Coordinates2=NULL;    double *Coordinates2=NULL;
35    dim_t n,i;    dim_t n,i;
36        
37    /*  allocate memory: */    /*  allocate memory: */
 #ifdef PASO_MPI  
   Dom2=MEMALLOC(numNodes,index_t);  
 #endif  
38    Id2=MEMALLOC(numNodes,index_t);    Id2=MEMALLOC(numNodes,index_t);
39    Coordinates2=MEMALLOC(numNodes*in->numDim,double);    Coordinates2=MEMALLOC(numNodes*in->numDim,double);
40    Tag2=MEMALLOC(numNodes,index_t);    Tag2=MEMALLOC(numNodes,index_t);
41    degreeOfFreedom2=MEMALLOC(numNodes,index_t);    globalDegreesOfFreedom2=MEMALLOC(numNodes,index_t);
42    reducedDegreeOfFreedom2=MEMALLOC(numNodes,index_t);    globalReducedDOFIndex2=MEMALLOC(numNodes,index_t);
43    toReduced2=MEMALLOC(numNodes,index_t);    globalReducedNodesIndex2=MEMALLOC(numNodes,index_t);
44      globalNodesIndex2=MEMALLOC(numNodes,index_t);
45      reducedNodesId2=MEMALLOC(numNodes,index_t);
46      degreesOfFreedomId2=MEMALLOC(numNodes,index_t);
47      reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
48        
49    /*  if fine, deallocate the old table and replace by new: */    /*  if fine, freeate the old table and replace by new: */
50  #ifdef PASO_MPI    if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2)
51    if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) || Finley_checkPtr(Dom2) ||               || Finley_checkPtr(globalDegreesOfFreedom2)
52        Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {               || Finley_checkPtr(globalReducedDOFIndex2)
53          MEMFREE( Dom2 );               || Finley_checkPtr(globalReducedNodesIndex2)
54  #else               || Finley_checkPtr(globalNodesIndex2)
55    if (Finley_checkPtr(Id2) || Finley_checkPtr(Coordinates2) || Finley_checkPtr(Tag2) ||               || Finley_checkPtr(reducedNodesId2)
56        Finley_checkPtr(degreeOfFreedom2) || Finley_checkPtr(reducedDegreeOfFreedom2) || Finley_checkPtr(toReduced2) ) {               || Finley_checkPtr(degreesOfFreedomId2) ) {
57  #endif    reducedDegreesOfFreedomId2=MEMALLOC(numNodes,index_t);
58      MEMFREE(Id2);      MEMFREE(Id2);
59      MEMFREE(Coordinates2);      MEMFREE(Coordinates2);
60      MEMFREE(Tag2);      MEMFREE(Tag2);
61      MEMFREE(degreeOfFreedom2);      MEMFREE(globalDegreesOfFreedom2);
62      MEMFREE(reducedDegreeOfFreedom2);      MEMFREE(globalReducedDOFIndex2);
63      MEMFREE(toReduced2);      MEMFREE(globalReducedNodesIndex2);
64        MEMFREE(globalNodesIndex2);
65        MEMFREE(reducedNodesId2);
66        MEMFREE(degreesOfFreedomId2);
67        MEMFREE(reducedDegreesOfFreedomId2);
68    } else {    } else {
69      Finley_NodeFile_deallocTable(in);      Finley_NodeFile_freeTable(in);
 #ifdef PASO_MPI  
         in->Dom=Dom2;  
 #endif  
70      in->Id=Id2;      in->Id=Id2;
71      in->Coordinates=Coordinates2;      in->Coordinates=Coordinates2;
72        in->globalDegreesOfFreedom=globalDegreesOfFreedom2;
73      in->Tag=Tag2;      in->Tag=Tag2;
74      in->degreeOfFreedom=degreeOfFreedom2;      in->globalReducedDOFIndex=globalReducedDOFIndex2;
75      in->reducedDegreeOfFreedom=reducedDegreeOfFreedom2;      in->globalReducedNodesIndex=globalReducedNodesIndex2;
76      in->toReduced=toReduced2;      in->globalNodesIndex=globalNodesIndex2;
77        in->reducedNodesId=reducedNodesId2;
78        in->degreesOfFreedomId=degreesOfFreedomId2;
79        in->reducedDegreesOfFreedomId=reducedDegreesOfFreedomId2;
80      in->numNodes=numNodes;      in->numNodes=numNodes;
     in->numDegreesOfFreedom=numNodes;  
     in->reducedNumDegreesOfFreedom=numNodes;  
     in->reducedNumNodes=numNodes;  
81      /* this initialization makes sure that data are located on the right processor */      /* this initialization makes sure that data are located on the right processor */
82      #pragma omp parallel for private(n,i) schedule(static)      #pragma omp parallel for private(n,i) schedule(static)
83      for (n=0;n<numNodes;n++) {      for (n=0;n<numNodes;n++) {
84         for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;         for (i=0;i<in->numDim;i++) in->Coordinates[INDEX2(i,n,in->numDim)]=0.;
 #ifdef PASO_MPI  
        in->Dom[n]=-1;  
 #endif  
85         in->Id[n]=-1;         in->Id[n]=-1;
86         in->Tag[n]=-1;         in->Tag[n]=-1;
87         in->degreeOfFreedom[n]=n;         in->globalDegreesOfFreedom[n]=-1;
88         in->reducedDegreeOfFreedom[n]=n;         in->globalReducedDOFIndex[n]=-1;
89         in->toReduced[n]=n;         in->globalReducedNodesIndex[n]=-1;
90           in->globalNodesIndex[n]=-1;
91           in->reducedNodesId[n]=-1;
92           in->degreesOfFreedomId[n]=-1;
93           in->reducedDegreesOfFreedomId[n]=-1;
94      }      }
95    }    }
96    return;    return;
97  }  }
98    
99  /*  deallocates the node table within an node file: */  /*  frees the node table within an node file: */
100    
101  void Finley_NodeFile_deallocTable(Finley_NodeFile* in) {  void Finley_NodeFile_freeTable(Finley_NodeFile* in) {
102    if (in!=NULL) {    if (in!=NULL) {
 #ifdef PASO_MPI  
     MEMFREE(in->Dom);  
 #endif  
103      MEMFREE(in->Id);      MEMFREE(in->Id);
104      MEMFREE(in->Coordinates);      MEMFREE(in->Coordinates);
105        MEMFREE(in->globalDegreesOfFreedom);
106        MEMFREE(in->globalReducedDOFIndex);
107        MEMFREE(in->globalReducedNodesIndex);
108        MEMFREE(in->globalNodesIndex);
109      MEMFREE(in->Tag);      MEMFREE(in->Tag);
110      MEMFREE(in->degreeOfFreedom);      MEMFREE(in->reducedNodesId);
111      MEMFREE(in->degreeOfFreedomId);      MEMFREE(in->degreesOfFreedomId);
112      MEMFREE(in->reducedDegreeOfFreedom);      MEMFREE(in->reducedDegreesOfFreedomId);
113      MEMFREE(in->reducedDegreeOfFreedomId);      Finley_NodeMapping_free(in->nodesMapping);
114      MEMFREE(in->toReduced);      in->nodesMapping=NULL;
115        Finley_NodeMapping_free(in->reducedNodesMapping);
116        in->reducedNodesMapping=NULL;
117        Finley_NodeMapping_free(in->degreesOfFreedomMapping);
118        in->degreesOfFreedomMapping=NULL;
119        Finley_NodeMapping_free(in->reducedDegreesOfFreedomMapping);
120        in->reducedDegreesOfFreedomMapping=NULL;
121        Paso_Distribution_free(in->nodesDistribution);
122        in->nodesDistribution=NULL;
123        Paso_Distribution_free(in->reducedNodesDistribution);
124        in->nodesDistribution=NULL;
125        Paso_Distribution_free(in->degreesOfFreedomDistribution);
126        in->degreesOfFreedomDistribution=NULL;
127        Paso_Distribution_free(in->reducedDegreesOfFreedomDistribution);
128        in->reducedDegreesOfFreedomDistribution=NULL;
129        Paso_Coupler_free(in->degreesOfFreedomCoupler);
130        in->degreesOfFreedomCoupler=NULL;
131        Paso_Coupler_free(in->reducedDegreesOfFreedomCoupler);
132        in->reducedDegreesOfFreedomCoupler=NULL;
133    
134      in->numNodes=0;      in->numNodes=0;
     in->numDegreesOfFreedom=0;  
     in->reducedNumDegreesOfFreedom=0;  
     in->reducedNumNodes=0;  
135    }    }
136  }  }
 /*  
 * $Log$  
 * Revision 1.6  2005/09/15 03:44:23  jgs  
 * Merge of development branch dev-02 back to main trunk on 2005-09-15  
 *  
 * Revision 1.5.2.1  2005/09/07 06:26:20  gross  
 * the solver from finley are put into the standalone package paso now  
 *  
 * Revision 1.5  2005/07/08 04:07:55  jgs  
 * Merge of development branch back to main trunk on 2005-07-08  
 *  
 * Revision 1.4  2004/12/15 07:08:33  jgs  
 * *** empty log message ***  
 * Revision 1.1.1.1.2.2  2005/06/29 02:34:54  gross  
 * some changes towards 64 integers in finley  
 *  
 * Revision 1.1.1.1.2.1  2004/11/24 01:37:15  gross  
 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now  
 *  
 *  
 *  
 */  

Legend:
Removed from v.964  
changed lines
  Added in v.1312

  ViewVC Help
Powered by ViewVC 1.1.26