Mercurial > repos > public > sbplib
comparison +grid/lebedev2d.m @ 1331:60c875c18de3 feature/D2_boundary_opt
Merge with feature/poroelastic for Elastic schemes
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 10 Mar 2022 16:54:26 +0100 |
parents | cf542444f022 |
children |
comparison
equal
deleted
inserted
replaced
1330:855871e0b852 | 1331:60c875c18de3 |
---|---|
1 % Creates a 2D staggered grid of Lebedev (checkerboard) type | |
2 % Primal grid: equidistant with m points. | |
3 % Dual grid: m + 1 points, h/2 spacing first point. | |
4 % First grid line is "primal", 2nd is "dual", etc. | |
5 % | |
6 % Examples | |
7 % g = grid.Lebedev2d(m, xlims, ylims) | |
8 % g = grid.Lebedev2d([21, 31], {0,2}, {0,3}) | |
9 function g = lebedev2d(m, xlims, ylims, opSet) | |
10 | |
11 default_arg('opSet', @(m,lim) sbp.D1StaggeredUpwind(m,lim,2)); | |
12 | |
13 if ~iscell(xlims) || numel(xlims) ~= 2 | |
14 error('grid:lebedev2D:InvalidLimits','The limits should be cell arrays with 2 elements.'); | |
15 end | |
16 | |
17 if ~iscell(ylims) || numel(ylims) ~= 2 | |
18 error('grid:lebedev2D:InvalidLimits','The limits should be cell arrays with 2 elements.'); | |
19 end | |
20 | |
21 if xlims{1} > xlims{2} | |
22 error('grid:lebedev2D:InvalidLimits','The elements of the limit must be increasing.'); | |
23 end | |
24 | |
25 if ylims{1} > ylims{2} | |
26 error('grid:lebedev2D:InvalidLimits','The elements of the limit must be increasing.'); | |
27 end | |
28 | |
29 opsX = opSet(m(1), xlims); | |
30 xp = opsX.x_primal; | |
31 xd = opsX.x_dual; | |
32 | |
33 opsY = opSet(m(2), ylims); | |
34 yp = opsY.x_primal; | |
35 yd = opsY.x_dual; | |
36 | |
37 % 4 Cartesian grids with spacing h | |
38 % 2 grids for displacements (u) | |
39 % 2 grids for stresses (sigma) | |
40 % Density needs to be evaluated on the u grids | |
41 % The stiffness tensor is evaluated on the sigma grids | |
42 | |
43 gu1 = grid.Cartesian(xp, yp); | |
44 gu2 = grid.Cartesian(xd, yd); | |
45 gs1 = grid.Cartesian(xd, yp); | |
46 gs2 = grid.Cartesian(xp, yd); | |
47 | |
48 gu = {gu1, gu2}; | |
49 gs = {gs1, gs2}; | |
50 | |
51 dim = 2; | |
52 g = grid.Staggered(dim, gu, gs); | |
53 | |
54 end | |
55 | |
56 | |
57 |