Points Derived Type

type, public, extends(Points_t) :: Points


Inherits

type~~points~~InheritsGraph type~points Points c_ptr c_ptr type~points->c_ptr elements_gpu, coordinates_gpu, lS_cache_gpu, lT_cache_gpu, lU_cache_gpu type~points_t Points_t type~points->type~points_t

Contents

Source Code


Components

TypeVisibilityAttributesNameInitial
character(len=3), public :: backend ="gpu"
real(kind=prec), public, pointer:: coordinates(:,:)=> null()

Reference coordinates (s,t[,u]) in [-1,1]^nDim, shape (1:nPoints, 1:nDim). Defined only where elements(p) > 0.

type(c_ptr), public :: coordinates_gpu =c_null_ptr
integer, public, pointer:: elements(:)=> null()

Element id (rank-local) containing each point; 0 = not found.

type(c_ptr), public :: elements_gpu =c_null_ptr
real(kind=prec), public, pointer:: lS_cache(:,:)=> null()

Lagrange basis at coordinates(p,1), shape (0:nCached, 1:nPoints). Filled by LocatePoints for points with elements(p) > 0.

type(c_ptr), public :: lS_cache_gpu =c_null_ptr
real(kind=prec), public, pointer:: lT_cache(:,:)=> null()

Lagrange basis at coordinates(p,2), shape (0:nCached, 1:nPoints).

type(c_ptr), public :: lT_cache_gpu =c_null_ptr
real(kind=prec), public, pointer:: lU_cache(:,:)=> null()

Lagrange basis at coordinates(p,3), shape (0:nCached, 1:nPoints). Allocated only for nDim = 3.

type(c_ptr), public :: lU_cache_gpu =c_null_ptr
integer, public :: nCached =0

Polynomial degree at which the per-point Lagrange basis cache is valid. Zero means no cache. The cache is filled by LocatePoints and consumed by EvaluateScalar when the field's interpolant degree matches.

integer, public :: nCachedAlloc =0

Capacity (polynomial degree) of l*_cache_gpu; 0 = unallocated.

integer, public :: nDim =0
integer, public :: nPoints =0
integer, public :: nPointsAlloc =0

Capacity of elements_gpu / coordinates_gpu (set in Init).

real(kind=prec), public, allocatable:: x(:,:)

Physical coordinates, shape (1:nPoints, 1:nDim). User input.


Type-Bound Procedures

procedure, public :: EvalScalar_2D_Points_t

  • public subroutine EvalScalar_2D_Points_t(this, scalar, values)

    Evaluate a 2D MappedScalar at all located points by tensor-product Lagrange interpolation at the stored reference coordinates. Points with elements(p) == 0 receive a value of zero. When LocatePoints has cached the per-point basis at the matching polynomial degree, this routine reuses it and skips Lagrange-polynomial evaluation altogether.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(in) :: this
    class(MappedScalar2D_t), intent(in) :: scalar
    real(kind=prec), intent(out) :: values(1:this%nPoints,1:scalar%nVar)

procedure, private :: EvalScalar_2D_dev_Points

  • public subroutine EvalScalar_2D_dev_Points(this, scalar, values_dev)

    Evaluate a 2D MappedScalar at the cached points on the device. The caller is responsible for hipMalloc-ing values_dev with capacity nPointsnVarprec bytes. Layout is column-major (nPoints, nVar).

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(in) :: this
    class(MappedScalar2D), intent(in) :: scalar
    type(c_ptr), intent(inout) :: values_dev

procedure, public :: EvalScalar_3D_Points_t

  • public subroutine EvalScalar_3D_Points_t(this, scalar, values)

    Evaluate a 3D MappedScalar at all located points by tensor-product Lagrange interpolation. Points with elements(p) == 0 receive zero. When LocatePoints has cached the basis at the matching degree, this routine reuses it.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(in) :: this
    class(MappedScalar3D_t), intent(in) :: scalar
    real(kind=prec), intent(out) :: values(1:this%nPoints,1:scalar%nVar)

procedure, private :: EvalScalar_3D_dev_Points

  • public subroutine EvalScalar_3D_dev_Points(this, scalar, values_dev)

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(in) :: this
    class(MappedScalar3D), intent(in) :: scalar
    type(c_ptr), intent(inout) :: values_dev
  • public subroutine EvalScalar_2D_Points_t(this, scalar, values)

    Evaluate a 2D MappedScalar at all located points by tensor-product Lagrange interpolation at the stored reference coordinates. Points with elements(p) == 0 receive a value of zero. When LocatePoints has cached the per-point basis at the matching polynomial degree, this routine reuses it and skips Lagrange-polynomial evaluation altogether.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(in) :: this
    class(MappedScalar2D_t), intent(in) :: scalar
    real(kind=prec), intent(out) :: values(1:this%nPoints,1:scalar%nVar)
  • public subroutine EvalScalar_3D_Points_t(this, scalar, values)

    Evaluate a 3D MappedScalar at all located points by tensor-product Lagrange interpolation. Points with elements(p) == 0 receive zero. When LocatePoints has cached the basis at the matching degree, this routine reuses it.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(in) :: this
    class(MappedScalar3D_t), intent(in) :: scalar
    real(kind=prec), intent(out) :: values(1:this%nPoints,1:scalar%nVar)
  • public subroutine EvalScalar_2D_dev_Points(this, scalar, values_dev)

    Evaluate a 2D MappedScalar at the cached points on the device. The caller is responsible for hipMalloc-ing values_dev with capacity nPointsnVarprec bytes. Layout is column-major (nPoints, nVar).

    Read more…

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(in) :: this
    class(MappedScalar2D), intent(in) :: scalar
    type(c_ptr), intent(inout) :: values_dev
  • public subroutine EvalScalar_3D_dev_Points(this, scalar, values_dev)

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(in) :: this
    class(MappedScalar3D), intent(in) :: scalar
    type(c_ptr), intent(inout) :: values_dev

procedure, public :: Free => Free_Points

  • public subroutine Free_Points(this)

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(inout) :: this

procedure, public :: Init => Init_Points

  • public subroutine Init_Points(this, nPoints, nDim)

    Allocate host + device storage for nPoints in nDim dimensions. The basis-cache device buffers are allocated lazily in UpdateDevice once the polynomial degree N is known (it is set by LocatePoints).

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(out) :: this
    integer, intent(in) :: nPoints
    integer, intent(in) :: nDim

generic, public :: LocatePoints => LocatePoints_2D_Points_t, LocatePoints_3D_Points_t

  • public subroutine LocatePoints_2D_Points_t(this, geometry)

    Locate each stored physical point inside the 2D SEMQuad geometry. On exit, elements(p) holds the (rank-local) element id and coordinates(p,:) holds the (s,t) reference coordinates, both for points that resolve. Points that resolve to no element are marked with elements(p) = 0.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(inout) :: this
    type(SEMQuad), intent(in) :: geometry
  • public subroutine LocatePoints_3D_Points_t(this, geometry)

    Locate each stored physical point inside the 3D SEMHex geometry. On exit, elements(p) and coordinates(p,1:3) hold the located element id and reference (s,t,u) for points that resolve; elements(p) = 0 otherwise.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(inout) :: this
    type(SEMHex), intent(in) :: geometry

procedure, public :: LocatePoints_2D_Points_t => LocatePoints_2D_Points

  • public subroutine LocatePoints_2D_Points(this, geometry)

    Run the host spatial-hash + Newton search (inherited from Points_t), then mirror per-point state to the device.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(inout) :: this
    type(SEMQuad), intent(in) :: geometry

procedure, public :: LocatePoints_3D_Points_t => LocatePoints_3D_Points

  • public subroutine LocatePoints_3D_Points(this, geometry)

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(inout) :: this
    type(SEMHex), intent(in) :: geometry

procedure, public :: SetPoints => SetPoints_Points_t

  • public subroutine SetPoints_Points_t(this, xIn)

    Copy user-supplied physical coordinates into the cloud. xIn must be shape (nPoints, nDim) matching the init dimensions.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points_t), intent(inout) :: this
    real(kind=prec), intent(in) :: xIn(:,:)

procedure, public :: UpdateDevice => UpdateDevice_Points

  • public subroutine UpdateDevice_Points(this)

    Copy elements, coordinates, and the per-point Lagrange basis cache from host to device. Lazily (re)allocates the cache buffers if their degree changed since the previous call.

    Arguments

    TypeIntentOptionalAttributesName
    class(Points), intent(inout) :: this

Source Code

  type,extends(Points_t),public :: Points
    character(3) :: backend = "gpu"
    integer :: nPointsAlloc = 0
      !! Capacity of elements_gpu / coordinates_gpu (set in Init).
    integer :: nCachedAlloc = 0
      !! Capacity (polynomial degree) of l*_cache_gpu; 0 = unallocated.
    type(c_ptr) :: elements_gpu = c_null_ptr
    type(c_ptr) :: coordinates_gpu = c_null_ptr
    type(c_ptr) :: lS_cache_gpu = c_null_ptr
    type(c_ptr) :: lT_cache_gpu = c_null_ptr
    type(c_ptr) :: lU_cache_gpu = c_null_ptr

  contains
    procedure,public :: Init => Init_Points
    procedure,public :: Free => Free_Points
    procedure,public :: UpdateDevice => UpdateDevice_Points

    ! Override the inherited specifics so LocatePoints automatically syncs
    ! device state after the host search.
    procedure,public :: LocatePoints_2D_Points_t => LocatePoints_2D_Points
    procedure,public :: LocatePoints_3D_Points_t => LocatePoints_3D_Points

    ! Add device-output specifics under the same EvaluateScalar generic. The
    ! inherited (host-output) specifics remain available for callers that
    ! want results in a Fortran array.
    procedure,private :: EvalScalar_2D_dev_Points
    procedure,private :: EvalScalar_3D_dev_Points
    generic,public :: EvaluateScalar => EvalScalar_2D_dev_Points,EvalScalar_3D_dev_Points

  endtype Points