Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mpp
MLUQ
Commits
4ce7755d
Commit
4ce7755d
authored
Jan 24, 2020
by
niklas.baumgarten
Browse files
refactored HybridFluxGenerator
parent
7a88a3d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
mlmc/src/stochastics/HybridFluxGenerator.C
View file @
4ce7755d
...
@@ -2,38 +2,45 @@
...
@@ -2,38 +2,45 @@
void
HybridFluxGenerator
::
generateFineSample
(
Vector
&
fineField
)
{
void
HybridFluxGenerator
::
generateFineSample
(
Vector
&
fineField
)
{
Vector
&
normalFlux
=
fineField
;
initialize
(
true
);
Vector
flux
(
cellMg3
[
l
-
meshes
.
pLevel
()]);
permeabilityGenerator
->
GetFineSample
(
*
finePerm
);
Vector
perm
(
cellMg1
[
l
-
meshes
.
pLevel
()]);
assemble
->
problem
->
LoadNewSample
(
finePerm
);
Vector
u
(
faceMg
[
l
-
meshes
.
pLevel
()]);
permeabilityGenerator
->
GetFineSample
(
perm
);
Preconditioner
*
pc
=
GetPC
(
"SuperLU"
);
assemble
->
problem
->
LoadNewSample
(
&
perm
);
Preconditioner
*
pc
=
GetPC
(
faceMg
,
*
assemble
,
"SuperLU"
);
Solver
solver
(
pc
,
"GMRES"
);
Solver
solver
(
pc
,
"GMRES"
);
Newton
newton
(
solver
);
Newton
newton
(
solver
);
newton
(
*
assemble
,
u
);
(
newton
)
(
*
assemble
,
*
u
);
assemble
->
setFlux
(
u
,
flux
);
assemble
->
setFlux
(
*
u
,
*
flux
);
assemble
->
SetNormalFlux
(
u
,
normalFlux
);
assemble
->
SetNormalFlux
(
*
u
,
fineField
);
if
(
plotting
)
generatePlot
(
flux
);
if
(
plotting
)
generatePlot
(
*
flux
);
}
}
void
HybridFluxGenerator
::
generateCoarseSample
(
const
Vector
&
fineField
,
void
HybridFluxGenerator
::
generateCoarseSample
(
const
Vector
&
fineField
,
Vector
&
coarseField
)
{
Vector
&
coarseField
)
{
coarseField
=
0
;
initialize
(
false
);
for
(
cell
c
=
coarseField
.
cells
();
c
!=
coarseField
.
cells_end
();
c
++
)
{
permeabilityGenerator
->
GetCoarseSample
(
*
finePerm
,
*
coarsePerm
);
row
coarseRow
=
coarseField
.
find_row
(
c
());
assemble
->
problem
->
LoadNewSample
(
coarsePerm
);
for
(
int
k
=
0
;
k
<
c
.
Children
();
++
k
)
{
row
fineRow
=
fineField
.
find_row
(
c
.
Child
(
k
));
Preconditioner
*
pc
=
GetPC
(
"SuperLU"
);
for
(
int
i
=
0
;
i
<
coarseRow
.
n
();
++
i
)
Solver
solver
(
pc
,
"GMRES"
);
coarseField
(
coarseRow
,
i
)
+=
fineField
(
fineRow
,
i
);
Newton
newton
(
solver
);
}
for
(
int
i
=
0
;
i
<
coarseRow
.
n
();
++
i
)
(
newton
)(
*
assemble
,
*
u
);
coarseField
(
coarseRow
,
i
)
/=
c
.
Children
();
assemble
->
setFlux
(
*
u
,
*
flux
);
assemble
->
SetNormalFlux
(
*
u
,
coarseField
);
if
(
plotting
)
generatePlot
(
*
flux
);
}
void
HybridFluxGenerator
::
initialize
(
bool
fineField
)
{
if
(
fineField
)
{
flux
=
new
Vector
(
cellMatrixGraphs
[
l
-
meshes
.
pLevel
()]);
u
=
new
Vector
(
faceMatrixGraphs
[
l
-
meshes
.
pLevel
()]);
}
else
{
flux
=
new
Vector
(
cellMatrixGraphs
[
l
-
meshes
.
pLevel
()
-
1
]);
u
=
new
Vector
(
faceMatrixGraphs
[
l
-
meshes
.
pLevel
()
-
1
]);
}
}
// TOD0
*
flux
=
0
.
0
,
*
u
=
0
.
0
;
// if (plotting) generatePlot(flux);
}
}
\ No newline at end of file
mlmc/src/stochastics/HybridFluxGenerator.h
View file @
4ce7755d
...
@@ -8,9 +8,19 @@
...
@@ -8,9 +8,19 @@
class
HybridFluxGenerator
:
public
SampleGenerator
{
class
HybridFluxGenerator
:
public
SampleGenerator
{
private:
private:
MatrixGraphs
cellMg1
;
MatrixGraphs
cellMatrixGraphs
;
MatrixGraphs
cellMg3
;
MatrixGraphs
faceMatrixGraphs
;
MatrixGraphs
faceMg
;
// Preconditioner *pc;
// Solver *solver;
// Newton *newton;
Vector
*
finePerm
=
nullptr
;
Vector
*
coarsePerm
=
nullptr
;
Vector
*
flux
=
nullptr
;
Vector
*
u
=
nullptr
;
void
initialize
(
bool
fineField
);
protected:
protected:
Discretization
*
disc
=
nullptr
;
Discretization
*
disc
=
nullptr
;
...
@@ -31,9 +41,13 @@ protected:
...
@@ -31,9 +41,13 @@ protected:
public:
public:
explicit
HybridFluxGenerator
(
int
l
,
Meshes
&
meshes
)
explicit
HybridFluxGenerator
(
int
l
,
Meshes
&
meshes
)
:
SampleGenerator
(
l
,
meshes
),
:
SampleGenerator
(
l
,
meshes
),
cellMg1
(
MatrixGraphs
(
meshes
,
dof
(
"cell"
,
1
))),
cellMatrixGraphs
(
MatrixGraphs
(
meshes
,
dof
(
"cell"
,
3
))),
cellMg3
(
MatrixGraphs
(
meshes
,
dof
(
"cell"
,
3
))),
faceMatrixGraphs
(
MatrixGraphs
(
meshes
,
dof
(
"face"
,
1
)))
{
faceMg
(
MatrixGraphs
(
meshes
,
dof
(
"face"
,
1
)))
{
finePerm
=
new
Vector
(
cellMatrixGraphs
[
l
-
meshes
.
pLevel
()]);
if
(
l
!=
meshes
.
pLevel
())
coarsePerm
=
new
Vector
(
cellMatrixGraphs
[
l
-
meshes
.
pLevel
()
-
1
]);
else
coarsePerm
=
nullptr
;
}
}
~
HybridFluxGenerator
()
{
~
HybridFluxGenerator
()
{
...
@@ -41,7 +55,12 @@ public:
...
@@ -41,7 +55,12 @@ public:
delete
problem
;
delete
problem
;
delete
assemble
;
delete
assemble
;
delete
permeabilityGenerator
;
delete
permeabilityGenerator
;
};
delete
finePerm
;
delete
coarsePerm
;
delete
flux
;
delete
u
;
}
void
SetPlot
(
Plot
*
plotFromMC
)
override
{
void
SetPlot
(
Plot
*
plotFromMC
)
override
{
permeabilityGenerator
->
SetPlot
(
plotFromMC
);
permeabilityGenerator
->
SetPlot
(
plotFromMC
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment