/[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 4286 - (show annotations)
Thu Mar 7 04:28:11 2013 UTC (6 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 4564 byte(s)
Assorted spelling fixes.

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

  ViewVC Help
Powered by ViewVC 1.1.26