Skip to content

Commit

Permalink
Topography Smoothing
Browse files Browse the repository at this point in the history
  • Loading branch information
OsKnoth committed Jan 9, 2024
1 parent 68603b8 commit 82bf86c
Show file tree
Hide file tree
Showing 18 changed files with 538 additions and 264 deletions.
50 changes: 50 additions & 0 deletions AA
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@kernel function HyperViscTracerKernel!(FTr,@Const(Tr),@Const(Rho),@Const(D),@Const(DW),@Const(dXdxI),
@Const(JJ),@Const(M),@Const(Glob))

I, J, iz = @index(Local, NTuple)
_,_,Iz,IF = @index(Global, NTuple)

ColumnTilesDim = @uniform @groupsize()[3]
N = @uniform @groupsize()[1]
Nz = @uniform @ndrange()[3]
NF = @uniform @ndrange()[4]

ID = I + (J - 1) * N
@inbounds ind = Glob[ID,IF]

TrCol = @localmem eltype(FTr) (N,N, ColumnTilesDim)
TrCxCol = @localmem eltype(FTr) (N,N, ColumnTilesDim)
TrCyCol = @localmem eltype(FTr) (N,N, ColumnTilesDim)
if Iz <= Nz && IF <= NF
@inbounds TrCol[I,J,iz] = Tr[Iz,ind] / Rho[Iz,ind]
end
@synchronize

ID = I + (J - 1) * N
@inbounds ind = Glob[ID,IF]

if Iz <= Nz && IF <= NF
@inbounds Dxc = D[I,1] * TrCol[1,J,iz]
@inbounds Dyc = D[J,1] * TrCol[I,1,iz]
for k = 2 : N
@inbounds Dxc += D[I,k] * TrCol[k,J,iz]
@inbounds Dyc += D[J,k] * TrCol[I,k,iz]
end
@views @inbounds (GradDx, GradDy) = Grad12(Dxc,Dyc,dXdxI[1:2,1:2,:,ID,Iz,IF],JJ[ID,:,Iz,IF])
@views @inbounds (tempx, tempy) = Contra12(GradDx,GradDy,dXdxI[1:2,1:2,:,ID,Iz,IF])
@inbounds TrCxCol[I,J,iz] = tempx
@inbounds TrCyCol[I,J,iz] = tempy
end

@synchronize

ID = I + (J - 1) * N
@inbounds ind = Glob[ID,IF]
if Iz <= Nz && IF <= NF
@inbounds DivTr = DW[I,1] * TrCxCol[1,J,iz] + DW[J,1] * TrCyCol[I,1,iz]
for k = 2 : N
@inbounds DivTr += DW[I,k] * TrCxCol[k,J,iz] + DW[J,k] * TrCyCol[I,k,iz]
end
@inbounds @atomic FTr[Iz,ind] += DivTr / M[Iz,ind]
end
end
7 changes: 7 additions & 0 deletions Examples/testPolynom.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import CGDycore:
Examples, Parallels, Models, Grids, Outputs, Integration, GPU, DyCore, FiniteElements
using MPI

function main(Order)
F1 = FiniteElements.W1(Order)
end
Binary file modified GlobInd
Binary file not shown.
48 changes: 27 additions & 21 deletions Jobs/NHSphere/JobNHBaroWaveDrySphereOro
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
mpirun -n 6 julia --project Examples/testNHSphere.jl \
--Problem="BaroWaveDrySphereOro" \
--Problem="BaroWaveDrySphere" \
--Device="CPU" \
--GPUType="Metal" \
--FloatTypeBackend="Float32" \
--NumberThreadGPU=512 \
--NumV=5 \
--NumTr=0 \
--ProfRho="BaroWaveDrySphere" \
--ProfTheta="BaroWaveDrySphere" \
--ProfVel="BaroWaveDrySphere" \
--ProfpBGrd="" \
--ProfRhoBGrd="" \
--Source=false \
--ProfpBGrd="IsoThermal" \
--ProfRhoBGrd="IsoThermal" \
--RefProfile=false \
--Coriolis=true \
--SurfaceFluxMom=false \
--VerticalDiffusionMom=false \
--Curl=true\
--Forcing=false \
--Curl=false \
--ModelType="VectorInvariant" \
--StrideDamp=15000 \
--Relax=1.0e-2 \
--Coriolis=true \
--VerticalDiffusion=false \
--Upwind=true \
--HorLimit=false \
--Buoyancy=true \
--Decomp="EqualArea" \
--SimDays=20 \
--PrintDays=1 \
--dtau=300.0 \
--SimDays=10 \
--SimSeconds=0 \
--PrintSeconds=150 \
--PrintMinutes=0 \
--PrintHours=0 \
--PrintDays=0 \
--StartAverageDays=100 \
--Flat=true \
--dtau=75 \
--IntMethod="Rosenbrock" \
--Table="SSP-Knoth" \
--TopoS="EarthOrography" \
--Stretch=true \
--StretchType="Exp" \
--GridType="CubedSphere" \
--nz=45 \
--nPanel=16 \
--nz=64 \
--nPanel=30 \
--H=30000.0 \
--OrdPoly=3 \
--HyperVisc=true \
--HyperDCurl=1.e16 \
--HyperDGrad=1.e16 \
--HyperDDiv=1.e16
--HyperDCurl=1.e15 \
--HyperDGrad=1.e15 \
--HyperDDiv=1.e15 \
--HyperDDivW=1.e15
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ProfileCanvas = "efd6af41-a80b-495e-886c-e51b0c7d77a3"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
RootSolvers = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SpecialPolynomials = "a25cea48-d430-424a-8ee7-0d3ad3742e9e"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StrideArraysCore = "7792a7ef-975c-4747-a70f-980b88e8d1da"
Expand Down
1 change: 1 addition & 0 deletions src/CGDycore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ include("Outputs/Outputs.jl")
include("Integration/Integration.jl")
include("DyCore/DyCore.jl")
include("GPU/GPU.jl")
include("FiniteElements/FiniteElements.jl")

OOP = 5

Expand Down
1 change: 0 additions & 1 deletion src/DyCore/DyCore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ include("Source.jl")
include("simpson.jl")
include("Diffusion.jl")
include("ThreadCache.jl")
include("TopographySmoothing.jl")
include("parse_commandline.jl")
include("GlobalVariables.jl")
include("InitDriver.jl")
Expand Down
3 changes: 3 additions & 0 deletions src/DyCore/GlobalVariables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ mutable struct OutputStruct
RadPrint::Float64
H::Float64
OrdPrint::Int
dTol::Float64
end
function OutputStruct()
vtk=0
Expand All @@ -90,6 +91,7 @@ function OutputStruct()
RadPrint=1000.0
H=1000.0
OrdPrint=1
dTol=1.e-8
return OutputStruct(
vtk,
vtkFileName,
Expand All @@ -109,6 +111,7 @@ function OutputStruct()
RadPrint,
H,
OrdPrint,
dTol,
)
end

Expand Down
33 changes: 17 additions & 16 deletions src/DyCore/InitDriver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,32 @@ function InitSphere(backend,FT,OrdPoly,OrdPolyZ,nz,nPanel,H,GridType,Topography,
Global = GlobalStruct{FT}(backend,SubGrid,Model,TimeStepper,ParallelCom,Output,DoF,nz,
Model.NumV,Model.NumTr,())
CG = CGQuad{FT}(backend,OrdPoly,OrdPolyZ,Global.Grid)
(CG,Metric) = DiscretizationCG(backend,FT,Grids.JacobiSphere3,CG,Exchange,Global)

# Output partition
nzTemp = Global.Grid.nz
Global.Grid.nz = 1
vtkCachePart = Outputs.vtkStruct{FT}(backend,1,Grids.TransSphereX!,CG,Metric,Global)
Outputs.unstructured_vtkPartition(vtkCachePart,Global.Grid.NumFaces,Proc,ProcNumber)
Global.Grid.nz = nzTemp

if Topography.TopoS == "EarthOrography"
zS = Grids.Orography(CG,Global)
Output.RadPrint = H
Output.Flat=false
nzTemp = Global.Grid.nz
Global.Grid.nz = 1
vtkCacheOrography = Outputs.vtkStruct(OrdPoly,Grids.TransSphereX,CG,Global)
Outputs.unstructured_vtkOrography(zS,vtkCacheOrography,Global.Grid.NumFaces,CG,Proc,ProcNumber)
Global.Grid.nz = nzTemp
zS = Grids.Orography(backend,FT,CG,Exchange,Global)
end

if Topography.TopoS == "EarthOrography"
(CG,Metric) = DiscretizationCG(backend,FT,Grids.JacobiSphere3,CG,Exchange,Global,zS)
else
(CG,Metric) = DiscretizationCG(backend,FT,Grids.JacobiSphere3,CG,Exchange,Global)
end
Global.Output.dTol = 2*pi / nPanel
# Output Orography
if Topography.TopoS == "EarthOrography"
Output.Flat=true
nzTemp = Global.Grid.nz
Global.Grid.nz = 1
vtkCacheOrography = Outputs.vtkInit2D(CG.OrdPoly,Grids.TransSphereX!,CG,Metric,Global)
Outputs.unstructured_vtkOrography(zS,vtkCacheOrography,Global.Grid.NumFaces,CG,Proc,ProcNumber)
Global.Grid.nz = nzTemp
end
# Output partition
nzTemp = Global.Grid.nz
Global.Grid.nz = 1
vtkCachePart = Outputs.vtkStruct{FT}(backend,1,Grids.TransSphereX!,CG,Metric,Global)
Outputs.unstructured_vtkPartition(vtkCachePart,Global.Grid.NumFaces,Proc,ProcNumber)
Global.Grid.nz = nzTemp
return CG,Metric,Exchange,Global
end

Expand Down
156 changes: 0 additions & 156 deletions src/DyCore/TopographySmoothing.jl

This file was deleted.

Loading

0 comments on commit 82bf86c

Please sign in to comment.