/[escript]/trunk/dudley/src/ElementFile_jacobeans.c
ViewVC logotype

Contents of /trunk/dudley/src/ElementFile_jacobeans.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years ago) by jfenwick
File MIME type: text/plain
File size: 4377 byte(s)
Merging dudley and scons updates from branches

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14 #include "ElementFile.h"
15 #include "Assemble.h"
16 #ifdef _OPENMP
17 #include <omp.h>
18 #endif
19
20 #include "ShapeTable.h"
21
22 /**************************************************************/
23
24 Dudley_ElementFile_Jacobeans *Dudley_ElementFile_Jacobeans_alloc(void)
25 {
26 Dudley_ElementFile_Jacobeans *out = MEMALLOC(1, Dudley_ElementFile_Jacobeans);
27 if (Dudley_checkPtr(out))
28 {
29 return NULL;
30 }
31 else
32 {
33 out->status = DUDLEY_INITIAL_STATUS - 1;
34 out->numDim = 0;
35 out->numQuad = 0;
36 out->numElements = 0;
37 out->absD = NULL;
38 out->quadweight = 0;
39 out->DSDX = NULL;
40 return out;
41 }
42 }
43
44 /**************************************************************/
45
46 void Dudley_ElementFile_Jacobeans_dealloc(Dudley_ElementFile_Jacobeans * in)
47 {
48 if (in != NULL)
49 {
50 MEMFREE(in->DSDX);
51 MEMFREE(in->absD);
52 MEMFREE(in);
53 }
54 }
55
56 /**************************************************************/
57
58 Dudley_ElementFile_Jacobeans *Dudley_ElementFile_borrowJacobeans(Dudley_ElementFile * self, Dudley_NodeFile * nodes,
59 bool_t reducedIntegrationOrder)
60 {
61 Dudley_ElementFile_Jacobeans *out = NULL;
62
63 dim_t numNodes = self->numNodes;
64
65 if (reducedIntegrationOrder)
66 {
67 out = self->jacobeans_reducedQ;
68 }
69 else
70 {
71 out = self->jacobeans;
72 }
73 if (out->status < nodes->status)
74 {
75 out->numDim = nodes->numDim;
76 out->numQuad = QuadNums[self->numDim][!reducedIntegrationOrder];
77 out->numShapes = self->numDim + 1;
78 out->numElements = self->numElements;
79 if (out->DSDX == NULL)
80 out->DSDX = MEMALLOC((out->numElements) * (out->numShapes) * (out->numDim) * (out->numQuad), double);
81 if (out->absD == NULL)
82 out->absD = MEMALLOC(out->numElements, double);
83 if (!(Dudley_checkPtr(out->DSDX) || Dudley_checkPtr(out->absD)))
84 {
85 /*========================== dim = 1 ============================================== */
86 if (out->numDim == 1)
87 {
88 Dudley_setError(SYSTEM_ERROR, "Dudley does not support 1D domains.");
89 /*========================== dim = 2 ============================================== */
90 }
91 else if (out->numDim == 2)
92 {
93 if (self->numLocalDim == 0)
94 {
95 Dudley_setError(SYSTEM_ERROR,
96 "Dudley_ElementFile_borrowJacobeans: 2D does not support local dimension 0.");
97 }
98 else if (self->numLocalDim == 1)
99 {
100 Dudley_Assemble_jacobeans_2D_M1D_E1D(nodes->Coordinates, out->numQuad, self->numElements, numNodes,
101 self->Nodes, out->DSDX, out->absD, &(out->quadweight), self->Id);
102 }
103 else if (self->numLocalDim == 2)
104 {
105 Dudley_Assemble_jacobeans_2D(nodes->Coordinates, out->numQuad, self->numElements, numNodes, self->Nodes,
106 out->DSDX, out->absD, &(out->quadweight), self->Id);
107 }
108 else
109 {
110 Dudley_setError(SYSTEM_ERROR,
111 "Dudley_ElementFile_borrowJacobeans: local dimenion in a 2D domain has to be 1 or 2.");
112 }
113 /*========================== dim = 3 ============================================== */
114 }
115 else if (out->numDim == 3)
116 {
117 if (self->numLocalDim == 0)
118 {
119 Dudley_setError(SYSTEM_ERROR,
120 "Dudley_ElementFile_borrowJacobeans: 3D does not support local dimension 0.");
121 }
122 else if (self->numLocalDim == 2)
123 {
124 Dudley_Assemble_jacobeans_3D_M2D_E2D(nodes->Coordinates, out->numQuad, self->numElements, numNodes,
125 self->Nodes, out->DSDX, out->absD, &(out->quadweight), self->Id);
126 }
127 else if (self->numLocalDim == 3)
128 {
129 Dudley_Assemble_jacobeans_3D(nodes->Coordinates, out->numQuad, self->numElements, numNodes, self->Nodes,
130 out->DSDX, out->absD, &(out->quadweight), self->Id);
131 }
132 else
133 {
134 Dudley_setError(SYSTEM_ERROR,
135 "Dudley_ElementFile_borrowJacobeans: local dimenion in a 3D domain has to be 2 or 3.");
136 }
137 }
138 else
139 {
140 Dudley_setError(SYSTEM_ERROR,
141 "Dudley_ElementFile_borrowJacobeans: spatial dimension has to be 1, 2 or 3.");
142 }
143 }
144 if (Dudley_noError())
145 {
146 out->status = nodes->status;
147 }
148 else
149 {
150 out = NULL;
151 }
152
153 }
154
155 return out;
156 }

  ViewVC Help
Powered by ViewVC 1.1.26