Mercurial > repos > public > sbplib
annotate +scheme/+bc/closureSetup.m @ 1031:2ef20d00b386 feature/advectionRV
For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 17 Jan 2019 10:25:06 +0100 |
parents | ba10f24bf476 |
children |
rev | line source |
---|---|
873
dee5b5a57be6
Clean up closureSetup
Jonatan Werpers <jonatan@werpers.com>
parents:
870
diff
changeset
|
1 % Setup closure and penalty matrices for several boundary conditions at once. |
899
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
2 % Each bc is a struct with the fields |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
3 % * type -- Type of boundary condition |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
4 % * boundary -- Boundary identifier |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
5 % * data -- A function_handle for a function which provides boundary data.(see below) |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
6 % Also takes S_sign which modifies the sign of the penalty function, [-1,1] |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
7 % Returns a closure matrix and a penalty matrices for each boundary condition. |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
8 % |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
9 % The boundary data function can either be a function of time or a function of time and space coordinates. |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
10 % In the case where it only depends on time it should return the data as grid function for the boundary. |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
11 % In the case where it also takes space coordinates the number of space coordinates should match the number of dimensions of the problem domain. |
ba10f24bf476
Fix the documentation of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
873
diff
changeset
|
12 % For example in the 2D case: f(t,x,y). |
870
fb91d12093f8
Change some naming of functions
Jonatan Werpers <jonatan@werpers.com>
parents:
869
diff
changeset
|
13 function [closure, penalties] = closureSetup(diffOp, bcs) |
873
dee5b5a57be6
Clean up closureSetup
Jonatan Werpers <jonatan@werpers.com>
parents:
870
diff
changeset
|
14 scheme.bc.verifyFormat(bcs, diffOp); |
869
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
15 |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
16 % Setup storage arrays |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
17 closure = spzeros(size(diffOp)); |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
18 penalties = cell(1, length(bcs)); |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
19 |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
20 % Collect closures and penalties |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
21 for i = 1:length(bcs) |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
22 [localClosure, penalties{i}] = diffOp.boundary_condition(bcs{i}.boundary, bcs{i}.type); |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
23 closure = closure + localClosure; |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
24 end |
d356f1a22d4f
Start organizing the code
Jonatan Werpers <jonatan@werpers.com>
parents:
diff
changeset
|
25 end |