/[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 1347 by ksteube, Fri Nov 16 05:37:07 2007 UTC revision 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #ifdef PASO_MPI  #ifdef PASO_MPI
16  #include <mpi.h>  #include <mpi.h>
# Line 57  namespace finley { Line 56  namespace finley {
56      AbstractContinuousDomain* temp;      AbstractContinuousDomain* temp;
57      Finley_Mesh *mesh_p=NULL;      Finley_Mesh *mesh_p=NULL;
58      char error_msg[LenErrorMsg_MAX];      char error_msg[LenErrorMsg_MAX];
59      char *fName = Paso_MPI_appendRankToFileName(strdup(fileName.c_str()), mpi_info->size, mpi_info->rank);  
60        char *fName = Paso_MPI_appendRankToFileName(fileName.c_str(),
61                                                    mpi_info->size,
62                                                    mpi_info->rank);
63    
64      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
65      Finley_resetError();      Finley_resetError();
66        int *first_DofComponent, *first_NodeComponent;
67    
68      // Open NetCDF file for reading      // Open NetCDF file for reading
69      NcAtt *attr;      NcAtt *attr;
# Line 77  namespace finley { Line 80  namespace finley {
80      }      }
81    
82      // Read NetCDF integer attributes      // Read NetCDF integer attributes
83      int mpi_size            = NetCDF_Get_Int_Attribute(&dataFile, fName, "mpi_size");      int mpi_size            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"mpi_size");
84      int mpi_rank            = NetCDF_Get_Int_Attribute(&dataFile, fName, "mpi_rank");      int mpi_rank            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"mpi_rank");
85      int numDim              = NetCDF_Get_Int_Attribute(&dataFile, fName, "numDim");      int numDim              = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"numDim");
86      int order               = NetCDF_Get_Int_Attribute(&dataFile, fName, "order");      int order               = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"order");
87      int reduced_order           = NetCDF_Get_Int_Attribute(&dataFile, fName, "reduced_order");      int reduced_order           = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"reduced_order");
88      int numNodes            = NetCDF_Get_Int_Attribute(&dataFile, fName, "numNodes");      int numNodes            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"numNodes");
89      int num_Elements            = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Elements");      int num_Elements            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Elements");
90      int num_FaceElements        = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_FaceElements");      int num_FaceElements        = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_FaceElements");
91      int num_ContactElements     = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_ContactElements");      int num_ContactElements     = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_ContactElements");
92      int num_Points          = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Points");      int num_Points          = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Points");
93      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");
94      int Elements_TypeId         = NetCDF_Get_Int_Attribute(&dataFile, fName, "Elements_TypeId");      int Elements_TypeId         = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"Elements_TypeId");
95      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");
96      int FaceElements_TypeId     = NetCDF_Get_Int_Attribute(&dataFile, fName, "FaceElements_TypeId");      int FaceElements_TypeId     = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"FaceElements_TypeId");
97      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");
98      int ContactElements_TypeId      = NetCDF_Get_Int_Attribute(&dataFile, fName, "ContactElements_TypeId");      int ContactElements_TypeId      = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"ContactElements_TypeId");
99      int Points_TypeId           = NetCDF_Get_Int_Attribute(&dataFile, fName, "Points_TypeId");      int Points_TypeId           = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"Points_TypeId");
100      int num_Tags            = NetCDF_Get_Int_Attribute(&dataFile, fName, "num_Tags");      int num_Tags            = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Tags");
101    
102      // Verify size and rank      // Verify size and rank
103      if (mpi_info->size != mpi_size) {      if (mpi_info->size != mpi_size) {
# Line 124  namespace finley { Line 127  namespace finley {
127          if (! ( nc_var_temp = dataFile.get_var("Nodes_Id")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_Id")) )
128            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);
129          if (! nc_var_temp->get(&mesh_p->Nodes->Id[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->Id[0], numNodes) ) {
130            free(&mesh_p->Nodes->Id);            TMPMEMFREE(mesh_p->Nodes->Id);
131            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);
132          }          }
133      // Nodes_Tag      // Nodes_Tag
134          if (! ( nc_var_temp = dataFile.get_var("Nodes_Tag")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_Tag")) )
135            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);
136          if (! nc_var_temp->get(&mesh_p->Nodes->Tag[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->Tag[0], numNodes) ) {
137            free(&mesh_p->Nodes->Tag);            TMPMEMFREE(mesh_p->Nodes->Tag);
138            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);
139          }          }
140      // Nodes_gDOF      // Nodes_gDOF
141          if (! ( nc_var_temp = dataFile.get_var("Nodes_gDOF")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_gDOF")) )
142            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);
143          if (! nc_var_temp->get(&mesh_p->Nodes->globalDegreesOfFreedom[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalDegreesOfFreedom[0], numNodes) ) {
144            free(&mesh_p->Nodes->globalDegreesOfFreedom);            TMPMEMFREE(mesh_p->Nodes->globalDegreesOfFreedom);
145            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);
146          }          }
147      // Nodes_gNI      // Nodes_gNI
148          if (! ( nc_var_temp = dataFile.get_var("Nodes_gNI")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_gNI")) )
149            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);
150          if (! nc_var_temp->get(&mesh_p->Nodes->globalNodesIndex[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalNodesIndex[0], numNodes) ) {
151            free(&mesh_p->Nodes->globalNodesIndex);            TMPMEMFREE(mesh_p->Nodes->globalNodesIndex);
152            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);
153          }          }
154      // Nodes_grDfI      // Nodes_grDfI
155          if (! ( nc_var_temp = dataFile.get_var("Nodes_grDfI")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_grDfI")) )
156            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);
157          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedDOFIndex[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedDOFIndex[0], numNodes) ) {
158            free(&mesh_p->Nodes->globalReducedDOFIndex);            TMPMEMFREE(mesh_p->Nodes->globalReducedDOFIndex);
159            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);
160          }          }
161      // Nodes_grNI      // Nodes_grNI
162          if (! ( nc_var_temp = dataFile.get_var("Nodes_grNI")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_grNI")) )
163            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);
164          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedNodesIndex[0], numNodes) ) {          if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedNodesIndex[0], numNodes) ) {
165            free(&mesh_p->Nodes->globalReducedNodesIndex);            TMPMEMFREE(mesh_p->Nodes->globalReducedNodesIndex);
166            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);
167          }          }
168      // Nodes_Coordinates      // Nodes_Coordinates
169          if (!(nc_var_temp = dataFile.get_var("Nodes_Coordinates"))) {          if (!(nc_var_temp = dataFile.get_var("Nodes_Coordinates"))) {
170            free(&mesh_p->Nodes->Coordinates);            TMPMEMFREE(mesh_p->Nodes->Coordinates);
171            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);
172          }          }
173          if (! nc_var_temp->get(&(mesh_p->Nodes->Coordinates[0]), numNodes, numDim) ) {          if (! nc_var_temp->get(&(mesh_p->Nodes->Coordinates[0]), numNodes, numDim) ) {
174            free(&mesh_p->Nodes->Coordinates);            TMPMEMFREE(mesh_p->Nodes->Coordinates);
175            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);
176          }          }
177      // Nodes_DofDistribution      // Nodes_DofDistribution
178      int *first_component = TMPMEMALLOC(mpi_size+1,index_t);      first_DofComponent = TMPMEMALLOC(mpi_size+1,index_t);
179          if (! ( nc_var_temp = dataFile.get_var("Nodes_DofDistribution")) )          if (! ( nc_var_temp = dataFile.get_var("Nodes_DofDistribution")) )
180            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);
181          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);  
182            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);
183          }          }
184      mesh_p->Nodes->degreesOfFreedomDistribution=Paso_Distribution_alloc(mesh_p->Nodes->MPIInfo,first_component,1,0);  
185      TMPMEMFREE(first_component);      // Nodes_NodeDistribution
186        first_NodeComponent = TMPMEMALLOC(mpi_size+1,index_t);
187            if (! ( nc_var_temp = dataFile.get_var("Nodes_NodeDistribution")) )
188              throw DataException("Error - loadMesh:: unable to read Nodes_NodeDistribution from netCDF file: " + *fName);
189            if (! nc_var_temp->get(&first_NodeComponent[0], mpi_size+1) ) {
190              throw DataException("Error - loadMesh:: unable to recover Nodes_NodeDistribution from NetCDF file: " + *fName);
191            }
192    
193          /* read elements */          /* read elements */
194          if (Finley_noError()) {          if (Finley_noError()) {
# Line 194  namespace finley { Line 202  namespace finley {
202                     if (! ( nc_var_temp = dataFile.get_var("Elements_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Id")) )
203                       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);
204                     if (! nc_var_temp->get(&mesh_p->Elements->Id[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Id[0], num_Elements) ) {
205                       free(&mesh_p->Elements->Id);                       TMPMEMFREE(mesh_p->Elements->Id);
206                       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);
207                     }                     }
208                 // Elements_Tag                 // Elements_Tag
209                     if (! ( nc_var_temp = dataFile.get_var("Elements_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Tag")) )
210                       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);
211                     if (! nc_var_temp->get(&mesh_p->Elements->Tag[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Tag[0], num_Elements) ) {
212                       free(&mesh_p->Elements->Tag);                       TMPMEMFREE(mesh_p->Elements->Tag);
213                       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);
214                     }                     }
215                 // Elements_Owner                 // Elements_Owner
216                     if (! ( nc_var_temp = dataFile.get_var("Elements_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Owner")) )
217                       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);
218                     if (! nc_var_temp->get(&mesh_p->Elements->Owner[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Owner[0], num_Elements) ) {
219                       free(&mesh_p->Elements->Owner);                       TMPMEMFREE(mesh_p->Elements->Owner);
220                       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);
221                     }                     }
222                 // Elements_Color                 // Elements_Color
223                     if (! ( nc_var_temp = dataFile.get_var("Elements_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("Elements_Color")) )
224                       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);
225                     if (! nc_var_temp->get(&mesh_p->Elements->Color[0], num_Elements) ) {                     if (! nc_var_temp->get(&mesh_p->Elements->Color[0], num_Elements) ) {
226                       free(&mesh_p->Elements->Color);                       TMPMEMFREE(mesh_p->Elements->Color);
227                       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);
228                     }                     }
229                 // Elements_Nodes                 // Elements_Nodes
230             int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);             int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
231                     if (!(nc_var_temp = dataFile.get_var("Elements_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("Elements_Nodes"))) {
232                       free(&mesh_p->Elements->Nodes);                       TMPMEMFREE(mesh_p->Elements->Nodes);
233                       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);
234                     }                     }
235                     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) ) {
236                       free(&Elements_Nodes);                       TMPMEMFREE(Elements_Nodes);
237                       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);
238                     }                     }
239             // Copy temp array into mesh_p->Elements->Nodes             // Copy temp array into mesh_p->Elements->Nodes
# Line 252  namespace finley { Line 260  namespace finley {
260                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Id")) )
261                       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);
262                     if (! nc_var_temp->get(&mesh_p->FaceElements->Id[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Id[0], num_FaceElements) ) {
263                       free(&mesh_p->FaceElements->Id);                       TMPMEMFREE(mesh_p->FaceElements->Id);
264                       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);
265                     }                     }
266                 // FaceElements_Tag                 // FaceElements_Tag
267                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Tag")) )
268                       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);
269                     if (! nc_var_temp->get(&mesh_p->FaceElements->Tag[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Tag[0], num_FaceElements) ) {
270                       free(&mesh_p->FaceElements->Tag);                       TMPMEMFREE(mesh_p->FaceElements->Tag);
271                       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);
272                     }                     }
273                 // FaceElements_Owner                 // FaceElements_Owner
274                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Owner")) )
275                       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);
276                     if (! nc_var_temp->get(&mesh_p->FaceElements->Owner[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Owner[0], num_FaceElements) ) {
277                       free(&mesh_p->FaceElements->Owner);                       TMPMEMFREE(mesh_p->FaceElements->Owner);
278                       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);
279                     }                     }
280                 // FaceElements_Color                 // FaceElements_Color
281                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("FaceElements_Color")) )
282                       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);
283                     if (! nc_var_temp->get(&mesh_p->FaceElements->Color[0], num_FaceElements) ) {                     if (! nc_var_temp->get(&mesh_p->FaceElements->Color[0], num_FaceElements) ) {
284                       free(&mesh_p->FaceElements->Color);                       TMPMEMFREE(mesh_p->FaceElements->Color);
285                       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);
286                     }                     }
287                 // FaceElements_Nodes                 // FaceElements_Nodes
288             int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);             int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
289                     if (!(nc_var_temp = dataFile.get_var("FaceElements_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("FaceElements_Nodes"))) {
290                       free(&mesh_p->FaceElements->Nodes);                       TMPMEMFREE(mesh_p->FaceElements->Nodes);
291                       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);
292                     }                     }
293                     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) ) {
294                       free(&FaceElements_Nodes);                       TMPMEMFREE(FaceElements_Nodes);
295                       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);
296                     }                     }
297             // Copy temp array into mesh_p->FaceElements->Nodes             // Copy temp array into mesh_p->FaceElements->Nodes
# Line 310  namespace finley { Line 318  namespace finley {
318                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Id")) )
319                       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);
320                     if (! nc_var_temp->get(&mesh_p->ContactElements->Id[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Id[0], num_ContactElements) ) {
321                       free(&mesh_p->ContactElements->Id);                       TMPMEMFREE(mesh_p->ContactElements->Id);
322                       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);
323                     }                     }
324                 // ContactElements_Tag                 // ContactElements_Tag
325                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Tag")) )
326                       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);
327                     if (! nc_var_temp->get(&mesh_p->ContactElements->Tag[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Tag[0], num_ContactElements) ) {
328                       free(&mesh_p->ContactElements->Tag);                       TMPMEMFREE(mesh_p->ContactElements->Tag);
329                       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);
330                     }                     }
331                 // ContactElements_Owner                 // ContactElements_Owner
332                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Owner")) )
333                       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);
334                     if (! nc_var_temp->get(&mesh_p->ContactElements->Owner[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Owner[0], num_ContactElements) ) {
335                       free(&mesh_p->ContactElements->Owner);                       TMPMEMFREE(mesh_p->ContactElements->Owner);
336                       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);
337                     }                     }
338                 // ContactElements_Color                 // ContactElements_Color
339                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("ContactElements_Color")) )
340                       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);
341                     if (! nc_var_temp->get(&mesh_p->ContactElements->Color[0], num_ContactElements) ) {                     if (! nc_var_temp->get(&mesh_p->ContactElements->Color[0], num_ContactElements) ) {
342                       free(&mesh_p->ContactElements->Color);                       TMPMEMFREE(mesh_p->ContactElements->Color);
343                       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);
344                     }                     }
345                 // ContactElements_Nodes                 // ContactElements_Nodes
346             int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);             int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
347                     if (!(nc_var_temp = dataFile.get_var("ContactElements_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("ContactElements_Nodes"))) {
348                       free(&mesh_p->ContactElements->Nodes);                       TMPMEMFREE(mesh_p->ContactElements->Nodes);
349                       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);
350                     }                     }
351                     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) ) {
352                       free(&ContactElements_Nodes);                       TMPMEMFREE(ContactElements_Nodes);
353                       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);
354                     }                     }
355             // Copy temp array into mesh_p->ContactElements->Nodes             // Copy temp array into mesh_p->ContactElements->Nodes
# Line 368  namespace finley { Line 376  namespace finley {
376                     if (! ( nc_var_temp = dataFile.get_var("Points_Id")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Id")) )
377                       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);
378                     if (! nc_var_temp->get(&mesh_p->Points->Id[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Id[0], num_Points) ) {
379                       free(&mesh_p->Points->Id);                       TMPMEMFREE(mesh_p->Points->Id);
380                       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);
381                     }                     }
382                 // Points_Tag                 // Points_Tag
383                     if (! ( nc_var_temp = dataFile.get_var("Points_Tag")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Tag")) )
384                       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);
385                     if (! nc_var_temp->get(&mesh_p->Points->Tag[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Tag[0], num_Points) ) {
386                       free(&mesh_p->Points->Tag);                       TMPMEMFREE(mesh_p->Points->Tag);
387                       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);
388                     }                     }
389                 // Points_Owner                 // Points_Owner
390                     if (! ( nc_var_temp = dataFile.get_var("Points_Owner")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Owner")) )
391                       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);
392                     if (! nc_var_temp->get(&mesh_p->Points->Owner[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Owner[0], num_Points) ) {
393                       free(&mesh_p->Points->Owner);                       TMPMEMFREE(mesh_p->Points->Owner);
394                       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);
395                     }                     }
396                 // Points_Color                 // Points_Color
397                     if (! ( nc_var_temp = dataFile.get_var("Points_Color")) )                     if (! ( nc_var_temp = dataFile.get_var("Points_Color")) )
398                       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);
399                     if (! nc_var_temp->get(&mesh_p->Points->Color[0], num_Points) ) {                     if (! nc_var_temp->get(&mesh_p->Points->Color[0], num_Points) ) {
400                       free(&mesh_p->Points->Color);                       TMPMEMFREE(mesh_p->Points->Color);
401                       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);
402                     }                     }
403                 // Points_Nodes                 // Points_Nodes
404             int *Points_Nodes = TMPMEMALLOC(num_Points,int);             int *Points_Nodes = TMPMEMALLOC(num_Points,int);
405                     if (!(nc_var_temp = dataFile.get_var("Points_Nodes"))) {                     if (!(nc_var_temp = dataFile.get_var("Points_Nodes"))) {
406                       free(&mesh_p->Points->Nodes);                       TMPMEMFREE(mesh_p->Points->Nodes);
407                       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);
408                     }                     }
409                     if (! nc_var_temp->get(&(Points_Nodes[0]), num_Points) ) {                     if (! nc_var_temp->get(&(Points_Nodes[0]), num_Points) ) {
410                       free(&Points_Nodes);                       TMPMEMFREE(Points_Nodes);
411                       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);
412                     }                     }
413             // Copy temp array into mesh_p->Points->Nodes             // Copy temp array into mesh_p->Points->Nodes
# Line 423  namespace finley { Line 431  namespace finley {
431              if (! ( nc_var_temp = dataFile.get_var("Tags_keys")) )              if (! ( nc_var_temp = dataFile.get_var("Tags_keys")) )
432                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);
433              if (! nc_var_temp->get(&Tags_keys[0], num_Tags) ) {              if (! nc_var_temp->get(&Tags_keys[0], num_Tags) ) {
434                free(&Tags_keys);                TMPMEMFREE(Tags_keys);
435                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);
436              }              }
437          for (i=0; i<num_Tags; i++) {          for (i=0; i<num_Tags; i++) {
# Line 442  namespace finley { Line 450  namespace finley {
450    
451      } /* Finley_noError() after Finley_Mesh_alloc() */      } /* Finley_noError() after Finley_Mesh_alloc() */
452        
453      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);
454        TMPMEMFREE(first_DofComponent);
455        TMPMEMFREE(first_NodeComponent);
456    
457      checkFinleyError();      checkFinleyError();
458      temp=new MeshAdapter(mesh_p);      temp=new MeshAdapter(mesh_p);
# Line 471  namespace finley { Line 481  namespace finley {
481      // to Finley_Mesh_read      // to Finley_Mesh_read
482      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
483      // Win32 refactor      // Win32 refactor
484      char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;      if( fileName.size() == 0 )
485        {
486           throw DataException("Null file name!");
487        }
488    
489        char *fName = TMPMEMALLOC(fileName.size()+1,char);
490        
491      strcpy(fName,fileName.c_str());      strcpy(fName,fileName.c_str());
492      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
493    
494      fMesh=Finley_Mesh_read(fName,integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));      fMesh=Finley_Mesh_read_MPI(fName,integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
495      checkFinleyError();      checkFinleyError();
496      AbstractContinuousDomain* temp=new MeshAdapter(fMesh);      AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
497            
# Line 497  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    

Legend:
Removed from v.1347  
changed lines
  Added in v.1811

  ViewVC Help
Powered by ViewVC 1.1.26