This repository has been archived by the owner on Jul 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChannel_Mesh.jl
80 lines (66 loc) · 1.88 KB
/
Channel_Mesh.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using Gridap
using Gridap.FESpaces
using Gridap.ReferenceFEs
using Gridap.Arrays
using Gridap.Geometry
using Gridap.Fields
using Gridap.CellData
using FillArrays
using Test
using InteractiveUtils
using GridapDistributed
using PartitionedArrays
function mesh_channel(; D::Integer, N=32::Integer, parts=1, printmodel=false::Bool, periodic=true)
"""
mesh_channel() generate a mesh for a channel;
Periodic boundaries in dimensions 1 and 3 if periodic is set
In dimensions 1 and 3 equally spaced
In dimension 2 function distributed
#Arguments
- D::Integer number of dimensions (2 or 3)
- N::Integer numer of cells in each dimension, deault value N=32
- parts :: if distributed
- printmodel::Boolean if true create vtk file pf the model
"""
#D = 2 # Number of spatial dimensions
Lx = 2 * pi
Ly = 2
Lz = 2 / 3 * pi
nx = N
ny = N
nz = N
#N = 32 # Partition (i.e., number of cells per space dimension)
function stretching(x::Point)
m = zeros(length(x))
m[1] = x[1]
gamma1 = 2.5
m[2] = -tanh(gamma1 * (x[2])) / tanh(gamma1)
if length(x) > 2
m[3] = x[3]
end
Point(m)
end
if D > 2
pmin = Point(0, -Ly / 2, -Lz / 2)
pmax = Point(Lx, Ly / 2, Lz / 2)
partition = (nx, ny, nz)
periodic_tuple = (periodic, false, periodic)
model_name = "model3d"
else
pmin = Point(0, -Ly / 2)
pmax = Point(Lx, Ly / 2)
partition = (nx, ny)
periodic_tuple = (periodic, false)
model_name = "model2d"
end
#partition = Tuple(Fill(N, D))
if parts != 1
model = CartesianDiscreteModel(parts, pmin, pmax, partition, map=stretching, isperiodic=periodic_tuple)
else
model = CartesianDiscreteModel(pmin, pmax, partition, map=stretching, isperiodic=periodic_tuple)
end
if printmodel
writevtk(model, model_name)
end
return model
end