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

Contents of /branches/doubleplusgood/dudley/src/CPPAdapter/MeshAdapterFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4332 - (show annotations)
Thu Mar 21 04:21:14 2013 UTC (6 years ago) by jfenwick
File size: 24714 byte(s)
like sand though the hourglass
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16 #include "MeshAdapterFactory.h"
17 #include "DudleyError.h"
18 #include "esysUtils/blocktimer.h"
19 #include "dudley/Dudley.h"
20 #include "dudley/Mesh.h"
21 #include "dudley/TriangularMesh.h"
22 #ifdef ESYS_MPI
23 #include "esysUtils/Esys_MPI.h"
24 #endif
25
26 #ifdef USE_NETCDF
27 #include <netcdfcpp.h>
28 #endif
29
30 #include <boost/python/extract.hpp>
31
32 #include <sstream>
33
34 using namespace std;
35 using namespace escript;
36
37 namespace dudley {
38
39 #ifdef USE_NETCDF
40 // A convenience method to retrieve an integer attribute from a NetCDF file
41 int NetCDF_Get_Int_Attribute(NcFile *dataFile, char *fName, char *attr_name) {
42 NcAtt *attr;
43 char error_msg[LenErrorMsg_MAX];
44 if (! (attr=dataFile->get_att(attr_name)) ) {
45 sprintf(error_msg,"loadMesh: Error retrieving integer attribute '%s' from NetCDF file '%s'", attr_name, fName);
46 throw DataException(error_msg);
47 }
48 int temp = attr->as_int(0);
49 delete attr;
50 return(temp);
51 }
52 #endif
53
54 inline void cleanupAndThrow(Dudley_Mesh* mesh, Esys_MPIInfo* info, string msg)
55 {
56 Dudley_Mesh_free(mesh);
57 Esys_MPIInfo_free(info);
58 string msgPrefix("loadMesh: NetCDF operation failed - ");
59 throw DataException(msgPrefix+msg);
60 }
61
62 // AbstractContinuousDomain* loadMesh(const std::string& fileName)
63 Domain_ptr loadMesh(const std::string& fileName)
64 {
65 #ifdef USE_NETCDF
66 Esys_MPIInfo *mpi_info = Esys_MPIInfo_alloc( MPI_COMM_WORLD );
67 Dudley_Mesh *mesh_p=NULL;
68 char error_msg[LenErrorMsg_MAX];
69
70 char *fName = Esys_MPI_appendRankToFileName(fileName.c_str(),
71 mpi_info->size,
72 mpi_info->rank);
73
74 double blocktimer_start = blocktimer_time();
75 Dudley_resetError();
76 int *first_DofComponent, *first_NodeComponent;
77
78 // Open NetCDF file for reading
79 NcAtt *attr;
80 NcVar *nc_var_temp;
81 // netCDF error handler
82 NcError err(NcError::silent_nonfatal);
83 // Create the NetCDF file.
84 NcFile dataFile(fName, NcFile::ReadOnly);
85 if (!dataFile.is_valid()) {
86 sprintf(error_msg,"loadMesh: Opening NetCDF file '%s' for reading failed.", fName);
87 Dudley_setError(IO_ERROR,error_msg);
88 Esys_MPIInfo_free( mpi_info );
89 throw DataException(error_msg);
90 }
91
92 // Read NetCDF integer attributes
93 int mpi_size = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"mpi_size");
94 int mpi_rank = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"mpi_rank");
95 int numDim = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"numDim");
96 int numNodes = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"numNodes");
97 int num_Elements = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Elements");
98 int num_FaceElements = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_FaceElements");
99 int num_Points = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Points");
100 int num_Elements_numNodes = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Elements_numNodes");
101 int Elements_TypeId = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"Elements_TypeId");
102 int num_FaceElements_numNodes = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_FaceElements_numNodes");
103 int FaceElements_TypeId = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"FaceElements_TypeId");
104 int Points_TypeId = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"Points_TypeId");
105 int num_Tags = NetCDF_Get_Int_Attribute(&dataFile, fName, (char *)"num_Tags");
106
107 // Verify size and rank
108 if (mpi_info->size != mpi_size) {
109 sprintf(error_msg, "loadMesh: The NetCDF file '%s' can only be read on %d CPUs instead of %d", fName, mpi_size, mpi_info->size);
110 throw DataException(error_msg);
111 }
112 if (mpi_info->rank != mpi_rank) {
113 sprintf(error_msg, "loadMesh: The NetCDF file '%s' should be read on CPU #%d instead of %d", fName, mpi_rank, mpi_info->rank);
114 throw DataException(error_msg);
115 }
116
117 // Read mesh name
118 if (! (attr=dataFile.get_att("Name")) ) {
119 sprintf(error_msg,"loadMesh: Error retrieving mesh name from NetCDF file '%s'", fName);
120 throw DataException(error_msg);
121 }
122 char *name = attr->as_string(0);
123 delete attr;
124
125 delete[] fName;
126
127 /* allocate mesh */
128 mesh_p = Dudley_Mesh_alloc(name,numDim,mpi_info);
129 if (Dudley_noError()) {
130
131 /* read nodes */
132 Dudley_NodeFile_allocTable(mesh_p->Nodes, numNodes);
133 // Nodes_Id
134 if (! ( nc_var_temp = dataFile.get_var("Nodes_Id")) )
135 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_Id)");
136 if (! nc_var_temp->get(&mesh_p->Nodes->Id[0], numNodes) )
137 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_Id)");
138 // Nodes_Tag
139 if (! ( nc_var_temp = dataFile.get_var("Nodes_Tag")) )
140 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_Tag)");
141 if (! nc_var_temp->get(&mesh_p->Nodes->Tag[0], numNodes) )
142 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_Tag)");
143 // Nodes_gDOF
144 if (! ( nc_var_temp = dataFile.get_var("Nodes_gDOF")) )
145 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_gDOF)");
146 if (! nc_var_temp->get(&mesh_p->Nodes->globalDegreesOfFreedom[0], numNodes) )
147 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_gDOF)");
148 // Nodes_gNI
149 if (! ( nc_var_temp = dataFile.get_var("Nodes_gNI")) )
150 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_gNI)");
151 if (! nc_var_temp->get(&mesh_p->Nodes->globalNodesIndex[0], numNodes) )
152 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_gNI)");
153 // Nodes_grDfI
154 if (! ( nc_var_temp = dataFile.get_var("Nodes_grDfI")) )
155 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_grDfI)");
156 if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedDOFIndex[0], numNodes) )
157 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_grDfI)");
158 // Nodes_grNI
159 if (! ( nc_var_temp = dataFile.get_var("Nodes_grNI")) )
160 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_grNI)");
161 if (! nc_var_temp->get(&mesh_p->Nodes->globalReducedNodesIndex[0], numNodes) )
162 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_grNI)");
163 // Nodes_Coordinates
164 if (!(nc_var_temp = dataFile.get_var("Nodes_Coordinates")))
165 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_Coordinates)");
166 if (! nc_var_temp->get(&(mesh_p->Nodes->Coordinates[0]), numNodes, numDim) )
167 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_Coordinates)");
168
169 Dudley_NodeFile_setTagsInUse(mesh_p->Nodes);
170
171 /* read elements */
172 if (Dudley_noError()) {
173 mesh_p->Elements=Dudley_ElementFile_alloc((Dudley_ElementTypeId)Elements_TypeId, mpi_info);
174 if (Dudley_noError())
175 Dudley_ElementFile_allocTable(mesh_p->Elements, num_Elements);
176 if (Dudley_noError()) {
177 mesh_p->Elements->minColor=0;
178 mesh_p->Elements->maxColor=num_Elements-1;
179 if (num_Elements>0) {
180 // Elements_Id
181 if (! ( nc_var_temp = dataFile.get_var("Elements_Id")) )
182 cleanupAndThrow(mesh_p, mpi_info, "get_var(Elements_Id)");
183 if (! nc_var_temp->get(&mesh_p->Elements->Id[0], num_Elements) )
184 cleanupAndThrow(mesh_p, mpi_info, "get(Elements_Id)");
185 // Elements_Tag
186 if (! ( nc_var_temp = dataFile.get_var("Elements_Tag")) )
187 cleanupAndThrow(mesh_p, mpi_info, "get_var(Elements_Tag)");
188 if (! nc_var_temp->get(&mesh_p->Elements->Tag[0], num_Elements) )
189 cleanupAndThrow(mesh_p, mpi_info, "get(Elements_Tag)");
190 // Elements_Owner
191 if (! ( nc_var_temp = dataFile.get_var("Elements_Owner")) )
192 cleanupAndThrow(mesh_p, mpi_info, "get_var(Elements_Owner)");
193 if (! nc_var_temp->get(&mesh_p->Elements->Owner[0], num_Elements) )
194 cleanupAndThrow(mesh_p, mpi_info, "get(Elements_Owner)");
195 // Elements_Color
196 if (! ( nc_var_temp = dataFile.get_var("Elements_Color")) )
197 cleanupAndThrow(mesh_p, mpi_info, "get_var(Elements_Color)");
198 if (! nc_var_temp->get(&mesh_p->Elements->Color[0], num_Elements) )
199 cleanupAndThrow(mesh_p, mpi_info, "get(Elements_Color)");
200 // Elements_Nodes
201 int *Elements_Nodes = new int[num_Elements*num_Elements_numNodes];
202 if (!(nc_var_temp = dataFile.get_var("Elements_Nodes"))) {
203 delete[] Elements_Nodes;
204 cleanupAndThrow(mesh_p, mpi_info, "get_var(Elements_Nodes)");
205 }
206 if (! nc_var_temp->get(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes) ) {
207 delete[] Elements_Nodes;
208 cleanupAndThrow(mesh_p, mpi_info, "get(Elements_Nodes)");
209 }
210
211 // Copy temp array into mesh_p->Elements->Nodes
212 for (int i=0; i<num_Elements; i++) {
213 for (int j=0; j<num_Elements_numNodes; j++) {
214 mesh_p->Elements->Nodes[INDEX2(j,i,num_Elements_numNodes)]
215 = Elements_Nodes[INDEX2(j,i,num_Elements_numNodes)];
216 }
217 }
218 delete[] Elements_Nodes;
219 Dudley_ElementFile_setTagsInUse(mesh_p->Elements);
220 } /* num_Elements>0 */
221 }
222 }
223
224 /* get the face elements */
225 if (Dudley_noError()) {
226 mesh_p->FaceElements=Dudley_ElementFile_alloc((Dudley_ElementTypeId)FaceElements_TypeId, mpi_info);
227 if (Dudley_noError())
228 Dudley_ElementFile_allocTable(mesh_p->FaceElements, num_FaceElements);
229 if (Dudley_noError()) {
230 mesh_p->FaceElements->minColor=0;
231 mesh_p->FaceElements->maxColor=num_FaceElements-1;
232 if (num_FaceElements>0) {
233 // FaceElements_Id
234 if (! ( nc_var_temp = dataFile.get_var("FaceElements_Id")) )
235 cleanupAndThrow(mesh_p, mpi_info, "get_var(FaceElements_Id)");
236 if (! nc_var_temp->get(&mesh_p->FaceElements->Id[0], num_FaceElements) )
237 cleanupAndThrow(mesh_p, mpi_info, "get(FaceElements_Id)");
238 // FaceElements_Tag
239 if (! ( nc_var_temp = dataFile.get_var("FaceElements_Tag")) )
240 cleanupAndThrow(mesh_p, mpi_info, "get_var(FaceElements_Tag)");
241 if (! nc_var_temp->get(&mesh_p->FaceElements->Tag[0], num_FaceElements) )
242 cleanupAndThrow(mesh_p, mpi_info, "get(FaceElements_Tag)");
243 // FaceElements_Owner
244 if (! ( nc_var_temp = dataFile.get_var("FaceElements_Owner")) )
245 cleanupAndThrow(mesh_p, mpi_info, "get_var(FaceElements_Owner)");
246 if (! nc_var_temp->get(&mesh_p->FaceElements->Owner[0], num_FaceElements) )
247 cleanupAndThrow(mesh_p, mpi_info, "get(FaceElements_Owner)");
248 // FaceElements_Color
249 if (! ( nc_var_temp = dataFile.get_var("FaceElements_Color")) )
250 cleanupAndThrow(mesh_p, mpi_info, "get_var(FaceElements_Color)");
251 if (! nc_var_temp->get(&mesh_p->FaceElements->Color[0], num_FaceElements) )
252 cleanupAndThrow(mesh_p, mpi_info, "get(FaceElements_Color)");
253 // FaceElements_Nodes
254 int *FaceElements_Nodes = new int[num_FaceElements*num_FaceElements_numNodes];
255 if (!(nc_var_temp = dataFile.get_var("FaceElements_Nodes"))) {
256 delete[] FaceElements_Nodes;
257 cleanupAndThrow(mesh_p, mpi_info, "get_var(FaceElements_Nodes)");
258 }
259 if (! nc_var_temp->get(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes) ) {
260 delete[] FaceElements_Nodes;
261 cleanupAndThrow(mesh_p, mpi_info, "get(FaceElements_Nodes)");
262 }
263 // Copy temp array into mesh_p->FaceElements->Nodes
264 for (int i=0; i<num_FaceElements; i++) {
265 for (int j=0; j<num_FaceElements_numNodes; j++) {
266 mesh_p->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)];
267 }
268 }
269 delete[] FaceElements_Nodes;
270 Dudley_ElementFile_setTagsInUse(mesh_p->FaceElements);
271 } /* num_FaceElements>0 */
272 }
273 }
274
275 /* get the Points (nodal elements) */
276 if (Dudley_noError()) {
277 mesh_p->Points=Dudley_ElementFile_alloc((Dudley_ElementTypeId)Points_TypeId, mpi_info);
278 if (Dudley_noError())
279 Dudley_ElementFile_allocTable(mesh_p->Points, num_Points);
280 if (Dudley_noError()) {
281 mesh_p->Points->minColor=0;
282 mesh_p->Points->maxColor=num_Points-1;
283 if (num_Points>0) {
284 // Points_Id
285 if (! ( nc_var_temp = dataFile.get_var("Points_Id")))
286 cleanupAndThrow(mesh_p, mpi_info, "get_var(Points_Id)");
287 if (! nc_var_temp->get(&mesh_p->Points->Id[0], num_Points))
288 cleanupAndThrow(mesh_p, mpi_info, "get(Points_Id)");
289 // Points_Tag
290 if (! ( nc_var_temp = dataFile.get_var("Points_Tag")))
291 cleanupAndThrow(mesh_p, mpi_info, "get_var(Points_Tag)");
292 if (! nc_var_temp->get(&mesh_p->Points->Tag[0], num_Points))
293 cleanupAndThrow(mesh_p, mpi_info, "get(Points_Tag)");
294 // Points_Owner
295 if (! ( nc_var_temp = dataFile.get_var("Points_Owner")))
296 cleanupAndThrow(mesh_p, mpi_info, "get_var(Points_Owner)");
297 if (!nc_var_temp->get(&mesh_p->Points->Owner[0], num_Points))
298 cleanupAndThrow(mesh_p, mpi_info, "get(Points_Owner)");
299 // Points_Color
300 if (! ( nc_var_temp = dataFile.get_var("Points_Color")))
301 cleanupAndThrow(mesh_p, mpi_info, "get_var(Points_Color)");
302 if (!nc_var_temp->get(&mesh_p->Points->Color[0], num_Points))
303 cleanupAndThrow(mesh_p, mpi_info, "get(Points_Color)");
304 // Points_Nodes
305 int *Points_Nodes = new int[num_Points];
306 if (!(nc_var_temp = dataFile.get_var("Points_Nodes"))) {
307 delete[] Points_Nodes;
308 cleanupAndThrow(mesh_p, mpi_info, "get_var(Points_Nodes)");
309 }
310 if (! nc_var_temp->get(&(Points_Nodes[0]), num_Points) ) {
311 delete[] Points_Nodes;
312 cleanupAndThrow(mesh_p, mpi_info, "get(Points_Nodes)");
313 }
314 // Copy temp array into mesh_p->Points->Nodes
315 for (int i=0; i<num_Points; i++) {
316 mesh_p->Points->Id[mesh_p->Points->Nodes[INDEX2(0,i,1)]] = Points_Nodes[i];
317 }
318 delete[] Points_Nodes;
319 Dudley_ElementFile_setTagsInUse(mesh_p->Points);
320 } /* num_Points>0 */
321 }
322 }
323
324 /* get the tags */
325 if (Dudley_noError()) {
326 if (num_Tags>0) {
327 // Temp storage to gather node IDs
328 int *Tags_keys = new int[num_Tags];
329 char name_temp[4096];
330 int i;
331
332 // Tags_keys
333 if (! ( nc_var_temp = dataFile.get_var("Tags_keys")) ) {
334 delete[] Tags_keys;
335 cleanupAndThrow(mesh_p, mpi_info, "get_var(Tags_keys)");
336 }
337 if (! nc_var_temp->get(&Tags_keys[0], num_Tags) ) {
338 delete[] Tags_keys;
339 cleanupAndThrow(mesh_p, mpi_info, "get(Tags_keys)");
340 }
341 for (i=0; i<num_Tags; i++) {
342 // Retrieve tag name
343 sprintf(name_temp, "Tags_name_%d", i);
344 if (! (attr=dataFile.get_att(name_temp)) ) {
345 delete[] Tags_keys;
346 sprintf(error_msg,"get_att(%s)", name_temp);
347 cleanupAndThrow(mesh_p, mpi_info, error_msg);
348 }
349 char *name = attr->as_string(0);
350 delete attr;
351 Dudley_Mesh_addTagMap(mesh_p, name, Tags_keys[i]);
352 }
353 delete[] Tags_keys;
354 }
355 }
356
357 if (Dudley_noError()) {
358 // Nodes_DofDistribution
359 first_DofComponent = new index_t[mpi_size+1];
360 if (! ( nc_var_temp = dataFile.get_var("Nodes_DofDistribution")) ) {
361 delete[] first_DofComponent;
362 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_DofDistribution)");
363 }
364 if (! nc_var_temp->get(&first_DofComponent[0], mpi_size+1) ) {
365 delete[] first_DofComponent;
366 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_DofDistribution)");
367 }
368
369 // Nodes_NodeDistribution
370 first_NodeComponent = new index_t[mpi_size+1];
371 if (! ( nc_var_temp = dataFile.get_var("Nodes_NodeDistribution")) ) {
372 delete[] first_DofComponent;
373 delete[] first_NodeComponent;
374 cleanupAndThrow(mesh_p, mpi_info, "get_var(Nodes_NodeDistribution)");
375 }
376 if (! nc_var_temp->get(&first_NodeComponent[0], mpi_size+1) ) {
377 delete[] first_DofComponent;
378 delete[] first_NodeComponent;
379 cleanupAndThrow(mesh_p, mpi_info, "get(Nodes_NodeDistribution)");
380 }
381 Dudley_Mesh_createMappings(mesh_p, first_DofComponent, first_NodeComponent);
382 delete[] first_DofComponent;
383 delete[] first_NodeComponent;
384 }
385
386 } /* Dudley_noError() after Dudley_Mesh_alloc() */
387
388 checkDudleyError();
389 AbstractContinuousDomain* dom=new MeshAdapter(mesh_p);
390
391 if (! Dudley_noError()) {
392 Dudley_Mesh_free(mesh_p);
393 }
394
395 blocktimer_increment("LoadMesh()", blocktimer_start);
396 return dom->getPtr();
397 #else
398 throw DataException("loadMesh: not compiled with NetCDF. Please contact your installation manager.");
399 #endif /* USE_NETCDF */
400 }
401
402 Domain_ptr readMesh(const std::string& fileName,
403 int integrationOrder,
404 int reducedIntegrationOrder,
405 int optimize)
406 {
407 //
408 // create a copy of the filename to overcome the non-constness of call
409 // to Dudley_Mesh_read
410 Dudley_Mesh* fMesh=0;
411 // Win32 refactor
412 if( fileName.size() == 0 )
413 {
414 throw DataException("Null file name!");
415 }
416
417 char *fName = new char[fileName.size()+1];
418
419 strcpy(fName,fileName.c_str());
420 double blocktimer_start = blocktimer_time();
421
422 fMesh=Dudley_Mesh_read(fName,integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
423 checkDudleyError();
424 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
425
426 /* win32 refactor */
427 delete[] fName;
428
429 blocktimer_increment("ReadMesh()", blocktimer_start);
430 return temp->getPtr();
431 }
432
433 Domain_ptr readGmsh(const std::string& fileName,
434 int numDim,
435 int integrationOrder,
436 int reducedIntegrationOrder,
437 int optimize,
438 int useMacroElements)
439 {
440 //
441 // create a copy of the filename to overcome the non-constness of call
442 // to Dudley_Mesh_read
443 Dudley_Mesh* fMesh=0;
444 // Win32 refactor
445 if( fileName.size() == 0 )
446 {
447 throw DataException("Null file name!");
448 }
449
450 char *fName = new char[fileName.size()+1];
451
452 strcpy(fName,fileName.c_str());
453 double blocktimer_start = blocktimer_time();
454
455 fMesh=Dudley_Mesh_readGmsh(fName, numDim, integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE), (useMacroElements ? TRUE : FALSE));
456 checkDudleyError();
457 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
458
459 /* win32 refactor */
460 delete[] fName;
461
462 blocktimer_increment("ReadGmsh()", blocktimer_start);
463 return temp->getPtr();
464 }
465
466 Domain_ptr brick(double n0, double n1,double n2,int order,
467 double l0,double l1,double l2,
468 int periodic0,int periodic1,
469 int periodic2,
470 int integrationOrder,
471 int reducedIntegrationOrder,
472 int useElementsOnFace,
473 int useFullElementOrder,
474 int optimize)
475 {
476 int numElements[]={static_cast<int>(n0),static_cast<int>(n1),static_cast<int>(n2)};
477 double length[]={l0,l1,l2};
478
479 if (periodic0 || periodic1) // we don't support periodic boundary conditions
480 {
481 throw DudleyAdapterException("Dudley does not support periodic boundary conditions.");
482 }
483 else if (integrationOrder>3 || reducedIntegrationOrder>1)
484 {
485 throw DudleyAdapterException("Dudley does not support the requested integrationOrders.");
486 }
487 else if (useElementsOnFace || useFullElementOrder)
488 {
489 throw DudleyAdapterException("Dudley does not support useElementsOnFace or useFullElementOrder.");
490 }
491 if (order>1)
492 {
493 throw DudleyAdapterException("Dudley does not support element order greater than 1.");
494 }
495
496 //
497 // linearInterpolation
498 Dudley_Mesh* fMesh=NULL;
499
500 fMesh=Dudley_TriangularMesh_Tet4(numElements, length, integrationOrder,
501 reducedIntegrationOrder, (optimize ? TRUE : FALSE));
502
503 //
504 // Convert any dudley errors into a C++ exception
505 checkDudleyError();
506 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
507 return temp->getPtr();
508 }
509
510 Domain_ptr rectangle(double n0, double n1, int order,
511 double l0, double l1,
512 int periodic0,int periodic1,
513 int integrationOrder,
514 int reducedIntegrationOrder,
515 int useElementsOnFace,
516 int useFullElementOrder,
517 int optimize)
518 {
519 int numElements[]={static_cast<int>(n0), static_cast<int>(n1)};
520 double length[]={l0,l1};
521
522 if (periodic0 || periodic1) // we don't support periodic boundary conditions
523 {
524 throw DudleyAdapterException("Dudley does not support periodic boundary conditions.");
525 }
526 else if (integrationOrder>3 || reducedIntegrationOrder>1)
527 {
528 throw DudleyAdapterException("Dudley does not support the requested integrationOrders.");
529 }
530 else if (useElementsOnFace || useFullElementOrder)
531 {
532 throw DudleyAdapterException("Dudley does not support useElementsOnFace or useFullElementOrder.");
533 }
534
535 if (order>1)
536 {
537 throw DudleyAdapterException("Dudley does not support element order greater than 1.");
538 }
539 Dudley_Mesh* fMesh=Dudley_TriangularMesh_Tri3(numElements, length,
540 integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
541 //
542 // Convert any dudley errors into a C++ exception
543 checkDudleyError();
544 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
545
546 return temp->getPtr();
547 }
548
549 // end of namespace
550
551 }
552

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26