/[escript]/branches/more_shared_ptrs_from_1812/finley/src/CPPAdapter/MeshAdapterFactory.cpp
ViewVC logotype

Diff of /branches/more_shared_ptrs_from_1812/finley/src/CPPAdapter/MeshAdapterFactory.cpp

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

revision 1360 by ksteube, Thu Dec 13 05:05:00 2007 UTC revision 1776 by ksteube, Tue Sep 9 06:03:53 2008 UTC
# Line 57  namespace finley { Line 57  namespace finley {
57      AbstractContinuousDomain* temp;      AbstractContinuousDomain* temp;
58      Finley_Mesh *mesh_p=NULL;      Finley_Mesh *mesh_p=NULL;
59      char error_msg[LenErrorMsg_MAX];      char error_msg[LenErrorMsg_MAX];
60      char *fName = Paso_MPI_appendRankToFileName(strdup(fileName.c_str()), mpi_info->size, mpi_info->rank);  
61        char *fName = Paso_MPI_appendRankToFileName(fileName.c_str(),
62                                                    mpi_info->size,
63                                                    mpi_info->rank);
64    
65      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
66      Finley_resetError();      Finley_resetError();
67        int *first_DofComponent, *first_NodeComponent;
68    
69      // Open NetCDF file for reading      // Open NetCDF file for reading
70      NcAtt *attr;      NcAtt *attr;
# Line 77  namespace finley { Line 81  namespace finley {
81      }      }
82    
83      // Read NetCDF integer attributes      // Read NetCDF integer attributes
84      int mpi_size            = NetCDF_Get_Int_Attribute(&dataFile, fName, "mpi_size");      int mpi_size            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"mpi_size");
85      int mpi_rank            = NetCDF_Get_Int_Attribute(&dataFile, fName, "mpi_rank");      int mpi_rank            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"mpi_rank");
86      int numDim              = NetCDF_Get_Int_Attribute(&dataFile, fName, "numDim");      int numDim              = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"numDim");
87      int order               = NetCDF_Get_Int_Attribute(&dataFile, fName, "order");      int order               = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"order");
88      int reduced_order           = NetCDF_Get_Int_Attribute(&dataFile, fName, "reduced_order");      int reduced_order           = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"reduced_order");
89      int numNodes            = NetCDF_Get_Int_Attribute(&dataFile, fName, "numNodes");      int numNodes            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"numNodes");
90      int num_Elements            = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Elements");      int num_Elements            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Elements");
91      int num_FaceElements        = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_FaceElements");      int num_FaceElements        = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_FaceElements");
92      int num_ContactElements     = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_ContactElements");      int num_ContactElements     = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_ContactElements");
93      int num_Points          = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Points");      int num_Points          = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Points");
94      int num_Elements_numNodes       = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Elements_numNodes");      int num_Elements_numNodes       = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Elements_numNodes");
95      int Elements_TypeId         = NetCDF_Get_Int_Attribute(&dataFile, fName, "Elements_TypeId");      int Elements_TypeId         = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"Elements_TypeId");
96      int num_FaceElements_numNodes   = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_FaceElements_numNodes");      int num_FaceElements_numNodes   = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_FaceElements_numNodes");
97      int FaceElements_TypeId     = NetCDF_Get_Int_Attribute(&dataFile, fName, "FaceElements_TypeId");      int FaceElements_TypeId     = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"FaceElements_TypeId");
98      int num_ContactElements_numNodes    = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_ContactElements_numNodes");      int num_ContactElements_numNodes    = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_ContactElements_numNodes");
99      int ContactElements_TypeId      = NetCDF_Get_Int_Attribute(&dataFile, fName, "ContactElements_TypeId");      int ContactElements_TypeId      = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"ContactElements_TypeId");
100      int Points_TypeId           = NetCDF_Get_Int_Attribute(&dataFile, fName, "Points_TypeId");      int Points_TypeId           = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"Points_TypeId");
101      int num_Tags            = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Tags");      int num_Tags            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Tags");
102    
103      // Verify size and rank      // Verify size and rank
104      if (mpi_info->size != mpi_size) {      if (mpi_info->size != mpi_size) {
# Line 124  namespace finley { Line 128  namespace finley {
128          if (! ( nc_var_temp = dataFile.get_var("Nodes_Id")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_Id")) )
129            throw DataException("Error - loadMesh:: unable to read Nodes_Id from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_Id from netCDF file: " + *fName);
130          if (! nc_var_temp->get(&mesh_p->Nodes->Id[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->Id[0], numNodes) ) {
131            free(&mesh_p->Nodes->Id);            TMPMEMFREE(mesh_p->Nodes->Id);
132            throw DataException("Error - loadMesh:: unable to recover Nodes_Id from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_Id from NetCDF file: " + *fName);
133          }          }
134      // Nodes_Tag      // Nodes_Tag
135          if (! ( nc_var_temp = dataFile.get_var("Nodes_Tag")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_Tag")) )
136            throw DataException("Error - loadMesh:: unable to read Nodes_Tag from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_Tag from netCDF file: " + *fName);
137          if (! nc_var_temp->get(&mesh_p->Nodes->Tag[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->Tag[0], numNodes) ) {
138            free(&mesh_p->Nodes->Tag);            TMPMEMFREE(mesh_p->Nodes->Tag);
139            throw DataException("Error - loadMesh:: unable to recover Nodes_Tag from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_Tag from NetCDF file: " + *fName);
140          }          }
141      // Nodes_gDOF      // Nodes_gDOF
142          if (! ( nc_var_temp = dataFile.get_var("Nodes_gDOF")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_gDOF")) )
143            throw DataException("Error - loadMesh:: unable to read Nodes_gDOF from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_gDOF from netCDF file: " + *fName);
144          if (! nc_var_temp->get(&mesh_p->Nodes->globalDegreesOfFreedom[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalDegreesOfFreedom[0], numNodes) ) {
145            free(&mesh_p->Nodes->globalDegreesOfFreedom);            TMPMEMFREE(mesh_p->Nodes->globalDegreesOfFreedom);
146            throw DataException("Error - loadMesh:: unable to recover Nodes_gDOF from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_gDOF from NetCDF file: " + *fName);
147          }          }
148      // Nodes_gNI      // Nodes_gNI
149          if (! ( nc_var_temp = dataFile.get_var("Nodes_gNI")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_gNI")) )
150            throw DataException("Error - loadMesh:: unable to read Nodes_gNI from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_gNI from netCDF file: " + *fName);
151          if (! nc_var_temp->get(&mesh_p->Nodes->globalNodesIndex[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalNodesIndex[0], numNodes) ) {
152            free(&mesh_p->Nodes->globalNodesIndex);            TMPMEMFREE(mesh_p->Nodes->globalNodesIndex);
153            throw DataException("Error - loadMesh:: unable to recover Nodes_gNI from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_gNI from NetCDF file: " + *fName);
154          }          }
155      // Nodes_grDfI      // Nodes_grDfI
156          if (! ( nc_var_temp = dataFile.get_var("Nodes_grDfI")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_grDfI")) )
157            throw DataException("Error - loadMesh:: unable to read Nodes_grDfI from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_grDfI from netCDF file: " + *fName);
158          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedDOFIndex[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedDOFIndex[0], numNodes) ) {
159            free(&mesh_p->Nodes->globalReducedDOFIndex);            TMPMEMFREE(mesh_p->Nodes->globalReducedDOFIndex);
160            throw DataException("Error - loadMesh:: unable to recover Nodes_grDfI from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_grDfI from NetCDF file: " + *fName);
161          }          }
162      // Nodes_grNI      // Nodes_grNI
163          if (! ( nc_var_temp = dataFile.get_var("Nodes_grNI")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_grNI")) )
164            throw DataException("Error - loadMesh:: unable to read Nodes_grNI from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_grNI from netCDF file: " + *fName);
165          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedNodesIndex[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedNodesIndex[0], numNodes) ) {
166            free(&mesh_p->Nodes->globalReducedNodesIndex);            TMPMEMFREE(mesh_p->Nodes->globalReducedNodesIndex);
167            throw DataException("Error - loadMesh:: unable to recover Nodes_grNI from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_grNI from NetCDF file: " + *fName);
168          }          }
169      // Nodes_Coordinates      // Nodes_Coordinates
170          if (!(nc_var_temp = dataFile.get_var("Nodes_Coordinates"))) {          if (!(nc_var_temp = dataFile.get_var("Nodes_Coordinates"))) {
171            free(&mesh_p->Nodes->Coordinates);            TMPMEMFREE(mesh_p->Nodes->Coordinates);
172            throw DataException("Error - loadMesh:: unable to read Nodes_Coordinates from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_Coordinates from netCDF file: " + *fName);
173          }          }
174          if (! nc_var_temp->get(&(mesh_p->Nodes->Coordinates[0]), numNodes, numDim) ) {          if (! nc_var_temp->get(&(mesh_p->Nodes->Coordinates[0]), numNodes, numDim) ) {
175            free(&mesh_p->Nodes->Coordinates);            TMPMEMFREE(mesh_p->Nodes->Coordinates);
176            throw DataException("Error - load:: unable to recover Nodes_Coordinates from netCDF file: " + *fName);            throw DataException("Error - load:: unable to recover Nodes_Coordinates from netCDF file: " + *fName);
177          }          }
178      // Nodes_DofDistribution      // Nodes_DofDistribution
179      int *first_component = TMPMEMALLOC(mpi_size+1,index_t);      first_DofComponent = TMPMEMALLOC(mpi_size+1,index_t);
180          if (! ( nc_var_temp = dataFile.get_var("Nodes_DofDistribution")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_DofDistribution")) )
181            throw DataException("Error - loadMesh:: unable to read Nodes_DofDistribution from netCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to read Nodes_DofDistribution from netCDF file: " + *fName);
182          if (! nc_var_temp->get(&first_component[0], mpi_size+1) ) {          if (! nc_var_temp->get(&first_DofComponent[0], mpi_size+1) ) {
           free(&first_component);  
183            throw DataException("Error - loadMesh:: unable to recover Nodes_DofDistribution from NetCDF file: " + *fName);            throw DataException("Error - loadMesh:: unable to recover Nodes_DofDistribution from NetCDF file: " + *fName);
184          }          }
185      mesh_p->Nodes->degreesOfFreedomDistribution=Paso_Distribution_alloc(mesh_p->Nodes->MPIInfo,first_component,1,0);  
186      TMPMEMFREE(first_component);      // Nodes_NodeDistribution
187        first_NodeComponent = TMPMEMALLOC(mpi_size+1,index_t);
188            if (! ( nc_var_temp = dataFile.get_var("Nodes_NodeDistribution")) )
189              throw DataException("Error - loadMesh:: unable to read Nodes_NodeDistribution from netCDF file: " + *fName);
190            if (! nc_var_temp->get(&first_NodeComponent[0], mpi_size+1) ) {
191              throw DataException("Error - loadMesh:: unable to recover Nodes_NodeDistribution from NetCDF file: " + *fName);
192            }
193    
194          /* read elements */          /* read elements */
195          if (Finley_noError()) {          if (Finley_noError()) {
# Line 194  namespace finley { Line 203  namespace finley {
203                     if (! ( nc_var_temp = dataFile.get_var("Elements_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Id")) )
204                       throw DataException("Error - loadMesh:: unable to read Elements_Id from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Elements_Id from netCDF file: " + *fName);
205                     if (! nc_var_temp->get(&mesh_p->Elements->Id[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Id[0], num_Elements) ) {
206                       free(&mesh_p->Elements->Id);                       TMPMEMFREE(mesh_p->Elements->Id);
207                       throw DataException("Error - loadMesh:: unable to recover Elements_Id from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Elements_Id from NetCDF file: " + *fName);
208                     }                     }
209                 // Elements_Tag                 // Elements_Tag
210                     if (! ( nc_var_temp = dataFile.get_var("Elements_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Tag")) )
211                       throw DataException("Error - loadMesh:: unable to read Elements_Tag from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Elements_Tag from netCDF file: " + *fName);
212                     if (! nc_var_temp->get(&mesh_p->Elements->Tag[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Tag[0], num_Elements) ) {
213                       free(&mesh_p->Elements->Tag);                       TMPMEMFREE(mesh_p->Elements->Tag);
214                       throw DataException("Error - loadMesh:: unable to recover Elements_Tag from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Elements_Tag from NetCDF file: " + *fName);
215                     }                     }
216                 // Elements_Owner                 // Elements_Owner
217                     if (! ( nc_var_temp = dataFile.get_var("Elements_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Owner")) )
218                       throw DataException("Error - loadMesh:: unable to read Elements_Owner from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Elements_Owner from netCDF file: " + *fName);
219                     if (! nc_var_temp->get(&mesh_p->Elements->Owner[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Owner[0], num_Elements) ) {
220                       free(&mesh_p->Elements->Owner);                       TMPMEMFREE(mesh_p->Elements->Owner);
221                       throw DataException("Error - loadMesh:: unable to recover Elements_Owner from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Elements_Owner from NetCDF file: " + *fName);
222                     }                     }
223                 // Elements_Color                 // Elements_Color
224                     if (! ( nc_var_temp = dataFile.get_var("Elements_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Color")) )
225                       throw DataException("Error - loadMesh:: unable to read Elements_Color from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Elements_Color from netCDF file: " + *fName);
226                     if (! nc_var_temp->get(&mesh_p->Elements->Color[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Color[0], num_Elements) ) {
227                       free(&mesh_p->Elements->Color);                       TMPMEMFREE(mesh_p->Elements->Color);
228                       throw DataException("Error - loadMesh:: unable to recover Elements_Color from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Elements_Color from NetCDF file: " + *fName);
229                     }                     }
230                 // Elements_Nodes                 // Elements_Nodes
231             int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);             int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
232                     if (!(nc_var_temp = dataFile.get_var("Elements_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("Elements_Nodes"))) {
233                       free(&mesh_p->Elements->Nodes);                       TMPMEMFREE(mesh_p->Elements->Nodes);
234                       throw DataException("Error - loadMesh:: unable to read Elements_Nodes from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Elements_Nodes from netCDF file: " + *fName);
235                     }                     }
236                     if (! nc_var_temp->get(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes) ) {                     if (! nc_var_temp->get(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes) ) {
237                       free(&Elements_Nodes);                       TMPMEMFREE(Elements_Nodes);
238                       throw DataException("Error - load:: unable to recover Elements_Nodes from netCDF file: " + *fName);                       throw DataException("Error - load:: unable to recover Elements_Nodes from netCDF file: " + *fName);
239                     }                     }
240             // Copy temp array into mesh_p->Elements->Nodes             // Copy temp array into mesh_p->Elements->Nodes
# Line 252  namespace finley { Line 261  namespace finley {
261                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Id")) )
262                       throw DataException("Error - loadMesh:: unable to read FaceElements_Id from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read FaceElements_Id from netCDF file: " + *fName);
263                     if (! nc_var_temp->get(&mesh_p->FaceElements->Id[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Id[0], num_FaceElements) ) {
264                       free(&mesh_p->FaceElements->Id);                       TMPMEMFREE(mesh_p->FaceElements->Id);
265                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Id from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Id from NetCDF file: " + *fName);
266                     }                     }
267                 // FaceElements_Tag                 // FaceElements_Tag
268                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Tag")) )
269                       throw DataException("Error - loadMesh:: unable to read FaceElements_Tag from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read FaceElements_Tag from netCDF file: " + *fName);
270                     if (! nc_var_temp->get(&mesh_p->FaceElements->Tag[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Tag[0], num_FaceElements) ) {
271                       free(&mesh_p->FaceElements->Tag);                       TMPMEMFREE(mesh_p->FaceElements->Tag);
272                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Tag from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Tag from NetCDF file: " + *fName);
273                     }                     }
274                 // FaceElements_Owner                 // FaceElements_Owner
275                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Owner")) )
276                       throw DataException("Error - loadMesh:: unable to read FaceElements_Owner from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read FaceElements_Owner from netCDF file: " + *fName);
277                     if (! nc_var_temp->get(&mesh_p->FaceElements->Owner[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Owner[0], num_FaceElements) ) {
278                       free(&mesh_p->FaceElements->Owner);                       TMPMEMFREE(mesh_p->FaceElements->Owner);
279                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Owner from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Owner from NetCDF file: " + *fName);
280                     }                     }
281                 // FaceElements_Color                 // FaceElements_Color
282                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Color")) )
283                       throw DataException("Error - loadMesh:: unable to read FaceElements_Color from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read FaceElements_Color from netCDF file: " + *fName);
284                     if (! nc_var_temp->get(&mesh_p->FaceElements->Color[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Color[0], num_FaceElements) ) {
285                       free(&mesh_p->FaceElements->Color);                       TMPMEMFREE(mesh_p->FaceElements->Color);
286                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Color from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover FaceElements_Color from NetCDF file: " + *fName);
287                     }                     }
288                 // FaceElements_Nodes                 // FaceElements_Nodes
289             int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);             int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
290                     if (!(nc_var_temp = dataFile.get_var("FaceElements_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("FaceElements_Nodes"))) {
291                       free(&mesh_p->FaceElements->Nodes);                       TMPMEMFREE(mesh_p->FaceElements->Nodes);
292                       throw DataException("Error - loadMesh:: unable to read FaceElements_Nodes from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read FaceElements_Nodes from netCDF file: " + *fName);
293                     }                     }
294                     if (! nc_var_temp->get(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes) ) {                     if (! nc_var_temp->get(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes) ) {
295                       free(&FaceElements_Nodes);                       TMPMEMFREE(FaceElements_Nodes);
296                       throw DataException("Error - load:: unable to recover FaceElements_Nodes from netCDF file: " + *fName);                       throw DataException("Error - load:: unable to recover FaceElements_Nodes from netCDF file: " + *fName);
297                     }                     }
298             // Copy temp array into mesh_p->FaceElements->Nodes             // Copy temp array into mesh_p->FaceElements->Nodes
# Line 310  namespace finley { Line 319  namespace finley {
319                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Id")) )
320                       throw DataException("Error - loadMesh:: unable to read ContactElements_Id from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read ContactElements_Id from netCDF file: " + *fName);
321                     if (! nc_var_temp->get(&mesh_p->ContactElements->Id[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Id[0], num_ContactElements) ) {
322                       free(&mesh_p->ContactElements->Id);                       TMPMEMFREE(mesh_p->ContactElements->Id);
323                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Id from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Id from NetCDF file: " + *fName);
324                     }                     }
325                 // ContactElements_Tag                 // ContactElements_Tag
326                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Tag")) )
327                       throw DataException("Error - loadMesh:: unable to read ContactElements_Tag from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read ContactElements_Tag from netCDF file: " + *fName);
328                     if (! nc_var_temp->get(&mesh_p->ContactElements->Tag[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Tag[0], num_ContactElements) ) {
329                       free(&mesh_p->ContactElements->Tag);                       TMPMEMFREE(mesh_p->ContactElements->Tag);
330                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Tag from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Tag from NetCDF file: " + *fName);
331                     }                     }
332                 // ContactElements_Owner                 // ContactElements_Owner
333                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Owner")) )
334                       throw DataException("Error - loadMesh:: unable to read ContactElements_Owner from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read ContactElements_Owner from netCDF file: " + *fName);
335                     if (! nc_var_temp->get(&mesh_p->ContactElements->Owner[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Owner[0], num_ContactElements) ) {
336                       free(&mesh_p->ContactElements->Owner);                       TMPMEMFREE(mesh_p->ContactElements->Owner);
337                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Owner from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Owner from NetCDF file: " + *fName);
338                     }                     }
339                 // ContactElements_Color                 // ContactElements_Color
340                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Color")) )
341                       throw DataException("Error - loadMesh:: unable to read ContactElements_Color from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read ContactElements_Color from netCDF file: " + *fName);
342                     if (! nc_var_temp->get(&mesh_p->ContactElements->Color[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Color[0], num_ContactElements) ) {
343                       free(&mesh_p->ContactElements->Color);                       TMPMEMFREE(mesh_p->ContactElements->Color);
344                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Color from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover ContactElements_Color from NetCDF file: " + *fName);
345                     }                     }
346                 // ContactElements_Nodes                 // ContactElements_Nodes
347             int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);             int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
348                     if (!(nc_var_temp = dataFile.get_var("ContactElements_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("ContactElements_Nodes"))) {
349                       free(&mesh_p->ContactElements->Nodes);                       TMPMEMFREE(mesh_p->ContactElements->Nodes);
350                       throw DataException("Error - loadMesh:: unable to read ContactElements_Nodes from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read ContactElements_Nodes from netCDF file: " + *fName);
351                     }                     }
352                     if (! nc_var_temp->get(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes) ) {                     if (! nc_var_temp->get(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes) ) {
353                       free(&ContactElements_Nodes);                       TMPMEMFREE(ContactElements_Nodes);
354                       throw DataException("Error - load:: unable to recover ContactElements_Nodes from netCDF file: " + *fName);                       throw DataException("Error - load:: unable to recover ContactElements_Nodes from netCDF file: " + *fName);
355                     }                     }
356             // Copy temp array into mesh_p->ContactElements->Nodes             // Copy temp array into mesh_p->ContactElements->Nodes
# Line 368  namespace finley { Line 377  namespace finley {
377                     if (! ( nc_var_temp = dataFile.get_var("Points_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Id")) )
378                       throw DataException("Error - loadMesh:: unable to read Points_Id from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Points_Id from netCDF file: " + *fName);
379                     if (! nc_var_temp->get(&mesh_p->Points->Id[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Id[0], num_Points) ) {
380                       free(&mesh_p->Points->Id);                       TMPMEMFREE(mesh_p->Points->Id);
381                       throw DataException("Error - loadMesh:: unable to recover Points_Id from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Points_Id from NetCDF file: " + *fName);
382                     }                     }
383                 // Points_Tag                 // Points_Tag
384                     if (! ( nc_var_temp = dataFile.get_var("Points_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Tag")) )
385                       throw DataException("Error - loadMesh:: unable to read Points_Tag from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Points_Tag from netCDF file: " + *fName);
386                     if (! nc_var_temp->get(&mesh_p->Points->Tag[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Tag[0], num_Points) ) {
387                       free(&mesh_p->Points->Tag);                       TMPMEMFREE(mesh_p->Points->Tag);
388                       throw DataException("Error - loadMesh:: unable to recover Points_Tag from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Points_Tag from NetCDF file: " + *fName);
389                     }                     }
390                 // Points_Owner                 // Points_Owner
391                     if (! ( nc_var_temp = dataFile.get_var("Points_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Owner")) )
392                       throw DataException("Error - loadMesh:: unable to read Points_Owner from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Points_Owner from netCDF file: " + *fName);
393                     if (! nc_var_temp->get(&mesh_p->Points->Owner[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Owner[0], num_Points) ) {
394                       free(&mesh_p->Points->Owner);                       TMPMEMFREE(mesh_p->Points->Owner);
395                       throw DataException("Error - loadMesh:: unable to recover Points_Owner from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Points_Owner from NetCDF file: " + *fName);
396                     }                     }
397                 // Points_Color                 // Points_Color
398                     if (! ( nc_var_temp = dataFile.get_var("Points_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Color")) )
399                       throw DataException("Error - loadMesh:: unable to read Points_Color from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Points_Color from netCDF file: " + *fName);
400                     if (! nc_var_temp->get(&mesh_p->Points->Color[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Color[0], num_Points) ) {
401                       free(&mesh_p->Points->Color);                       TMPMEMFREE(mesh_p->Points->Color);
402                       throw DataException("Error - loadMesh:: unable to recover Points_Color from NetCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to recover Points_Color from NetCDF file: " + *fName);
403                     }                     }
404                 // Points_Nodes                 // Points_Nodes
405             int *Points_Nodes = TMPMEMALLOC(num_Points,int);             int *Points_Nodes = TMPMEMALLOC(num_Points,int);
406                     if (!(nc_var_temp = dataFile.get_var("Points_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("Points_Nodes"))) {
407                       free(&mesh_p->Points->Nodes);                       TMPMEMFREE(mesh_p->Points->Nodes);
408                       throw DataException("Error - loadMesh:: unable to read Points_Nodes from netCDF file: " + *fName);                       throw DataException("Error - loadMesh:: unable to read Points_Nodes from netCDF file: " + *fName);
409                     }                     }
410                     if (! nc_var_temp->get(&(Points_Nodes[0]), num_Points) ) {                     if (! nc_var_temp->get(&(Points_Nodes[0]), num_Points) ) {
411                       free(&Points_Nodes);                       TMPMEMFREE(Points_Nodes);
412                       throw DataException("Error - load:: unable to recover Points_Nodes from netCDF file: " + *fName);                       throw DataException("Error - load:: unable to recover Points_Nodes from netCDF file: " + *fName);
413                     }                     }
414             // Copy temp array into mesh_p->Points->Nodes             // Copy temp array into mesh_p->Points->Nodes
# Line 423  namespace finley { Line 432  namespace finley {
432              if (! ( nc_var_temp = dataFile.get_var("Tags_keys")) )              if (! ( nc_var_temp = dataFile.get_var("Tags_keys")) )
433                throw DataException("Error - loadMesh:: unable to read Tags_keys from netCDF file: " + *fName);                throw DataException("Error - loadMesh:: unable to read Tags_keys from netCDF file: " + *fName);
434              if (! nc_var_temp->get(&Tags_keys[0], num_Tags) ) {              if (! nc_var_temp->get(&Tags_keys[0], num_Tags) ) {
435                free(&Tags_keys);                TMPMEMFREE(Tags_keys);
436                throw DataException("Error - loadMesh:: unable to recover Tags_keys from NetCDF file: " + *fName);                throw DataException("Error - loadMesh:: unable to recover Tags_keys from NetCDF file: " + *fName);
437              }              }
438          for (i=0; i<num_Tags; i++) {          for (i=0; i<num_Tags; i++) {
# Line 442  namespace finley { Line 451  namespace finley {
451    
452      } /* Finley_noError() after Finley_Mesh_alloc() */      } /* Finley_noError() after Finley_Mesh_alloc() */
453        
454      if (Finley_noError()) Finley_Mesh_createMappings(mesh_p, mesh_p->Nodes->degreesOfFreedomDistribution->first_component);      if (Finley_noError()) Finley_Mesh_createMappings(mesh_p, first_DofComponent, first_NodeComponent);
455        TMPMEMFREE(first_DofComponent);
456        TMPMEMFREE(first_NodeComponent);
457    
458      checkFinleyError();      checkFinleyError();
459      temp=new MeshAdapter(mesh_p);      temp=new MeshAdapter(mesh_p);
# Line 471  namespace finley { Line 482  namespace finley {
482      // to Finley_Mesh_read      // to Finley_Mesh_read
483      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
484      // Win32 refactor      // Win32 refactor
485      char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;      if( fileName.size() == 0 )
486        {
487           throw DataException("Null file name!");
488        }
489    
490        char *fName = TMPMEMALLOC(fileName.size()+1,char);
491        
492      strcpy(fName,fileName.c_str());      strcpy(fName,fileName.c_str());
493      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
494    
# Line 496  namespace finley { Line 513  namespace finley {
513      // to Finley_Mesh_read      // to Finley_Mesh_read
514      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
515      // Win32 refactor      // Win32 refactor
516      char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;      if( fileName.size() == 0 )
517        {
518           throw DataException("Null file name!");
519        }
520    
521        char *fName = TMPMEMALLOC(fileName.size()+1,char);
522        
523      strcpy(fName,fileName.c_str());      strcpy(fName,fileName.c_str());
524      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
525    
# Line 522  namespace finley { Line 545  namespace finley {
545      // to Finley_Mesh_read      // to Finley_Mesh_read
546      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
547      // Win32 refactor      // Win32 refactor
548      char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;      if( fileName.size() == 0 )
549        {
550           throw DataException("Null file name!");
551        }
552    
553        char *fName = TMPMEMALLOC(fileName.size()+1,char);
554        
555      strcpy(fName,fileName.c_str());      strcpy(fName,fileName.c_str());
556      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
557    

Legend:
Removed from v.1360  
changed lines
  Added in v.1776

  ViewVC Help
Powered by ViewVC 1.1.26