/[escript]/branches/doubleplusgood/dudley/src/Mesh.cpp
ViewVC logotype

Diff of /branches/doubleplusgood/dudley/src/Mesh.cpp

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

revision 3080 by jfenwick, Tue Aug 3 04:28:03 2010 UTC revision 3163 by jfenwick, Tue Sep 7 05:30:39 2010 UTC
# Line 13  Line 13 
13    
14  /**************************************************************/  /**************************************************************/
15    
16  /*   Finley: Mesh */  /*   Dudley: Mesh */
17    
18  /**************************************************************/  /**************************************************************/
19    
# Line 24  Line 24 
24  /*   allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */  /*   allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
25  /*   the most appropriate order is selected indepently. */  /*   the most appropriate order is selected indepently. */
26    
27  Finley_Mesh* Finley_Mesh_alloc(char* name,dim_t numDim, Paso_MPIInfo *mpi_info)  Dudley_Mesh* Dudley_Mesh_alloc(char* name,dim_t numDim, Paso_MPIInfo *mpi_info)
28  {  {
29    Finley_Mesh *out;    Dudley_Mesh *out;
30        
31    /*  allocate the return value */    /*  allocate the return value */
32        
33    out=MEMALLOC(1,Finley_Mesh);    out=MEMALLOC(1,Dudley_Mesh);
34    if (Finley_checkPtr(out)) return NULL;    if (Dudley_checkPtr(out)) return NULL;
35    out->Name=NULL;      out->Name=NULL;  
36    out->Nodes=NULL;    out->Nodes=NULL;
37    out->Elements=NULL;      out->Elements=NULL;  
38    out->FaceElements=NULL;    out->FaceElements=NULL;
39    out->Points=NULL;          out->Points=NULL;      
   out->ContactElements=NULL;        
40    out->TagMap=NULL;          out->TagMap=NULL;      
41    out->reference_counter=0;    out->reference_counter=0;
42    
# Line 46  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 45  Finley_Mesh* Finley_Mesh_alloc(char* nam
45    out->ReducedFullPattern=NULL;    out->ReducedFullPattern=NULL;
46    out->ReducedReducedPattern=NULL;    out->ReducedReducedPattern=NULL;
47    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );    out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
48    if (! Finley_noError()) {    if (! Dudley_noError()) {
49        Finley_Mesh_free(out);        Dudley_Mesh_free(out);
50        return NULL;        return NULL;
51    }    }
52    /*   copy name: */    /*   copy name: */
53        
54    out->Name=MEMALLOC(strlen(name)+1,char);    out->Name=MEMALLOC(strlen(name)+1,char);
55    if (Finley_checkPtr(out->Name)) {    if (Dudley_checkPtr(out->Name)) {
56        Finley_Mesh_free(out);        Dudley_Mesh_free(out);
57        return NULL;        return NULL;
58    }    }
59    strcpy(out->Name,name);    strcpy(out->Name,name);
60        
61    /*   allocate node table: */    /*   allocate node table: */
62    out->Nodes=Finley_NodeFile_alloc( numDim, mpi_info );    out->Nodes=Dudley_NodeFile_alloc( numDim, mpi_info );
63    if (! Finley_noError()) {    if (! Dudley_noError()) {
64        Finley_Mesh_free(out);        Dudley_Mesh_free(out);
65        return NULL;        return NULL;
66    }    }
67    out->approximationOrder=-1;    out->approximationOrder=-1;
# Line 73  Finley_Mesh* Finley_Mesh_alloc(char* nam Line 72  Finley_Mesh* Finley_Mesh_alloc(char* nam
72    out->Elements=NULL;    out->Elements=NULL;
73    out->FaceElements=NULL;    out->FaceElements=NULL;
74    out->Points=NULL;    out->Points=NULL;
   out->ContactElements=NULL;  
75    out->reference_counter++;    out->reference_counter++;
76    return out;    return out;
77  }  }
78    
79  /* returns a reference to Finley_Mesh in */  /* returns a reference to Dudley_Mesh in */
80    
81  Finley_Mesh* Finley_Mesh_reference(Finley_Mesh* in) {  Dudley_Mesh* Dudley_Mesh_reference(Dudley_Mesh* in) {
82       if (in!=NULL) ++(in->reference_counter);       if (in!=NULL) ++(in->reference_counter);
83       return in;       return in;
84  }  }
85    
86  /*   freeates a mesh: */  /*   freeates a mesh: */
87    
88  void Finley_Mesh_free(Finley_Mesh* in) {  void Dudley_Mesh_free(Dudley_Mesh* in) {
89    if (in!=NULL) {    if (in!=NULL) {
90       in->reference_counter--;       in->reference_counter--;
91       if (in->reference_counter<1) {       if (in->reference_counter<1) {
92         MEMFREE(in->Name);         MEMFREE(in->Name);
93         Finley_NodeFile_free(in->Nodes);         Dudley_NodeFile_free(in->Nodes);
94         Finley_ElementFile_free(in->FaceElements);         Dudley_ElementFile_free(in->FaceElements);
95         Finley_ElementFile_free(in->Elements);           Dudley_ElementFile_free(in->Elements);  
96         Finley_ElementFile_free(in->ContactElements);         Dudley_ElementFile_free(in->Points);
97         Finley_ElementFile_free(in->Points);         Dudley_TagMap_free(in->TagMap);
        Finley_TagMap_free(in->TagMap);  
98         Paso_SystemMatrixPattern_free(in->FullFullPattern);         Paso_SystemMatrixPattern_free(in->FullFullPattern);
99         Paso_SystemMatrixPattern_free(in->FullReducedPattern);         Paso_SystemMatrixPattern_free(in->FullReducedPattern);
100         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);         Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
# Line 112  void Finley_Mesh_free(Finley_Mesh* in) { Line 109  void Finley_Mesh_free(Finley_Mesh* in) {
109    
110  /*  returns the spatial dimension of the mesh: */  /*  returns the spatial dimension of the mesh: */
111    
112  dim_t Finley_Mesh_getDim(Finley_Mesh *in) {  dim_t Dudley_Mesh_getDim(Dudley_Mesh *in) {
113    return in->Nodes->numDim;    return in->Nodes->numDim;
114  }  }
115    
116  void Finley_Mesh_setElements(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setElements(Dudley_Mesh* self,Dudley_ElementFile *elements) {
117      Finley_ElementFile_free(self->Elements);      Dudley_ElementFile_free(self->Elements);
118      self->Elements=elements;      self->Elements=elements;
119  }  }
120  void Finley_Mesh_setFaceElements(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setFaceElements(Dudley_Mesh* self,Dudley_ElementFile *elements) {
121      Finley_ElementFile_free(self->FaceElements);      Dudley_ElementFile_free(self->FaceElements);
122      self->FaceElements=elements;      self->FaceElements=elements;
123  }  }
124  void Finley_Mesh_setContactElements(Finley_Mesh* self,Finley_ElementFile *elements) {  void Dudley_Mesh_setPoints(Dudley_Mesh* self,Dudley_ElementFile *elements) {
125      Finley_ElementFile_free(self->ContactElements);      Dudley_ElementFile_free(self->Points);
     self->ContactElements=elements;  
 }  
 void Finley_Mesh_setPoints(Finley_Mesh* self,Finley_ElementFile *elements) {  
     Finley_ElementFile_free(self->Points);  
126      self->Points=elements;      self->Points=elements;
127  }  }
128  int  Finley_Mesh_getStatus(Finley_Mesh* in) {  int  Dudley_Mesh_getStatus(Dudley_Mesh* in) {
129     if  (in == NULL) {     if  (in == NULL) {
130          return -1;          return -1;
131     } else if (in->Nodes == NULL) {     } else if (in->Nodes == NULL) {
# Line 142  int  Finley_Mesh_getStatus(Finley_Mesh* Line 135  int  Finley_Mesh_getStatus(Finley_Mesh*
135     }     }
136  }  }
137    
138  void Mesh_setOrders(Finley_Mesh *in)  void Mesh_setOrders(Dudley_Mesh *in)
139  {  {
140     const dim_t order_max=9999999;     const dim_t order_max=9999999;
141     dim_t locals[4];     dim_t locals[3];
142     #ifdef PASO_MPI     #ifdef PASO_MPI
143         dim_t globals[4];         dim_t globals[3];
144     #endif     #endif
145     locals[0]=order_max; locals[1]=order_max; locals[2]=order_max; locals[3]=order_max;     locals[0]=order_max; locals[1]=order_max; locals[2]=order_max;
146    
147    if ( in->Elements!=NULL) {    if ( in->Elements!=NULL) {
148       if (in->Elements->numElements > 0) {       if (in->Elements->numElements > 0) {
149           locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);           locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
150           locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);           locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->integrationOrder);
151           locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElement->integrationOrder);           locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
          locals[3]=MIN(locals[3], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);  
152       }       }
153    }    }
154    if ( in->FaceElements!=NULL) {    if ( in->FaceElements!=NULL) {
155       if (in->FaceElements->numElements > 0) {       if (in->FaceElements->numElements > 0) {
156           locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);           locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
157           locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);           locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);
158           locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);           locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
          locals[3]=MIN(locals[3], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);  
159       }       }
160    
161    
162    }    }
   if ( in->ContactElements!=NULL) {  
      if (in->ContactElements->numElements > 0) {  
          locals[0]=MIN(locals[0], in->ContactElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);  
          locals[1]=MIN(locals[1], in->ContactElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);  
          locals[2]=MIN(locals[2], in->ContactElements->referenceElementSet->referenceElement->integrationOrder);  
          locals[3]=MIN(locals[3], in->ContactElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);  
      }  
   
   }  
163    
164     #ifdef PASO_MPI     #ifdef PASO_MPI
165         MPI_Allreduce( locals, globals, 4, MPI_INT, MPI_MIN, in->MPIInfo->comm );         MPI_Allreduce( locals, globals, 3, MPI_INT, MPI_MIN, in->MPIInfo->comm );
166         in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );         in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );
167         in->reducedApproximationOrder=(globals[1] < order_max ? globals[1] : -1 );         in->reducedApproximationOrder=in->approximationOrder;
168         in->integrationOrder=(globals[2] < order_max ? globals[2] : -1 );         in->integrationOrder=(globals[1] < order_max ? globals[1] : -1 );
169         in->reducedIntegrationOrder=(globals[3] < order_max ? globals[3] : -1 );         in->reducedIntegrationOrder=(globals[2] < order_max ? globals[2] : -1 );
170     #else     #else
171         in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );         in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );
172         in->reducedApproximationOrder=(locals[1] < order_max ? locals[1] : -1 );         in->reducedApproximationOrder=(locals[0] < order_max ? locals[0] : -1 );
173         in->integrationOrder=(locals[2] < order_max ? locals[2] : -1 );         in->integrationOrder=(locals[1] < order_max ? locals[1] : -1 );
174         in->reducedIntegrationOrder=(locals[3] < order_max ? locals[3] : -1 );         in->reducedIntegrationOrder=(locals[2] < order_max ? locals[2] : -1 );
175     #endif     #endif
176    
177    

Legend:
Removed from v.3080  
changed lines
  Added in v.3163

  ViewVC Help
Powered by ViewVC 1.1.26