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
a12ac537
Commit
a12ac537
authored
Jul 06, 2021
by
niklas.baumgarten
Browse files
removed SampleGeneratorContainer
parent
ee108579
Pipeline
#157210
passed with stages
in 11 minutes and 24 seconds
Changes
16
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
mluq/src/generators/CMakeLists.txt
View file @
a12ac537
...
...
@@ -2,9 +2,8 @@ add_library(GENERATORS STATIC
NormalDistribution.cpp
UniformDistribution.cpp
SparseGridGenerator.cpp
SampleGeneratorContainer.cpp
algorithms/CirculantEmbedding.cpp
algorithms/SymmetricCovariance.cpp
algorithms/HybridFluxGenerator.cpp
CirculantEmbedding.cpp
SymmetricCovariance.cpp
HybridFluxGenerator.cpp
)
target_link_libraries
(
GENERATORS PDESOLVER sprng
MPP_LIBRARIES
Tasmanian_libsparsegrid
)
target_link_libraries
(
GENERATORS
MPP_LIBRARIES
PDESOLVER sprng Tasmanian_libsparsegrid
)
mluq/src/generators/
algorithms/
CirculantEmbedding.cpp
→
mluq/src/generators/CirculantEmbedding.cpp
View file @
a12ac537
File moved
mluq/src/generators/
algorithms/
CirculantEmbedding.hpp
→
mluq/src/generators/CirculantEmbedding.hpp
View file @
a12ac537
File moved
mluq/src/generators/
algorithms/
HybridFluxGenerator.cpp
→
mluq/src/generators/HybridFluxGenerator.cpp
View file @
a12ac537
File moved
mluq/src/generators/
algorithms/
HybridFluxGenerator.hpp
→
mluq/src/generators/HybridFluxGenerator.hpp
View file @
a12ac537
File moved
mluq/src/generators/NormalDistribution.hpp
View file @
a12ac537
#ifndef NORMALDISTRIBUTION_HPP
#define NORMALDISTRIBUTION_HPP
#include
"SampleGenerator.hpp"
#include
"UniformDistribution.hpp"
...
...
@@ -9,9 +8,9 @@ class NormalDistributionReal : public SampleGenerator<Scalar> {
private:
UniformDistributionReal
uniformDist
;
Scalar
firstSample
;
Scalar
firstSample
{}
;
Scalar
secondSample
;
Scalar
secondSample
{}
;
int
internalCounter
=
0
;
...
...
@@ -20,7 +19,7 @@ private:
void
updateCounter
();
public:
NormalDistributionReal
(
const
Meshes
&
meshes
)
:
explicit
NormalDistributionReal
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
),
uniformDist
(
UniformDistributionReal
(
meshes
,
0.0
,
1.0
))
{}
Scalar
EvalSample
()
const
override
;
...
...
@@ -43,7 +42,7 @@ private:
}
public:
NormalDistributionComplex
(
const
Meshes
&
meshes
)
:
explicit
NormalDistributionComplex
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
),
normalDist
(
meshes
)
{}
...
...
@@ -68,7 +67,7 @@ private:
}
public:
NormalDistributionRVector
(
const
Meshes
&
meshes
,
int
size
=
-
1
)
:
explicit
NormalDistributionRVector
(
const
Meshes
&
meshes
,
int
size
=
-
1
)
:
SampleGenerator
(
meshes
),
normalDist
(
meshes
)
{
if
(
size
!=
-
1
)
...
...
@@ -102,7 +101,7 @@ private:
}
public:
NormalDistributionCVector
(
const
Meshes
&
meshes
,
int
size
=
-
1
)
:
explicit
NormalDistributionCVector
(
const
Meshes
&
meshes
,
int
size
=
-
1
)
:
SampleGenerator
(
meshes
),
normalDist
(
meshes
)
{
if
(
size
!=
-
1
)
...
...
@@ -115,10 +114,6 @@ public:
sample
.
resize
(
sizeN
);
}
size_t
SampleSize
()
const
override
{
return
sample
.
size
();
}
CVector
EvalSample
()
const
override
{
return
sample
;
}
...
...
@@ -140,7 +135,7 @@ private:
}
public:
NormalDistributionRMatrix
(
const
Meshes
&
meshes
,
int
rows
=
-
1
,
int
cols
=
-
1
)
:
explicit
NormalDistributionRMatrix
(
const
Meshes
&
meshes
,
int
rows
=
-
1
,
int
cols
=
-
1
)
:
SampleGenerator
(
meshes
),
normalDist
(
meshes
,
cols
)
{
if
(
rows
!=
-
1
)
...
...
mluq/src/generators/SampleGenerator.hpp
View file @
a12ac537
...
...
@@ -35,7 +35,7 @@ public:
config
.
get
(
"GeneratorVerbose"
,
verbose
);
}
virtual
~
SampleGenerator
()
{}
virtual
~
SampleGenerator
()
=
default
;
void
DrawSample
(
const
SampleID
&
id
)
{
mout
.
StartBlock
(
Name
());
...
...
@@ -46,8 +46,6 @@ public:
virtual
string
Name
()
const
=
0
;
virtual
size_t
SampleSize
()
const
{
return
0
;
};
virtual
T
EvalSample
()
const
{
Exit
(
"Not implemented"
)
}
...
...
@@ -114,90 +112,98 @@ public:
class
ScalarDummy
:
public
SampleGenerator
<
Scalar
>
{
public:
ScalarDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
ScalarDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
ComplexDummy
:
public
SampleGenerator
<
Complex
>
{
public:
ComplexDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
ComplexDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
VectorFieldDummy
:
public
SampleGenerator
<
VectorField
>
{
public:
VectorFieldDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
VectorFieldDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
TensorDummy
:
public
SampleGenerator
<
Tensor
>
{
public:
TensorDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
TensorDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
RVectorDummy
:
public
SampleGenerator
<
RVector
>
{
public:
RVectorDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
RVectorDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
CVectorDummy
:
public
SampleGenerator
<
CVector
>
{
public:
CVectorDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
CVectorDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
RMatrixDummy
:
public
SampleGenerator
<
RMatrix
>
{
public:
RMatrixDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
RMatrixDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
class
CMatrixDummy
:
public
SampleGenerator
<
CMatrix
>
{
public:
CMatrixDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
explicit
CMatrixDummy
(
const
Meshes
&
meshes
)
:
SampleGenerator
(
meshes
)
{
verbose
=
0
;
}
void
drawSample
(
const
SampleID
&
id
)
override
{
vout
(
1
)
<<
"Dummy Generator"
<<
endl
;
};
virtual
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
string
Name
()
const
override
{
return
"DummyGenerator"
;
};
};
#endif //SAMPLEGENERATOR_HPP
mluq/src/generators/SampleGeneratorContainer.cpp
deleted
100644 → 0
View file @
ee108579
#include
"SampleGeneratorContainer.hpp"
void
SampleGeneratorContainer
::
init
(
const
Meshes
&
meshes
,
GeneratorNames
names
)
{
for
(
auto
const
&
genName
:
names
)
{
if
(
genName
==
"NormalDistributionReal"
)
scalarGenerator
=
new
NormalDistributionReal
(
meshes
);
if
(
genName
==
"NormalDistributionComplex"
)
complexGenerator
=
new
NormalDistributionComplex
(
meshes
);
if
(
genName
==
"NormalDistributionRVector"
)
rVectorGenerator
=
new
NormalDistributionRVector
(
meshes
);
if
(
genName
==
"NormalDistributionCVector"
)
cVectorGenerator
=
new
NormalDistributionCVector
(
meshes
);
if
(
genName
==
"NormalDistributionRMatrix"
)
rMatrixGenerator
=
new
NormalDistributionRMatrix
(
meshes
);
if
(
genName
==
"NormalDistributionCMatrix"
)
cMatrixGenerator
=
new
NormalDistributionCMatrix
(
meshes
);
if
(
genName
==
"UniformDistributionReal"
)
scalarGenerator
=
new
UniformDistributionReal
(
meshes
,
0.0
,
1.0
);
if
(
genName
==
"UniformDistributionRVector"
)
rVectorGenerator
=
new
UniformDistributionRVector
(
meshes
,
2
,
-
1.0
,
1.0
);
if
(
genName
==
"CirculantEmbedding"
)
{
if
(
meshes
.
dim
()
==
1
)
tensorGenerator
=
new
CirculantEmbedding1D
(
meshes
);
else
tensorGenerator
=
new
CirculantEmbedding2D
(
meshes
);
}
if
(
genName
==
"HybridFluxGenerator"
)
new
HybridFaceNormalFluxGenerator
(
meshes
);
}
}
void
SampleGeneratorContainer
::
DrawSample
(
const
SampleID
&
id
)
{
if
(
scalarGenerator
!=
nullptr
)
scalarGenerator
->
DrawSample
(
id
);
if
(
complexGenerator
!=
nullptr
)
complexGenerator
->
DrawSample
(
id
);
if
(
vectorFieldGenerator
!=
nullptr
)
vectorFieldGenerator
->
DrawSample
(
id
);
if
(
tensorGenerator
!=
nullptr
)
tensorGenerator
->
DrawSample
(
id
);
if
(
rVectorGenerator
!=
nullptr
)
rVectorGenerator
->
DrawSample
(
id
);
if
(
cVectorGenerator
!=
nullptr
)
cVectorGenerator
->
DrawSample
(
id
);
if
(
rMatrixGenerator
!=
nullptr
)
rMatrixGenerator
->
DrawSample
(
id
);
if
(
cMatrixGenerator
!=
nullptr
)
cMatrixGenerator
->
DrawSample
(
id
);
}
mluq/src/generators/SampleGeneratorContainer.hpp
deleted
100644 → 0
View file @
ee108579
#ifndef SAMPLEGENERATORCONTAINER_HPP
#define SAMPLEGENERATORCONTAINER_HPP
#include
"SampleGenerator.hpp"
#include
"algorithms/CirculantEmbedding.hpp"
#include
"HybridFluxGenerator.hpp"
#include
"NormalDistribution.hpp"
#include
"UniformDistribution.hpp"
typedef
std
::
vector
<
std
::
string
>
GeneratorNames
;
class
SampleGeneratorContainer
{
void
init
(
const
Meshes
&
meshes
,
GeneratorNames
names
);
public:
SampleGenerator
<
Scalar
>
*
scalarGenerator
=
nullptr
;
SampleGenerator
<
Complex
>
*
complexGenerator
=
nullptr
;
SampleGenerator
<
VectorField
>
*
vectorFieldGenerator
=
nullptr
;
SampleGenerator
<
Tensor
>
*
tensorGenerator
=
nullptr
;
SampleGenerator
<
RVector
>
*
rVectorGenerator
=
nullptr
;
SampleGenerator
<
CVector
>
*
cVectorGenerator
=
nullptr
;
SampleGenerator
<
RMatrix
>
*
rMatrixGenerator
=
nullptr
;
SampleGenerator
<
CMatrix
>
*
cMatrixGenerator
=
nullptr
;
SampleGeneratorContainer
(
const
GeneratorNames
&
names
,
const
Meshes
&
meshes
)
{
init
(
meshes
,
names
);
}
~
SampleGeneratorContainer
()
{
delete
scalarGenerator
;
delete
complexGenerator
;
delete
vectorFieldGenerator
;
delete
tensorGenerator
;
delete
rVectorGenerator
;
delete
cVectorGenerator
;
delete
rMatrixGenerator
;
delete
cMatrixGenerator
;
}
void
DrawSample
(
const
SampleID
&
id
);
};
#endif //SAMPLEGENERATORCONTAINER_HPP
mluq/src/generators/
algorithms/
SymmetricCovariance.cpp
→
mluq/src/generators/SymmetricCovariance.cpp
View file @
a12ac537
File moved
mluq/src/generators/
algorithms/
SymmetricCovariance.hpp
→
mluq/src/generators/SymmetricCovariance.hpp
View file @
a12ac537
File moved
mluq/src/problems/IStochasticProblem.hpp
View file @
a12ac537
#ifndef ISTOCHASTICPROBLEM_HPP
#define ISTOCHASTICPROBLEM_HPP
#include
"Sample.hpp"
#include
"SampleGeneratorContainer.hpp"
#include
"NormalDistribution.hpp"
#include
"UniformDistribution.hpp"
#include
"SparseGridGenerator.hpp"
#include
"HybridFluxGenerator.hpp"
#include
"CirculantEmbedding.hpp"
class
IStochasticProblem
{
...
...
mluq/src/problems/StochasticReactionProblem.hpp
View file @
a12ac537
...
...
@@ -4,32 +4,6 @@
#include
"IStochasticProblem.hpp"
// Todo rmv
#include
"HybridEllipticAssemble.hpp"
class
StochasticHybridFlux
{
public:
HybridEllipticAssemble
*
hybrid
=
nullptr
;
Vector
*
flux
=
nullptr
;
explicit
StochasticHybridFlux
()
=
default
;;
StochasticHybridFlux
(
HybridEllipticAssemble
*
hybrid
,
Vector
*
flux
)
:
hybrid
(
hybrid
),
flux
(
flux
)
{}
void
SetHybridEllipticAssemble
(
HybridEllipticAssemble
*
hybridEllipticAssemble
)
{
this
->
hybrid
=
hybridEllipticAssemble
;
}
void
SetFlux
(
Vector
*
normalFlux
)
{
this
->
flux
=
normalFlux
;
}
};
class
IStochasticReactionProblem
:
public
IStochasticProblem
{
protected:
double
convection
=
1.0
;
...
...
@@ -37,7 +11,7 @@ protected:
double
reaction
=
1.0
;
public:
IStochasticReactionProblem
(
const
Meshes
&
meshes
,
GeneratorNames
genNames
=
{}
)
:
explicit
IStochasticReactionProblem
(
const
Meshes
&
meshes
)
:
IStochasticProblem
(
meshes
)
{
config
.
get
(
"Diffusion"
,
diffusion
);
config
.
get
(
"Convection"
,
convection
);
...
...
@@ -170,38 +144,37 @@ public:
string
Name
()
const
override
{
return
"LogisticReaction2D"
;
}
};
class
HybridExponentialReaction2D
:
public
ExponentialReaction2D
,
public
StochasticHybridFlux
{
VectorField
CellConvection
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
return
this
->
convection
*
hybrid
->
EvaluateCellFlux
(
*
flux
,
c
);
}
double
FaceConvection
(
const
cell
&
c
,
int
f
,
const
VectorField
&
N
,
const
Point
&
x
)
const
override
{
return
this
->
convection
*
hybrid
->
EvaluateNormalFlux
(
*
flux
,
c
,
f
);
}
string
Name
()
const
override
{
return
"HybridExponentialReaction2D"
;
}
};
class
HybridLogisticReaction2D
:
public
LogisticReaction2D
,
public
StochasticHybridFlux
{
VectorField
CellConvection
(
const
cell
&
c
,
const
Point
&
x
)
const
override
{
return
this
->
convection
*
hybrid
->
EvaluateCellFlux
(
*
flux
,
c
);
}
double
FaceConvection
(
const
cell
&
c
,
int
f
,
const
VectorField
&
N
,
const
Point
&
x
)
const
override
{
return
this
->
convection
*
hybrid
->
EvaluateNormalFlux
(
*
flux
,
c
,
f
);
}
string
Name
()
const
override
{
return
"HybridLogisticReaction2D"
;
}
};
//class HybridExponentialReaction2D : public ExponentialReaction2D {
//
// VectorField CellConvection(const cell &c, const Point &x) const override {
// return this->convection * hybrid->EvaluateCellFlux(*flux, c);
// }
//
// double FaceConvection(const cell &c,
// int f,
// const VectorField &N,
// const Point &x) const override {
// return this->convection * hybrid->EvaluateNormalFlux(*flux, c, f);
// }
//
// string Name() const override { return "HybridExponentialReaction2D"; }
//};
//
//class HybridLogisticReaction2D : public LogisticReaction2D,
// public StochasticHybridFlux {
//
// VectorField CellConvection(const cell &c, const Point &x) const override {
// return this->convection * hybrid->EvaluateCellFlux(*flux, c);
// }
//
// double FaceConvection(const cell &c,
// int f,
// const VectorField &N,
// const Point &x) const override {
// return this->convection * hybrid->EvaluateNormalFlux(*flux, c, f);
// }
//
// string Name() const override { return "HybridLogisticReaction2D"; }
//};
#endif //STOCHASTICREACTIONPROBLEM_HPP
mluq/src/problems/StochasticTransportProblem.hpp
View file @
a12ac537
#ifndef MLMC_STOCHASTICTRANSPORTPROBLEM_HPP
#define MLMC_STOCHASTICTRANSPORTPROBLEM_HPP
#include
"
problems/
IStochasticProblem.hpp"
#include
"IStochasticProblem.hpp"
class
IStochasticTransportProblem
:
public
IStochasticProblem
{
...
...
@@ -16,8 +16,7 @@ private:
double
T
=
1.0
;
public:
explicit
IStochasticTransportProblem
(
const
Meshes
&
meshes
,
const
GeneratorNames
&
genNames
=
{})
explicit
IStochasticTransportProblem
(
const
Meshes
&
meshes
)
:
IStochasticProblem
(
meshes
)
{
config
.
get
(
"CFL"
,
CFL
);
config
.
get
(
"t0"
,
t0
);
...
...
mluq/tests/generators/TestCirculantEmbedding.cpp
View file @
a12ac537
#include
"
generators/algorithms/
CirculantEmbedding.hpp"
#include
"CirculantEmbedding.hpp"
#include
"MeshesCreator.hpp"
#include
"TestEnvironment.hpp"
...
...
mluq/tests/generators/TestSymmetricCovariance.cpp
View file @
a12ac537
#include
"
generators/algorithms/
SymmetricCovariance.hpp"
#include
"SymmetricCovariance.hpp"
#include
"FFT.hpp"
#include
"TestEnvironment.hpp"
...
...
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