! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! ! ! Maintainers : support@fluidnumerics.com ! Official Repository : https://github.com/FluidNumerics/self/ ! ! Copyright © 2024 Fluid Numerics LLC ! ! Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ! ! 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. ! ! 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in ! the documentation and/or other materials provided with the distribution. ! ! 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from ! this software without specific prior written permission. ! ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ! HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ! LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ! THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ! ! //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ! module SELF_MultiSetModel3D !! GPU backend of MultiSetModel3D. The interface exchange gathers each set's face trace !! from solution%boundary_gpu, and the default FillInterfaceBoundary writes !! solution%extBoundary_gpu with a device kernel. Overrides of FillInterfaceBoundary must !! likewise write the device copy (iface%ghost_gpu holds the ghost traces there), and must !! not call solution%UpdateDevice inside the step loop: it resets the halo exchange's !! static-variable state. use SELF_MultiSetModel3D_t use SELF_SetInterface_3D use SELF_GPU use iso_c_binding implicit none type,extends(MultiSetModel3D_t) :: MultiSetModel3D contains procedure :: SetupInterfaces => SetupInterfaces_MultiSetModel3D procedure :: FillInterfaceBoundary => FillInterfaceBoundary_MultiSetModel3D endtype MultiSetModel3D contains subroutine SetupInterfaces_MultiSetModel3D(this) !! As SetupInterfaces_MultiSetModel3D_t, then points each set's trace reference at !! the device copy of its solution%boundary. implicit none class(MultiSetModel3D),intent(inout) :: this ! Local integer :: k call SetupInterfaces_MultiSetModel3D_t(this) do k = 1,this%nSets this%traces(k)%trace_gpu = this%sets(k)%model%solution%boundary_gpu enddo endsubroutine SetupInterfaces_MultiSetModel3D subroutine FillInterfaceBoundary_MultiSetModel3D(this,iset) !! Device version of FillInterfaceBoundary_MultiSetModel3D_t: !! extBoundary(i,j,s,e,v) = ghost(i,j,v,f) on the interface faces of set iset, written !! to solution%extBoundary_gpu. The partner set must have the same nvar. implicit none class(MultiSetModel3D),intent(inout) :: this integer,intent(in) :: iset ! Local integer :: f,nvar,nk nvar = this%sets(iset)%model%nvar do f = this%iface%setFaceStart(iset),this%iface%setFaceStart(iset+1)-1 if(this%iface%nvarOfSet(this%iface%facePartnerSet(f)) /= nvar) then print*,__FILE__," : sets ",iset," and ",this%iface%facePartnerSet(f), & " have different nvar" error stop "MultiSetModel3D : override FillInterfaceBoundary to couple these sets" endif enddo nk = this%iface%setFaceStart(iset+1)-this%iface%setFaceStart(iset) if(nk == 0) return call FillSetInterfaceBoundary_gpu(this%sets(iset)%model%solution%extBoundary_gpu, & this%iface%ghost_gpu, & this%iface%faceElem_gpu,this%iface%faceSide_gpu, & this%iface%setFaceStart(iset)-1,nk,nvar, & this%iface%nvarMax,this%iface%N, & this%sets(iset)%mesh%nElem) endsubroutine FillInterfaceBoundary_MultiSetModel3D endmodule SELF_MultiSetModel3D