Commit 8838feeb authored by Praetorius, Simon's avatar Praetorius, Simon

cleanup

parent 7072a71d
cmake_minimum_required(VERSION 3.0)
project(dune-amdis CXX)
set(ALBERTA_ROOT /opt/software/alberta)
# set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include)
set(CMAKE_PREFIX_PATH /opt/software/dune/lib/cmake)
set(UG_DIR /opt/software/dune/lib/cmake/ug)
set(Vc_DIR /opt/software/dune/lib/cmake/Vc)
set(ALBERTA_ROOT /opt/software/alberta)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
......
......@@ -28,15 +28,15 @@ namespace AMDiS
namespace Impl
{
// add arg to repeated constructor argument list
template <class Tuple, size_t n, class Arg, class... Args>
Tuple construct_tuple_aux(int_<n>, Arg&& arg, Args&&... args)
template <class Tuple, size_t N, class Arg, class... Args>
Tuple construct_tuple_aux(index_<N>, Arg&& arg, Args&&... args)
{
return construct_tuple_aux<Tuple>(int_<n-1>(),
return construct_tuple_aux<Tuple>(index_<N-1>(),
std::forward<Arg>(arg), std::forward<Arg>(arg), std::forward<Args>(args)...);
}
template <class Tuple, class... Args>
Tuple construct_tuple_aux(int_<1>, Args&&... args)
Tuple construct_tuple_aux(index_<1>, Args&&... args)
{
static_assert(std::tuple_size<Tuple>::value == sizeof...(args),
"Nr. of argument != tuple-size");
......@@ -44,7 +44,7 @@ namespace AMDiS
}
template <class Tuple, class... Args>
Tuple construct_tuple_aux(int_<0>, Args&&... args)
Tuple construct_tuple_aux(index_<0>, Args&&... args)
{
static_assert(std::tuple_size<Tuple>::value == 0,
"Construction of empty tuples with empty argument list only!");
......@@ -56,7 +56,7 @@ namespace AMDiS
template <class Tuple, class Arg>
Tuple construct_tuple(Arg&& arg)
{
return Impl::construct_tuple_aux<Tuple>(int_<std::tuple_size<Tuple>::value>(),
return Impl::construct_tuple_aux<Tuple>(index_<std::tuple_size<Tuple>::value>(),
std::forward<Arg>(arg));
}
......
......@@ -22,12 +22,12 @@
#include "SystemVector.hpp"
#include "Timer.hpp"
namespace AMDiS
namespace AMDiS {
template <class Param>
class ProblemStat : public ProblemStatBase
{
template <class Param>
class ProblemStat : public ProblemStatBase
{
public:
public:
using FeSpaces = typename Param::FeSpaces;
using Mesh = typename Param::Mesh;
......@@ -62,8 +62,9 @@ namespace AMDiS
using OperatorType = Operator<MeshView>;
public:
/// Constructor
public:
/// \brief Constructor. Takes the name of the problem that is used to
/// access values correpsonding to this püroblem in the parameter file.
/**
* Parameters read by ProblemStatSeq, with name 'PROB'
* PROB->names: \ref componentNames
......@@ -78,7 +79,7 @@ namespace AMDiS
}
/// Initialisation of the problem.
/// \brief Initialisation of the problem.
/**
* Parameters read in initialize() for problem with name 'PROB'
* MESH[0]->global refinements: nr of initial global refinements
......@@ -101,8 +102,6 @@ namespace AMDiS
/// Adds a Dirichlet boundary condition
template <class Predicate, class Values>
// requires( Dune::Functions::Concept::isCallable<Predicate, WorldVector>() &&
// Dune::Functions::Concept::isCallable<Values, WorldVector>() )
void addDirichletBC(Predicate const& predicate,
int row, int col,
Values const& values);
......@@ -167,31 +166,31 @@ namespace AMDiS
return name;
}
public:
public:
// Reads a filename from the init file and creates the mesh object with
// respect to this file.
void createMesh()
{
// TODO: Creation from meshname must be generalized to other meshes than AlbertaGrid.
meshName = "";
Parameters::get(name + "->mesh", meshName);
AMDIS_TEST_EXIT(!meshName.empty(),
"No mesh name specified for '" << name << "->mesh'!");
std::string macro_filename = "";
Parameters::get(meshName + "->macro file name", macro_filename);
// TODO: Creation from meshname must be generalized to other meshes than AlbertaGrid.
meshName = "";
Parameters::get(name + "->mesh", meshName);
AMDIS_TEST_EXIT(!meshName.empty(),
"No mesh name specified for '" << name << "->mesh'!");
std::string macro_filename = "";
Parameters::get(meshName + "->macro file name", macro_filename);
mesh = std::make_shared<Mesh>(macro_filename);
meshView = std::make_shared<MeshView>(mesh->leafGridView());
mesh = std::make_shared<Mesh>(macro_filename);
meshView = std::make_shared<MeshView>(mesh->leafGridView());
}
//
void createFeSpaces()
{
feSpaces = std::make_shared<FeSpaces>(construct_tuple<FeSpaces>(*meshView));
rhs = std::make_shared<SystemVectorType>(*feSpaces, std::vector<std::string>(nComponents, "rhs"));
solution = std::make_shared<SystemVectorType>(*feSpaces, componentNames);
feSpaces = std::make_shared<FeSpaces>(construct_tuple<FeSpaces>(*meshView));
rhs = std::make_shared<SystemVectorType>(*feSpaces, std::vector<std::string>(nComponents, "rhs"));
solution = std::make_shared<SystemVectorType>(*feSpaces, componentNames);
}
//
......@@ -221,7 +220,7 @@ namespace AMDiS
DOFMatrix* matrix,
Vector* rhs);
private:
private:
/// Name of this problem.
std::string name;
......@@ -251,7 +250,7 @@ namespace AMDiS
IdxPairList<DirichletBC<WorldVector>> dirichletBc;
IdxPairList<OperatorType> matrixOperators;
IdxList<OperatorType> vectorOperators;
};
};
#ifndef AMDIS_NO_EXTERN_PROBLEMSTAT
......
......@@ -368,10 +368,10 @@ namespace AMDiS
ElementMatrix& elementMatrix,
std::list<std::shared_ptr<OperatorType>>& operators)
{
const auto& rowFE = rowView.tree().finiteElement();
const auto& colFE = colView.tree().finiteElement();
const auto nRows = rowView.tree().finiteElement().size();
const auto nCols = colView.tree().finiteElement().size();
elementMatrix.setSize(rowFE.size(), colFE.size());
elementMatrix.setSize(nRows, nCols);
elementMatrix = 0.0; // fills the entire matrix with zeroes
for (auto op : operators)
......@@ -388,10 +388,10 @@ namespace AMDiS
ElementVector& elementVector,
std::list<std::shared_ptr<OperatorType>>& operators)
{
const auto& rowFE = rowView.tree().finiteElement();
const auto nRows = rowView.tree().finiteElement().size();
// Set all entries to zero
elementVector.resize(rowFE.size());
elementVector.resize(nRows);
elementVector = 0.0;
for (auto op : operators)
......
......@@ -16,6 +16,14 @@
namespace AMDiS
{
/// \brief Container that repesents multiple data-Vectors of different value types.
/**
* Represents a \ref Dune::MultiTypeBlockVector + a tuple of corresponding
* feSpaces. This I'th \ref Dune::BlockVector compbined with the I'th FeSpace
* builds a \ref DOFVector and can be return by the \ref operator[].
*
* By default, the ValueTypes are all \ref Dune::FieldVector of 1 double entry.
**/
template <class FeSpaces,
class ValueTypes = Repeat_t<std::tuple_size<FeSpaces>::value, Dune::FieldVector<double,1>> >
class SystemVector
......@@ -28,7 +36,7 @@ namespace AMDiS
using DOFVectors = MakeTuple2_t<DOFVector, FeSpaces, ValueTypes>;
AMDIS_STATIC_ASSERT( (std::tuple_size<FeSpaces>::value > 0) );
AMDIS_STATIC_ASSERT( std::tuple_size<FeSpaces>::value > 0 );
AMDIS_STATIC_ASSERT( std::tuple_size<FeSpaces>::value == std::tuple_size<ValueTypes>::value );
AMDIS_STATIC_ASSERT( std::is_same< typename std::tuple_element_t<0, DOFVectors>::BaseVector,
std::tuple_element_t<0, BaseVectors> >::value );
......@@ -37,10 +45,17 @@ namespace AMDiS
SystemVector(FeSpaces const& feSpaces, std::vector<std::string> const& names)
: feSpaces(feSpaces)
, names(names)
, vector(std::make_shared<MultiVector>())
, vector(new MultiVector)
, allocated(true)
{
compress();
}
~SystemVector()
{
if (allocated)
delete vector;
}
/// Return the number of vector entries
static constexpr size_t size()
......@@ -123,14 +138,17 @@ namespace AMDiS
}
private:
FeSpaces const& feSpaces;
std::vector<std::string> names;
FeSpaces const& feSpaces; ///< a tuple of feSpaces
std::vector<std::string> names; ///< a vector of component names
std::shared_ptr<MultiVector> vector;
MultiVector* vector; ///< a tuple of data-vectors
bool allicated = false;
};
#ifndef AMDIS_NO_EXTERN_SYSTEMVECTOR
extern template class SystemVector<typename ProblemParametersBase<2>::FeSpaces>;
// explicit instantiation in SystemVector.cpp
extern template class SystemVector<typename ProblemParametersBase<2>::FeSpaces>;
#endif
} // end namespace AMDiS
......@@ -4,7 +4,7 @@
namespace AMDiS
{
/// Helper class to distinguish between different time measurement methods
/// Helper class to measure execution times
class Timer
{
using Clock = std::chrono::high_resolution_clock;
......
......@@ -2,7 +2,7 @@ import os
import subprocess
def shell(command):
subprocess.check_output(command, shell=True)
subprocess.call(command, shell=True)
def cd(directory):
os.chdir(directory)
......@@ -21,9 +21,11 @@ blas_lib = blas_dir + '/lib' + blas_name + '.a'
# configure source and install directory
source_dir = '/opt/sources/dune'
install_dir = '/opt/software/dune'
install_dir = '/opt/software/dune_debug'
alberta_install_dir = '/opt/software/alberta_debug'
num_proc = 4
num_proc = 8
build_type = 'Debug'
alberta_source = ['alberta-3.0.1',
......@@ -58,10 +60,13 @@ if not os.path.exists(alberta_source[0] + '.tar-gz') and \
mkdir(alberta_source[0] + '/build')
cd(alberta_source[0] + '/build')
shell('../configure --disable-graphics --disable-debug '
disable_debug = '--disable_debug '
if build_type == 'Debug':
disable_debug = ''
shell('../configure --disable-graphics ' + disable_debug
+ '--disable-chained-basis-functions --disable-vector-basis-functions '
+ '--with-blas --with-blas-name=' + blas_name + ' --with-blas-lib=' + blas_dir + ' '
+ '--prefix=/opt/software/alberta')
+ '--prefix=' + alberta_install_dir)
shell('make -j' + str(num_proc))
shell('make install')
......@@ -88,7 +93,7 @@ if not os.path.exists('Vc'):
cd(source_dir + '/Vc/build')
rm('CMakeCache.txt')
shell('cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=' + install_dir + ' '
shell('cmake -DCMAKE_BUILD_TYPE=' + build_type + ' -DCMAKE_INSTALL_PREFIX:PATH=' + install_dir + ' '
+ '-DENABLE_MIC:BOOL=OFF ..')
shell('make -j' + str(num_proc) + ' install')
......@@ -103,18 +108,18 @@ for i, m in enumerate(modules):
for m in modules:
cd(source_dir + '/' + m + '/build')
rm('CMakeCache.txt')
shell('cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=' + install_dir + ' '
shell('cmake -DCMAKE_BUILD_TYPE=' + build_type + ' -DCMAKE_INSTALL_PREFIX:PATH=' + install_dir + ' '
+ '-DCXX_MAX_STANDARD=14 -DCMAKE_PREFIX_PATH:PATH=' + install_dir + '/lib/cmake '
+ '-DUG_DIR:PATH=' + install_dir + '/lib/cmake/ug -DVc_DIR:PATH=' + install_dir + '/lib/cmake/Vc '
+ '-DBLAS_blas_LIBRARY:PATH=' + blas_lib + ' '
+ '-DALBERTA_ROOT:PATH=/opt/software/alberta ..')
+ '-DALBERTA_ROOT:PATH=' + alberta_install_dir + ' ..')
shell('make -j' + str(num_proc) + ' install')
# manually change the following things:
# 1) Add AddVcFlags.cmake to /opt/sources/dune/dune-common/cmake/modules/CMakeLists.txt
# 2) Add constexpr to line 291 in /opt/sources/dune/dune-functions/dune/functions/functionspacesbases/interpolate.hh
# 3) Modiy /opt/sources/dune/dune-functions/CMakeLists and remove examples sub-directory
# 3) Modify /opt/sources/dune/dune-functions/CMakeLists and remove examples sub-directory
add_executable("amdis" amdis.cc)
add_dune_alberta_flags("amdis")
add_dune_alberta_flags(GRIDDIM 2 WORLDDIM 2 "amdis")
target_link_dune_default_libraries("amdis")
target_link_libraries("amdis" "duneamdis")
target_compile_definitions("amdis" PRIVATE DIM=2 DOW=2)
......@@ -9,15 +9,19 @@
#include <dune/amdis/AMDiS.hpp>
#include <dune/amdis/ProblemStat.hpp>
#define DIM 2
#define DOW 2
#ifndef DIM
#define DIM 2
#endif
#ifndef DOW
#define DOW 2
#endif
using namespace AMDiS;
// 1 component with polynomial degree 1
using HeatParam = ProblemParametersBase<DIM, DOW, 1>;
using HeatParam = ProblemParametersBase<DIM, DOW, 1>;
using HeatProblem = ProblemStat<HeatParam>;
using MeshView = HeatProblem::MeshView;
using MeshView = HeatProblem::MeshView;
int main(int argc, char** argv)// try
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment