Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KiT-RT
KiT-RT
Commits
66466fe1
Commit
66466fe1
authored
Dec 10, 2020
by
Steffen Schotthöfer
Browse files
pulled master into nnDataGen
Former-commit-id:
9d23f5b6
parents
ddd36751
7590242d
Changes
54
Expand all
Hide whitespace changes
Inline
Side-by-side
code/src/solvers/solverbase.cpp
View file @
66466fe1
...
...
@@ -26,10 +26,32 @@ Solver::Solver( Config* settings ) {
_settings
->
SetNCells
(
_nCells
);
// build quadrature object and store frequently used params
_quadrature
=
QuadratureBase
::
Create
Quadrature
(
settings
);
_quadrature
=
QuadratureBase
::
Create
(
settings
);
_nq
=
_quadrature
->
GetNq
();
_settings
->
SetNQuadPoints
(
_nq
);
// build slope related params
_reconstructor
=
Reconstructor
::
Create
(
settings
);
_reconsOrder
=
_reconstructor
->
GetReconsOrder
();
auto
nodes
=
_mesh
->
GetNodes
();
auto
cells
=
_mesh
->
GetCells
();
std
::
vector
<
std
::
vector
<
Vector
>>
interfaceMidPoints
(
_nCells
,
std
::
vector
<
Vector
>
(
_mesh
->
GetNumNodesPerCell
(),
Vector
(
2
,
1e-10
)
)
);
for
(
unsigned
idx_cell
=
0
;
idx_cell
<
_nCells
;
++
idx_cell
)
{
for
(
unsigned
k
=
0
;
k
<
_mesh
->
GetDim
();
++
k
)
{
for
(
unsigned
j
=
0
;
j
<
_neighbors
[
idx_cell
].
size
()
-
1
;
++
j
)
{
interfaceMidPoints
[
idx_cell
][
j
][
k
]
=
0.5
*
(
nodes
[
cells
[
idx_cell
][
j
]][
k
]
+
nodes
[
cells
[
idx_cell
][
j
+
1
]][
k
]
);
}
interfaceMidPoints
[
idx_cell
][
_neighbors
[
idx_cell
].
size
()
-
1
][
k
]
=
0.5
*
(
nodes
[
cells
[
idx_cell
][
_neighbors
[
idx_cell
].
size
()
-
1
]][
k
]
+
nodes
[
cells
[
idx_cell
][
0
]][
k
]
);
}
}
_interfaceMidPoints
=
interfaceMidPoints
;
_cellMidPoints
=
_mesh
->
GetCellMidPoints
();
_psiDx
=
VectorVector
(
_nCells
,
Vector
(
_nq
,
0.0
)
);
_psiDy
=
VectorVector
(
_nCells
,
Vector
(
_nq
,
0.0
)
);
// set time step
_dE
=
ComputeTimeStep
(
settings
->
GetCFL
()
);
_nEnergies
=
unsigned
(
settings
->
GetTEnd
()
/
_dE
);
...
...
code/src/toolboxes/interpolation.cpp
View file @
66466fe1
...
...
@@ -91,19 +91,19 @@ double Interpolation::operator()( double x, double y ) const {
if
(
_type
==
cubic
)
{
// find closest values to x and y in table (lower bounds)
unsigned
xId
=
IndexOfClosestValue
(
x
,
_x
);
unsigned
yId
=
IndexOfClosestValue
(
y
,
_y
);
int
xId
=
IndexOfClosestValue
(
x
,
_x
);
int
yId
=
IndexOfClosestValue
(
y
,
_y
);
// store all 16 interpolation points needed
double
points
[
4
][
4
];
for
(
int
i
=
-
1
;
i
<
3
;
++
i
)
{
unsigned
idx_y
;
idx_y
=
yId
+
i
<
0
?
0
:
yId
+
i
;
idx_y
=
yId
+
i
>
_data
.
rows
()
-
1
?
_data
.
rows
()
-
1
:
yId
+
i
;
idx_y
=
yId
+
i
>
static_cast
<
int
>
(
_data
.
rows
()
-
1
)
?
_data
.
rows
()
-
1
:
yId
+
i
;
for
(
int
j
=
-
1
;
j
<
3
;
++
j
)
{
unsigned
idx_x
;
idx_x
=
xId
+
j
<
0
?
0
:
xId
+
j
;
idx_x
=
xId
+
j
>
_data
.
columns
()
-
1
?
_data
.
columns
()
-
1
:
xId
+
j
;
idx_x
=
xId
+
j
>
static_cast
<
int
>
(
_data
.
columns
()
-
1
)
?
_data
.
columns
()
-
1
:
xId
+
j
;
points
[
i
+
1
][
j
+
1
]
=
_data
(
idx_x
,
idx_y
);
}
...
...
code/src/toolboxes/reconstructor.cpp
View file @
66466fe1
#include "toolboxes/reconstructor.h"
#include "common/config.h"
Reconstructor
::
Reconstructor
(
Config
*
settings
)
{}
Reconstructor
::
Reconstructor
(
Config
*
settings
)
{
_reconsOrder
=
settings
->
GetReconsOrder
();
}
Reconstructor
*
Reconstructor
::
Create
(
Config
*
settings
)
{
return
new
Reconstructor
(
settings
);
}
double
FortSign
(
double
a
,
double
b
)
{
if
(
b
>
0.0
)
return
abs
(
a
);
if
(
b
<
0.0
)
return
-
abs
(
a
);
if
(
b
>
0.0
)
return
std
::
f
abs
(
a
);
if
(
b
<
0.0
)
return
-
std
::
f
abs
(
a
);
return
0.0
;
}
double
LMinMod
(
double
sL
,
double
sR
)
{
return
0.5
*
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.
,
sR
)
)
*
fmin
(
abs
(
sL
),
abs
(
sR
)
);
}
double
LMinMod
(
double
sL
,
double
sR
)
{
return
0.5
*
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.
,
sR
)
)
*
fmin
(
std
::
f
abs
(
sL
),
std
::
f
abs
(
sR
)
);
}
double
LVanLeer
(
double
sL
,
double
sR
)
{
return
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.0
,
sR
)
)
*
abs
(
sL
)
*
abs
(
sR
)
/
(
abs
(
sL
)
+
abs
(
sR
)
+
0.0000001
);
return
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.0
,
sR
)
)
*
std
::
f
abs
(
sL
)
*
std
::
f
abs
(
sR
)
/
(
std
::
f
abs
(
sL
)
+
std
::
f
abs
(
sR
)
+
0.0000001
);
}
double
LSuperBee
(
double
sL
,
double
sR
)
{
if
(
sR
>=
0.5
*
sL
&&
sR
<=
2.0
*
sL
)
return
0.5
*
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.
,
sR
)
)
*
fmax
(
abs
(
sL
),
abs
(
sR
)
);
if
(
sR
<
0.5
*
sL
&&
sR
>
2.0
*
sL
)
return
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.
,
sR
)
)
*
fmin
(
abs
(
sL
),
abs
(
sR
)
);
if
(
sR
>=
0.5
*
sL
&&
sR
<=
2.0
*
sL
)
return
0.5
*
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.
,
sR
)
)
*
fmax
(
std
::
f
abs
(
sL
),
std
::
f
abs
(
sR
)
);
if
(
sR
<
0.5
*
sL
&&
sR
>
2.0
*
sL
)
return
(
FortSign
(
1.0
,
sL
)
+
FortSign
(
1.
,
sR
)
)
*
fmin
(
std
::
f
abs
(
sL
),
std
::
f
abs
(
sR
)
);
return
0.0
;
}
double
LVanAlbaba
(
double
sL
,
double
sR
)
{
return
(
sL
*
sL
*
sR
+
sL
*
sR
*
sR
)
/
(
sL
*
sL
+
sR
*
sR
+
0.0000001
);
}
double
LWENOJS
(
double
x
)
{
return
0.0
;
}
double
LWENOJS
(
double
/*x*/
)
{
return
0.0
;
}
double
Reconstructor
::
ReconstructSlopeStruct
(
double
uL
,
double
uC
,
double
uR
,
double
dxL
,
double
dxR
,
std
::
string
limiter
)
const
{
double
sL
=
(
uC
-
uL
)
/
dxL
;
...
...
code/src/
solver
s/sphericalharmonics.cpp
→
code/src/
toolboxe
s/sphericalharmonics.cpp
View file @
66466fe1
#include "
solver
s/sphericalharmonics.h"
#include "
toolboxe
s/sphericalharmonics.h"
#include <math.h>
SphericalHarmonics
::
SphericalHarmonics
(
unsigned
L_degree
)
{
...
...
code/tests/input/validation_tests/MN_solver/checkerboard_MN.cfg
View file @
66466fe1
...
...
@@ -18,7 +18,7 @@ PROBLEM = CHECKERBOARD
% ---- Solver specifications ----
%
CFL_NUMBER = 0.5
TIME_FINAL =
3.2
TIME_FINAL =
0.4
SOLVER = MN_SOLVER
MAX_MOMENT_SOLVER = 2
ENTROPY_FUNCTIONAL = MAXWELL_BOLTZMANN
...
...
code/tests/input/validation_tests/MN_solver/checkerboard_MN_reference.vtk
View file @
66466fe1
This diff is collapsed.
Click to expand it.
code/tests/input/validation_tests/PN_solver/checkerboard_PN.cfg
View file @
66466fe1
...
...
@@ -18,7 +18,7 @@ PROBLEM = CHECKERBOARD
% ---- Solver specifications ----
%
CFL_NUMBER = 0.5
TIME_FINAL =
3.2
TIME_FINAL =
0.4
SOLVER = PN_SOLVER
MAX_MOMENT_SOLVER = 2
%
...
...
code/tests/input/validation_tests/PN_solver/checkerboard_PN_reference.vtk
View file @
66466fe1
This diff is collapsed.
Click to expand it.
code/tests/input/validation_tests/SN_solver/checkerboard_SN.cfg
View file @
66466fe1
...
...
@@ -18,7 +18,7 @@ PROBLEM = CHECKERBOARD
% ---- Solver specifications ----
%
CFL_NUMBER = 0.5
TIME_FINAL =
3.2
TIME_FINAL =
0.4
SOLVER = SN_SOLVER
%
% ---- Boundary Conditions ----
...
...
code/tests/input/validation_tests/SN_solver/checkerboard_SN_reference.vtk
View file @
66466fe1
This diff is collapsed.
Click to expand it.
code/tests/test_harmonics.cpp
View file @
66466fe1
...
...
@@ -2,7 +2,7 @@
#include "catch.hpp"
#include "common/config.h"
#include "quadratures/qgausslegendretensorized.h"
#include "
solver
s/sphericalharmonics.h"
#include "
toolboxe
s/sphericalharmonics.h"
#include <fstream>
#include <iostream>
...
...
code/tests/test_kernel.cpp
View file @
66466fe1
...
...
@@ -11,7 +11,7 @@ TEST_CASE( "test all scattering kernels", "[kernel]" ) {
// Load Settings from File
Config
*
config
=
new
Config
(
filename
);
QuadratureBase
*
quad
=
QuadratureBase
::
Create
Quadrature
(
config
);
//@TODO: swap out for different quadrature rule
QuadratureBase
*
quad
=
QuadratureBase
::
Create
(
config
);
//@TODO: swap out for different quadrature rule
SECTION
(
"isotropic scattering kernel"
)
{
...
...
code/tests/test_optimizer.cpp
View file @
66466fe1
...
...
@@ -4,7 +4,7 @@
#include "common/config.h"
#include "optimizers/optimizerbase.h"
#include "quadratures/quadraturebase.h"
#include "
solver
s/sphericalharmonics.h"
#include "
toolboxe
s/sphericalharmonics.h"
TEST_CASE
(
"Test the Newton Optimizer"
,
"[optimizers]"
)
{
std
::
string
filename
=
std
::
string
(
TESTS_PATH
)
+
"input/unit_tests/optimizers/unit_optimizerNewton.cfg"
;
...
...
@@ -16,7 +16,7 @@ TEST_CASE( "Test the Newton Optimizer", "[optimizers]" ) {
SphericalHarmonics
basis
(
config
->
GetMaxMomentDegree
()
);
// Get Quadrature
QuadratureBase
*
quad
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
quad
=
QuadratureBase
::
Create
(
config
);
// Get Optimizer (Newton)
OptimizerBase
*
optimizer
=
OptimizerBase
::
Create
(
config
);
...
...
code/tests/test_quadrature.cpp
View file @
66466fe1
...
...
@@ -52,7 +52,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Set quadOrder
config
->
SetQuadOrder
(
quadratureorder
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
if
(
quadraturename
==
QUAD_GaussLegendre1D
)
{
if
(
!
approxequal
(
Q
->
SumUpWeights
(),
2
,
lowAccuracyTesting
)
)
{
...
...
@@ -79,7 +79,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Special case for Gauss Legendre with half weights
if
(
quadraturename
==
QUAD_GaussLegendreTensorized
)
{
config
->
SetSNAllGaussPts
(
false
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
if
(
!
approxequal
(
Q
->
SumUpWeights
(),
4
*
M_PI
,
lowAccuracyTesting
)
)
{
printf
(
"Quadrature %d at order %d . Error : %.15f (low accuracy testing was set to %d). Reduced number of quadrature "
"points used.
\n
"
,
...
...
@@ -116,7 +116,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
bool
errorWithinBounds
=
true
;
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
VectorVector
points
=
Q
->
GetPoints
();
for
(
unsigned
i
=
0
;
i
<
Q
->
GetNq
();
i
++
)
{
if
(
!
approxequal
(
1.0
,
norm
(
points
[
i
]
),
lowAccuracyTesting
)
)
{
...
...
@@ -134,7 +134,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Special case for Gauss Legendre with half weights
if
(
quadraturename
==
QUAD_GaussLegendreTensorized
)
{
config
->
SetSNAllGaussPts
(
false
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
VectorVector
points
=
Q
->
GetPoints
();
for
(
unsigned
i
=
0
;
i
<
Q
->
GetNq
();
i
++
)
{
...
...
@@ -169,14 +169,14 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Set quadOrder
config
->
SetQuadOrder
(
quadratureorder
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
REQUIRE
(
Q
->
GetNq
()
==
size
(
Q
->
GetWeights
()
)
);
// Special case for Gauss Legendre with half weights
if
(
quadraturename
==
QUAD_GaussLegendreTensorized
)
{
config
->
SetSNAllGaussPts
(
false
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
REQUIRE
(
Q
->
GetNq
()
==
size
(
Q
->
GetWeights
()
)
);
config
->
SetSNAllGaussPts
(
true
);
}
...
...
@@ -194,13 +194,13 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Set quadOrder
config
->
SetQuadOrder
(
quadratureorder
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
REQUIRE
(
Q
->
GetNq
()
==
size
(
Q
->
GetPoints
()
)
);
// Special case for Gauss Legendre with half weights
if
(
quadraturename
==
QUAD_GaussLegendreTensorized
)
{
config
->
SetSNAllGaussPts
(
false
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
REQUIRE
(
Q
->
GetNq
()
==
size
(
Q
->
GetPoints
()
)
);
config
->
SetSNAllGaussPts
(
true
);
}
...
...
@@ -224,7 +224,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Set quadOrder
config
->
SetQuadOrder
(
quadratureorder
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
if
(
quadraturename
==
QUAD_GaussLegendre1D
)
{
if
(
!
approxequal
(
Q
->
Integrate
(
sin
),
0
,
lowAccuracyTesting
)
)
{
...
...
@@ -252,7 +252,7 @@ TEST_CASE( "Quadrature Tests", "[quadrature]" ) {
// Special case for Gauss Legendre with half weights
if
(
quadraturename
==
QUAD_GaussLegendreTensorized
)
{
config
->
SetSNAllGaussPts
(
false
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
Quadrature
(
config
);
QuadratureBase
*
Q
=
QuadratureBase
::
Create
(
config
);
if
(
!
approxequal
(
Q
->
Integrate
(
f
),
4.0
*
M_PI
,
lowAccuracyTesting
)
)
{
printf
(
...
...
Prev
1
2
3
Next
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