diff --git a/.travis.yml b/.travis.yml index 68a2659f..0db2dbf0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,9 @@ notifications: language: cpp before_install: - - test -d build-travis || mkdir build-travis; sudo chown -R 1000:1000 build-travis - - test -d ./scripts/programs || ./scripts/dr.sh "cd deal2lkit; ./scripts/download_clang_format" - - ./scripts/dr.sh "cd deal2lkit; ./scripts/check_indentation.sh" + - test -d build-travis || mkdir build-travis + - ./scripts/dr.sh "./scripts/check_indentation.sh" script: - - ./scripts/dr.sh "cd deal2lkit/build-travis; cmake -DD2K_ENABLE_TESTING=ON -DD2K_COMPONENT_DOCUMENTATION=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..; make -j4" - - ./scripts/dr.sh "cd deal2lkit/build-travis; make setup_tests; ctest -j4 -V" + - ./scripts/dr.sh "cd build-travis; cmake -DD2K_ENABLE_TESTING=ON -DD2K_COMPONENT_DOCUMENTATION=OFF -DCMAKE_BUILD_TYPE=$BUILD_TYPE ..; make -j4" + - ./scripts/dr.sh "cd build-travis; make setup_tests; ctest -j4 -V" diff --git a/docker/Makefile b/docker/Makefile index 981b39f3..65686d89 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -11,7 +11,7 @@ locks/base.%: Dockerfile.base.% touch locks/base.$* locks/deal2lkit.%: Dockerfile.deal2lkit.% - docker build -t mathlab/deal2lkit:$*-debugrelease -f Dockerfile.deal2lkit.$* . + docker build --build-arg VER=$* -t mathlab/deal2lkit:$*-debugrelease -f Dockerfile.deal2lkit.$* . touch locks/deal2lkit.$* push-%: locks/base.% locks/deal2lkit.% diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e2dc52fb..40c58c85 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -39,7 +39,6 @@ IF(D2K_COMPONENT_EXAMPLES) # All CMakeLists.txt except the one in examples/ # PATTERN "poisson/CMakeLists.txt" - PATTERN "assimp_importer/CMakeLists.txt" PATTERN "heat_equation/CMakeLists.txt" PATTERN "heat_equation/tests/CMakeLists.txt" PATTERN "dynamic_stokes/CMakeLists.txt" diff --git a/examples/heat_equation/include/heat_ida.h b/examples/heat_equation/include/heat_ida.h index c93c1e86..1d3396cb 100644 --- a/examples/heat_equation/include/heat_ida.h +++ b/examples/heat_equation/include/heat_ida.h @@ -13,49 +13,48 @@ // //----------------------------------------------------------- -#ifndef _d2k_heat_ida_h -#define _d2k_heat_ida_h +#ifndef d2k_heat_ida_h +#define d2k_heat_ida_h -#include +#include +#include +#include -#ifdef D2K_WITH_SUNDIALS -# include -# include +#include -# include +#include +#include +#include +#include +#include +#include -# include -# include -# include -# include -# include -# include +#include -# include +#include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -# include +#include using namespace dealii; using namespace deal2lkit; -typedef TrilinosWrappers::MPI::Vector VEC; +using VEC = TrilinosWrappers::MPI::Vector; + template -class Heat : public ParameterAcceptor +class Heat : public deal2lkit::ParameterAcceptor { public: Heat(const MPI_Comm comm); @@ -141,7 +140,7 @@ class Heat : public ParameterAcceptor const MPI_Comm comm; - unsigned int initial_global_refinement; + unsigned int initial_global_refinement = 4; unsigned int max_time_iterations; std::string timer_file_name; @@ -150,13 +149,13 @@ class Heat : public ParameterAcceptor std::ofstream timer_outfile; ConditionalOStream tcout; - shared_ptr> mapping; + std::unique_ptr> mapping; - shared_ptr> triangulation; - shared_ptr> fe; - shared_ptr> dof_handler; + std::unique_ptr> triangulation; + std::unique_ptr> fe; + std::unique_ptr> dof_handler; - ConstraintMatrix constraints; + AffineConstraints constraints; TrilinosWrappers::SparsityPattern jacobian_matrix_sp; TrilinosWrappers::SparseMatrix jacobian_matrix; @@ -172,23 +171,23 @@ class Heat : public ParameterAcceptor mutable TimerOutput computing_timer; - ErrorHandler eh; + ParsedConvergenceTable convergence_table; ParsedGridGenerator pgg; ParsedGridRefinement pgr; ParsedFiniteElement fe_builder; - ParsedFunction exact_solution; - ParsedFunction forcing_term; - - ParsedFunction initial_solution; - ParsedFunction initial_solution_dot; - ParsedDirichletBCs dirichlet_bcs; + ParameterAcceptorProxy> exact_solution; + ParameterAcceptorProxy> forcing_term; + ParameterAcceptorProxy> initial_solution; + ParameterAcceptorProxy> initial_solution_dot; + ParsedDirichletBCs dirichlet_bcs; ParsedDataOut data_out; ParsedSolver Ainv; - IDAInterface ida; + SUNDIALS::IDA::AdditionalData ida_parameters; + SUNDIALS::IDA ida; IndexSet global_partitioning; IndexSet partitioning; @@ -201,5 +200,3 @@ class Heat : public ParameterAcceptor }; #endif - -#endif diff --git a/examples/heat_equation/scripts/astyle.rc b/examples/heat_equation/scripts/astyle.rc deleted file mode 100644 index 91c5c922..00000000 --- a/examples/heat_equation/scripts/astyle.rc +++ /dev/null @@ -1,33 +0,0 @@ -## --------------------------------------------------------------------- -## -## Copyright (C) 2012 - 2013 by the deal.II authors -## -## This file is part of the deal.II library. -## -## The deal.II library is free software; you can use it, redistribute -## it, and/or modify it under the terms of the GNU Lesser General -## Public License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## The full text of the license can be found in the file LICENSE at -## the top level of the deal.II distribution. -## -## --------------------------------------------------------------------- - -# astyle 2.02 indentation style for deal.II - ---style=gnu - ---convert-tabs ---indent-preprocessor ---indent=spaces=2 ---indent-namespaces ---min-conditional-indent=0 ---pad-header - -# write things as 'char *p' ---align-pointer=name ---align-reference=name - ---max-instatement-indent=60 ---suffix=none ---quiet diff --git a/examples/heat_equation/scripts/check_indentation.sh b/examples/heat_equation/scripts/check_indentation.sh deleted file mode 100755 index 75dfa045..00000000 --- a/examples/heat_equation/scripts/check_indentation.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then - echo "Running indentation test on master merge." -else - echo "Running indentation test on Pull Request #${TRAVIS_PULL_REQUEST}" -fi - -export PATH=`pwd`/astyle/build/gcc/bin:$PATH - -./scripts/indent -git diff -git diff-files --quiet diff --git a/examples/heat_equation/scripts/indent b/examples/heat_equation/scripts/indent deleted file mode 100755 index 7bfaa718..00000000 --- a/examples/heat_equation/scripts/indent +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -## --------------------------------------------------------------------- -## -## Copyright (C) 2012 - 2013, 2015 by the deal.II authors -## -## This file is part of the deal.II library. -## -## The deal.II library is free software; you can use it, redistribute -## it, and/or modify it under the terms of the GNU Lesser General -## Public License as published by the Free Software Foundation; either -## version 2.1 of the License, or (at your option) any later version. -## The full text of the license can be found in the file LICENSE at -## the top level of the deal.II distribution. -## -## --------------------------------------------------------------------- - -if test ! -f scripts/astyle.rc ; then - echo "*** No style file scripts/astyle.rc found." - exit -fi - - -# loop over all directories in which we may have source files; -# collect a list of files and then spawn a parallel process to -# indent all of them -echo "--- Indenting all header and source files" -for dir in source include tests; do -files=`find $dir | egrep '\.(cc|h)$'` ; - if test -n "$files" ; then - (astyle --options=scripts/astyle.rc $files ) & - fi -done - -wait diff --git a/examples/heat_equation/scripts/setup_astyle.sh b/examples/heat_equation/scripts/setup_astyle.sh deleted file mode 100755 index cb148859..00000000 --- a/examples/heat_equation/scripts/setup_astyle.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -echo "Downloading and installing astyle." -wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.04/astyle_2.04_linux.tar.gz > /dev/null -tar xvfz astyle_2.04_linux.tar.gz > /dev/null -cd astyle/build/gcc -make -j4 > /dev/null -cd ../../../ -export PATH=`pwd`/astyle/build/gcc/bin:$PATH diff --git a/examples/heat_equation/source/heat_ida.cc b/examples/heat_equation/source/heat_ida.cc index aa6242a9..22c41929 100644 --- a/examples/heat_equation/source/heat_ida.cc +++ b/examples/heat_equation/source/heat_ida.cc @@ -15,31 +15,29 @@ #include "heat_ida.h" -#ifdef D2K_WITH_SUNDIALS +#include -# include +#include +#include +#include -# include -# include -# include +#include +#include +#include -# include -# include -# include +#include +#include +#include +#include -# include -# include -# include -# include - -# include +#include //#include -# include -# include +#include +#include -# include -# include -# include +#include +#include +#include template Heat::Heat(const MPI_Comm communicator) @@ -48,41 +46,32 @@ Heat::Heat(const MPI_Comm communicator) , timer_outfile("timer.txt") , tcout(timer_outfile, (Utilities::MPI::this_mpi_process(comm) == 0)) , computing_timer(comm, tcout, TimerOutput::summary, TimerOutput::wall_times) - , - - eh("Error Tables", "u", "L2,H1") - , - - pgg("Domain") + , pgg("Domain") , pgr("Refinement") , fe_builder("Finite Element") - , - - exact_solution("Exact solution", 1) + , exact_solution("Exact solution", 1) , forcing_term("Forcing term", 1) , initial_solution("Initial solution", 1) , initial_solution_dot("Initial solution_dot", 1) , dirichlet_bcs("Dirichlet BCs", 1, "u", "0=u") - , - - data_out("Output Parameters", "vtu") + , data_out("Output Parameters", "vtu") , Ainv("Solver", "cg", /* iter= */ 1000, /* reduction= */ 1e-8, linear_operator(jacobian_matrix)) - , ida("IDA Solver Parameters", comm) + , ida(ida_parameters, comm) {} template void Heat::declare_parameters(ParameterHandler &prm) { - add_parameter(prm, - &initial_global_refinement, - "Initial global refinement", - "1", - Patterns::Integer(0)); + prm.enter_subsection("Sundials IDA parameters"); + ida_parameters.add_parameters(prm); + prm.leave_subsection(); + + prm.add_parameter("Initial global refinement", initial_global_refinement); add_parameter(prm, &max_time_iterations, @@ -119,9 +108,9 @@ template void Heat::make_grid_fe() { - triangulation = SP(pgg.distributed(comm)); - dof_handler = SP(new DoFHandler(*triangulation)); - fe = SP(fe_builder()); + triangulation = pgg.distributed(comm); + dof_handler = std::make_unique>(*triangulation); + fe = fe_builder(); triangulation->refine_global(initial_global_refinement); } @@ -134,7 +123,7 @@ Heat::setup_dofs(const bool &first_run) dof_handler->distribute_dofs(*fe); - mapping = SP(new MappingQ(1)); + mapping = std::make_unique>(1); const unsigned int n_dofs = dof_handler->n_dofs(); @@ -392,8 +381,7 @@ template shared_ptr Heat::create_new_vector() const { - shared_ptr ret = SP(new VEC(solution)); - return ret; + return std::make_shared(solution); } template @@ -437,10 +425,10 @@ Heat::output_step(const double t, data_out.add_data_vector(distributed_solution_dot, print(sol_dot_names, ",")); data_out.write_data_and_clear(*mapping); - eh.error_from_exact(*mapping, - *dof_handler, - distributed_solution, - exact_solution); + convergence_table.error_from_exact(*mapping, + *dof_handler, + distributed_solution, + exact_solution); computing_timer.exit_section(); } @@ -462,7 +450,7 @@ Heat::solver_should_restart(const double, VEC &solution, VEC &solution_dot) KellyErrorEstimator::estimate( *dof_handler, QGauss(fe->degree + 1), - typename FunctionMap::type(), + {}, distributed_solution, estimated_error_per_cell, ComponentMask(), @@ -597,9 +585,9 @@ Heat::run() constraints.distribute(solution); - ida.create_new_vector = [this]() -> shared_ptr { - return this->create_new_vector(); - }; + // ida.create_new_vector = [this]() -> shared_ptr { + // return this->create_new_vector(); + // }; ida.residual = [this](const double t, const VEC & y, const VEC & y_dot, @@ -629,22 +617,21 @@ Heat::run() const unsigned int step_number) { this->output_step(t, y, y_dot, step_number); }; - ida.differential_components = [this]() -> VEC & { - return this->differential_components(); - }; + // ida.differential_components = [this]() -> VEC & { + // return this->differential_components(); + // }; ida.solve_dae(solution, solution_dot); - eh.error_from_exact(*mapping, - *dof_handler, - distributed_solution, - exact_solution); + convergence_table.error_from_exact(*mapping, + *dof_handler, + distributed_solution, + exact_solution); - eh.output_table(pcout); + if (pcout.is_active()) + convergence_table.output_table(pcout.get_stream()); computing_timer.print_summary(); timer_outfile.close(); } template class Heat<2>; - -#endif diff --git a/examples/heat_equation/source/main.cc b/examples/heat_equation/source/main.cc index f26f7e1c..1b867bb8 100644 --- a/examples/heat_equation/source/main.cc +++ b/examples/heat_equation/source/main.cc @@ -13,6 +13,8 @@ // //----------------------------------------------------------- +#include + #include #include @@ -20,12 +22,13 @@ #include "heat_ida.h" +using namespace dealii; + int main(int argc, char **argv) { deallog.depth_console(0); -#ifdef D2K_WITH_SUNDIALS Utilities::MPI::MPI_InitFinalize mpi_initialization( argc, argv, numbers::invalid_unsigned_int); @@ -35,18 +38,8 @@ main(int argc, char **argv) Heat<2> solver(comm); - ParameterAcceptor::initialize("../source/heat_ida.prm", - "used_parameters.prm"); + dealii::ParameterAcceptor::initialize("../source/heat_ida.prm", + "used_parameters.prm"); solver.run(); - - return 0; - -#else - std::cout << "This example requires that the option \n" - << "D2K_WITH_SUNDIALS is set to ON. \n" - << "Please recompile the deal2lkit library \n" - << "with the option -DD2K_WITH_SUNDIALS=ON " << std::endl; - return 1; -#endif } diff --git a/include/deal2lkit/parsed_function_object.h b/include/deal2lkit/parsed_function_object.h new file mode 100644 index 00000000..ebf4019d --- /dev/null +++ b/include/deal2lkit/parsed_function_object.h @@ -0,0 +1,55 @@ +//----------------------------------------------------------- +// +// Copyright (C) 2015 by the deal2lkit authors +// +// This file is part of the deal2lkit library. +// +// The deal2lkit library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal2lkit distribution. +// +//----------------------------------------------------------- + + +#ifndef d2k_parsed_function_object_h +#define d2k_parsed_function_object_h + +#include + +#include + +D2K_NAMESPACE_OPEN + +#include +#include +#include +#include + +template +decltype(auto) +apply_tuple_impl(F &&fn, Tuple &&t, std::index_sequence) +{ + return std::forward(fn)(std::get(std::forward(t))...); +} + + +template +decltype(auto) +apply_from_tuple(F &&fn, Tuple &&t) +{ + std::size_t constexpr tSize = + std::tuple_size::type>::value; + return apply_tuple_impl(std::forward(fn), + std::forward(t), + std_cxx14::make_index_sequence()); +} + + +template + +D2K_NAMESPACE_CLOSE + +#endif diff --git a/scripts/dr.sh b/scripts/dr.sh index f7e8ed27..164d5a26 100755 --- a/scripts/dr.sh +++ b/scripts/dr.sh @@ -1 +1 @@ -docker run -t --rm -P -v `pwd`:/home/dealii/deal2lkit:rw dealii/dealii:v9.1.1-gcc-mpi-fulldepsspack-debugrelease /bin/sh -c "$@" +docker run --user $(id -u):$(id -g) -i -t --rm -P -v `pwd`:/home/dealii/deal2lkit:rw dealii/dealii:v9.1.1-gcc-mpi-fulldepsspack-debugrelease /bin/sh -c "cd deal2lkit; $@"