Fields

Implements data types:

  • 64-bit floating point: FieldDouble

  • integer: FieldInt

Basically a 3D array. Useful for e.g. internal variables.

The array-like functionnality is limited, but you can convert a numpy Array to it (with an array created with order=”F” you can avoid a copy of the underlying memory, otherwise use the constructor with copy=True)

import numpy as np
from amitex.field import FieldDouble

npArr0 = np.zeros((10, 10, 10), order="F")
field = FieldDouble(npArr0)

npArr1 = np.zeros((10, 10, 10), order="C")
field = FieldDouble(npArr1, copy=True)

Alternatively, you can make a numpy array pointing to the underlying memory buffer.

field = FieldDouble((10,10,10))
field.fill(4)
fieldArray = np.array(field, copy = False)
dx = 1.e-3
points = np.mgrid[0:10, 0:10, 0:10]
fieldArray[:,:,:] = points / 2
assert field[1,1,1] == 0.5

Fields are primarely useful for initialiazing internal variable

import numpy as np
from numpy.random import default_rng
from amitex.input import Grid, Material
from amitex.input.field import FieldDouble

grid = Grid([3, 3, 3], [1., 1., 1.])

intVar0Init = np.empty(grid.dims(), order='F')
default_rng().random(out=intVar0Init)

material = Material()
material.addIntVar(FieldDouble(intVar0Init))
class py4amitex.input.field.FieldDouble
at(self: py4amitex.input.field.FieldDouble, arg0: int, arg1: int, arg2: int) float

get data at grid point with bound checking

dims(self: py4amitex.input.field.FieldDouble) Annotated[list[int], FixedSize(3)]

Get dimensions

fill(self: py4amitex.input.field.FieldDouble, arg0: float) None

Fill all the (owned) space with value.

inBounds(*args, **kwargs)

Overloaded function.

  1. inBounds(self: py4amitex.input.field.FieldDouble, arg0: Annotated[list[int], FixedSize(3)]) -> bool

Check if p is in bounds

  1. inBounds(self: py4amitex.input.field.FieldDouble, arg0: int, arg1: int, arg2: int) -> bool

Check if {ix, iy, iz} is in bounds

lbound(self: py4amitex.input.field.FieldDouble, arg0: int) int

Get lower bound (inclusive)

static loadFromVtk(arg0: os.PathLike) py4amitex.input.field.FieldDouble

Create a field from a VTK file

Parameter path:

file path

ubound(self: py4amitex.input.field.FieldDouble, arg0: int) int

Get upper bound (exclusive)

class py4amitex.input.field.FieldInt
at(self: py4amitex.input.field.FieldInt, arg0: int, arg1: int, arg2: int) int

get data at grid point with bound checking

dims(self: py4amitex.input.field.FieldInt) Annotated[list[int], FixedSize(3)]

Get dimensions

fill(self: py4amitex.input.field.FieldInt, arg0: int) None

Fill all the (owned) space with value.

inBounds(*args, **kwargs)

Overloaded function.

  1. inBounds(self: py4amitex.input.field.FieldInt, arg0: Annotated[list[int], FixedSize(3)]) -> bool

Check if p is in bounds

  1. inBounds(self: py4amitex.input.field.FieldInt, arg0: int, arg1: int, arg2: int) -> bool

Check if {ix, iy, iz} is in bounds

lbound(self: py4amitex.input.field.FieldInt, arg0: int) int

Get lower bound (inclusive)

static loadFromVtk(arg0: os.PathLike) py4amitex.input.field.FieldInt

Create a field from a VTK file

Parameter path:

file path

ubound(self: py4amitex.input.field.FieldInt, arg0: int) int

Get upper bound (exclusive)