Commit fd736841 authored by niklas.baumgarten's avatar niklas.baumgarten

Merge branch 'feature'

parents 8865da52 3bd2726f
Pipeline #94404 failed with stages
in 7 minutes and 13 seconds
......@@ -4,5 +4,7 @@ sprng5/
results/
Todo.txt
cmake-build-debug/
*/__pycache__/*
*/.ipynb_checkpoints/*
\ No newline at end of file
notebooks/__pycache__/
notebooks/.idea/
python/__pycache__/
......@@ -2,52 +2,65 @@ stages:
- build
- test
cache:
paths:
- sprng5
before_script:
- module add foss
- module add Anaconda3
- if [ -z "$(ls sprng5/)" ]; then
- tar xjf sprng5.tar.bz2
- cd sprng5
- ./configure --with-mpi=yes --with-fortran=no
- make -j
- cd ..
- else
- echo "Using sprng5 from cache"
- fi
build-mlmc:
stage: build
except:
variables:
- $CI_PIPELINE_SOURCE == "pipeline"
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- module add foss
- module add Anaconda3
script:
- tar xjf sprng5.tar.bz2
- cd sprng5
- ./configure --with-mpi=yes --with-fortran=no
- make -j
- if [ -z "$UPSTREAM_COMMIT" ]; then
- echo "Using referenced mpp commit"
- else
- echo ${UPSTREAM_COMMIT}
- fi
- cd mpp
- git fetch --all
- git checkout $UPSTREAM_COMMIT
- cd ..
- mkdir build
- cd build
- cmake ..
- cmake .. -DBUILD_MLMC_TESTS=OFF
- make -j
downstream-build-mlmc:
stage: build
only:
variables:
- $CI_PIPELINE_SOURCE == "pipeline"
artifacts:
paths:
- build/mpp/src
- build/mpp/LIB_PS
- build/mpp/googletest
- build/mlmc
expire_in: '1h'
variables:
GIT_SUBMODULE_STRATEGY: recursive
before_script:
- module add foss
- module add Anaconda3
test-mlmc:
stage: test
script:
- tar xjf sprng5.tar.bz2
- cd sprng5
- ./configure --with-mpi=yes --with-fortran=no
- make -j
- cd ..
- mkdir build
- cd build
- cmake ..
- make -j
- cd tests
- mpirun -n 4 TestMainProgram
- mpirun -n 4 TestMultilevelPlotter
- touch dummy_results.txt
artifacts:
paths:
- build/dummy_results.txt
\ No newline at end of file
[submodule "mpp"]
path = mpp
url = ../mpp.git
url = ../../mpp/mpp.git
cmake_minimum_required(VERSION 3.5.1)
project(MLMC)
#---------------------------------------------------------------------------------------#
set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O0")
#set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O1")
#set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O2")
#set(CMAKE_CXX_FLAGS_DISTRIBUTION "-O3")
# Compiler options
#set(CXX_VERSION "17")
#set(COMPILER_VERSION "c++")
#set(COMPILER_VERSION "gnu++")
set(COMPILER_OPTIMIZE "-O0")
#set(COMPILER_OPTIMIZE "-O1")
#set(COMPILER_OPTIMIZE "-O2")
#set(COMPILER_OPTIMIZE "-O3")
#set(COMPILER_OPTIMIZE "-Ofast")
option(NO_DEPRECATED "Suppress deprecated warnings" OFF)
option(BUILD_TESTS "Build test executables" ON)
option(USE_CXSC "Use interval arithmetic library cxsc" OFF)
option(PROBLEM_NO_TIME "Time independent problem" OFF)
# Problem options
option(NO_DEPRECATED "Suppress deprecated warnings" ON)
option(PROBLEM_NO_TIME "Time independent problem" ON)
option(PROBLEM_1D "1 dimensional problem" OFF)
option(PROBLEM_2D "2 dimensional problem" OFF)
option(PROBLEM_2D "2 dimensional problem" ON)
option(AFFINE_LINEAR_TRAFO "Only affine linear transformations" ON)
# Constants
#set(CONST_GEOMETRIC_TOLERANCE "1e-10")
#set(CONST_NEAR_ZERO "1e-15")
#set(CONST_VERY_LARGE "1e30")
#set(CONST_INFTY "1e100")
# SuperLU options
option(USE_SUPERLU30 "Use SuperLU 3.0 (old version)" OFF)
option(AFFINE_LINEAR_TRAFO "Only affine linear transformations" OFF)
# Test options
option(BUILD_TESTS "Build test executables" OFF)
option(BUILD_MLMC_TESTS "Build mlmc test executables" ON)
#---------------------------------------------------------------------------------------#
# Set path for mpp
set(PROJECT_MPP_DIR ${PROJECT_SOURCE_DIR}/mpp)
......@@ -26,19 +42,24 @@ include(${PROJECT_MPP_DIR}/CMakeListsMpp.inc)
#find_package(FFTW3 REQUIRED) (Can't be found but still seems to link in)
link_directories(${PROJECT_SOURCE_DIR}/sprng5/lib)
# Include directories
include_directories(${PROJECT_SOURCE_DIR}/sprng5/include)
include_directories(${PROJECT_SOURCE_DIR}/mlmc/src)
# Subdirectories
# Subdirectory
add_subdirectory(mlmc/src)
add_subdirectory(tests)
#---------------------------------------------------------------------------------------#
# Libraries
set(MLMC_LIBRARIES MLMC sprng fftw3 m ${MPP_LIBRARIES})
# Executables
add_executable(MLMC-M++ mlmc/src/Main.cpp)
# Linking
target_link_libraries(MLMC-M++ MLMC sprng SRC LIB_PS ${SUPERLU}
${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} fftw3 m)
#---------------------------------------------------------------------------------------#
\ No newline at end of file
target_link_libraries(MLMC-M++ ${MLMC_LIBRARIES})
# Tests
if (BUILD_MLMC_TESTS)
add_subdirectory(tests)
endif ()
## Getting Started
This project combines MLMC methods and the parallel PDE solving software M++. This guide
walks you through the installation process.
walks you through the installation process and presents some example computations.
### Prerequisites
* This version of M++ uses CMake (https://cmake.org/download/) as building tool.
......@@ -49,8 +49,8 @@ Transform in the West http://fftw.org/). To install it run:
```cmake ..```
```make -j```
### MLMC-M++ Experiments
You can find jupyter notebooks with experiments in the
in the ```notebooks``` directory.
### MLMC-M++ Exercises
You can find a PDF with exercises in the ```doc``` directory
and a complementing jupyter notebook in the ```notebook``` directory.
Model = LagrangeFEM
#Model = MixedFEM
#Model = HybridFEM
#Model = DGFEM
#sign = 1
#penalty = 20
# ----- Problem Settings -----
Experiment = MLMCExperiment
#Experiment = ConvergenceTest
#Problem = StochasticLaplace1D
#Problem = DeterministicLaplace1D
Problem = StochasticLaplace2D
functional = L2
#functional = Energy
#funcitonal = H1
#functional = Outflow
#functional = Goal
StochasticField = LogNormal
#StochasticField = Gaussian
#Experiment = ConvergenceTest
Experiment = MLMCExperiment
#Experiment = MLMCOverEpsilon
initLevels = 3, 4, 5
initSampleAmount = 12, 6, 3
uniformSampleAmount = 500
epsilon = 0.005
mcOnly = false
Model = LagrangeFEM
#Model = MixedFEM
#Model = HybridFEM
#Model = DGFEM
maxLevel = 9
plevel = 2
degree = 1
plevel = 2
MainVerbose = 1
MCVerbose = 2
MLMCVerbose = 2
PDEVerbose = 0
GeneratorVerbose = 0
Functional = L2
#Functional = Energy
#Funcitonal = H1
#Functional = Outflow
#Functional = Goal
GeneratorPlotting = 1
MCPlotting = 0
# ----- Multilevel Monte Carlo -----
maxLevel = 7
epsilon = 0.01
mcOnly = false
initLevels = [3, 4, 5]
initSampleAmount = [12, 6, 3]
uniformSampleAmount = 500
# Stochastic Field
# ----- Stochastic Field -----
StochasticField = LogNormal
mean = 1.0
sigma = 1.0
norm_p = 2
......@@ -52,21 +37,29 @@ lambda2 = 0.15
smoothing = 1.8
evtol = 1e-10
# Other
Distribution = RCB
LinearSolver = GMRES
Preconditioner = LIB_PS
# ----- Solver -----
LinearReduction = 1e-12
LinearEpsilon = 1e-10
LinearSteps = 3000
NewtonSteps = 1
NewtonLineSearchSteps = 0
ConfigVerbose = 0
# ----- Plotting -----
GeneratorPlotting = 1
MCPlotting = 1
# ----- Verbose -----
MCVerbose =1
PDEVerbose =1
MainVerbose =1
MeshVerbose =1
MLMCVerbose =1
ConfigVerbose =1
LinearVerbose = 1
NewtonVerbose = 1
GeneratorVerbose =1
# ----- Logging -----
TimeLevel = -1
LinearVerbose = -1
MuteLevel = -1
NewtonVerbose = -1
DebugLevel = -1
\ No newline at end of file
Model = DGTransport
Overlap = dG1
flux_alpha = 1 #Upwind: 1, Central: 0
deg = 2 #DG
degree = 2
Degree = 2
#Problem = StochasticPollution1D
#Problem = DeterministicPollution1D
#Problem = StochasticPollution2D
#Problem = DeterministicPollution2D
#Problem = StochasticPollutionCosHat2D
#Problem = DeterministicPollutionCosHat2D
#Problem = DeterministicPollutionCosHatSquare500
Problem = StochasticPollutionMollifiedBar2D
scaling = 8
TimeSeries = uniform
startTime = 0.0
endTime = 1.0
Kmax = 250
Keps = 1e-5
functional = Mass
#funcitonal = Energy
#functional = Outflow
#rkorder = 0 #Exponential integrator
#rkorder = 1 #Explicit Euler
#rkorder = 2 #Heun
#rkorder = 2 #Runge
rkorder = -2 #Implicit MP-rule
#rkorder = 1000 #Polynomial Krylov-Arnoldi method
gamma = 0.01
StochasticField = LogNormal
#StochasticField = Gaussian
Experiment = ConvergenceTest
#Experiment = MLMCExperiment
#Experiment = MLMCOverEpsilon
initLevels = 4, 5, 6, 7, 8
initSampleAmount = 100, 100, 100, 100, 100
uniformSampleAmount = 100
epsilon = 0.01
mcOnly = false
epsilonList = 0.01, 0.005, 0.003, 0.001
maxLevel = 9
plevel = 3
MainVerbose = 1
MCVerbose = 0
MLMCVerbose = 1
PDEVerbose = 0
GeneratorVerbose = 0
AssembleVerbose = 0
GeneratorPlotting = 0
MCPlotting = 0
MLMCPlotting = 0
# Stochastic Field
mean = 1.0
sigma = 1.0
norm_p = 2
lambda1 = 0.1
lambda2 = 0.1
smoothing = 1.9
evtol = 1e-10
# Other
Distribution = RCB
LinearSolver = GMRES
Preconditioner = LIB_PS
#Preconditioner = SGS
#Preconditioner = GaussSeidel
#Preconditioner = Jacobi
LinearReduction = 1e-12
LinearEpsilon = 1e-10
LinearSteps = 3000
NewtonSteps = 1
NewtonLineSearchSteps = 0
ConfigVerbose = 3
TimeLevel = -1
LinearVerbose = -1
MuteLevel = -1
NewtonVerbose = -1
DebugLevel = -1
Model = DGTransport
Overlap = dG1
flux_alpha = 1 #Upwind: 1, Central: 0
# ----- Problem Settings -----
Experiment = MLMCExperiment
#Experiment = ConvergenceTest
#Problem = StochasticPollution1D
#Problem = DeterministicPollution1D
#Problem = StochasticPollutionCosHat1D
#Problem = DeterministicPollutionCosHat1D
#Problem = StochasticPollution2D
#Problem = DeterministicPollution2D
#Problem = StochasticPollutionCosHat2D
#Problem = DeterministicPollutionCosHat2D
Problem = StochasticPollutionMollifiedBar2D
#Problem = DeterministicPollutionMollifiedBar2D
scaling = 8
TimeSeries = uniform
startTime = 0.0
endTime = 0.5
Kmax = 250
Keps = 1e-5
functional = Mass
#funcitonal = Energy
#functional = Outflow
Model = DGTransport
#Model = PGTransport
#rkorder = 0 #Exponential integrator
#rkorder = 1 #Explicit Euler
#rkorder = 2 #Heun
#rkorder = 2 #Runge
rkorder = -2 #Implicit MP-rule
#rkorder = 1000 #Polynomial Krylov-Arnoldi method
Overlap = dG1
flux_alpha = 1 #Upwind: 1, Central: 0
# Streamline diffusion parameter
gamma = 0.01
degree = 2
plevel = 2
StochasticField = LogNormal
#StochasticField = Gaussian
Functional = Mass
#Funcitonal = Energy
#Functional = Outflow
#Experiment = ConvergenceTest
Experiment = MLMCExperiment
#Experiment = MLMCOverEpsilon
initLevels = [4, 5, 6]
initSampleAmount = [12, 6, 2]
uniformSampleAmount = 1
# ----- Time Series -----
TimeSeries = uniform
rkorder = -2
startTime = 0.0
endTime = 1.0
scaling = 8
Kmax = 250
gamma = 0.01
Keps = 1e-5
# ----- Multilevel Monte Carlo -----
maxLevel = 7
epsilon = 0.01
mcOnly = false
initLevels = [4, 5, 6]
initSampleAmount = [8, 4, 2]
uniformSampleAmount = 100
maxLevel = 7
plevel = 3
degree = 2
MainVerbose = 1
MCVerbose = 2
MLMCVerbose = 2
PDEVerbose = 1
GeneratorVerbose = 0
AssembleVerbose = 1
GeneratorPlotting = 1
MCPlotting = 1
MLMCPlotting = 1
# Stochastic Field
# ----- Stochastic Field -----
StochasticField = LogNormal
mean = 1.0
sigma = 1.0
norm_p = 2
lambda1 = 0.1
lambda2 = 0.1
smmothing = 1.8
lambda1 = 0.10
lambda2 = 0.10
smoothing = 1.9
evtol = 1e-10
# Other
Distribution = RCB
LinearSolver = GMRES
Preconditioner = LIB_PS
#Preconditioner = SGS
#Preconditioner = GaussSeidel
#Preconditioner = Jacobi
# ----- Solver -----
LinearReduction = 1e-12
LinearEpsilon = 1e-10
LinearSteps = 3000
NewtonSteps = 1
NewtonLineSearchSteps = 0
# ----- Plotting -----
GeneratorPlotting = 1
MCPlotting = 1
# ----- Verbose -----
MCVerbose = 1
PDEVerbose = 1
MainVerbose = 1
MLMCVerbose = 1
ConfigVerbose = 0
TimeLevel = -1
LinearVerbose = -1
NewtonVerbose = 1
GeneratorVerbose = 1
TimeIntegratorVerbose = 1
# ----- Logging -----
TimeLevel = -1
MuteLevel = -1
NewtonVerbose = -1
DebugLevel = -1
\ No newline at end of file
set(MLMC_SRC
Main.cpp
Utils.C
utils/Utils.cpp
MainProgram.cpp
MultilevelMonteCarlo.cpp
utils/IndentedLogger.cpp
mc/MonteCarlo.cpp
mc/MonteCarloElliptic.cpp
mc/MonteCarloTransport.cpp
......
#include "m++.h"
#include "m++.hpp"
#include "MainProgram.hpp"
#ifdef COMPLEX
#error undef COMPLEX in src/Compiler.h
#endif
......@@ -9,12 +8,11 @@
int main(int argc, char **argv) {
Config::setSearchPath("../mlmc/");
Config::setConfigFileName("m++.conf");
DPO dpo(&argc, argv);
Mpp::initialize(&argc, argv);
std::unique_ptr<MainProgram> mainProgram =
std::make_unique<MainProgram>();
std::unique_ptr<MainProgram> mainProgram = std::make_unique<MainProgram>();
mainProgram->Initialize();
mainProgram->Run();
int rc = mainProgram->Run();
return 0;
return rc;
}
......@@ -10,13 +10,13 @@ void MainProgram::Initialize() {
problem = createStochasticProblem();
assemble = createAssemble();
plots = make_unique<MultilevelPlotter>(*meshes);
mlmc = make_unique<MultilevelMonteCarlo>(initLevels, initSampleAmount, meshes,
stochField, assemble, plots);
plotter = make_shared<MultilevelPlotter>(*meshes);
mlmc = make_unique<MultilevelMonteCarlo>(initLevels, initSampleAmount,
meshes.get(), stochField.get(),
assemble.get());
}
void MainProgram::Run() {
int MainProgram::Run() {
this->PrintInfo();
meshes->PrintInfo();
// disc->PrintInfo();
......@@ -38,20 +38,18 @@ void MainProgram::Run() {
mlmc->ShowKurtosisWarning();
mlmc->ShowExponentResults();
}
return 0;
}
void MainProgram::PrintInfo() {
Vout(1) << endl
<< "Main Info:" << endl
<< " Problem: " << problemName << endl
<< " Model: " << modelName << endl
<< " StochField: " << fieldName << endl
<< " Experiment: " << experimentName << endl;
if (experimentName == "MLMCExperiment")
Vout(1) << " epsilon: " << epsilon << endl;
Vout(1) << endl;
mout.PrintInfo("Main", verbose,
PrintInfoEntry("Problem", problemName),
PrintInfoEntry("Model", modelName),
PrintInfoEntry("StochField", fieldName),
PrintInfoEntry("Experiment", experimentName));
}
void MainProgram::checkValues() {
if (verbose == -1) Exit("\nPlease set MainVerbose\n")
if (problemName.empty()) Exit("\nPlease set Problem\n")
......@@ -67,7 +65,7 @@ void MainProgram::checkValues() {
if (initSampleAmount.empty() && experimentName == "MLMCExperiment") Exit(
"\nPlease set initSampleAmount\n")
if (experimentName == "ConvergenceTest") {
if (uniformSampleAmount != -1) Exit("\nPlease set uniformSampleAmount\n")
if (uniformSampleAmount == -1) Exit("\nPlease set uniformSampleAmount\n")
initSampleAmount = {};
for (auto &level: initLevels)
initSampleAmount.push_back(uniformSampleAmount);
......@@ -80,23 +78,33 @@ void MainProgram::checkValues() {
shared_ptr<Meshes> MainProgram::createMeshes() {
if (problemName.find("1D") != string::npos)
return make_unique<Meshes>("Line", pLevel, maxLevel);
return make_shared<Meshes>("Line", pLevel, maxLevel);
if (problemName.find("2D") != string::npos)
return make_shared<Meshes>("UnitSquare", pLevel, maxLevel);
Exit("\nMesh not found in " + problemName + "\n")
}
shared_ptr<Discretization> MainProgram::createDiscretization() {
if (modelName == "LagrangeFEM" && degree == 1)
return make_shared<Discretization>("linear", 1, meshes->dim());
if (modelName == "LagrangeFEM" && degree == 2)
return make_shared<Discretization>("serendipity", 1, meshes->dim());
if (modelName == "MixedFEM" || modelName == "HybridFEM")