ceed_basis.py (e15f9bd09af0280c89b79924fa9af7dd2e3e30be) ceed_basis.py (66ce82e0a71c19ea7217385b30cf4d3e9f880c71)
1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3# reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.

--- 149 unchanged lines hidden (view full) ---

158
159 # libCEED call
160 err_code = lib.CeedBasisCreateTensorH1(self._ceed._pointer[0], dim, ncomp,
161 P1d, Q1d, interp1d_pointer,
162 grad1d_pointer, qref1d_pointer,
163 qweight1d_pointer, self._pointer)
164 self._ceed._check_error(err_code)
165
1# Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2# the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3# reserved. See files LICENSE and NOTICE for details.
4#
5# This file is part of CEED, a collection of benchmarks, miniapps, software
6# libraries and APIs for efficient high-order finite element and spectral
7# element discretizations for exascale applications. For more information and
8# source code availability see http://github.com/ceed.

--- 149 unchanged lines hidden (view full) ---

158
159 # libCEED call
160 err_code = lib.CeedBasisCreateTensorH1(self._ceed._pointer[0], dim, ncomp,
161 P1d, Q1d, interp1d_pointer,
162 grad1d_pointer, qref1d_pointer,
163 qweight1d_pointer, self._pointer)
164 self._ceed._check_error(err_code)
165
166 #
167 def get_interp1d(self):
166 # Get 1D interpolation matrix
167 def get_interp_1d(self):
168 """Return 1D interpolation matrix of a tensor product Basis.
169
170 Returns:
171 *array: Numpy array"""
172
173 # Compute the length of the array
174 nnodes_pointer = ffi.new("CeedInt *")
175 lib.CeedBasisGetNumNodes1D(self._pointer[0], nnodes_pointer)

--- 13 unchanged lines hidden (view full) ---

189 array_pointer[0],
190 ffi.sizeof("CeedScalar") *
191 length)
192 # return read only Numpy array
193 ret = np.frombuffer(buff, dtype="float64")
194 ret.flags['WRITEABLE'] = False
195 return ret
196
168 """Return 1D interpolation matrix of a tensor product Basis.
169
170 Returns:
171 *array: Numpy array"""
172
173 # Compute the length of the array
174 nnodes_pointer = ffi.new("CeedInt *")
175 lib.CeedBasisGetNumNodes1D(self._pointer[0], nnodes_pointer)

--- 13 unchanged lines hidden (view full) ---

189 array_pointer[0],
190 ffi.sizeof("CeedScalar") *
191 length)
192 # return read only Numpy array
193 ret = np.frombuffer(buff, dtype="float64")
194 ret.flags['WRITEABLE'] = False
195 return ret
196
197 # Get 1D gradient matrix
198 def get_grad_1d(self):
199 """Return 1D gradient matrix of a tensor product Basis.
197
200
201 Returns:
202 *array: Numpy array"""
203
204 # Compute the length of the array
205 nnodes_pointer = ffi.new("CeedInt *")
206 lib.CeedBasisGetNumNodes1D(self._pointer[0], nnodes_pointer)
207 nqpts_pointer = ffi.new("CeedInt *")
208 lib.CeedBasisGetNumQuadraturePoints1D(self._pointer[0], nqpts_pointer)
209 length = nnodes_pointer[0] * nqpts_pointer[0]
210
211 # Setup the pointer's pointer
212 array_pointer = ffi.new("CeedScalar **")
213
214 # libCEED call
215 lib.CeedBasisGetGrad1D(self._pointer[0], array_pointer)
216
217 # Return array created from buffer
218 # Create buffer object from returned pointer
219 buff = ffi.buffer(
220 array_pointer[0],
221 ffi.sizeof("CeedScalar") *
222 length)
223 # return read only Numpy array
224 ret = np.frombuffer(buff, dtype="float64")
225 ret.flags['WRITEABLE'] = False
226 return ret
227
228 # Get 1D quadrature weights matrix
229 def get_q_weight_1d(self):
230 """Return 1D quadrature weights matrix of a tensor product Basis.
231
232 Returns:
233 *array: Numpy array"""
234
235 # Compute the length of the array
236 nqpts_pointer = ffi.new("CeedInt *")
237 lib.CeedBasisGetNumQuadraturePoints1D(self._pointer[0], nqpts_pointer)
238 length = nqpts_pointer[0]
239
240 # Setup the pointer's pointer
241 array_pointer = ffi.new("CeedScalar **")
242
243 # libCEED call
244 lib.CeedBasisGetQWeights(self._pointer[0], array_pointer)
245
246 # Return array created from buffer
247 # Create buffer object from returned pointer
248 buff = ffi.buffer(
249 array_pointer[0],
250 ffi.sizeof("CeedScalar") *
251 length)
252 # return read only Numpy array
253 ret = np.frombuffer(buff, dtype="float64")
254 ret.flags['WRITEABLE'] = False
255 return ret
256
257 # Get 1D quadrature points matrix
258 def get_q_ref_1d(self):
259 """Return 1D quadrature points matrix of a tensor product Basis.
260
261 Returns:
262 *array: Numpy array"""
263
264 # Compute the length of the array
265 nqpts_pointer = ffi.new("CeedInt *")
266 lib.CeedBasisGetNumQuadraturePoints1D(self._pointer[0], nqpts_pointer)
267 length = nqpts_pointer[0]
268
269 # Setup the pointer's pointer
270 array_pointer = ffi.new("CeedScalar **")
271
272 # libCEED call
273 lib.CeedBasisGetQRef(self._pointer[0], array_pointer)
274
275 # Return array created from buffer
276 # Create buffer object from returned pointer
277 buff = ffi.buffer(
278 array_pointer[0],
279 ffi.sizeof("CeedScalar") *
280 length)
281 # return read only Numpy array
282 ret = np.frombuffer(buff, dtype="float64")
283 ret.flags['WRITEABLE'] = False
284 return ret
285
286
198# ------------------------------------------------------------------------------
199
200
201class BasisTensorH1Lagrange(BasisTensorH1):
202 """Ceed Tensor H1 Lagrange Basis: finite element tensor-product Lagrange basis
203 objects for H^1 discretizations."""
204
205 # Constructor

--- 88 unchanged lines hidden ---
287# ------------------------------------------------------------------------------
288
289
290class BasisTensorH1Lagrange(BasisTensorH1):
291 """Ceed Tensor H1 Lagrange Basis: finite element tensor-product Lagrange basis
292 objects for H^1 discretizations."""
293
294 # Constructor

--- 88 unchanged lines hidden ---