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

cleanup

parent 7072a71d
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(dune-amdis CXX) 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(UG_DIR /opt/software/dune/lib/cmake/ug)
set(Vc_DIR /opt/software/dune/lib/cmake/Vc) 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 if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*")) "${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
......
...@@ -28,15 +28,15 @@ namespace AMDiS ...@@ -28,15 +28,15 @@ namespace AMDiS
namespace Impl namespace Impl
{ {
// add arg to repeated constructor argument list // add arg to repeated constructor argument list
template <class Tuple, size_t n, class Arg, class... Args> template <class Tuple, size_t N, class Arg, class... Args>
Tuple construct_tuple_aux(int_<n>, Arg&& arg, Args&&... 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)...); std::forward<Arg>(arg), std::forward<Arg>(arg), std::forward<Args>(args)...);
} }
template <class Tuple, class... 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), static_assert(std::tuple_size<Tuple>::value == sizeof...(args),
"Nr. of argument != tuple-size"); "Nr. of argument != tuple-size");
...@@ -44,7 +44,7 @@ namespace AMDiS ...@@ -44,7 +44,7 @@ namespace AMDiS
} }
template <class Tuple, class... Args> 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, static_assert(std::tuple_size<Tuple>::value == 0,
"Construction of empty tuples with empty argument list only!"); "Construction of empty tuples with empty argument list only!");
...@@ -56,7 +56,7 @@ namespace AMDiS ...@@ -56,7 +56,7 @@ namespace AMDiS
template <class Tuple, class Arg> template <class Tuple, class Arg>
Tuple construct_tuple(Arg&& 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)); std::forward<Arg>(arg));
} }
......
...@@ -22,12 +22,12 @@ ...@@ -22,12 +22,12 @@
#include "SystemVector.hpp" #include "SystemVector.hpp"
#include "Timer.hpp" #include "Timer.hpp"
namespace AMDiS namespace AMDiS {
template <class Param>
class ProblemStat : public ProblemStatBase
{ {
template <class Param> public:
class ProblemStat : public ProblemStatBase
{
public:
using FeSpaces = typename Param::FeSpaces; using FeSpaces = typename Param::FeSpaces;
using Mesh = typename Param::Mesh; using Mesh = typename Param::Mesh;
...@@ -62,8 +62,9 @@ namespace AMDiS ...@@ -62,8 +62,9 @@ namespace AMDiS
using OperatorType = Operator<MeshView>; using OperatorType = Operator<MeshView>;
public: public:
/// Constructor /// \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' * Parameters read by ProblemStatSeq, with name 'PROB'
* PROB->names: \ref componentNames * PROB->names: \ref componentNames
...@@ -78,7 +79,7 @@ namespace AMDiS ...@@ -78,7 +79,7 @@ namespace AMDiS
} }
/// Initialisation of the problem. /// \brief Initialisation of the problem.
/** /**
* Parameters read in initialize() for problem with name 'PROB' * Parameters read in initialize() for problem with name 'PROB'
* MESH[0]->global refinements: nr of initial global refinements * MESH[0]->global refinements: nr of initial global refinements
...@@ -101,8 +102,6 @@ namespace AMDiS ...@@ -101,8 +102,6 @@ namespace AMDiS
/// Adds a Dirichlet boundary condition /// Adds a Dirichlet boundary condition
template <class Predicate, class Values> template <class Predicate, class Values>
// requires( Dune::Functions::Concept::isCallable<Predicate, WorldVector>() &&
// Dune::Functions::Concept::isCallable<Values, WorldVector>() )
void addDirichletBC(Predicate const& predicate, void addDirichletBC(Predicate const& predicate,
int row, int col, int row, int col,
Values const& values); Values const& values);
...@@ -167,31 +166,31 @@ namespace AMDiS ...@@ -167,31 +166,31 @@ namespace AMDiS
return name; return name;
} }
public: public:
// Reads a filename from the init file and creates the mesh object with // Reads a filename from the init file and creates the mesh object with
// respect to this file. // respect to this file.
void createMesh() void createMesh()
{ {
// TODO: Creation from meshname must be generalized to other meshes than AlbertaGrid. // TODO: Creation from meshname must be generalized to other meshes than AlbertaGrid.
meshName = ""; meshName = "";
Parameters::get(name + "->mesh", meshName); Parameters::get(name + "->mesh", meshName);
AMDIS_TEST_EXIT(!meshName.empty(), AMDIS_TEST_EXIT(!meshName.empty(),
"No mesh name specified for '" << name << "->mesh'!"); "No mesh name specified for '" << name << "->mesh'!");
std::string macro_filename = ""; std::string macro_filename = "";
Parameters::get(meshName + "->macro file name", macro_filename); Parameters::get(meshName + "->macro file name", macro_filename);
mesh = std::make_shared<Mesh>(macro_filename); mesh = std::make_shared<Mesh>(macro_filename);
meshView = std::make_shared<MeshView>(mesh->leafGridView()); meshView = std::make_shared<MeshView>(mesh->leafGridView());
} }
// //
void createFeSpaces() void createFeSpaces()
{ {
feSpaces = std::make_shared<FeSpaces>(construct_tuple<FeSpaces>(*meshView)); feSpaces = std::make_shared<FeSpaces>(construct_tuple<FeSpaces>(*meshView));
rhs = std::make_shared<SystemVectorType>(*feSpaces, std::vector<std::string>(nComponents, "rhs")); rhs = std::make_shared<SystemVectorType>(*feSpaces, std::vector<std::string>(nComponents, "rhs"));
solution = std::make_shared<SystemVectorType>(*feSpaces, componentNames); solution = std::make_shared<SystemVectorType>(*feSpaces, componentNames);
} }
// //
...@@ -221,7 +220,7 @@ namespace AMDiS ...@@ -221,7 +220,7 @@ namespace AMDiS
DOFMatrix* matrix, DOFMatrix* matrix,
Vector* rhs); Vector* rhs);
private: private:
/// Name of this problem. /// Name of this problem.
std::string name; std::string name;
...@@ -251,7 +250,7 @@ namespace AMDiS ...@@ -251,7 +250,7 @@ namespace AMDiS
IdxPairList<DirichletBC<WorldVector>> dirichletBc; IdxPairList<DirichletBC<WorldVector>> dirichletBc;
IdxPairList<OperatorType> matrixOperators; IdxPairList<OperatorType> matrixOperators;
IdxList<OperatorType> vectorOperators; IdxList<OperatorType> vectorOperators;
}; };
#ifndef AMDIS_NO_EXTERN_PROBLEMSTAT #ifndef AMDIS_NO_EXTERN_PROBLEMSTAT
......
...@@ -368,10 +368,10 @@ namespace AMDiS ...@@ -368,10 +368,10 @@ namespace AMDiS
ElementMatrix& elementMatrix, ElementMatrix& elementMatrix,
std::list<std::shared_ptr<OperatorType>>& operators) std::list<std::shared_ptr<OperatorType>>& operators)
{ {
const auto& rowFE = rowView.tree().finiteElement(); const auto nRows = rowView.tree().finiteElement().size();
const auto& colFE = colView.tree().finiteElement(); 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 elementMatrix = 0.0; // fills the entire matrix with zeroes
for (auto op : operators) for (auto op : operators)
...@@ -388,10 +388,10 @@ namespace AMDiS ...@@ -388,10 +388,10 @@ namespace AMDiS
ElementVector& elementVector, ElementVector& elementVector,
std::list<std::shared_ptr<OperatorType>>& operators) 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 // Set all entries to zero
elementVector.resize(rowFE.size()); elementVector.resize(nRows);
elementVector = 0.0; elementVector = 0.0;
for (auto op : operators) for (auto op : operators)
......
...@@ -16,6 +16,14 @@ ...@@ -16,6 +16,14 @@
namespace AMDiS 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, template <class FeSpaces,
class ValueTypes = Repeat_t<std::tuple_size<FeSpaces>::value, Dune::FieldVector<double,1>> > class ValueTypes = Repeat_t<std::tuple_size<FeSpaces>::value, Dune::FieldVector<double,1>> >
class SystemVector class SystemVector
...@@ -28,7 +36,7 @@ namespace AMDiS ...@@ -28,7 +36,7 @@ namespace AMDiS
using DOFVectors = MakeTuple2_t<DOFVector, FeSpaces, ValueTypes>; 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::tuple_size<FeSpaces>::value == std::tuple_size<ValueTypes>::value );
AMDIS_STATIC_ASSERT( std::is_same< typename std::tuple_element_t<0, DOFVectors>::BaseVector, AMDIS_STATIC_ASSERT( std::is_same< typename std::tuple_element_t<0, DOFVectors>::BaseVector,
std::tuple_element_t<0, BaseVectors> >::value ); std::tuple_element_t<0, BaseVectors> >::value );
...@@ -37,10 +45,17 @@ namespace AMDiS ...@@ -37,10 +45,17 @@ namespace AMDiS
SystemVector(FeSpaces const& feSpaces, std::vector<std::string> const& names) SystemVector(FeSpaces const& feSpaces, std::vector<std::string> const& names)
: feSpaces(feSpaces) : feSpaces(feSpaces)
, names(names) , names(names)
, vector(std::make_shared<MultiVector>()) , vector(new MultiVector)
, allocated(true)
{ {
compress(); compress();
} }
~SystemVector()
{
if (allocated)
delete vector;
}
/// Return the number of vector entries /// Return the number of vector entries
static constexpr size_t size() static constexpr size_t size()
...@@ -123,14 +138,17 @@ namespace AMDiS ...@@ -123,14 +138,17 @@ namespace AMDiS
} }
private: private:
FeSpaces const& feSpaces; FeSpaces const& feSpaces; ///< a tuple of feSpaces
std::vector<std::string> names;
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 #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 #endif
} // end namespace AMDiS } // end namespace AMDiS
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
namespace AMDiS namespace AMDiS
{ {
/// Helper class to distinguish between different time measurement methods /// Helper class to measure execution times
class Timer class Timer
{ {
using Clock = std::chrono::high_resolution_clock; using Clock = std::chrono::high_resolution_clock;
......
...@@ -2,7 +2,7 @@ import os ...@@ -2,7 +2,7 @@ import os
import subprocess import subprocess
def shell(command): def shell(command):
subprocess.check_output(command, shell=True) subprocess.call(command, shell=True)
def cd(directory): def cd(directory):
os.chdir(directory) os.chdir(directory)
...@@ -21,9 +21,11 @@ blas_lib = blas_dir + '/lib' + blas_name + '.a' ...@@ -21,9 +21,11 @@ blas_lib = blas_dir + '/lib' + blas_name + '.a'
# configure source and install directory # configure source and install directory
source_dir = '/opt/sources/dune' 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', alberta_source = ['alberta-3.0.1',
...@@ -58,10 +60,13 @@ if not os.path.exists(alberta_source[0] + '.tar-gz') and \ ...@@ -58,10 +60,13 @@ if not os.path.exists(alberta_source[0] + '.tar-gz') and \
mkdir(alberta_source[0] + '/build') mkdir(alberta_source[0] + '/build')
cd(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 ' + '--disable-chained-basis-functions --disable-vector-basis-functions '
+ '--with-blas --with-blas-name=' + blas_name + ' --with-blas-lib=' + blas_dir + ' ' + '--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 -j' + str(num_proc))
shell('make install') shell('make install')
...@@ -88,7 +93,7 @@ if not os.path.exists('Vc'): ...@@ -88,7 +93,7 @@ if not os.path.exists('Vc'):
cd(source_dir + '/Vc/build') cd(source_dir + '/Vc/build')
rm('CMakeCache.txt') 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 ..') + '-DENABLE_MIC:BOOL=OFF ..')
shell('make -j' + str(num_proc) + ' install') shell('make -j' + str(num_proc) + ' install')
...@@ -103,18 +108,18 @@ for i, m in enumerate(modules): ...@@ -103,18 +108,18 @@ for i, m in enumerate(modules):
for m in modules: for m in modules:
cd(source_dir + '/' + m + '/build') cd(source_dir + '/' + m + '/build')
rm('CMakeCache.txt') 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 ' + '-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 ' + '-DUG_DIR:PATH=' + install_dir + '/lib/cmake/ug -DVc_DIR:PATH=' + install_dir + '/lib/cmake/Vc '
+ '-DBLAS_blas_LIBRARY:PATH=' + blas_lib + ' ' + '-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') shell('make -j' + str(num_proc) + ' install')
# manually change the following things: # manually change the following things:
# 1) Add AddVcFlags.cmake to /opt/sources/dune/dune-common/cmake/modules/CMakeLists.txt # 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 # 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_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_dune_default_libraries("amdis")
target_link_libraries("amdis" "duneamdis") target_link_libraries("amdis" "duneamdis")
target_compile_definitions("amdis" PRIVATE DIM=2 DOW=2)
...@@ -9,15 +9,19 @@ ...@@ -9,15 +9,19 @@
#include <dune/amdis/AMDiS.hpp> #include <dune/amdis/AMDiS.hpp>
#include <dune/amdis/ProblemStat.hpp> #include <dune/amdis/ProblemStat.hpp>
#define DIM 2 #ifndef DIM
#define DOW 2 #define DIM 2
#endif
#ifndef DOW
#define DOW 2
#endif
using namespace AMDiS; using namespace AMDiS;
// 1 component with polynomial degree 1 // 1 component with polynomial degree 1
using HeatParam = ProblemParametersBase<DIM, DOW, 1>; using HeatParam = ProblemParametersBase<DIM, DOW, 1>;
using HeatProblem = ProblemStat<HeatParam>; using HeatProblem = ProblemStat<HeatParam>;
using MeshView = HeatProblem::MeshView; using MeshView = HeatProblem::MeshView;
int main(int argc, char** argv)// try int main(int argc, char** argv)// try
{ {
......
Supports Markdown
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