HybridFluxGenerator.C 1.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#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);
    assemble.problem->LoadNewSample(&perm);

    Preconditioner *pc = GetPC(faceMatrixGraph, assemble, "LIB_PS");
    Solver solver(pc, "GMRES");
    Newton newton(solver);
    newton(assemble, solution);
    assemble.setFlux(solution, fineField);
}

void HybridFluxGenerator2D::GetCoarseSample(const Vector &fineField,
                                            Vector &coarseField) {
    coarseField = 0;

    mout << OUTX(fineField) << endl;
    mout << OUTX(coarseField) << endl;

    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();
    }

    mout << OUTX(fineField) << endl;
    mout << OUTX(coarseField) << endl;

}