HybridFluxGenerator.C 1.68 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "HybridFluxGenerator.h"


void HybridFluxGenerator1D::GetFineSample(Vector &fineField) {
}

void HybridFluxGenerator1D::GetCoarseSample(const Vector &fineField,
                                            Vector &coarseField) {
}

void HybridFluxGenerator2D::GetFineSample(Vector &fineField) {
    MatrixGraphs cellMatrixGraph(meshes, dof("cell", 1));
    MatrixGraphs faceMatrixGraph(meshes, dof("face", 1));
    Vector perm(cellMatrixGraph[l - meshes.pLevel()]);
    Vector solution(faceMatrixGraph[l - meshes.pLevel()]);
    permeabilityGenerator.GetFineSample(perm);
niklas.baumgarten's avatar
niklas.baumgarten committed
17
18
19
20
21
22
23
24
25

    bool plotPermForTransport = false;
    config.get("plotPermForTransport", plotPermForTransport);
    if (plotPermForTransport) {
        Plot plot(meshes[l], 2);
        plot.celldata(perm, 1);
        plot.vtk_celldata("permeability");
    }

26
27
    assemble.problem->LoadNewSample(&perm);

niklas.baumgarten's avatar
niklas.baumgarten committed
28
    Preconditioner *pc = GetPC(faceMatrixGraph, assemble, "GaussSeidel");
niklas.baumgarten's avatar
niklas.baumgarten committed
29

30
    Solver solver(pc, "GMRES");
niklas.baumgarten's avatar
niklas.baumgarten committed
31

32
    Newton newton(solver);
niklas.baumgarten's avatar
niklas.baumgarten committed
33

niklas.baumgarten's avatar
niklas.baumgarten committed
34
35
    newton(assemble, solution);
    assemble.setFlux(solution, fineField);
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
}

void HybridFluxGenerator2D::GetCoarseSample(const Vector &fineField,
                                            Vector &coarseField) {
    coarseField = 0;
    for (cell c = coarseField.cells(); c != coarseField.cells_end(); c++) {
        row coarseRow = coarseField.find_row(c());
        for (int k = 0; k < c.Children(); ++k) {
            row fineRow = fineField.find_row(c.Child(k));
            for (int i = 0; i < coarseRow.n(); ++i)
                coarseField(coarseRow, i) += fineField(fineRow, i);
        }
        for (int i = 0; i < coarseRow.n(); ++i)
            coarseField(coarseRow, i) /= c.Children();
    }
}