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
47aaf151
Commit
47aaf151
authored
Feb 03, 2021
by
niklas.baumgarten
Browse files
moved time information to problem, bug fixes and problem refactoring
parent
0f3a34ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
mlmc/src/problems/StochasticTransportProblem.hpp
View file @
47aaf151
...
@@ -8,9 +8,25 @@ class IStochasticTransportProblem : public IStochasticProblem {
...
@@ -8,9 +8,25 @@ class IStochasticTransportProblem : public IStochasticProblem {
private:
private:
bool
rhs
=
true
;
bool
rhs
=
true
;
double
CFL
=
0.5
;
double
t0
=
0.0
;
double
T
=
1.0
;
public:
public:
IStochasticTransportProblem
(
Meshes
&
meshes
,
GeneratorNames
genNames
=
{})
IStochasticTransportProblem
(
Meshes
&
meshes
,
GeneratorNames
genNames
=
{})
:
IStochasticProblem
(
meshes
,
genNames
)
{}
:
IStochasticProblem
(
meshes
,
genNames
)
{
config
.
get
(
"CFL"
,
CFL
);
config
.
get
(
"t0"
,
t0
);
config
.
get
(
"T"
,
T
);
}
double
GetStartTime
()
{
return
t0
;
}
double
GetEndTime
()
{
return
T
;
}
double
GetCFL
()
{
return
CFL
;
}
bool
RHS
()
const
{
return
rhs
;
}
bool
RHS
()
const
{
return
rhs
;
}
...
@@ -135,13 +151,13 @@ public:
...
@@ -135,13 +151,13 @@ public:
Pollution2D
(
Meshes
&
meshes
)
:
IStochasticTransportProblem
(
meshes
)
{}
Pollution2D
(
Meshes
&
meshes
)
:
IStochasticTransportProblem
(
meshes
)
{}
Scalar
Solution
(
double
t
,
const
Point
&
x
)
const
override
{
Scalar
Solution
(
double
t
,
const
Point
&
x
)
const
override
{
if
((
abs
(
1
-
x
[
1
]
-
1.5
*
d
)
<
d
/
2
)
&&
(
abs
(
0.5
-
x
[
0
])
<
3
*
d
))
if
((
abs
(
1
-
x
[
1
]
-
1.5
*
d
)
<
d
/
2
)
&&
(
abs
(
0.5
-
x
[
0
])
<
4
*
d
))
return
1
.0
;
return
32
.0
;
return
0.0
;
return
0.0
;
}
}
VectorField
TransportFlux
(
const
Point
&
x
)
const
{
VectorField
TransportFlux
(
const
Point
&
x
)
const
{
return
VectorField
(
-
1.0
,
0.0
,
0
.0
);
return
VectorField
(
0.0
,
-
1
.0
);
}
}
VectorField
CellFlux
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
VectorField
CellFlux
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
...
@@ -185,16 +201,15 @@ public:
...
@@ -185,16 +201,15 @@ public:
};
};
class
PollutionCosHat2D
:
public
IStochasticTransportProblem
{
class
PollutionCosHat2D
:
public
IStochasticTransportProblem
{
double
amplitude
=
1.00
;
double
amplitude
=
2.0
/
Pi
;
double
cc
=
0.5
;
public:
public:
explicit
PollutionCosHat2D
(
Meshes
&
meshes
)
:
IStochasticTransportProblem
(
meshes
)
{}
explicit
PollutionCosHat2D
(
Meshes
&
meshes
)
:
IStochasticTransportProblem
(
meshes
)
{}
double
Solution
(
double
t
,
const
Point
&
x
)
const
override
{
double
Solution
(
double
t
,
const
Point
&
x
)
const
override
{
Point
midPoint
=
5.0
*
Point
(
cos
(
2.
*
Pi
*
t
),
sin
(
2.
*
Pi
*
t
));
Point
midPoint
=
0.25
*
(
Point
(
cos
(
2.
*
Pi
*
t
),
sin
(
2.
*
Pi
*
t
))
+
Point
(
1.0
,
1.0
));
double
r
=
dist
(
midPoint
,
x
);
double
r
=
dist
(
midPoint
,
x
);
if
(
r
<
1
/
cc
)
if
(
r
<
1.0
/
(
2.0
*
Pi
))
return
amplitude
*
pow
(
cos
(
r
/
2.0
),
2.0
);
return
amplitude
*
pow
(
cos
(
cc
*
Pi
*
r
)
+
1.0
,
2.0
);
return
0.0
;
return
0.0
;
}
}
...
@@ -233,13 +248,17 @@ public:
...
@@ -233,13 +248,17 @@ public:
return
1.0
;
return
1.0
;
}
}
VectorField
CircleVectorField
(
const
Point
&
x
)
const
{
return
2
*
Pi
*
VectorField
(
-
x
[
1
],
x
[
0
],
0.0
);
}
VectorField
CellFlux
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
VectorField
CellFlux
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
return
v
ectorField
;
return
CircleV
ectorField
(
x
)
;
}
}
Scalar
FaceNormalFlux
(
const
cell
&
c
,
int
face
,
Scalar
FaceNormalFlux
(
const
cell
&
c
,
int
face
,
const
VectorField
&
N
,
const
Point
&
x
)
const
override
{
const
VectorField
&
N
,
const
Point
&
x
)
const
override
{
return
v
ectorField
*
N
;
return
CircleV
ectorField
(
x
)
*
N
;
}
}
string
Name
()
const
override
{
return
"GaussHat2D"
;
}
string
Name
()
const
override
{
return
"GaussHat2D"
;
}
...
@@ -247,38 +266,42 @@ public:
...
@@ -247,38 +266,42 @@ public:
class
GaussHat2D
:
public
IStochasticTransportProblem
{
class
GaussHat2D
:
public
IStochasticTransportProblem
{
private:
private:
VectorField
vectorField
;
VectorField
mu
;
Tensor
sigma
;
Tensor
sigma
;
public:
public:
GaussHat2D
(
Meshes
&
meshes
)
:
GaussHat2D
(
Meshes
&
meshes
)
:
mu
(
VectorField
(
0.5
,
0.5
,
0.0
)),
sigma
(
Tensor
()),
sigma
(
Tensor
()),
vectorField
(
VectorField
(
1
/
sqrt
(
2
),
1
/
sqrt
(
2
),
0
)),
IStochasticTransportProblem
(
meshes
)
{
IStochasticTransportProblem
(
meshes
)
{
sigma
[
0
][
0
]
=
0.0
1
;
sigma
[
0
][
0
]
=
0.0
05
;
sigma
[
0
][
1
]
=
0.0
;
sigma
[
0
][
1
]
=
0.0
;
sigma
[
1
][
0
]
=
0.0
;
sigma
[
1
][
0
]
=
0.0
;
sigma
[
1
][
1
]
=
0.01
;
sigma
[
1
][
1
]
=
0.005
;
sigma
[
2
][
2
]
=
1.0
;
// Todo might not be working for 2D Point
// sigma[2][2] = 1.0; // Todo might not be working for 2D Point
}
Point
mu
(
double
t
)
const
{
return
0.25
*
(
Point
(
cos
(
2.
*
Pi
*
t
),
sin
(
2.
*
Pi
*
t
))
+
Point
(
1.0
,
1.0
));
}
}
Scalar
Solution
(
double
t
,
const
Point
&
x
)
const
override
{
Scalar
Solution
(
double
t
,
const
Point
&
x
)
const
override
{
double
factor
=
1
/
sqrt
(
pow
(
2
*
Pi
,
2
)
*
sigma
.
det
());
double
factor
=
1
/
sqrt
(
pow
(
2
*
Pi
,
2
)
*
sigma
.
det
());
VectorField
diff
=
(
x
-
mu
);
VectorField
diff
=
(
x
-
mu
(
t
)
);
VectorField
temp
=
Invert
(
sigma
)
*
diff
;
VectorField
temp
=
Invert
(
sigma
)
*
diff
;
Scalar
exponent
=
-
0.5
*
diff
*
temp
;
Scalar
exponent
=
-
0.5
*
diff
*
temp
;
return
factor
*
exp
(
exponent
);
return
factor
*
exp
(
exponent
);
}
}
VectorField
CircleVectorField
(
const
Point
&
x
)
const
{
return
2
*
Pi
*
VectorField
(
-
x
[
1
],
x
[
0
],
0.0
);
}
VectorField
CellFlux
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
VectorField
CellFlux
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
return
v
ectorField
;
return
CircleV
ectorField
(
x
)
;
}
}
Scalar
FaceNormalFlux
(
const
cell
&
c
,
int
face
,
Scalar
FaceNormalFlux
(
const
cell
&
c
,
int
face
,
const
VectorField
&
N
,
const
Point
&
x
)
const
override
{
const
VectorField
&
N
,
const
Point
&
x
)
const
override
{
return
v
ectorField
*
N
;
return
CircleV
ectorField
(
x
)
*
N
;
}
}
string
Name
()
const
override
{
return
"GaussHat2D"
;
}
string
Name
()
const
override
{
return
"GaussHat2D"
;
}
...
...
Write
Preview
Supports
Markdown
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