|
1 | | -function loadstruct = setupBCpercase(runcase, G, tbls, mappings) |
| 1 | +function loadstruct = setupBCpercase(runcase, G, tbls, mappings, extras) |
2 | 2 | % Boundary conditions |
3 | 3 |
|
4 | 4 | %{ |
|
29 | 29 | cellnodefacecoltbl = tbls.cellnodefacecoltbl; |
30 | 30 | coltbl = tbls.coltbl; |
31 | 31 | cellcoltbl = tbls.cellcoltbl; |
| 32 | + celltbl = tbls.celltbl; |
32 | 33 |
|
33 | 34 | nodeface_from_cellnodeface = mappings.nodeface_from_cellnodeface; |
34 | 35 |
|
|
47 | 48 | % in cellnodefacetbl. |
48 | 49 | facetNormals = reshape(facetNormals', [], 1); |
49 | 50 |
|
50 | | - % no volumetric force |
51 | | - force = zeros(cellcoltbl.num, 1); |
52 | | - |
| 51 | + % force and extforce will be set to zero if nothing is set otherwise |
| 52 | + force = []; |
| 53 | + extforce = []; |
53 | 54 |
|
54 | 55 | switch runcase |
55 | 56 |
|
|
156 | 157 |
|
157 | 158 | force = tblmap(force, coltbl, sourcetbl, {'coldim'}); |
158 | 159 | force = tblmap(force, sourcetbl, cellcoltbl, {'cells', 'coldim'}); |
| 160 | + |
159 | 161 | end |
160 | | - |
| 162 | + |
161 | 163 | case {'3d-linear', '3d-compaction'} |
162 | 164 | switch runcase |
163 | 165 | case '3d-linear' |
|
222 | 224 | map = map.setup(); |
223 | 225 | extforce = map.eval(-extFacetNormals); |
224 | 226 |
|
| 227 | + case '3d-gravity' |
| 228 | + |
| 229 | + ind = 1; |
| 230 | + for i = 1 : 3 |
| 231 | + for j = 1 : 2 |
| 232 | + addface = true; |
| 233 | + if j == 1 |
| 234 | + if i == 3 |
| 235 | + % The bottom face is free. (Note that for geological reservoir, bottom face corresponds to top face.) |
| 236 | + addface = false; |
| 237 | + else |
| 238 | + v = min(G.faces.centroids(:, i)); |
| 239 | + end |
| 240 | + else |
| 241 | + v = max(G.faces.centroids(:, i)); |
| 242 | + end |
| 243 | + |
| 244 | + if addface |
| 245 | + |
| 246 | + extfaces{ind} = find(abs(G.faces.centroids(:, i) - v) < 1e-5); |
| 247 | + |
| 248 | + n = numel(extfaces{ind}); |
| 249 | + |
| 250 | + linform = zeros(3, 1); |
| 251 | + linform(i) = 1; |
| 252 | + linforms{ind} = repmat(linform, n, 1); |
| 253 | + |
| 254 | + linformvals{ind} = zeros(n, 1); |
| 255 | + |
| 256 | + ind = ind + 1; |
| 257 | + |
| 258 | + end |
| 259 | + end |
| 260 | + end |
| 261 | + |
| 262 | + % for ind = 1 : numel(extfaces) |
| 263 | + % figure |
| 264 | + % plotGrid(G, 'facecolor', 'none'); |
| 265 | + % plotFaces(G, extfaces{ind}); |
| 266 | + % end |
| 267 | + |
| 268 | + vols = G.cells.volumes; |
| 269 | + |
| 270 | + ztbl.coldim = 3; |
| 271 | + ztbl = IndexArray(ztbl); |
| 272 | + |
| 273 | + cellztbl = crossIndexArray(celltbl, ztbl, {}); |
| 274 | + |
| 275 | + map = TensorMap(); |
| 276 | + map.fromTbl = cellztbl; |
| 277 | + map.toTbl = cellcoltbl; |
| 278 | + map.mergefds= {'cells', 'coldim'}; |
| 279 | + map = map.setup(); |
| 280 | + |
| 281 | + rho = extras.rho; |
| 282 | + force = map.eval(rho*vols*10); |
| 283 | + |
225 | 284 | otherwise |
| 285 | + |
226 | 286 | error('runcase not recognized'); |
| 287 | + |
227 | 288 | end |
228 | 289 |
|
229 | 290 | bc.extfaces = vertcat(extfaces{:}); |
|
232 | 293 |
|
233 | 294 | bc = setupFaceBC(bc, G, tbls); |
234 | 295 |
|
235 | | - loadstruct.bc = bc; |
| 296 | + if isempty(force) |
| 297 | + force = zeros(cellcoltbl.num, 1); |
| 298 | + end |
| 299 | + |
| 300 | + if isempty(extforce) |
| 301 | + extforce = zeros(nodefacecoltbl.num, 1); |
| 302 | + end |
| 303 | + |
| 304 | + loadstruct.bc = bc; |
236 | 305 | loadstruct.extforce = extforce; |
237 | | - loadstruct.force = force; |
| 306 | + loadstruct.force = force; |
| 307 | + |
238 | 308 | end |
0 commit comments