Mercurial > repos > public > sbplib
comparison +rv/+diffops/constructDiffOpsMultiGrid.m @ 1167:66c0fbbc406f feature/rv
Make constructDiffOps return a struct with the operators
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Fri, 28 Jun 2019 12:53:47 +0200 |
parents | 17bb3c46472c |
children | af3c4eb0cbbd |
comparison
equal
deleted
inserted
replaced
1166:17bb3c46472c | 1167:66c0fbbc406f |
---|---|
1 function [D_scheme, D_coarse, D_flux, D_t, penalties_scheme, penalties_res] = constructDiffOpsMultiGrid(scheme, g, schemeOrder, residualOrder, schemeParams, opSet, BCs) | 1 function diffOpsStruct = constructDiffOpsMultiGrid(scheme, g, schemeOrder, residualOrder, schemeParams, opSet, BCs) |
2 % DiffOps for solution vector | 2 % DiffOps for stabilized solution vector |
3 [D_scheme, penalties_scheme, ~] = rv.diffops.constructSchemeDiffOp(scheme, g, schemeOrder, schemeParams, opSet, BCs); | 3 [D_scheme, penalties_scheme] = rv.diffops.constructSchemeDiffOp(scheme, g, schemeOrder, schemeParams, opSet, BCs); |
4 [D_coarse, penalties_coarse] = rv.diffops.constructFluxDiffOpWithClosures(scheme, g, schemeOrder, schemeParams, opSet, BCs); | 4 % DiffOp for unstabilized solution vector |
5 D_unstable = rv.diffops.constructFluxDiffOpWithClosures(scheme, g, schemeOrder, schemeParams, opSet, BCs); | |
5 %% DiffOps for residual viscosity | 6 %% DiffOps for residual viscosity |
6 [D_t, penalties_res] = rv.diffops.constructFluxDiffOpWithClosures(scheme, g, residualOrder, schemeParams, opSet, BCs); | 7 [D_t, penalties_res] = rv.diffops.constructFluxDiffOpWithClosures(scheme, g, residualOrder, schemeParams, opSet, BCs); |
7 D_flux = @(v) -D_t(v); | 8 D_flux = @(v) -D_t(v); |
8 rvOperators = {} | 9 diffOpsStruct = struct('D_scheme', D_scheme,... |
10 'D_unstable', D_unstable,... | |
11 'D_flux', D_flux,... | |
12 'D_t', D_t,... | |
13 'penalties_scheme', penalties_scheme,... | |
14 'penalties_res', penalties_res); | |
9 end | 15 end |
10 | 16 |
11 % TODO: Not clear if this is needed | 17 % TODO: Not clear if this is needed |
12 % TODO: Only works for equidistant grids | 18 % TODO: Only works for equidistant grids |
13 function [D_coarse, penalties_coarse] = constructCoarserGridDiffOp(scheme, g, schemeOrder, schemeParams, opSet, BCs) | 19 function [D_coarse, penalties_coarse] = constructCoarserGridDiffOp(scheme, g, schemeOrder, schemeParams, opSet, BCs) |
14 m = g.m(); | 20 m = g.m(); |
15 lim = g.lim(); | 21 lim = g.lim(); |
16 m_coarse = (m-1)/2 + 1; | 22 m_coarse = (m-1)/2 + 1; |
17 g_coarse = grid.equidistant(m_coarse, lim{1}); | 23 g_coarse = grid.equidistant(m_coarse, lim{1}); |
18 [D_coarse, penalties_coarse] = rv.diffops.constructFluxDiffOpWithClosures(scheme, g_coarse, schemeOrder, schemeParams, opSet, BCs); | 24 [D_coarse, penalties_coarse] = rv.diffops.constructFluxDiffOpWithClosures(scheme, g_coarse, schemeOrder, schemeParams, opSet, BCs); |
19 x = g.x{1}; | 25 x = g.x{1}; |
20 x_coarse = x(1:2:end); | 26 x_coarse = x(1:2:end); |
21 % TODO: Fix interpolation | 27 % TODO: Fix interpolation |
22 D_coarse = @(v) interp1(x_coarse,D_coarse(v(1:2:end)),x,'spline'); | 28 D_coarse = @(v) interp1(x_coarse,D_coarse(v(1:2:end)),x,'spline'); |
23 end | 29 end |