41 use json_module,
only : json_file
43 use,
intrinsic :: iso_c_binding, only : c_ptr
61 procedure, pass(this) :: init_from_components => &
76 class(
symmetry_t),
intent(inout),
target :: this
77 type(
coef_t),
intent(in) :: coef
78 type(json_file),
intent(inout) ::json
80 call this%init_from_components(coef)
87 class(
symmetry_t),
intent(inout),
target :: this
88 type(
coef_t),
intent(in) :: coef
93 call this%init_base(coef)
94 call this%bc_x%init_from_components(this%coef)
95 call this%bc_y%init_from_components(this%coef)
96 call this%bc_z%init_from_components(this%coef)
104 class(
symmetry_t),
target,
intent(inout) :: this
105 integer :: i, m, j, l
107 real(kind=
rp) :: sx, sy, sz
108 real(kind=
rp),
parameter :: tol = 1e-3_rp
112 call this%finalize_base()
114 associate(c => this%coef, nx => this%coef%nx, ny => this%coef%ny, &
116 bfp => this%marked_facet%array()
117 do i = 1, this%marked_facet%size()
119 facet = bc_facet%x(1)
121 call this%get_normal_axis(sx, sy, sz, facet, el)
123 if (sx .lt. tol)
then
124 call this%bc_x%mark_facet(facet, el)
127 if (sy .lt. tol)
then
128 call this%bc_y%mark_facet(facet, el)
131 if (sz .lt. tol)
then
132 call this%bc_z%mark_facet(facet, el)
136 call this%bc_x%finalize()
137 call this%bc_y%finalize()
138 call this%bc_z%finalize()
145 class(
symmetry_t),
target,
intent(inout) :: this
146 real(kind=rp),
intent(out) :: sx, sy, sz
147 integer,
intent(in) :: facet
148 integer,
intent(in) :: el
149 integer :: i, m, j, l
150 type(tuple_i4_t),
pointer :: bfp(:)
152 real(kind=rp),
parameter :: tol = 1d-3
153 type(tuple_i4_t) :: bc_facet
155 associate(c => this%coef, nx => this%coef%nx, ny => this%coef%ny, &
162 do l = 2, c%Xh%lx - 1
164 sx = sx + abs(abs(nx(l, j, facet, el)) - 1d0)
165 sy = sy + abs(abs(ny(l, j, facet, el)) - 1d0)
166 sz = sz + abs(abs(nz(l, j, facet, el)) - 1d0)
170 do l = 2, c%Xh%lx - 1
171 do j = 2, c%Xh%lx - 1
172 sx = sx + abs(abs(nx(l, j, facet, el)) - 1d0)
173 sy = sy + abs(abs(ny(l, j, facet, el)) - 1d0)
174 sz = sz + abs(abs(nz(l, j, facet, el)) - 1d0)
178 do l = 2, c%Xh%lx - 1
179 do j = 2, c%Xh%lx - 1
180 sx = sx + abs(abs(nx(l, j, facet, el)) - 1d0)
181 sy = sy + abs(abs(ny(l, j, facet, el)) - 1d0)
182 sz = sz + abs(abs(nz(l, j, facet, el)) - 1d0)
186 sx = sx / (c%Xh%lx - 2)**2
187 sy = sy / (c%Xh%lx - 2)**2
188 sz = sz / (c%Xh%lx - 2)**2
200 integer,
intent(in) :: n
201 real(kind=rp),
intent(inout),
dimension(n) :: x
202 real(kind=rp),
intent(in),
optional :: t
203 integer,
intent(in),
optional :: tstep
204 logical,
intent(in),
optional :: strong
217 integer,
intent(in) :: n
218 real(kind=rp),
intent(inout),
dimension(n) :: x
219 real(kind=rp),
intent(inout),
dimension(n) :: y
220 real(kind=rp),
intent(inout),
dimension(n) :: z
221 real(kind=rp),
intent(in),
optional :: t
222 integer,
intent(in),
optional :: tstep
223 logical,
intent(in),
optional :: strong
224 logical :: strong_ = .true.
226 if (
present(strong)) strong_ = strong
229 call this%bc_x%apply_scalar(x, n)
230 call this%bc_y%apply_scalar(y, n)
231 call this%bc_z%apply_scalar(z, n)
242 class(
symmetry_t),
intent(inout),
target :: this
244 real(kind=rp),
intent(in),
optional :: t
245 integer,
intent(in),
optional :: tstep
246 logical,
intent(in),
optional :: strong
257 class(
symmetry_t),
intent(inout),
target :: this
261 real(kind=rp),
intent(in),
optional :: t
262 integer,
intent(in),
optional :: tstep
263 logical,
intent(in),
optional :: strong
264 logical :: strong_ = .true.
266 if (
present(strong)) strong_ = strong
268 if (strong_ .and. (this%msk(0) .gt. 0))
then
269 call device_symmetry_apply_vector(this%bc_x%msk_d, this%bc_y%msk_d, &
270 this%bc_z%msk_d, x_d, y_d, z_d, &
271 this%bc_x%msk(0), this%bc_y%msk(0), this%bc_z%msk(0))
277 class(
symmetry_t),
target,
intent(inout) :: this
279 call this%free_base()
280 call this%bc_x%free()
281 call this%bc_y%free()
282 call this%bc_z%free()
Defines a boundary condition.
subroutine device_symmetry_apply_vector(xmsk, ymsk, zmsk, x, y, z, m, n, l)
Defines a dirichlet boundary condition.
integer, parameter, public rp
Global precision used in computations.
Mixed Dirichlet-Neumann axis aligned symmetry plane.
subroutine symmetry_init_from_components(this, coef)
Constructor from components.
subroutine symmetry_apply_scalar(this, x, n, t, tstep, strong)
No-op scalar apply.
subroutine symmetry_init(this, coef, json)
Constructor.
subroutine symmetry_apply_scalar_dev(this, x_d, t, tstep, strong)
No-op scalar apply (device version)
subroutine symmetry_finalize(this)
Finalize. Marks the appropriate faces for application of a homogeneous Dirchlet condition based on th...
subroutine symmetry_apply_vector_dev(this, x_d, y_d, z_d, t, tstep, strong)
Apply symmetry conditions (axis aligned) (device version)
subroutine symmetry_apply_vector(this, x, y, z, n, t, tstep, strong)
Apply symmetry conditions (axis aligned)
subroutine symmetry_free(this)
Destructor.
subroutine symmetry_get_normal_axis(this, sx, sy, sz, facet, el)
Compute the average normal for a facet of an element.
Defines a zero-valued Dirichlet boundary condition.
Base type for a boundary condition.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Generic Dirichlet boundary condition on .
Mixed Dirichlet-Neumann symmetry plane condition.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...