42 use json_module,
only : json_file
46 use,
intrinsic :: iso_c_binding, only : c_ptr, c_null_ptr
65 real(kind=
rp),
allocatable :: g(:)
67 real(kind=
rp),
allocatable :: xm(:)
68 real(kind=
rp),
allocatable :: ym(:)
69 real(kind=
rp),
allocatable :: zm(:)
71 type(c_ptr) :: g_d = c_null_ptr
76 procedure, pass(this) :: init_from_components => &
87 procedure, pass(this) :: apply_scalar_dev => &
90 procedure, pass(this) :: apply_vector_dev => &
105 type(
coef_t),
target,
intent(in) :: coef
106 type(json_file),
intent(inout) :: json
107 character(len=:),
allocatable :: str
110 call this%init_from_components(coef, str)
111 if (
allocated(str))
deallocate(str)
120 type(
coef_t),
target,
intent(in) :: coef
121 character(len=*),
intent(in) :: str
124 call this%init_base(coef)
126 if (len_trim(str) .eq. 0)
then
127 call neko_error(
"An expression boundary condition needs a non-empty " &
128 //
"expression under the value keyword")
131 call this%expr%init(str)
139 call this%free_base()
140 call this%expr%free()
142 if (
allocated(this%g))
then
149 if (
allocated(this%xm))
deallocate(this%xm)
150 if (
allocated(this%ym))
deallocate(this%ym)
151 if (
allocated(this%zm))
deallocate(this%zm)
162 logical,
optional,
intent(in) :: only_facets
163 logical :: only_facets_
166 if (
present(only_facets))
then
167 only_facets_ = only_facets
169 only_facets_ = .false.
172 call this%finalize_base(only_facets_)
177 allocate(this%xm(m), this%ym(m), this%zm(m), this%g(m))
185 if (.not. this%expr%time_dependent)
then
186 call this%expr%eval(this%g, m, this%xm, this%ym, this%zm)
188 "boundary condition")
205 type(c_ptr),
intent(inout),
optional :: strm
208 if (.not. this%expr%time_dependent)
return
209 if (this%updated)
return
211 if (.not.
present(time))
then
212 call neko_error(
"The boundary condition expression '" // &
213 this%expr%src //
"' depends on time, but the solver did not " // &
214 "provide a time state")
218 call this%expr%eval(this%g, m, this%xm, this%ym, this%zm, time%t, time%dt)
220 "boundary condition")
226 sync = .true., strm = strm)
229 this%updated = .true.
240 integer,
intent(in) :: n
241 real(kind=
rp),
intent(inout),
dimension(n) :: x
243 logical,
intent(in),
optional :: strong
247 if (
present(strong))
then
254 if (.not. strong_ .or. m .eq. 0)
return
261 call this%update(time)
266 x(this%msk(i)) = this%g(i)
281 integer,
intent(in) :: n
282 real(kind=
rp),
intent(inout),
dimension(n) :: x
283 real(kind=
rp),
intent(inout),
dimension(n) :: y
284 real(kind=
rp),
intent(inout),
dimension(n) :: z
286 logical,
intent(in),
optional :: strong
297 type(c_ptr),
intent(inout) :: x_d
299 logical,
intent(in),
optional :: strong
300 type(c_ptr),
intent(inout) :: strm
304 if (
present(strong))
then
311 if (.not. strong_ .or. m .eq. 0)
return
313 call this%update(time, strm)
329 type(c_ptr),
intent(inout) :: x_d
330 type(c_ptr),
intent(inout) :: y_d
331 type(c_ptr),
intent(inout) :: z_d
333 logical,
intent(in),
optional :: strong
334 type(c_ptr),
intent(inout) :: strm
344 class(
bc_t),
intent(in) ::
bc
345 real(kind=
rp),
intent(inout) :: xm(:)
346 real(kind=
rp),
intent(inout) :: ym(:)
347 real(kind=
rp),
intent(inout) :: zm(:)
350 size(
bc%dof%x), xm, ym, zm)
367 integer,
intent(in) :: m
368 integer,
intent(in) :: n
369 integer,
intent(in) :: msk(0:m)
370 real(kind=
rp),
intent(in) :: x(n)
371 real(kind=
rp),
intent(in) :: y(n)
372 real(kind=
rp),
intent(in) :: z(n)
373 real(kind=
rp),
intent(inout) :: xm(m)
374 real(kind=
rp),
intent(inout) :: ym(m)
375 real(kind=
rp),
intent(inout) :: zm(m)
Map a Fortran array to a device (allocate and associate)
Copy data between host and device (or device and device)
Unmap a Fortran array from a device (deassociate and free)
Retrieves a parameter by name or throws an error.
Defines a boundary condition.
subroutine device_inhom_dirichlet_apply_scalar(msk, x, bla_x, m, strm)
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Defines a Dirichlet condition prescribed by a mathematical expression.
subroutine expression_dirichlet_init(this, coef, json)
Constructor from JSON.
subroutine expression_dirichlet_update(this, time, strm)
Bring g up to date with the current time.
subroutine gather_coords(msk, m, x, y, z, n, xm, ym, zm)
Gather the coordinates of the masked points into contiguous arrays.
subroutine expression_dirichlet_apply_vector_dev(this, x_d, y_d, z_d, time, strong, strm)
(No-op) Apply vector (device version).
subroutine expression_dirichlet_apply_scalar(this, x, n, time, strong)
Apply the condition to a scalar field.
subroutine expression_dirichlet_apply_scalar_dev(this, x_d, time, strong, strm)
Apply the condition to a scalar field (device version).
subroutine expression_dirichlet_init_from_components(this, coef, str)
Constructor from components.
subroutine expression_dirichlet_finalize(this, only_facets)
Finalize.
subroutine, public expression_mask_coords(bc, xm, ym, zm)
Tabulate the coordinates of the points of the mask of a boundary condition.
subroutine expression_dirichlet_apply_vector(this, x, y, z, n, time, strong)
(No-op) Apply vector.
subroutine expression_dirichlet_free(this)
Destructor.
Evaluation of mathematical expressions given as strings in the case file.
subroutine, public expression_check_finite(str, res, n, usage)
Abort if an expression did not evaluate to a finite value everywhere.
Utilities for retrieving parameters from the case files.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Module with things related to the simulation time.
Base type for a boundary condition.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
A compiled mathematical expression.
Dirichlet condition on , where is a mathematical expression given in the case file.
A struct that contains all info about the time, expand as needed.