/[escript]/branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Annotation of /branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1346 - (hide annotations)
Wed Nov 14 22:48:12 2007 UTC (11 years, 5 months ago) by ksteube
Original Path: trunk/finley/src/CPPAdapter/MeshAdapter.cpp
File size: 80790 byte(s)
dump/LoadMesh methods work except for TagMap, Point elements probably OK but are untested.

1 jgs 472
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 203 #include "MeshAdapter.h"
17 robwdcock 682 #include "escript/Data.h"
18     #include "escript/DataFactory.h"
19 ksteube 1343 #ifdef USE_NETCDF
20     #include <netcdfcpp.h>
21     #endif
22 ksteube 1312 extern "C" {
23     #include "escript/blocktimer.h"
24     }
25     #include <vector>
26 jgs 480
27 jgs 82 using namespace std;
28     using namespace escript;
29    
30     namespace finley {
31 jgs 149
32 jgs 82 //
33 jgs 149 // define the static constants
34 jgs 82 MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;
35     const int MeshAdapter::DegreesOfFreedom=FINLEY_DEGREES_OF_FREEDOM;
36     const int MeshAdapter::ReducedDegreesOfFreedom=FINLEY_REDUCED_DEGREES_OF_FREEDOM;
37     const int MeshAdapter::Nodes=FINLEY_NODES;
38 gross 1062 const int MeshAdapter::ReducedNodes=FINLEY_REDUCED_NODES;
39 jgs 82 const int MeshAdapter::Elements=FINLEY_ELEMENTS;
40 gross 1059 const int MeshAdapter::ReducedElements=FINLEY_REDUCED_ELEMENTS;
41 jgs 82 const int MeshAdapter::FaceElements=FINLEY_FACE_ELEMENTS;
42 gross 1059 const int MeshAdapter::ReducedFaceElements=FINLEY_REDUCED_FACE_ELEMENTS;
43 jgs 82 const int MeshAdapter::Points=FINLEY_POINTS;
44     const int MeshAdapter::ContactElementsZero=FINLEY_CONTACT_ELEMENTS_1;
45 gross 1059 const int MeshAdapter::ReducedContactElementsZero=FINLEY_REDUCED_CONTACT_ELEMENTS_1;
46 jgs 82 const int MeshAdapter::ContactElementsOne=FINLEY_CONTACT_ELEMENTS_2;
47 gross 1059 const int MeshAdapter::ReducedContactElementsOne=FINLEY_REDUCED_CONTACT_ELEMENTS_2;
48 jgs 82
49     MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)
50     {
51     setFunctionSpaceTypeNames();
52     //
53 ksteube 1312 // need to use a null_deleter as Finley_Mesh_free deletes the pointer
54 jgs 82 // for us.
55     m_finleyMesh.reset(finleyMesh,null_deleter());
56     }
57 jgs 149
58 jgs 82 //
59     // The copy constructor should just increment the use count
60     MeshAdapter::MeshAdapter(const MeshAdapter& in):
61     m_finleyMesh(in.m_finleyMesh)
62     {
63     setFunctionSpaceTypeNames();
64     }
65    
66     MeshAdapter::~MeshAdapter()
67     {
68     //
69     // I hope the case for the pointer being zero has been taken care of.
70     // cout << "In MeshAdapter destructor." << endl;
71     if (m_finleyMesh.unique()) {
72 ksteube 1312 Finley_Mesh_free(m_finleyMesh.get());
73 jgs 82 }
74     }
75    
76 ksteube 1312 int MeshAdapter::getMPISize() const
77     {
78     return m_finleyMesh.get()->MPIInfo->size;
79     }
80     int MeshAdapter::getMPIRank() const
81     {
82     return m_finleyMesh.get()->MPIInfo->rank;
83     }
84    
85    
86 jgs 82 Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
87     return m_finleyMesh.get();
88     }
89    
90     void MeshAdapter::write(const std::string& fileName) const
91     {
92 woo409 757 char *fName = (fileName.size()+1>0) ? TMPMEMALLOC(fileName.size()+1,char) : (char*)NULL;
93 jgs 82 strcpy(fName,fileName.c_str());
94     Finley_Mesh_write(m_finleyMesh.get(),fName);
95     checkFinleyError();
96 woo409 757 TMPMEMFREE(fName);
97 jgs 82 }
98    
99 ksteube 1339 void MeshAdapter::Print_Mesh_Info(const bool full=false) const
100 ksteube 1326 {
101 ksteube 1339 Finley_PrintMesh_Info(m_finleyMesh.get(), full);
102 ksteube 1326 }
103    
104 ksteube 1312 void MeshAdapter::dump(const std::string& fileName) const
105     {
106 ksteube 1343 #ifdef USE_NETCDF
107     const NcDim* ncdims[25]; /* ksteube how big should ncdims be? */
108     NcVar *ids, *data;
109     int *int_ptr;
110     Finley_Mesh *mesh = m_finleyMesh.get();
111     int mpi_size = mesh->MPIInfo->size;
112     int mpi_rank = mesh->MPIInfo->rank;
113     int numDim = mesh->Nodes->numDim;
114     int numNodes = mesh->Nodes->numNodes;
115     int num_Elements = mesh->Elements->numElements;
116     int num_FaceElements = mesh->FaceElements->numElements;
117     int num_ContactElements = mesh->ContactElements->numElements;
118     int num_Points = mesh->Points->numElements;
119     int num_Elements_numNodes = mesh->Elements->numNodes;
120     int num_FaceElements_numNodes = mesh->FaceElements->numNodes;
121     int num_ContactElements_numNodes = mesh->ContactElements->numNodes;
122     char *newFileName = Paso_MPI_appendRankToFileName(strdup(fileName.c_str()), mpi_size, mpi_rank);
123    
124     // NetCDF error handler
125     NcError err(NcError::verbose_nonfatal);
126     // Create the file.
127     NcFile dataFile(newFileName, NcFile::Replace);
128     // check if writing was successful
129     if (!dataFile.is_valid())
130     throw DataException("Error - MeshAdapter::dump: opening of NetCDF file for output failed: " + *newFileName);
131    
132     // Define dimensions (num_Elements and dim_Elements are identical, dim_Elements only appears if > 0)
133     if (! (ncdims[0] = dataFile.add_dim("numNodes", numNodes)) )
134     throw DataException("Error - MeshAdapter::dump: appending dimension numNodes to netCDF file failed: " + *newFileName);
135     if (! (ncdims[1] = dataFile.add_dim("numDim", numDim)) )
136     throw DataException("Error - MeshAdapter::dump: appending dimension numDim to netCDF file failed: " + *newFileName);
137     if (! (ncdims[2] = dataFile.add_dim("mpi_size_plus_1", mpi_size+1)) )
138     throw DataException("Error - MeshAdapter::dump: appending dimension mpi_size to netCDF file failed: " + *newFileName);
139     if (num_Elements>0)
140     if (! (ncdims[3] = dataFile.add_dim("dim_Elements", num_Elements)) )
141     throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements to netCDF file failed: " + *newFileName);
142     if (num_FaceElements>0)
143     if (! (ncdims[4] = dataFile.add_dim("dim_FaceElements", num_FaceElements)) )
144     throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements to netCDF file failed: " + *newFileName);
145     if (num_ContactElements>0)
146     if (! (ncdims[5] = dataFile.add_dim("dim_ContactElements", num_ContactElements)) )
147     throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements to netCDF file failed: " + *newFileName);
148     if (num_Points>0)
149     if (! (ncdims[6] = dataFile.add_dim("dim_Points", num_Points)) )
150     throw DataException("Error - MeshAdapter::dump: appending dimension dim_Points to netCDF file failed: " + *newFileName);
151     if (num_Elements>0)
152     if (! (ncdims[7] = dataFile.add_dim("dim_Elements_Nodes", num_Elements_numNodes)) )
153     throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements_Nodes to netCDF file failed: " + *newFileName);
154     if (num_FaceElements>0)
155     if (! (ncdims[8] = dataFile.add_dim("dim_FaceElements_numNodes", num_FaceElements_numNodes)) )
156     throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements_numNodes to netCDF file failed: " + *newFileName);
157     if (num_ContactElements>0)
158     if (! (ncdims[9] = dataFile.add_dim("dim_ContactElements_numNodes", num_ContactElements_numNodes)) )
159     throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements_numNodes to netCDF file failed: " + *newFileName);
160    
161 ksteube 1345 // Attributes: MPI size, MPI rank, Name, order, reduced_order
162 ksteube 1343 if (!dataFile.add_att("mpi_size", mpi_size) )
163     throw DataException("Error - MeshAdapter::dump: appending mpi_size to NetCDF file failed: " + *newFileName);
164     if (!dataFile.add_att("mpi_rank", mpi_rank) )
165     throw DataException("Error - MeshAdapter::dump: appending mpi_rank to NetCDF file failed: " + *newFileName);
166     if (!dataFile.add_att("Name",mesh->Name) )
167     throw DataException("Error - MeshAdapter::dump: appending Name to NetCDF file failed: " + *newFileName);
168 ksteube 1345 if (!dataFile.add_att("numDim",numDim) )
169     throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
170 ksteube 1343 if (!dataFile.add_att("order",mesh->order) )
171     throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
172     if (!dataFile.add_att("reduced_order",mesh->reduced_order) )
173     throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);
174 ksteube 1345 if (!dataFile.add_att("numNodes",numNodes) )
175     throw DataException("Error - MeshAdapter::dump: appending numNodes to NetCDF file failed: " + *newFileName);
176 ksteube 1343 if (!dataFile.add_att("num_Elements",num_Elements) )
177     throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);
178     if (!dataFile.add_att("num_FaceElements",num_FaceElements) )
179     throw DataException("Error - MeshAdapter::dump: appending num_FaceElements to NetCDF file failed: " + *newFileName);
180     if (!dataFile.add_att("num_ContactElements",num_ContactElements) )
181     throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);
182     if (!dataFile.add_att("num_Points",num_Points) )
183     throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);
184 ksteube 1346 if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes) )
185     throw DataException("Error - MeshAdapter::dump: appending num_Elements_numNodes to NetCDF file failed: " + *newFileName);
186     if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )
187     throw DataException("Error - MeshAdapter::dump: appending num_FaceElements_numNodes to NetCDF file failed: " + *newFileName);
188     if (!dataFile.add_att("num_ContactElements_numNodes",num_ContactElements_numNodes) )
189     throw DataException("Error - MeshAdapter::dump: appending num_ContactElements_numNodes to NetCDF file failed: " + *newFileName);
190 ksteube 1343
191     // // // // // Nodes // // // // //
192    
193 ksteube 1345 // Only write nodes if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)
194     if (numNodes>0) {
195    
196 ksteube 1343 // Nodes Id
197     if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )
198     throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);
199     int_ptr = &mesh->Nodes->Id[0];
200     if (! (ids->put(int_ptr, numNodes)) )
201     throw DataException("Error - MeshAdapter::dump: copy Nodes_Id to netCDF buffer failed: " + *newFileName);
202    
203     // Nodes Tag
204     if (! ( ids = dataFile.add_var("Nodes_Tag", ncInt, ncdims[0])) )
205     throw DataException("Error - MeshAdapter::dump: appending Nodes_Tag to netCDF file failed: " + *newFileName);
206     int_ptr = &mesh->Nodes->Tag[0];
207     if (! (ids->put(int_ptr, numNodes)) )
208     throw DataException("Error - MeshAdapter::dump: copy Nodes_Tag to netCDF buffer failed: " + *newFileName);
209    
210     // Nodes gDOF
211     if (! ( ids = dataFile.add_var("Nodes_gDOF", ncInt, ncdims[0])) )
212     throw DataException("Error - MeshAdapter::dump: appending Nodes_gDOF to netCDF file failed: " + *newFileName);
213     int_ptr = &mesh->Nodes->globalDegreesOfFreedom[0];
214     if (! (ids->put(int_ptr, numNodes)) )
215     throw DataException("Error - MeshAdapter::dump: copy Nodes_gDOF to netCDF buffer failed: " + *newFileName);
216    
217     // Nodes global node index
218     if (! ( ids = dataFile.add_var("Nodes_gNI", ncInt, ncdims[0])) )
219     throw DataException("Error - MeshAdapter::dump: appending Nodes_gNI to netCDF file failed: " + *newFileName);
220     int_ptr = &mesh->Nodes->globalNodesIndex[0];
221     if (! (ids->put(int_ptr, numNodes)) )
222     throw DataException("Error - MeshAdapter::dump: copy Nodes_gNI to netCDF buffer failed: " + *newFileName);
223    
224     // Nodes grDof
225     if (! ( ids = dataFile.add_var("Nodes_grDfI", ncInt, ncdims[0])) )
226     throw DataException("Error - MeshAdapter::dump: appending Nodes_grDfI to netCDF file failed: " + *newFileName);
227     int_ptr = &mesh->Nodes->globalReducedDOFIndex[0];
228     if (! (ids->put(int_ptr, numNodes)) )
229     throw DataException("Error - MeshAdapter::dump: copy Nodes_grDfI to netCDF buffer failed: " + *newFileName);
230    
231     // Nodes grNI
232     if (! ( ids = dataFile.add_var("Nodes_grNI", ncInt, ncdims[0])) )
233     throw DataException("Error - MeshAdapter::dump: appending Nodes_grNI to netCDF file failed: " + *newFileName);
234     int_ptr = &mesh->Nodes->globalReducedNodesIndex[0];
235     if (! (ids->put(int_ptr, numNodes)) )
236     throw DataException("Error - MeshAdapter::dump: copy Nodes_grNI to netCDF buffer failed: " + *newFileName);
237    
238     // Nodes Coordinates
239     if (! ( ids = dataFile.add_var("Nodes_Coordinates", ncDouble, ncdims[0], ncdims[1]) ) )
240     throw DataException("Error - MeshAdapter::dump: appending Nodes_Coordinates to netCDF file failed: " + *newFileName);
241     if (! (ids->put(&(mesh->Nodes->Coordinates[INDEX2(0,0,numDim)]), numNodes, numDim)) )
242     throw DataException("Error - MeshAdapter::dump: copy Nodes_Coordinates to netCDF buffer failed: " + *newFileName);
243    
244     // Nodes degreesOfFreedomDistribution
245     if (! ( ids = dataFile.add_var("Nodes_DofDistribution", ncInt, ncdims[2])) )
246     throw DataException("Error - MeshAdapter::dump: appending Nodes_DofDistribution to netCDF file failed: " + *newFileName);
247     int_ptr = &mesh->Nodes->degreesOfFreedomDistribution->first_component[0];
248     if (! (ids->put(int_ptr, mpi_size+1)) )
249     throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);
250    
251 ksteube 1345 }
252    
253 ksteube 1343 // // // // // Elements // // // // //
254    
255     if (num_Elements>0) {
256    
257     // Temp storage to gather node IDs
258     int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
259    
260     // Elements ReferenceElement->ElementTypeId
261     if (!dataFile.add_att("Elements_TypeId", mesh->Elements->ReferenceElement->Type->TypeId) )
262     throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);
263    
264     // Elements_Id
265     if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
266     throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);
267     int_ptr = &mesh->Elements->Id[0];
268     if (! (ids->put(int_ptr, num_Elements)) )
269     throw DataException("Error - MeshAdapter::dump: copy Elements_Id to netCDF buffer failed: " + *newFileName);
270    
271     // Elements_Tag
272     if (! ( ids = dataFile.add_var("Elements_Tag", ncInt, ncdims[3])) )
273     throw DataException("Error - MeshAdapter::dump: appending Elements_Tag to netCDF file failed: " + *newFileName);
274     int_ptr = &mesh->Elements->Tag[0];
275     if (! (ids->put(int_ptr, num_Elements)) )
276     throw DataException("Error - MeshAdapter::dump: copy Elements_Tag to netCDF buffer failed: " + *newFileName);
277    
278     // Elements_Owner
279     if (! ( ids = dataFile.add_var("Elements_Owner", ncInt, ncdims[3])) )
280     throw DataException("Error - MeshAdapter::dump: appending Elements_Owner to netCDF file failed: " + *newFileName);
281     int_ptr = &mesh->Elements->Owner[0];
282     if (! (ids->put(int_ptr, num_Elements)) )
283     throw DataException("Error - MeshAdapter::dump: copy Elements_Owner to netCDF buffer failed: " + *newFileName);
284    
285     // Elements_Color
286     if (! ( ids = dataFile.add_var("Elements_Color", ncInt, ncdims[3])) )
287     throw DataException("Error - MeshAdapter::dump: appending Elements_Color to netCDF file failed: " + *newFileName);
288     int_ptr = &mesh->Elements->Color[0];
289     if (! (ids->put(int_ptr, num_Elements)) )
290     throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);
291    
292     // Elements_Nodes
293     for (int i=0; i<num_Elements; i++)
294     for (int j=0; j<num_Elements_numNodes; j++)
295     Elements_Nodes[INDEX2(j,i,num_Elements_numNodes)] = mesh->Nodes->Id[mesh->Elements->Nodes[INDEX2(j,i,num_Elements_numNodes)]];
296     if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )
297     throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);
298     if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )
299     throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);
300    
301 ksteube 1344 TMPMEMFREE(Elements_Nodes);
302    
303 ksteube 1343 }
304    
305     // // // // // Face_Elements // // // // //
306    
307     if (num_FaceElements>0) {
308    
309     // Temp storage to gather node IDs
310     int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
311    
312     // FaceElements ReferenceElement->ElementTypeId
313     if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )
314     throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);
315    
316     // FaceElements_Id
317     if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
318     throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);
319     int_ptr = &mesh->FaceElements->Id[0];
320     if (! (ids->put(int_ptr, num_FaceElements)) )
321     throw DataException("Error - MeshAdapter::dump: copy FaceElements_Id to netCDF buffer failed: " + *newFileName);
322    
323     // FaceElements_Tag
324     if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )
325     throw DataException("Error - MeshAdapter::dump: appending FaceElements_Tag to netCDF file failed: " + *newFileName);
326     int_ptr = &mesh->FaceElements->Tag[0];
327     if (! (ids->put(int_ptr, num_FaceElements)) )
328     throw DataException("Error - MeshAdapter::dump: copy FaceElements_Tag to netCDF buffer failed: " + *newFileName);
329    
330     // FaceElements_Owner
331     if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )
332     throw DataException("Error - MeshAdapter::dump: appending FaceElements_Owner to netCDF file failed: " + *newFileName);
333     int_ptr = &mesh->FaceElements->Owner[0];
334     if (! (ids->put(int_ptr, num_FaceElements)) )
335     throw DataException("Error - MeshAdapter::dump: copy FaceElements_Owner to netCDF buffer failed: " + *newFileName);
336    
337     // FaceElements_Color
338     if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )
339     throw DataException("Error - MeshAdapter::dump: appending FaceElements_Color to netCDF file failed: " + *newFileName);
340     int_ptr = &mesh->FaceElements->Color[0];
341     if (! (ids->put(int_ptr, num_FaceElements)) )
342     throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);
343    
344     // FaceElements_Nodes
345     for (int i=0; i<num_FaceElements; i++)
346     for (int j=0; j<num_FaceElements_numNodes; j++)
347     FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = mesh->Nodes->Id[mesh->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)]];
348     if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
349     throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);
350     if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
351     throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);
352    
353 ksteube 1344 TMPMEMFREE(FaceElements_Nodes);
354    
355 ksteube 1343 }
356    
357     // // // // // Contact_Elements // // // // //
358    
359     if (num_ContactElements>0) {
360    
361     // Temp storage to gather node IDs
362     int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
363    
364     // ContactElements ReferenceElement->ElementTypeId
365     if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )
366     throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);
367    
368     // ContactElements_Id
369     if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
370     throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);
371     int_ptr = &mesh->ContactElements->Id[0];
372     if (! (ids->put(int_ptr, num_ContactElements)) )
373     throw DataException("Error - MeshAdapter::dump: copy ContactElements_Id to netCDF buffer failed: " + *newFileName);
374    
375     // ContactElements_Tag
376     if (! ( ids = dataFile.add_var("ContactElements_Tag", ncInt, ncdims[5])) )
377     throw DataException("Error - MeshAdapter::dump: appending ContactElements_Tag to netCDF file failed: " + *newFileName);
378     int_ptr = &mesh->ContactElements->Tag[0];
379     if (! (ids->put(int_ptr, num_ContactElements)) )
380     throw DataException("Error - MeshAdapter::dump: copy ContactElements_Tag to netCDF buffer failed: " + *newFileName);
381    
382     // ContactElements_Owner
383     if (! ( ids = dataFile.add_var("ContactElements_Owner", ncInt, ncdims[5])) )
384     throw DataException("Error - MeshAdapter::dump: appending ContactElements_Owner to netCDF file failed: " + *newFileName);
385     int_ptr = &mesh->ContactElements->Owner[0];
386     if (! (ids->put(int_ptr, num_ContactElements)) )
387     throw DataException("Error - MeshAdapter::dump: copy ContactElements_Owner to netCDF buffer failed: " + *newFileName);
388    
389     // ContactElements_Color
390     if (! ( ids = dataFile.add_var("ContactElements_Color", ncInt, ncdims[5])) )
391     throw DataException("Error - MeshAdapter::dump: appending ContactElements_Color to netCDF file failed: " + *newFileName);
392     int_ptr = &mesh->ContactElements->Color[0];
393     if (! (ids->put(int_ptr, num_ContactElements)) )
394     throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);
395    
396     // ContactElements_Nodes
397     for (int i=0; i<num_ContactElements; i++)
398     for (int j=0; j<num_ContactElements_numNodes; j++)
399     ContactElements_Nodes[INDEX2(j,i,num_ContactElements_numNodes)] = mesh->Nodes->Id[mesh->ContactElements->Nodes[INDEX2(j,i,num_ContactElements_numNodes)]];
400     if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )
401     throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);
402     if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
403     throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);
404    
405 ksteube 1344 TMPMEMFREE(ContactElements_Nodes);
406    
407 ksteube 1343 }
408    
409     // // // // // Points // // // // //
410    
411     if (num_Points>0) {
412    
413     fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");
414    
415     // Temp storage to gather node IDs
416     int *Points_Nodes = TMPMEMALLOC(num_Points,int);
417    
418     // Points ReferenceElement->ElementTypeId
419     if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )
420     throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);
421    
422     // Points_Id
423     if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
424     throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);
425     int_ptr = &mesh->Points->Id[0];
426     if (! (ids->put(int_ptr, num_Points)) )
427     throw DataException("Error - MeshAdapter::dump: copy Points_Id to netCDF buffer failed: " + *newFileName);
428    
429     // Points_Tag
430     if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )
431     throw DataException("Error - MeshAdapter::dump: appending Points_Tag to netCDF file failed: " + *newFileName);
432     int_ptr = &mesh->Points->Tag[0];
433     if (! (ids->put(int_ptr, num_Points)) )
434     throw DataException("Error - MeshAdapter::dump: copy Points_Tag to netCDF buffer failed: " + *newFileName);
435    
436     // Points_Owner
437     if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )
438     throw DataException("Error - MeshAdapter::dump: appending Points_Owner to netCDF file failed: " + *newFileName);
439     int_ptr = &mesh->Points->Owner[0];
440     if (! (ids->put(int_ptr, num_Points)) )
441     throw DataException("Error - MeshAdapter::dump: copy Points_Owner to netCDF buffer failed: " + *newFileName);
442    
443     // Points_Color
444     if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )
445     throw DataException("Error - MeshAdapter::dump: appending Points_Color to netCDF file failed: " + *newFileName);
446     int_ptr = &mesh->Points->Color[0];
447     if (! (ids->put(int_ptr, num_Points)) )
448     throw DataException("Error - MeshAdapter::dump: copy Points_Color to netCDF buffer failed: " + *newFileName);
449    
450     // Points_Nodes
451     // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
452     for (int i=0; i<num_Points; i++)
453     Points_Nodes[i] = mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]];
454     if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
455     throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);
456     if (! (ids->put(&(Points_Nodes[0]), num_Points)) )
457     throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);
458    
459 ksteube 1344 TMPMEMFREE(Points_Nodes);
460    
461 ksteube 1343 }
462    
463     // // // // // TagMap // // // // //
464    
465     fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump does not save the TagMap yet\n\n\n");
466    
467     // NetCDF file is closed by destructor of NcFile object
468     #else
469     Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
470     #endif /* USE_NETCDF */
471     checkFinleyError();
472 ksteube 1312 }
473    
474 jgs 82 string MeshAdapter::getDescription() const
475     {
476 ksteube 1312 return "FinleyMesh";
477 jgs 82 }
478    
479     string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const
480     {
481     FunctionSpaceNamesMapType::iterator loc;
482     loc=m_functionSpaceTypeNames.find(functionSpaceType);
483     if (loc==m_functionSpaceTypeNames.end()) {
484     return "Invalid function space type code.";
485     } else {
486 ksteube 1312 return loc->second;
487 jgs 82 }
488     }
489    
490     bool MeshAdapter::isValidFunctionSpaceType(int functionSpaceType) const
491     {
492     FunctionSpaceNamesMapType::iterator loc;
493     loc=m_functionSpaceTypeNames.find(functionSpaceType);
494     return (loc!=m_functionSpaceTypeNames.end());
495     }
496    
497     void MeshAdapter::setFunctionSpaceTypeNames()
498     {
499     m_functionSpaceTypeNames.insert
500     (FunctionSpaceNamesMapType::value_type(DegreesOfFreedom,"Finley_DegreesOfFreedom"));
501     m_functionSpaceTypeNames.insert
502     (FunctionSpaceNamesMapType::value_type(ReducedDegreesOfFreedom,"Finley_ReducedDegreesOfFreedom"));
503     m_functionSpaceTypeNames.insert
504     (FunctionSpaceNamesMapType::value_type(Nodes,"Finley_Nodes"));
505     m_functionSpaceTypeNames.insert
506 gross 1062 (FunctionSpaceNamesMapType::value_type(ReducedNodes,"Finley_Reduced_Nodes"));
507     m_functionSpaceTypeNames.insert
508 jgs 82 (FunctionSpaceNamesMapType::value_type(Elements,"Finley_Elements"));
509     m_functionSpaceTypeNames.insert
510 gross 1059 (FunctionSpaceNamesMapType::value_type(ReducedElements,"Finley_Reduced_Elements"));
511     m_functionSpaceTypeNames.insert
512 jgs 82 (FunctionSpaceNamesMapType::value_type(FaceElements,"Finley_Face_Elements"));
513     m_functionSpaceTypeNames.insert
514 gross 1059 (FunctionSpaceNamesMapType::value_type(ReducedFaceElements,"Finley_Reduced_Face_Elements"));
515     m_functionSpaceTypeNames.insert
516 jgs 82 (FunctionSpaceNamesMapType::value_type(Points,"Finley_Points"));
517     m_functionSpaceTypeNames.insert
518     (FunctionSpaceNamesMapType::value_type(ContactElementsZero,"Finley_Contact_Elements_0"));
519     m_functionSpaceTypeNames.insert
520 gross 1059 (FunctionSpaceNamesMapType::value_type(ReducedContactElementsZero,"Finley_Reduced_Contact_Elements_0"));
521     m_functionSpaceTypeNames.insert
522 jgs 82 (FunctionSpaceNamesMapType::value_type(ContactElementsOne,"Finley_Contact_Elements_1"));
523 gross 1059 m_functionSpaceTypeNames.insert
524     (FunctionSpaceNamesMapType::value_type(ReducedContactElementsOne,"Finley_Reduced_Contact_Elements_1"));
525 jgs 82 }
526    
527     int MeshAdapter::getContinuousFunctionCode() const
528     {
529     return Nodes;
530     }
531 gross 1062 int MeshAdapter::getReducedContinuousFunctionCode() const
532     {
533     return ReducedNodes;
534     }
535 jgs 149
536 jgs 82 int MeshAdapter::getFunctionCode() const
537     {
538     return Elements;
539     }
540 gross 1059 int MeshAdapter::getReducedFunctionCode() const
541     {
542     return ReducedElements;
543     }
544 jgs 149
545 jgs 82 int MeshAdapter::getFunctionOnBoundaryCode() const
546     {
547     return FaceElements;
548     }
549 gross 1059 int MeshAdapter::getReducedFunctionOnBoundaryCode() const
550     {
551     return ReducedFaceElements;
552     }
553 jgs 149
554 jgs 82 int MeshAdapter::getFunctionOnContactZeroCode() const
555     {
556     return ContactElementsZero;
557     }
558 gross 1059 int MeshAdapter::getReducedFunctionOnContactZeroCode() const
559     {
560     return ReducedContactElementsZero;
561     }
562 jgs 149
563 jgs 82 int MeshAdapter::getFunctionOnContactOneCode() const
564     {
565     return ContactElementsOne;
566     }
567 gross 1059 int MeshAdapter::getReducedFunctionOnContactOneCode() const
568     {
569     return ReducedContactElementsOne;
570     }
571 jgs 82
572     int MeshAdapter::getSolutionCode() const
573     {
574     return DegreesOfFreedom;
575     }
576 jgs 149
577 jgs 82 int MeshAdapter::getReducedSolutionCode() const
578     {
579     return ReducedDegreesOfFreedom;
580     }
581 jgs 149
582 jgs 82 int MeshAdapter::getDiracDeltaFunctionCode() const
583     {
584     return Points;
585     }
586 jgs 149
587 jgs 82 //
588     // return the spatial dimension of the Mesh:
589     //
590     int MeshAdapter::getDim() const
591     {
592     int numDim=Finley_Mesh_getDim(m_finleyMesh.get());
593     checkFinleyError();
594     return numDim;
595     }
596 jgs 149
597 jgs 82 //
598     // return the number of data points per sample and the number of samples
599     // needed to represent data on a parts of the mesh.
600     //
601     pair<int,int> MeshAdapter::getDataShape(int functionSpaceCode) const
602     {
603     int numDataPointsPerSample=0;
604     int numSamples=0;
605     Finley_Mesh* mesh=m_finleyMesh.get();
606     switch (functionSpaceCode) {
607     case(Nodes):
608     numDataPointsPerSample=1;
609 ksteube 1312 numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);
610 jgs 82 break;
611 gross 1062 case(ReducedNodes):
612     numDataPointsPerSample=1;
613 ksteube 1312 numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);
614 gross 1062 break;
615 jgs 82 case(Elements):
616     if (mesh->Elements!=NULL) {
617     numSamples=mesh->Elements->numElements;
618     numDataPointsPerSample=mesh->Elements->ReferenceElement->numQuadNodes;
619     }
620     break;
621 gross 1062 case(ReducedElements):
622     if (mesh->Elements!=NULL) {
623     numSamples=mesh->Elements->numElements;
624     numDataPointsPerSample=mesh->Elements->ReferenceElementReducedOrder->numQuadNodes;
625     }
626     break;
627 jgs 82 case(FaceElements):
628     if (mesh->FaceElements!=NULL) {
629     numDataPointsPerSample=mesh->FaceElements->ReferenceElement->numQuadNodes;
630     numSamples=mesh->FaceElements->numElements;
631     }
632     break;
633 gross 1062 case(ReducedFaceElements):
634     if (mesh->FaceElements!=NULL) {
635     numDataPointsPerSample=mesh->FaceElements->ReferenceElementReducedOrder->numQuadNodes;
636     numSamples=mesh->FaceElements->numElements;
637     }
638     break;
639 jgs 82 case(Points):
640     if (mesh->Points!=NULL) {
641     numDataPointsPerSample=1;
642     numSamples=mesh->Points->numElements;
643     }
644     break;
645     case(ContactElementsZero):
646     if (mesh->ContactElements!=NULL) {
647     numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;
648     numSamples=mesh->ContactElements->numElements;
649     }
650     break;
651 gross 1062 case(ReducedContactElementsZero):
652     if (mesh->ContactElements!=NULL) {
653     numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;
654     numSamples=mesh->ContactElements->numElements;
655     }
656     break;
657 jgs 82 case(ContactElementsOne):
658     if (mesh->ContactElements!=NULL) {
659     numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;
660     numSamples=mesh->ContactElements->numElements;
661     }
662     break;
663 gross 1062 case(ReducedContactElementsOne):
664     if (mesh->ContactElements!=NULL) {
665     numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;
666     numSamples=mesh->ContactElements->numElements;
667     }
668     break;
669 jgs 82 case(DegreesOfFreedom):
670     if (mesh->Nodes!=NULL) {
671     numDataPointsPerSample=1;
672 ksteube 1312 numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);
673 jgs 82 }
674     break;
675     case(ReducedDegreesOfFreedom):
676     if (mesh->Nodes!=NULL) {
677     numDataPointsPerSample=1;
678 ksteube 1312 numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);
679 jgs 82 }
680     break;
681     default:
682     stringstream temp;
683 jgs 150 temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();
684 jgs 82 throw FinleyAdapterException(temp.str());
685     break;
686     }
687     return pair<int,int>(numDataPointsPerSample,numSamples);
688     }
689 jgs 149
690 jgs 82 //
691     // adds linear PDE of second order into a given stiffness matrix and right hand side:
692     //
693     void MeshAdapter::addPDEToSystem(
694 jgs 480 SystemMatrixAdapter& mat, escript::Data& rhs,
695     const escript::Data& A, const escript::Data& B, const escript::Data& C,const escript::Data& D,const escript::Data& X,const escript::Data& Y,
696     const escript::Data& d, const escript::Data& y,
697     const escript::Data& d_contact,const escript::Data& y_contact) const
698 jgs 82 {
699 gross 798 escriptDataC _rhs=rhs.getDataC();
700     escriptDataC _A =A.getDataC();
701     escriptDataC _B=B.getDataC();
702     escriptDataC _C=C.getDataC();
703     escriptDataC _D=D.getDataC();
704     escriptDataC _X=X.getDataC();
705     escriptDataC _Y=Y.getDataC();
706     escriptDataC _d=d.getDataC();
707     escriptDataC _y=y.getDataC();
708     escriptDataC _d_contact=d_contact.getDataC();
709     escriptDataC _y_contact=y_contact.getDataC();
710 bcumming 751
711 jgs 82 Finley_Mesh* mesh=m_finleyMesh.get();
712 gross 798
713 bcumming 751 Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(), &_rhs, &_A, &_B, &_C, &_D, &_X, &_Y );
714 jgs 82 checkFinleyError();
715 bcumming 751
716 gross 798 Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, mat.getPaso_SystemMatrix(), &_rhs, 0, 0, 0, &_d, 0, &_y );
717 jgs 82 checkFinleyError();
718 bcumming 751
719 gross 798 Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, mat.getPaso_SystemMatrix(), &_rhs , 0, 0, 0, &_d_contact, 0, &_y_contact );
720 jgs 82 checkFinleyError();
721     }
722 jgs 149
723 gross 1204 void MeshAdapter::addPDEToLumpedSystem(
724     escript::Data& mat,
725 ksteube 1312 const escript::Data& D,
726 gross 1204 const escript::Data& d) const
727     {
728     escriptDataC _mat=mat.getDataC();
729     escriptDataC _D=D.getDataC();
730     escriptDataC _d=d.getDataC();
731    
732     Finley_Mesh* mesh=m_finleyMesh.get();
733 ksteube 1312
734 gross 1204 Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);
735     Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);
736    
737     checkFinleyError();
738     }
739    
740    
741 jgs 82 //
742 jgs 102 // adds linear PDE of second order into the right hand side only
743     //
744 bcumming 751 void MeshAdapter::addPDEToRHS( escript::Data& rhs, const escript::Data& X,const escript::Data& Y, const escript::Data& y, const escript::Data& y_contact) const
745 jgs 102 {
746     Finley_Mesh* mesh=m_finleyMesh.get();
747 jgs 147
748 gross 798 escriptDataC _rhs=rhs.getDataC();
749     escriptDataC _X=X.getDataC();
750     escriptDataC _Y=Y.getDataC();
751     escriptDataC _y=y.getDataC();
752     escriptDataC _y_contact=y_contact.getDataC();
753    
754     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements, 0, &_rhs, 0, 0, 0, 0, &_X, &_Y );
755 jgs 102 checkFinleyError();
756 jgs 147
757 gross 798 Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, 0, &_rhs, 0, 0, 0, 0, 0, &_y );
758     checkFinleyError();
759 jgs 147
760 gross 798 Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );
761 jgs 102 checkFinleyError();
762     }
763 jgs 149
764 jgs 102 //
765 jgs 82 // interpolates data between different function spaces:
766     //
767 jgs 480 void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const
768 jgs 82 {
769     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());
770     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());
771 bcumming 751 if (inDomain!=*this)
772     throw FinleyAdapterException("Error - Illegal domain of interpolant.");
773 jgs 82 if (targetDomain!=*this)
774 bcumming 751 throw FinleyAdapterException("Error - Illegal domain of interpolation target.");
775 jgs 82
776     Finley_Mesh* mesh=m_finleyMesh.get();
777 gross 1062 escriptDataC _target=target.getDataC();
778     escriptDataC _in=in.getDataC();
779 jgs 82 switch(in.getFunctionSpace().getTypeCode()) {
780     case(Nodes):
781     switch(target.getFunctionSpace().getTypeCode()) {
782     case(Nodes):
783 gross 1062 case(ReducedNodes):
784     case(DegreesOfFreedom):
785 jgs 82 case(ReducedDegreesOfFreedom):
786 gross 1062 Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
787     break;
788     case(Elements):
789     case(ReducedElements):
790     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
791     break;
792     case(FaceElements):
793     case(ReducedFaceElements):
794     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
795     break;
796     case(Points):
797     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
798     break;
799     case(ContactElementsZero):
800     case(ReducedContactElementsZero):
801     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
802     break;
803     case(ContactElementsOne):
804     case(ReducedContactElementsOne):
805     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
806     break;
807     default:
808     stringstream temp;
809     temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
810     throw FinleyAdapterException(temp.str());
811     break;
812     }
813     break;
814     case(ReducedNodes):
815     switch(target.getFunctionSpace().getTypeCode()) {
816     case(Nodes):
817     case(ReducedNodes):
818 jgs 82 case(DegreesOfFreedom):
819 gross 1062 case(ReducedDegreesOfFreedom):
820     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
821 jgs 82 break;
822     case(Elements):
823 gross 1062 case(ReducedElements):
824     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
825 jgs 82 break;
826     case(FaceElements):
827 gross 1062 case(ReducedFaceElements):
828     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
829 jgs 82 break;
830     case(Points):
831 gross 1062 Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
832 jgs 82 break;
833     case(ContactElementsZero):
834 gross 1062 case(ReducedContactElementsZero):
835     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
836 jgs 82 break;
837     case(ContactElementsOne):
838 gross 1062 case(ReducedContactElementsOne):
839     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
840 jgs 82 break;
841     default:
842 jgs 150 stringstream temp;
843     temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
844     throw FinleyAdapterException(temp.str());
845 jgs 82 break;
846     }
847     break;
848     case(Elements):
849     if (target.getFunctionSpace().getTypeCode()==Elements) {
850 gross 1062 Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
851 gross 1116 } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
852     Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);
853 jgs 82 } else {
854 jgs 150 throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
855 jgs 82 }
856     break;
857 gross 1062 case(ReducedElements):
858     if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
859     Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
860     } else {
861     throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");
862     }
863     break;
864 jgs 82 case(FaceElements):
865     if (target.getFunctionSpace().getTypeCode()==FaceElements) {
866 gross 1062 Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
867 gross 1116 } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
868     Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
869 jgs 82 } else {
870 jgs 150 throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
871 jgs 82 }
872 gross 1062 break;
873     case(ReducedFaceElements):
874     if (target.getFunctionSpace().getTypeCode()==FaceElements) {
875     Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
876     } else {
877     throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
878     }
879     break;
880 jgs 82 case(Points):
881     if (target.getFunctionSpace().getTypeCode()==Points) {
882 gross 1062 Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);
883 jgs 82 } else {
884 jgs 150 throw FinleyAdapterException("Error - No interpolation with data on points possible.");
885 jgs 82 }
886     break;
887     case(ContactElementsZero):
888     case(ContactElementsOne):
889     if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
890 gross 1062 Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
891 gross 1116 } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
892     Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);
893 jgs 82 } else {
894 jgs 150 throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
895 jgs 82 break;
896     }
897     break;
898 gross 1062 case(ReducedContactElementsZero):
899     case(ReducedContactElementsOne):
900     if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
901     Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
902     } else {
903     throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");
904     break;
905     }
906     break;
907 bcumming 751 case(DegreesOfFreedom):
908 jgs 82 switch(target.getFunctionSpace().getTypeCode()) {
909     case(ReducedDegreesOfFreedom):
910     case(DegreesOfFreedom):
911 ksteube 1312 Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
912     break;
913    
914 jgs 82 case(Nodes):
915 gross 1062 case(ReducedNodes):
916 ksteube 1312 if (getMPISize()>1) {
917     escript::Data temp=escript::Data(in);
918     temp.expand();
919     escriptDataC _in2 = temp.getDataC();
920     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
921     } else {
922     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
923     }
924 jgs 82 break;
925     case(Elements):
926 gross 1062 case(ReducedElements):
927 ksteube 1312 if (getMPISize()>1) {
928     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
929     escriptDataC _in2 = temp.getDataC();
930     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
931     } else {
932     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
933     }
934 jgs 82 break;
935     case(FaceElements):
936 gross 1062 case(ReducedFaceElements):
937 ksteube 1312 if (getMPISize()>1) {
938     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
939     escriptDataC _in2 = temp.getDataC();
940     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
941    
942     } else {
943     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
944     }
945 jgs 82 break;
946     case(Points):
947 ksteube 1312 if (getMPISize()>1) {
948     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
949     escriptDataC _in2 = temp.getDataC();
950     } else {
951     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
952     }
953 jgs 82 break;
954     case(ContactElementsZero):
955     case(ContactElementsOne):
956 gross 1062 case(ReducedContactElementsZero):
957     case(ReducedContactElementsOne):
958 ksteube 1312 if (getMPISize()>1) {
959     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
960     escriptDataC _in2 = temp.getDataC();
961     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
962     } else {
963     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
964     }
965 jgs 82 break;
966     default:
967 jgs 150 stringstream temp;
968     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
969     throw FinleyAdapterException(temp.str());
970 jgs 82 break;
971     }
972     break;
973     case(ReducedDegreesOfFreedom):
974     switch(target.getFunctionSpace().getTypeCode()) {
975 gross 1062 case(Nodes):
976     throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
977     break;
978     case(ReducedNodes):
979 ksteube 1312 if (getMPISize()>1) {
980     escript::Data temp=escript::Data(in);
981     temp.expand();
982     escriptDataC _in2 = temp.getDataC();
983     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
984     } else {
985     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
986     }
987     break;
988 gross 1062 case(DegreesOfFreedom):
989     throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
990     break;
991 jgs 82 case(ReducedDegreesOfFreedom):
992 gross 1062 Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
993 jgs 82 break;
994     case(Elements):
995 gross 1062 case(ReducedElements):
996 ksteube 1312 if (getMPISize()>1) {
997     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
998     escriptDataC _in2 = temp.getDataC();
999     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
1000     } else {
1001     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
1002     }
1003 jgs 82 break;
1004     case(FaceElements):
1005 gross 1062 case(ReducedFaceElements):
1006 ksteube 1312 if (getMPISize()>1) {
1007     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
1008     escriptDataC _in2 = temp.getDataC();
1009     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1010     } else {
1011     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
1012     }
1013 jgs 82 break;
1014     case(Points):
1015 ksteube 1312 if (getMPISize()>1) {
1016     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
1017     escriptDataC _in2 = temp.getDataC();
1018     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
1019     } else {
1020     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1021     }
1022 jgs 82 break;
1023     case(ContactElementsZero):
1024     case(ContactElementsOne):
1025 gross 1062 case(ReducedContactElementsZero):
1026     case(ReducedContactElementsOne):
1027 ksteube 1312 if (getMPISize()>1) {
1028     escript::Data temp=escript::Data( in, continuousFunction(asAbstractContinuousDomain()) );
1029     escriptDataC _in2 = temp.getDataC();
1030     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1031     } else {
1032     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1033     }
1034 jgs 82 break;
1035     default:
1036 jgs 150 stringstream temp;
1037     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
1038     throw FinleyAdapterException(temp.str());
1039 jgs 82 break;
1040     }
1041     break;
1042     default:
1043 jgs 150 stringstream temp;
1044     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();
1045     throw FinleyAdapterException(temp.str());
1046 jgs 82 break;
1047     }
1048     checkFinleyError();
1049     }
1050    
1051     //
1052     // copies the locations of sample points into x:
1053     //
1054 jgs 480 void MeshAdapter::setToX(escript::Data& arg) const
1055 jgs 82 {
1056     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
1057     if (argDomain!=*this)
1058     throw FinleyAdapterException("Error - Illegal domain of data point locations");
1059     Finley_Mesh* mesh=m_finleyMesh.get();
1060     // in case of values node coordinates we can do the job directly:
1061     if (arg.getFunctionSpace().getTypeCode()==Nodes) {
1062 gross 1062 escriptDataC _arg=arg.getDataC();
1063     Finley_Assemble_NodeCoordinates(mesh->Nodes,&_arg);
1064 jgs 82 } else {
1065 jgs 480 escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);
1066 gross 1062 escriptDataC _tmp_data=tmp_data.getDataC();
1067     Finley_Assemble_NodeCoordinates(mesh->Nodes,&_tmp_data);
1068 jgs 82 // this is then interpolated onto arg:
1069     interpolateOnDomain(arg,tmp_data);
1070     }
1071     checkFinleyError();
1072     }
1073 jgs 149
1074 jgs 82 //
1075     // return the normal vectors at the location of data points as a Data object:
1076     //
1077 jgs 480 void MeshAdapter::setToNormal(escript::Data& normal) const
1078 jgs 82 {
1079     const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());
1080     if (normalDomain!=*this)
1081     throw FinleyAdapterException("Error - Illegal domain of normal locations");
1082     Finley_Mesh* mesh=m_finleyMesh.get();
1083 gross 1062 escriptDataC _normal=normal.getDataC();
1084 jgs 82 switch(normal.getFunctionSpace().getTypeCode()) {
1085     case(Nodes):
1086 jgs 150 throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");
1087 jgs 82 break;
1088 gross 1062 case(ReducedNodes):
1089     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced nodes");
1090     break;
1091 jgs 82 case(Elements):
1092 jgs 150 throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");
1093 jgs 82 break;
1094 gross 1062 case(ReducedElements):
1095     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements with reduced integration order");
1096     break;
1097 jgs 82 case (FaceElements):
1098 gross 1062 Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1099 jgs 82 break;
1100 gross 1062 case (ReducedFaceElements):
1101     Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1102     break;
1103 jgs 82 case(Points):
1104 jgs 150 throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");
1105 jgs 82 break;
1106     case (ContactElementsOne):
1107     case (ContactElementsZero):
1108 gross 1062 Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);
1109 jgs 82 break;
1110 gross 1062 case (ReducedContactElementsOne):
1111     case (ReducedContactElementsZero):
1112     Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);
1113     break;
1114 jgs 82 case(DegreesOfFreedom):
1115 jgs 150 throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");
1116 jgs 82 break;
1117     case(ReducedDegreesOfFreedom):
1118 jgs 150 throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced degrees of freedom.");
1119 jgs 82 break;
1120     default:
1121 jgs 150 stringstream temp;
1122     temp << "Error - Normal Vectors: Finley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();
1123     throw FinleyAdapterException(temp.str());
1124 jgs 82 break;
1125     }
1126     checkFinleyError();
1127     }
1128 jgs 149
1129 jgs 82 //
1130     // interpolates data to other domain:
1131     //
1132 jgs 480 void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const
1133 jgs 82 {
1134     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());
1135     if (targetDomain!=*this)
1136     throw FinleyAdapterException("Error - Illegal domain of interpolation target");
1137    
1138 jgs 150 throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");
1139 jgs 82 }
1140 jgs 149
1141 jgs 82 //
1142     // calculates the integral of a function defined of arg:
1143     //
1144 jgs 480 void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const
1145 jgs 82 {
1146     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
1147     if (argDomain!=*this)
1148     throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1149    
1150 ksteube 1312 double blocktimer_start = blocktimer_time();
1151 jgs 82 Finley_Mesh* mesh=m_finleyMesh.get();
1152 ksteube 1312 escriptDataC _temp;
1153     escript::Data temp;
1154 gross 1062 escriptDataC _arg=arg.getDataC();
1155 jgs 82 switch(arg.getFunctionSpace().getTypeCode()) {
1156     case(Nodes):
1157 ksteube 1312 temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1158     _temp=temp.getDataC();
1159     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1160 jgs 82 break;
1161 gross 1062 case(ReducedNodes):
1162 ksteube 1312 temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1163     _temp=temp.getDataC();
1164     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1165 gross 1062 break;
1166 jgs 82 case(Elements):
1167 gross 1062 Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1168 jgs 82 break;
1169 gross 1062 case(ReducedElements):
1170     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1171 gross 1064 break;
1172 jgs 82 case(FaceElements):
1173 gross 1062 Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1174 jgs 82 break;
1175 gross 1062 case(ReducedFaceElements):
1176     Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1177     break;
1178 jgs 82 case(Points):
1179 jgs 150 throw FinleyAdapterException("Error - Integral of data on points is not supported.");
1180 jgs 82 break;
1181     case(ContactElementsZero):
1182 gross 1062 Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1183 jgs 82 break;
1184 gross 1062 case(ReducedContactElementsZero):
1185     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1186     break;
1187 jgs 82 case(ContactElementsOne):
1188 gross 1062 Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1189 jgs 82 break;
1190 gross 1062 case(ReducedContactElementsOne):
1191     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1192     break;
1193 jgs 82 case(DegreesOfFreedom):
1194 ksteube 1312 temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1195     _temp=temp.getDataC();
1196     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1197 jgs 82 break;
1198     case(ReducedDegreesOfFreedom):
1199 ksteube 1312 temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1200     _temp=temp.getDataC();
1201     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1202 jgs 82 break;
1203     default:
1204 jgs 150 stringstream temp;
1205     temp << "Error - Integrals: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
1206     throw FinleyAdapterException(temp.str());
1207 jgs 82 break;
1208     }
1209     checkFinleyError();
1210 ksteube 1312 blocktimer_increment("integrate()", blocktimer_start);
1211 jgs 82 }
1212 jgs 149
1213 jgs 82 //
1214     // calculates the gradient of arg:
1215     //
1216 jgs 480 void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
1217 jgs 82 {
1218     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
1219     if (argDomain!=*this)
1220     throw FinleyAdapterException("Error - Illegal domain of gradient argument");
1221     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(grad.getFunctionSpace().getDomain());
1222     if (gradDomain!=*this)
1223     throw FinleyAdapterException("Error - Illegal domain of gradient");
1224    
1225     Finley_Mesh* mesh=m_finleyMesh.get();
1226 gross 1062 escriptDataC _grad=grad.getDataC();
1227 bcumming 751 escriptDataC nodeDataC;
1228 ksteube 1312 escript::Data temp;
1229     if (getMPISize()>1) {
1230     if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {
1231     temp=escript::Data( arg, continuousFunction(asAbstractContinuousDomain()) );
1232     nodeDataC = temp.getDataC();
1233     } else if( arg.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom ) {
1234     temp=escript::Data( arg, reducedContinuousFunction(asAbstractContinuousDomain()) );
1235     nodeDataC = temp.getDataC();
1236     } else {
1237     nodeDataC = arg.getDataC();
1238     }
1239     } else {
1240     nodeDataC = arg.getDataC();
1241 bcumming 751 }
1242 jgs 82 switch(grad.getFunctionSpace().getTypeCode()) {
1243     case(Nodes):
1244 jgs 150 throw FinleyAdapterException("Error - Gradient at nodes is not supported.");
1245 jgs 82 break;
1246 gross 1062 case(ReducedNodes):
1247     throw FinleyAdapterException("Error - Gradient at reduced nodes is not supported.");
1248     break;
1249 jgs 82 case(Elements):
1250 gross 1062 Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1251 jgs 82 break;
1252 gross 1062 case(ReducedElements):
1253     Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1254     break;
1255 jgs 82 case(FaceElements):
1256 gross 1062 Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1257 jgs 82 break;
1258 gross 1062 case(ReducedFaceElements):
1259     Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1260     break;
1261 jgs 82 case(Points):
1262 jgs 150 throw FinleyAdapterException("Error - Gradient at points is not supported.");
1263 jgs 82 break;
1264     case(ContactElementsZero):
1265 gross 1062 Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1266 jgs 82 break;
1267 gross 1062 case(ReducedContactElementsZero):
1268     Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1269     break;
1270 jgs 82 case(ContactElementsOne):
1271 gross 1062 Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1272 jgs 82 break;
1273 gross 1062 case(ReducedContactElementsOne):
1274     Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1275     break;
1276 jgs 82 case(DegreesOfFreedom):
1277 jgs 150 throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");
1278 jgs 82 break;
1279     case(ReducedDegreesOfFreedom):
1280 jgs 150 throw FinleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");
1281 jgs 82 break;
1282     default:
1283 jgs 150 stringstream temp;
1284     temp << "Error - Gradient: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
1285     throw FinleyAdapterException(temp.str());
1286 jgs 82 break;
1287     }
1288     checkFinleyError();
1289     }
1290 jgs 149
1291 jgs 82 //
1292     // returns the size of elements:
1293     //
1294 jgs 480 void MeshAdapter::setToSize(escript::Data& size) const
1295 jgs 82 {
1296     Finley_Mesh* mesh=m_finleyMesh.get();
1297     escriptDataC tmp=size.getDataC();
1298     switch(size.getFunctionSpace().getTypeCode()) {
1299     case(Nodes):
1300 jgs 150 throw FinleyAdapterException("Error - Size of nodes is not supported.");
1301 jgs 82 break;
1302 gross 1062 case(ReducedNodes):
1303     throw FinleyAdapterException("Error - Size of reduced nodes is not supported.");
1304     break;
1305 jgs 82 case(Elements):
1306     Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1307     break;
1308 gross 1062 case(ReducedElements):
1309     Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1310     break;
1311 jgs 82 case(FaceElements):
1312     Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1313     break;
1314 gross 1062 case(ReducedFaceElements):
1315     Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1316     break;
1317 jgs 82 case(Points):
1318 jgs 150 throw FinleyAdapterException("Error - Size of point elements is not supported.");
1319 jgs 82 break;
1320     case(ContactElementsZero):
1321     case(ContactElementsOne):
1322     Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
1323     break;
1324 gross 1062 case(ReducedContactElementsZero):
1325     case(ReducedContactElementsOne):
1326     Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
1327     break;
1328 jgs 82 case(DegreesOfFreedom):
1329 jgs 150 throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");
1330 jgs 82 break;
1331     case(ReducedDegreesOfFreedom):
1332 jgs 150 throw FinleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");
1333 jgs 82 break;
1334     default:
1335 jgs 150 stringstream temp;
1336     temp << "Error - Element size: Finley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();
1337     throw FinleyAdapterException(temp.str());
1338 jgs 82 break;
1339     }
1340     checkFinleyError();
1341     }
1342 jgs 149
1343 jgs 82 // sets the location of nodes:
1344 jgs 480 void MeshAdapter::setNewX(const escript::Data& new_x)
1345 jgs 82 {
1346     Finley_Mesh* mesh=m_finleyMesh.get();
1347 bcumming 751 escriptDataC tmp;
1348 jgs 82 const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());
1349     if (newDomain!=*this)
1350     throw FinleyAdapterException("Error - Illegal domain of new point locations");
1351 bcumming 751 tmp = new_x.getDataC();
1352     Finley_Mesh_setCoordinates(mesh,&tmp);
1353 jgs 82 checkFinleyError();
1354     }
1355 jgs 149
1356 jgs 82 // saves a data array in openDX format:
1357 jgs 153 void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const
1358     {
1359     int MAX_namelength=256;
1360     const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1361 woo409 757 /* win32 refactor */
1362     char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1363     for(int i=0;i<num_data;i++)
1364     {
1365     names[i] = (MAX_namelength>0) ? TMPMEMALLOC(MAX_namelength,char) : (char*)NULL;
1366     }
1367 jgs 153
1368 woo409 757 char* *c_names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1369     escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1370     escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1371    
1372 ksteube 1312 boost::python::list keys=arg.keys();
1373     for (int i=0;i<num_data;++i) {
1374     std::string n=boost::python::extract<std::string>(keys[i]);
1375 jgs 480 escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1376 jgs 153 if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1377 ksteube 1312 throw FinleyAdapterException("Error in saveVTK: Data must be defined on same Domain");
1378 jgs 153 data[i]=d.getDataC();
1379     ptr_data[i]=&(data[i]);
1380     c_names[i]=&(names[i][0]);
1381     if (n.length()>MAX_namelength-1) {
1382     strncpy(c_names[i],n.c_str(),MAX_namelength-1);
1383     c_names[i][MAX_namelength-1]='\0';
1384     } else {
1385     strcpy(c_names[i],n.c_str());
1386     }
1387     }
1388     Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
1389     checkFinleyError();
1390 woo409 757
1391     /* win32 refactor */
1392     TMPMEMFREE(c_names);
1393     TMPMEMFREE(data);
1394     TMPMEMFREE(ptr_data);
1395     for(int i=0;i<num_data;i++)
1396     {
1397     TMPMEMFREE(names[i]);
1398     }
1399     TMPMEMFREE(names);
1400    
1401 jgs 153 return;
1402 jgs 82 }
1403 jgs 149
1404 jgs 110 // saves a data array in openVTK format:
1405 jgs 153 void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const
1406     {
1407     int MAX_namelength=256;
1408     const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1409 woo409 757 /* win32 refactor */
1410     char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1411     for(int i=0;i<num_data;i++)
1412     {
1413     names[i] = (MAX_namelength>0) ? TMPMEMALLOC(MAX_namelength,char) : (char*)NULL;
1414     }
1415 jgs 153
1416 woo409 757 char* *c_names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1417     escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1418     escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1419    
1420 jgs 153 boost::python::list keys=arg.keys();
1421     for (int i=0;i<num_data;++i) {
1422 ksteube 1312 std::string n=boost::python::extract<std::string>(keys[i]);
1423 jgs 480 escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1424 jgs 153 if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1425     throw FinleyAdapterException("Error in saveVTK: Data must be defined on same Domain");
1426     data[i]=d.getDataC();
1427     ptr_data[i]=&(data[i]);
1428     c_names[i]=&(names[i][0]);
1429     if (n.length()>MAX_namelength-1) {
1430     strncpy(c_names[i],n.c_str(),MAX_namelength-1);
1431     c_names[i][MAX_namelength-1]='\0';
1432     } else {
1433     strcpy(c_names[i],n.c_str());
1434     }
1435     }
1436     Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
1437 dhawcroft 793
1438 ksteube 1312 checkFinleyError();
1439 woo409 757 /* win32 refactor */
1440     TMPMEMFREE(c_names);
1441     TMPMEMFREE(data);
1442     TMPMEMFREE(ptr_data);
1443     for(int i=0;i<num_data;i++)
1444     {
1445     TMPMEMFREE(names[i]);
1446     }
1447     TMPMEMFREE(names);
1448    
1449 jgs 153 return;
1450 jgs 110 }
1451 jgs 153
1452    
1453 jgs 82 // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
1454     SystemMatrixAdapter MeshAdapter::newSystemMatrix(
1455     const int row_blocksize,
1456     const escript::FunctionSpace& row_functionspace,
1457     const int column_blocksize,
1458     const escript::FunctionSpace& column_functionspace,
1459 jgs 102 const int type) const
1460 jgs 82 {
1461     int reduceRowOrder=0;
1462     int reduceColOrder=0;
1463     // is the domain right?
1464     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(row_functionspace.getDomain());
1465     if (row_domain!=*this)
1466     throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");
1467     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(column_functionspace.getDomain());
1468     if (col_domain!=*this)
1469     throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");
1470     // is the function space type right
1471     if (row_functionspace.getTypeCode()==DegreesOfFreedom) {
1472     reduceRowOrder=0;
1473     } else if (row_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1474     reduceRowOrder=1;
1475     } else {
1476     throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");
1477     }
1478     if (column_functionspace.getTypeCode()==DegreesOfFreedom) {
1479     reduceColOrder=0;
1480     } else if (column_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1481     reduceColOrder=1;
1482     } else {
1483     throw FinleyAdapterException("Error - illegal function space type for system matrix columns.");
1484     }
1485     // generate matrix:
1486 jgs 102
1487 jgs 150 Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
1488 jgs 82 checkFinleyError();
1489 ksteube 1312 Paso_SystemMatrix* fsystemMatrix;
1490     int trilinos = 0;
1491     if (trilinos) {
1492     #ifdef TRILINOS
1493     /* Allocation Epetra_VrbMatrix here */
1494     #endif
1495     }
1496     else {
1497     fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
1498     }
1499 jgs 150 checkPasoError();
1500 ksteube 1312 Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1501 jgs 82 return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
1502     }
1503 jgs 149
1504 jgs 82 //
1505     // vtkObject MeshAdapter::createVtkObject() const
1506     // TODO:
1507     //
1508 jgs 149
1509 jgs 82 //
1510     // returns true if data at the atom_type is considered as being cell centered:
1511     bool MeshAdapter::isCellOriented(int functionSpaceCode) const
1512     {
1513     switch(functionSpaceCode) {
1514     case(Nodes):
1515     case(DegreesOfFreedom):
1516     case(ReducedDegreesOfFreedom):
1517     return false;
1518     break;
1519     case(Elements):
1520     case(FaceElements):
1521     case(Points):
1522     case(ContactElementsZero):
1523     case(ContactElementsOne):
1524 gross 1062 case(ReducedElements):
1525     case(ReducedFaceElements):
1526     case(ReducedContactElementsZero):
1527     case(ReducedContactElementsOne):
1528 jgs 82 return true;
1529     break;
1530     default:
1531 jgs 150 stringstream temp;
1532     temp << "Error - Cell: Finley does not know anything about function space type " << functionSpaceCode;
1533     throw FinleyAdapterException(temp.str());
1534 jgs 82 break;
1535     }
1536     checkFinleyError();
1537     return false;
1538     }
1539 jgs 149
1540 jgs 82 bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
1541     {
1542     switch(functionSpaceType_source) {
1543     case(Nodes):
1544     switch(functionSpaceType_target) {
1545     case(Nodes):
1546 gross 1062 case(ReducedNodes):
1547 jgs 82 case(ReducedDegreesOfFreedom):
1548     case(DegreesOfFreedom):
1549     case(Elements):
1550 gross 1062 case(ReducedElements):
1551 jgs 82 case(FaceElements):
1552 gross 1062 case(ReducedFaceElements):
1553 jgs 82 case(Points):
1554     case(ContactElementsZero):
1555 gross 1062 case(ReducedContactElementsZero):
1556 jgs 82 case(ContactElementsOne):
1557 gross 1062 case(ReducedContactElementsOne):
1558 jgs 82 return true;
1559     default:
1560 jgs 150 stringstream temp;
1561     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1562     throw FinleyAdapterException(temp.str());
1563 jgs 82 }
1564     break;
1565 gross 1062 case(ReducedNodes):
1566     switch(functionSpaceType_target) {
1567     case(ReducedNodes):
1568     case(ReducedDegreesOfFreedom):
1569     case(Elements):
1570     case(ReducedElements):
1571     case(FaceElements):
1572     case(ReducedFaceElements):
1573     case(Points):
1574     case(ContactElementsZero):
1575     case(ReducedContactElementsZero):
1576     case(ContactElementsOne):
1577     case(ReducedContactElementsOne):
1578     return true;
1579     case(Nodes):
1580     case(DegreesOfFreedom):
1581     return false;
1582     default:
1583     stringstream temp;
1584     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1585     throw FinleyAdapterException(temp.str());
1586     }
1587     break;
1588 jgs 82 case(Elements):
1589     if (functionSpaceType_target==Elements) {
1590     return true;
1591 gross 1116 } else if (functionSpaceType_target==ReducedElements) {
1592     return true;
1593 jgs 82 } else {
1594     return false;
1595     }
1596 gross 1062 case(ReducedElements):
1597     if (functionSpaceType_target==ReducedElements) {
1598     return true;
1599     } else {
1600     return false;
1601     }
1602 jgs 82 case(FaceElements):
1603     if (functionSpaceType_target==FaceElements) {
1604     return true;
1605 gross 1116 } else if (functionSpaceType_target==ReducedFaceElements) {
1606     return true;
1607 jgs 82 } else {
1608     return false;
1609     }
1610 gross 1062 case(ReducedFaceElements):
1611     if (functionSpaceType_target==ReducedFaceElements) {
1612     return true;
1613     } else {
1614     return false;
1615     }
1616 jgs 82 case(Points):
1617     if (functionSpaceType_target==Points) {
1618     return true;
1619     } else {
1620     return false;
1621     }
1622     case(ContactElementsZero):
1623     case(ContactElementsOne):
1624     if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1625     return true;
1626 gross 1116 } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1627     return true;
1628 jgs 82 } else {
1629     return false;
1630     }
1631 gross 1062 case(ReducedContactElementsZero):
1632     case(ReducedContactElementsOne):
1633     if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1634     return true;
1635     } else {
1636     return false;
1637     }
1638 jgs 82 case(DegreesOfFreedom):
1639     switch(functionSpaceType_target) {
1640     case(ReducedDegreesOfFreedom):
1641     case(DegreesOfFreedom):
1642     case(Nodes):
1643 gross 1062 case(ReducedNodes):
1644 jgs 82 case(Elements):
1645 gross 1062 case(ReducedElements):
1646     case(Points):
1647 jgs 82 case(FaceElements):
1648 gross 1062 case(ReducedFaceElements):
1649 jgs 82 case(ContactElementsZero):
1650 gross 1062 case(ReducedContactElementsZero):
1651 jgs 82 case(ContactElementsOne):
1652 gross 1062 case(ReducedContactElementsOne):
1653 jgs 82 return true;
1654     default:
1655 jgs 150 stringstream temp;
1656     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1657     throw FinleyAdapterException(temp.str());
1658 jgs 82 }
1659     break;
1660     case(ReducedDegreesOfFreedom):
1661     switch(functionSpaceType_target) {
1662     case(ReducedDegreesOfFreedom):
1663 gross 1062 case(ReducedNodes):
1664 jgs 82 case(Elements):
1665 gross 1062 case(ReducedElements):
1666 jgs 82 case(FaceElements):
1667 gross 1062 case(ReducedFaceElements):
1668 jgs 82 case(Points):
1669     case(ContactElementsZero):
1670 gross 1062 case(ReducedContactElementsZero):
1671 jgs 82 case(ContactElementsOne):
1672 gross 1062 case(ReducedContactElementsOne):
1673 jgs 82 return true;
1674 jgs 147 case(Nodes):
1675 jgs 82 case(DegreesOfFreedom):
1676     return false;
1677     default:
1678 jgs 150 stringstream temp;
1679     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1680     throw FinleyAdapterException(temp.str());
1681 jgs 82 }
1682     break;
1683     default:
1684 jgs 150 stringstream temp;
1685     temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;
1686     throw FinleyAdapterException(temp.str());
1687 jgs 82 break;
1688     }
1689     checkFinleyError();
1690     return false;
1691     }
1692 jgs 149
1693 jgs 82 bool MeshAdapter::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const
1694     {
1695     return false;
1696     }
1697 jgs 104
1698 jgs 121 bool MeshAdapter::operator==(const AbstractDomain& other) const
1699 jgs 82 {
1700 jgs 121 const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);
1701     if (temp!=0) {
1702     return (m_finleyMesh==temp->m_finleyMesh);
1703     } else {
1704     return false;
1705     }
1706 jgs 82 }
1707    
1708 jgs 121 bool MeshAdapter::operator!=(const AbstractDomain& other) const
1709 jgs 104 {
1710 jgs 121 return !(operator==(other));
1711 jgs 104 }
1712    
1713 jgs 150 int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const
1714 jgs 102 {
1715 jgs 150 int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1716     checkPasoError();
1717 jgs 102 return out;
1718     }
1719 jgs 149
1720 jgs 480 escript::Data MeshAdapter::getX() const
1721 jgs 102 {
1722     return continuousFunction(asAbstractContinuousDomain()).getX();
1723     }
1724 jgs 149
1725 jgs 480 escript::Data MeshAdapter::getNormal() const
1726 jgs 102 {
1727     return functionOnBoundary(asAbstractContinuousDomain()).getNormal();
1728     }
1729 jgs 149
1730 jgs 480 escript::Data MeshAdapter::getSize() const
1731 jgs 102 {
1732     return function(asAbstractContinuousDomain()).getSize();
1733     }
1734    
1735 gross 1062 int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1736     {
1737     int *out=0,i;
1738     Finley_Mesh* mesh=m_finleyMesh.get();
1739     switch (functionSpaceType) {
1740     case(Nodes):
1741 ksteube 1312 out=mesh->Nodes->Id;
1742     break;
1743 gross 1062 case(ReducedNodes):
1744 ksteube 1312 out=mesh->Nodes->reducedNodesId;
1745 gross 1062 break;
1746     case(Elements):
1747 gross 1080 out=mesh->Elements->Id;
1748 gross 1062 break;
1749     case(ReducedElements):
1750     out=mesh->Elements->Id;
1751     break;
1752     case(FaceElements):
1753     out=mesh->FaceElements->Id;
1754     break;
1755     case(ReducedFaceElements):
1756     out=mesh->FaceElements->Id;
1757     break;
1758     case(Points):
1759     out=mesh->Points->Id;
1760     break;
1761     case(ContactElementsZero):
1762     out=mesh->ContactElements->Id;
1763     break;
1764     case(ReducedContactElementsZero):
1765     out=mesh->ContactElements->Id;
1766     break;
1767     case(ContactElementsOne):
1768     out=mesh->ContactElements->Id;
1769     break;
1770     case(ReducedContactElementsOne):
1771     out=mesh->ContactElements->Id;
1772     break;
1773     case(DegreesOfFreedom):
1774 ksteube 1312 out=mesh->Nodes->degreesOfFreedomId;
1775 gross 1062 break;
1776     case(ReducedDegreesOfFreedom):
1777 ksteube 1312 out=mesh->Nodes->reducedDegreesOfFreedomId;
1778 gross 1062 break;
1779     default:
1780     stringstream temp;
1781     temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1782     throw FinleyAdapterException(temp.str());
1783     break;
1784     }
1785     return out;
1786     }
1787 jgs 110 int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
1788     {
1789 gross 547 int out=0;
1790     Finley_Mesh* mesh=m_finleyMesh.get();
1791     switch (functionSpaceType) {
1792     case(Nodes):
1793     out=mesh->Nodes->Tag[sampleNo];
1794     break;
1795 gross 1062 case(ReducedNodes):
1796     throw FinleyAdapterException(" Error - ReducedNodes does not support tags.");
1797     break;
1798 gross 547 case(Elements):
1799     out=mesh->Elements->Tag[sampleNo];
1800     break;
1801 gross 1062 case(ReducedElements):
1802     out=mesh->Elements->Tag[sampleNo];
1803     break;
1804 gross 547 case(FaceElements):
1805     out=mesh->FaceElements->Tag[sampleNo];
1806     break;
1807 gross 1062 case(ReducedFaceElements):
1808     out=mesh->FaceElements->Tag[sampleNo];
1809     break;
1810 gross 547 case(Points):
1811     out=mesh->Points->Tag[sampleNo];
1812     break;
1813     case(ContactElementsZero):
1814     out=mesh->ContactElements->Tag[sampleNo];
1815     break;
1816 gross 1062 case(ReducedContactElementsZero):
1817     out=mesh->ContactElements->Tag[sampleNo];
1818     break;
1819 gross 547 case(ContactElementsOne):
1820     out=mesh->ContactElements->Tag[sampleNo];
1821     break;
1822 gross 1062 case(ReducedContactElementsOne):
1823     out=mesh->ContactElements->Tag[sampleNo];
1824 gross 547 break;
1825     case(DegreesOfFreedom):
1826 gross 1062 throw FinleyAdapterException(" Error - DegreesOfFreedom does not support tags.");
1827 gross 547 break;
1828     case(ReducedDegreesOfFreedom):
1829 gross 1062 throw FinleyAdapterException(" Error - ReducedDegreesOfFreedom does not support tags.");
1830 gross 547 break;
1831     default:
1832     stringstream temp;
1833     temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1834     throw FinleyAdapterException(temp.str());
1835     break;
1836     }
1837     return out;
1838 jgs 110 }
1839    
1840 gross 1062
1841 gross 767 void MeshAdapter::setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const
1842     {
1843     Finley_Mesh* mesh=m_finleyMesh.get();
1844     escriptDataC tmp=mask.getDataC();
1845     switch(functionSpaceType) {
1846     case(Nodes):
1847     Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);
1848     break;
1849 gross 1062 case(ReducedNodes):
1850     throw FinleyAdapterException("Error - ReducedNodes does not support tags");
1851     break;
1852 gross 767 case(DegreesOfFreedom):
1853     throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
1854     break;
1855     case(ReducedDegreesOfFreedom):
1856     throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
1857     break;
1858     case(Elements):
1859     Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1860     break;
1861 gross 1062 case(ReducedElements):
1862     Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1863     break;
1864 gross 767 case(FaceElements):
1865     Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1866     break;
1867 gross 1062 case(ReducedFaceElements):
1868     Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1869     break;
1870 gross 767 case(Points):
1871     Finley_ElementFile_setTags(mesh->Points,newTag,&tmp);
1872     break;
1873     case(ContactElementsZero):
1874     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1875     break;
1876 gross 1062 case(ReducedContactElementsZero):
1877     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1878     break;
1879 gross 767 case(ContactElementsOne):
1880     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1881     break;
1882 gross 1062 case(ReducedContactElementsOne):
1883     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1884     break;
1885 gross 767 default:
1886     stringstream temp;
1887     temp << "Error - Finley does not know anything about function space type " << functionSpaceType;
1888     throw FinleyAdapterException(temp.str());
1889     }
1890     checkFinleyError();
1891     return;
1892     }
1893    
1894 gross 1044 void MeshAdapter::setTagMap(const std::string& name, int tag)
1895     {
1896     Finley_Mesh* mesh=m_finleyMesh.get();
1897     Finley_Mesh_addTagMap(mesh, name.c_str(),tag);
1898     checkPasoError();
1899     // throwStandardException("MeshAdapter::set TagMap is not implemented.");
1900     }
1901 gross 767
1902 gross 1044 int MeshAdapter::getTag(const std::string& name) const
1903     {
1904     Finley_Mesh* mesh=m_finleyMesh.get();
1905     int tag=0;
1906     tag=Finley_Mesh_getTag(mesh, name.c_str());
1907     checkPasoError();
1908     // throwStandardException("MeshAdapter::getTag is not implemented.");
1909     return tag;
1910     }
1911    
1912     bool MeshAdapter::isValidTagName(const std::string& name) const
1913     {
1914     Finley_Mesh* mesh=m_finleyMesh.get();
1915     return Finley_Mesh_isValidTagName(mesh,name.c_str());
1916     }
1917    
1918     std::string MeshAdapter::showTagNames() const
1919     {
1920     stringstream temp;
1921     Finley_Mesh* mesh=m_finleyMesh.get();
1922     Finley_TagMap* tag_map=mesh->TagMap;
1923     while (tag_map) {
1924     temp << tag_map->name;
1925     tag_map=tag_map->next;
1926     if (tag_map) temp << ", ";
1927     }
1928 ksteube 1312 return temp.str();
1929 gross 1044 }
1930    
1931 jgs 82 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26