MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / Function

Class Function

python/dolfinx/fem/function.py:335–626  ·  view source on GitHub ↗

A finite element function. A finite element function is represented by a function space (domain, element and dofmap) and a vector holding the degrees-of-freedom.

Source from the content-addressed store, hash-verified

333
334
335class Function(ufl.Coefficient, Generic[Scalar]):
336 """A finite element function.
337
338 A finite element function is represented by a function space
339 (domain, element and dofmap) and a vector holding the
340 degrees-of-freedom.
341
342 """
343
344 _cpp_object: (
345 _cpp.fem.Function_complex64
346 | _cpp.fem.Function_complex128
347 | _cpp.fem.Function_float32
348 | _cpp.fem.Function_float64
349 )
350
351 _x: la.Vector[Scalar]
352
353 def __init__(
354 self,
355 V: FunctionSpace,
356 x: la.Vector[Scalar] | None = None,
357 name: str | None = None,
358 dtype: npt.DTypeLike | None = None,
359 ):
360 """Initialize a finite element Function.
361
362 Args:
363 V: The function space that the Function is defined on.
364 x: Function degree-of-freedom vector. Typically required
365 only when reading a saved Function from file.
366 name: Function name.
367 dtype: Scalar type. Is not set, the DOLFINx default scalar
368 type is used.
369 """
370 if x is not None:
371 if dtype is None:
372 dtype = x.array.dtype
373 else:
374 assert x.array.dtype == dtype, "Incompatible Vector and dtype."
375 else:
376 if dtype is None:
377 dtype = default_scalar_type
378
379 assert np.issubdtype(V.element.dtype, np.dtype(dtype).type(0).real.dtype), (
380 "Incompatible FunctionSpace dtype and requested dtype."
381 )
382
383 # Create cpp Function
384 def functiontype(dtype):
385 if np.issubdtype(dtype, np.float32):
386 return _cpp.fem.Function_float32
387 elif np.issubdtype(dtype, np.float64):
388 return _cpp.fem.Function_float64
389 elif np.issubdtype(dtype, np.complex64):
390 return _cpp.fem.Function_complex64
391 elif np.issubdtype(dtype, np.complex128):
392 return _cpp.fem.Function_complex128

Callers 15

test_linear_pdeMethod · 0.90
test_nonlinear_pdeMethod · 0.90
test_name_argumentFunction · 0.90
test_copyFunction · 0.90
test_evalFunction · 0.90
test_eval_manifoldFunction · 0.90
test_interpolation_rank0Function · 0.90
test_interpolation_rank1Function · 0.90

Calls

no outgoing calls

Tested by 15

test_linear_pdeMethod · 0.72
test_nonlinear_pdeMethod · 0.72
test_name_argumentFunction · 0.72
test_copyFunction · 0.72
test_evalFunction · 0.72
test_eval_manifoldFunction · 0.72
test_interpolation_rank0Function · 0.72
test_interpolation_rank1Function · 0.72