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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3126 - (hide annotations)
Wed Sep 1 00:37:53 2010 UTC (8 years, 6 months ago) by jfenwick
Original Path: branches/domexper/dudley/src/Mesh.c
File MIME type: text/plain
File size: 5930 byte(s)
Updated referenceElements and enums
1 ksteube 1312 /*******************************************************
2 ksteube 1811 *
3 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
4 ksteube 1811 * Earth Systems Science Computational Center (ESSCC)
5     * http://www.uq.edu.au/esscc
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     *******************************************************/
12 ksteube 1312
13 ksteube 1811
14 jgs 82 /**************************************************************/
15    
16 jfenwick 3086 /* Dudley: Mesh */
17 jgs 82
18     /**************************************************************/
19    
20     #include "Mesh.h"
21    
22     /**************************************************************/
23    
24     /* allocates a Mesh with name name for elements of type id using an integration order. If order is negative, */
25     /* the most appropriate order is selected indepently. */
26    
27 jfenwick 3086 Dudley_Mesh* Dudley_Mesh_alloc(char* name,dim_t numDim, Paso_MPIInfo *mpi_info)
28 bcumming 730 {
29 jfenwick 3086 Dudley_Mesh *out;
30 jgs 82
31     /* allocate the return value */
32    
33 jfenwick 3086 out=MEMALLOC(1,Dudley_Mesh);
34     if (Dudley_checkPtr(out)) return NULL;
35 jgs 82 out->Name=NULL;
36     out->Nodes=NULL;
37     out->Elements=NULL;
38     out->FaceElements=NULL;
39     out->Points=NULL;
40 gross 1044 out->TagMap=NULL;
41 jgs 82 out->reference_counter=0;
42 jgs 102
43     out->FullFullPattern=NULL;
44     out->FullReducedPattern=NULL;
45     out->ReducedFullPattern=NULL;
46     out->ReducedReducedPattern=NULL;
47 bcumming 730 out->MPIInfo = Paso_MPIInfo_getReference( mpi_info );
48 jfenwick 3086 if (! Dudley_noError()) {
49     Dudley_Mesh_free(out);
50 bcumming 730 return NULL;
51     }
52 jgs 82 /* copy name: */
53    
54 jgs 102 out->Name=MEMALLOC(strlen(name)+1,char);
55 jfenwick 3086 if (Dudley_checkPtr(out->Name)) {
56     Dudley_Mesh_free(out);
57 jgs 82 return NULL;
58     }
59     strcpy(out->Name,name);
60    
61     /* allocate node table: */
62 jfenwick 3086 out->Nodes=Dudley_NodeFile_alloc( numDim, mpi_info );
63     if (! Dudley_noError()) {
64     Dudley_Mesh_free(out);
65 jgs 82 return NULL;
66     }
67 gross 2856 out->approximationOrder=-1;
68     out->reducedApproximationOrder=-1;
69     out->integrationOrder=-1;
70     out->reducedIntegrationOrder=-1;
71    
72 jgs 82 out->Elements=NULL;
73     out->FaceElements=NULL;
74     out->Points=NULL;
75     out->reference_counter++;
76     return out;
77     }
78    
79 jfenwick 3086 /* returns a reference to Dudley_Mesh in */
80 jgs 102
81 jfenwick 3086 Dudley_Mesh* Dudley_Mesh_reference(Dudley_Mesh* in) {
82 jgs 102 if (in!=NULL) ++(in->reference_counter);
83     return in;
84     }
85    
86 ksteube 1312 /* freeates a mesh: */
87 jgs 82
88 jfenwick 3086 void Dudley_Mesh_free(Dudley_Mesh* in) {
89 jgs 82 if (in!=NULL) {
90     in->reference_counter--;
91     if (in->reference_counter<1) {
92     MEMFREE(in->Name);
93 jfenwick 3086 Dudley_NodeFile_free(in->Nodes);
94     Dudley_ElementFile_free(in->FaceElements);
95     Dudley_ElementFile_free(in->Elements);
96     Dudley_ElementFile_free(in->Points);
97     Dudley_TagMap_free(in->TagMap);
98 ksteube 1312 Paso_SystemMatrixPattern_free(in->FullFullPattern);
99     Paso_SystemMatrixPattern_free(in->FullReducedPattern);
100     Paso_SystemMatrixPattern_free(in->ReducedFullPattern);
101     Paso_SystemMatrixPattern_free(in->ReducedReducedPattern);
102     Paso_MPIInfo_free( in->MPIInfo );
103 jgs 82 MEMFREE(in);
104     }
105     }
106     }
107    
108     /**************************************************************/
109    
110     /* returns the spatial dimension of the mesh: */
111    
112 jfenwick 3086 dim_t Dudley_Mesh_getDim(Dudley_Mesh *in) {
113 jgs 82 return in->Nodes->numDim;
114     }
115    
116 jfenwick 3086 void Dudley_Mesh_setElements(Dudley_Mesh* self,Dudley_ElementFile *elements) {
117     Dudley_ElementFile_free(self->Elements);
118 ksteube 1312 self->Elements=elements;
119 jgs 82 }
120 jfenwick 3086 void Dudley_Mesh_setFaceElements(Dudley_Mesh* self,Dudley_ElementFile *elements) {
121     Dudley_ElementFile_free(self->FaceElements);
122 ksteube 1312 self->FaceElements=elements;
123 jgs 82 }
124 jfenwick 3086 void Dudley_Mesh_setPoints(Dudley_Mesh* self,Dudley_ElementFile *elements) {
125     Dudley_ElementFile_free(self->Points);
126 ksteube 1312 self->Points=elements;
127     }
128 jfenwick 3086 int Dudley_Mesh_getStatus(Dudley_Mesh* in) {
129 gross 2533 if (in == NULL) {
130     return -1;
131     } else if (in->Nodes == NULL) {
132     return -1;
133     } else {
134     return in->Nodes->status;
135     }
136     }
137 gross 2856
138 jfenwick 3086 void Mesh_setOrders(Dudley_Mesh *in)
139 gross 2856 {
140     const dim_t order_max=9999999;
141     dim_t locals[4];
142     #ifdef PASO_MPI
143     dim_t globals[4];
144     #endif
145     locals[0]=order_max; locals[1]=order_max; locals[2]=order_max; locals[3]=order_max;
146    
147     if ( in->Elements!=NULL) {
148     if (in->Elements->numElements > 0) {
149     locals[0]=MIN(locals[0], in->Elements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
150     locals[1]=MIN(locals[1], in->Elements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
151     locals[2]=MIN(locals[2], in->Elements->referenceElementSet->referenceElement->integrationOrder);
152     locals[3]=MIN(locals[3], in->Elements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
153     }
154     }
155     if ( in->FaceElements!=NULL) {
156     if (in->FaceElements->numElements > 0) {
157     locals[0]=MIN(locals[0], in->FaceElements->referenceElementSet->referenceElement->BasisFunctions->Type->numOrder);
158     locals[1]=MIN(locals[1], in->FaceElements->referenceElementSet->referenceElement->LinearBasisFunctions->Type->numOrder);
159     locals[2]=MIN(locals[2], in->FaceElements->referenceElementSet->referenceElement->integrationOrder);
160     locals[3]=MIN(locals[3], in->FaceElements->referenceElementSet->referenceElementReducedQuadrature->integrationOrder);
161     }
162    
163    
164     }
165    
166     #ifdef PASO_MPI
167     MPI_Allreduce( locals, globals, 4, MPI_INT, MPI_MIN, in->MPIInfo->comm );
168     in->approximationOrder=(globals[0] < order_max ? globals[0] : -1 );
169     in->reducedApproximationOrder=(globals[1] < order_max ? globals[1] : -1 );
170     in->integrationOrder=(globals[2] < order_max ? globals[2] : -1 );
171     in->reducedIntegrationOrder=(globals[3] < order_max ? globals[3] : -1 );
172     #else
173     in->approximationOrder=(locals[0] < order_max ? locals[0] : -1 );
174     in->reducedApproximationOrder=(locals[1] < order_max ? locals[1] : -1 );
175     in->integrationOrder=(locals[2] < order_max ? locals[2] : -1 );
176     in->reducedIntegrationOrder=(locals[3] < order_max ? locals[3] : -1 );
177     #endif
178    
179    
180     }
181    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26