Commit 9d10212a authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

some corrections of warnings

parent 442888a5
Pipeline #167 failed with stage
...@@ -9,6 +9,8 @@ cache: ...@@ -9,6 +9,8 @@ cache:
#- ./contrib/ci-setup #- ./contrib/ci-setup
#- dunecontrol --opts=/duneci/opts.clang --current all #- dunecontrol --opts=/duneci/opts.clang --current all
#- dunecontrol --current make test #- dunecontrol --current make test
#only:
#- master
dune:git--gcc: dune:git--gcc:
image: duneci/dune-fufem:git image: duneci/dune-fufem:git
...@@ -16,3 +18,5 @@ dune:git--gcc: ...@@ -16,3 +18,5 @@ dune:git--gcc:
- ./contrib/ci-setup - ./contrib/ci-setup
- dunecontrol --opts=/duneci/opts.gcc --current all - dunecontrol --opts=/duneci/opts.gcc --current all
- dunecontrol --current make test - dunecontrol --current make test
only:
- master
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_ROOT /opt/software/alberta)
# set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include) set(ALBERTA_INCLUDE_DIR /opt/software/alberta/include)
# set(CMAKE_PREFIX_PATH /opt/software/dune/lib/cmake) # 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)
......
...@@ -102,7 +102,7 @@ namespace AMDiS ...@@ -102,7 +102,7 @@ namespace AMDiS
boost::char_separator<char> sep(",; "); boost::char_separator<char> sep(",; ");
Tokenizer tokens(valStr, sep); Tokenizer tokens(valStr, sep);
int i = 0; size_t i = 0;
for (auto token : tokens) for (auto token : tokens)
{ {
AMDIS_TEST_EXIT(i < dim, "Vector data exceeds array dimension!"); AMDIS_TEST_EXIT(i < dim, "Vector data exceeds array dimension!");
......
...@@ -69,6 +69,13 @@ namespace AMDiS ...@@ -69,6 +69,13 @@ namespace AMDiS
return addSOTImpl(toTerm(A), _i, _j); return addSOTImpl(toTerm(A), _i, _j);
} }
static std::shared_ptr<Self> create()
{
return std::make_shared<Self>();
}
/// Extract the polynomial degree from \p rowFeSpace and \p colFeSpace. /// Extract the polynomial degree from \p rowFeSpace and \p colFeSpace.
template <class RowFeSpace, class ColFeSpace> template <class RowFeSpace, class ColFeSpace>
void init(RowFeSpace const& rowFeSpace, void init(RowFeSpace const& rowFeSpace,
......
...@@ -110,7 +110,7 @@ namespace AMDiS ...@@ -110,7 +110,7 @@ namespace AMDiS
{ {
// NOTE: This needs a change in mtl dense_vector implementation, i.e. we // NOTE: This needs a change in mtl dense_vector implementation, i.e. we
// have to add an alias for the function change_dim with the name resize. // have to add an alias for the function change_dim with the name resize.
Dune::Functions::interpolate(feSpace, *vector, f); Dune::Functions::interpolate(feSpace, wrapper(*vector), f);
} }
/// Calls the copy assignment operator of the BaseVector \ref vector /// Calls the copy assignment operator of the BaseVector \ref vector
......
...@@ -3,7 +3,7 @@ dune_add_test(NAME test_duneamdis ...@@ -3,7 +3,7 @@ dune_add_test(NAME test_duneamdis
TARGET duneamdis TARGET duneamdis
COMPILE_ONLY) COMPILE_ONLY)
find_package(GTest REQUIRED) # find_package(GTest REQUIRED)
set(projects "test1" "test2") set(projects "test1" "test2")
foreach(project ${projects}) foreach(project ${projects})
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <dune/amdis/ProblemStat.hpp> #include <dune/amdis/ProblemStat.hpp>
#include <dune/amdis/Literals.hpp> #include <dune/amdis/Literals.hpp>
#include <gtest/gtest.h> #define TEST_EQ(expr1, expr2) AMDIS_TEST_EXIT( (expr1) == (expr2), "'" << #expr1 << "' != '" << #expr2 << "'" )
#ifndef DIM #ifndef DIM
#define DIM 2 #define DIM 2
...@@ -21,18 +21,6 @@ namespace { ...@@ -21,18 +21,6 @@ namespace {
using Geometry = typename MeshView::template Codim<0>::Geometry; using Geometry = typename MeshView::template Codim<0>::Geometry;
using RefElements = Dune::ReferenceElements<typename Geometry::ctype, Geometry::mydimension>; using RefElements = Dune::ReferenceElements<typename Geometry::ctype, Geometry::mydimension>;
class AMDiSTester : public ::testing::Test
{
protected:
// create a problemStat
virtual void SetUp() override
{
prob = std::make_shared<TestProblem>("test");
prob->initialize(INIT_ALL);
}
std::shared_ptr<TestProblem> prob;
};
template <class FeSpace> template <class FeSpace>
...@@ -76,7 +64,18 @@ namespace { ...@@ -76,7 +64,18 @@ namespace {
}; };
TEST_F(AMDiSTester, CreateDOFVector) class AMDiSTester
{
public:
// create a problemStat
AMDiSTester(std::string name)
: prob(std::make_shared<TestProblem>(name))
{
prob->initialize(INIT_ALL);
}
void test1() // CreateDOFVector
{ {
using FeSpace = typename TestProblem::template FeSpace<0>; using FeSpace = typename TestProblem::template FeSpace<0>;
...@@ -108,7 +107,7 @@ namespace { ...@@ -108,7 +107,7 @@ namespace {
} }
TEST_F(AMDiSTester, FillDOFVector) void test2() // FillDOFVector
{ {
auto& vec = prob->getSolution(0_c); auto& vec = prob->getSolution(0_c);
auto const& feSpace = vec.getFeSpace(); auto const& feSpace = vec.getFeSpace();
...@@ -131,20 +130,25 @@ namespace { ...@@ -131,20 +130,25 @@ namespace {
auto data = evaluator.eval(vec, pos); auto data = evaluator.eval(vec, pos);
auto x = element.geometry().global(pos); auto x = element.geometry().global(pos);
EXPECT_EQ(data, x*x); TEST_EQ(data, x*x);
} }
} }
} }
protected:
std::shared_ptr<TestProblem> prob;
};
} // end namespace } // end namespace
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
AMDiS::init(argc, argv); AMDiS::init(argc, argv);
::testing::InitGoogleTest(&argc, argv); auto tester = std::make_shared<AMDiSTester>("test");
int error_code = RUN_ALL_TESTS(); tester->test1();
tester->test2();
AMDiS::finalize(); AMDiS::finalize();
return error_code; return 0;
} }
\ No newline at end of file
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#include <dune/amdis/ProblemStat.hpp> #include <dune/amdis/ProblemStat.hpp>
#include <dune/amdis/Literals.hpp> #include <dune/amdis/Literals.hpp>
#include <gtest/gtest.h>
#ifndef DIM #ifndef DIM
#define DIM 2 #define DIM 2
#endif #endif
...@@ -12,27 +10,25 @@ ...@@ -12,27 +10,25 @@
#endif #endif
using namespace AMDiS; using namespace AMDiS;
namespace { namespace {
using TestParam = ProblemStatTraits<DIM, DOW, 1>; using TestParam = ProblemStatTraits<DIM, DOW, 1>;
using TestProblem = ProblemStat<TestParam>; using TestProblem = ProblemStat<TestParam>;
using Op = TestProblem::OperatorType; using Op = TestProblem::OperatorType;
class AMDiSTester : public ::testing::Test class AMDiSTester
{ {
protected: public:
// create a problemStat // create a problemStat
virtual void SetUp() override AMDiSTester(std::string name)
: prob(std::make_shared<TestProblem>(name))
{ {
prob = std::make_shared<TestProblem>("test");
prob->initialize(INIT_ALL); prob->initialize(INIT_ALL);
} }
std::shared_ptr<TestProblem> prob;
};
TEST_F(AMDiSTester, AddOperators) void test1() // AddOperators
{ {
auto const& u = prob->getSolution<0>(); auto const& u = prob->getSolution<0>();
...@@ -50,7 +46,7 @@ namespace { ...@@ -50,7 +46,7 @@ namespace {
op1.addZOT( derivativeOf(u, 0) ); op1.addZOT( derivativeOf(u, 0) );
op1.addZOT( derivativeOf(u, 1) ); op1.addZOT( derivativeOf(u, 1) );
// op1.addFOT( gradientOf(u), GRD_PSI ); // op1.addFOT( gradientOf(u), GRD_PSI );
// evaluate functor at coordinates // evaluate functor at coordinates
op1.addZOT( eval([](auto const& x) { return x[0]; }) ); op1.addZOT( eval([](auto const& x) { return x[0]; }) );
...@@ -74,7 +70,7 @@ namespace { ...@@ -74,7 +70,7 @@ namespace {
} }
TEST_F(AMDiSTester, MatrixVector) void test2() // MatrixVector
{ {
auto const& u = prob->getSolution<0>(); auto const& u = prob->getSolution<0>();
...@@ -89,15 +85,21 @@ namespace { ...@@ -89,15 +85,21 @@ namespace {
double erg = v[0].dot(w[0]); double erg = v[0].dot(w[0]);
} }
protected:
std::shared_ptr<TestProblem> prob;
};
} // end namespace } // end namespace
int main(int argc, char** argv)
int main(int argc, char* argv[])
{ {
AMDiS::init(argc, argv); AMDiS::init(argc, argv);
::testing::InitGoogleTest(&argc, argv); auto tester = std::make_shared<AMDiSTester>("test");
int error_code = RUN_ALL_TESTS(); tester->test1();
tester->test2();
AMDiS::finalize(); AMDiS::finalize();
return error_code; return 0;
} }
\ No newline at end of file
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
}, },
"adapt": { "adapt": {
"timestep": 0.1, "timestep": 0.001,
"start time": 0.0, "start time": 0.0,
"end time": 1.0 "end time": 1.0
} }
......
...@@ -10,11 +10,11 @@ ...@@ -10,11 +10,11 @@
"mesh": "stokesMesh", "mesh": "stokesMesh",
"solver" : { "solver" : {
"name": "gmres", "name": "bicgstab_ell",
"max iteration": 500, "ell": 3,
"max iteration": 5000,
"reduction": 1e-6, "reduction": 1e-6,
"info": 1, "info": 1
"left precon": "diag"
}, },
"output": { "output": {
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
}, },
"adapt": { "adapt": {
"timestep": 0.001, "timestep": 1.0e-3,
"start time": 0.0, "start time": 0.0,
"end time": 1.0 "end time": 1.0
} }
......
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream> #include <iostream>
#include <ctime> #include <ctime>
#include <cmath> #include <cmath>
#include <dune/amdis/AMDiS.hpp> #include <dune/amdis/AMDiS.hpp>
#include <dune/amdis/AdaptInstationary.hpp>
#include <dune/amdis/ProblemStat.hpp> #include <dune/amdis/ProblemStat.hpp>
#include <dune/amdis/ProblemInstat.hpp>
#ifndef DIM #ifndef DIM
#define DIM 2 #define DIM 2
...@@ -21,6 +19,7 @@ using namespace AMDiS; ...@@ -21,6 +19,7 @@ using namespace AMDiS;
// 3 components: velocity with polynomial degree 2 and pressure with polynomial degree 1 // 3 components: velocity with polynomial degree 2 and pressure with polynomial degree 1
using StokesParam = ProblemStatTraits<DIM, DOW, 2, 2, 1>; using StokesParam = ProblemStatTraits<DIM, DOW, 2, 2, 1>;
using StokesProblem = ProblemStat<StokesParam>; using StokesProblem = ProblemStat<StokesParam>;
using StokesProblemInstat = ProblemInstat<StokesParam>;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
...@@ -29,6 +28,9 @@ int main(int argc, char** argv) ...@@ -29,6 +28,9 @@ int main(int argc, char** argv)
StokesProblem prob("stokes"); StokesProblem prob("stokes");
prob.initialize(INIT_ALL); prob.initialize(INIT_ALL);
StokesProblemInstat probInstat("stokes", prob);
probInstat.initialize(INIT_UH_OLD);
double viscosity = 1.0; double viscosity = 1.0;
double density = 1.0; double density = 1.0;
double vel = 1.0; double vel = 1.0;
...@@ -36,43 +38,55 @@ int main(int argc, char** argv) ...@@ -36,43 +38,55 @@ int main(int argc, char** argv)
Parameters::get("stokes->density", density); Parameters::get("stokes->density", density);
Parameters::get("stokes->boundary velocity", vel); Parameters::get("stokes->boundary velocity", vel);
using DOFVectorU = std::decay_t< decltype(prob.getSolution<0>()) >;
using DOFVectorP = std::decay_t< decltype(prob.getSolution<DOW>()) >;
std::array<DOFVectorU*, DOW> velocity;
For<0,DOW>::loop([&](auto const _i) { velocity[_i] = &prob.getSolution(_i); });
AdaptInfo adaptInfo("adapt"); AdaptInfo adaptInfo("adapt");
double tau = adaptInfo.getTimestep();
// define the differential operators // define the differential operators
using Op = StokesProblem::OperatorType; using Op = StokesProblem::OperatorType;
For<0,DOW>::loop([&](auto const _i) For<0,DOW>::loop([&](auto const _i)
{ {
// <1/tau * u_i, v_i> + <viscosity*grad(u_i), grad(v_i)> // <1/tau * u_i, v_i>
Op* opL = new Op; auto opTime = Op::create(), opTimeOld = Op::create();
opL->addZOT( constant(density/tau) ); opTime->addZOT( density );
opL->addSOT( constant(viscosity) ); opTimeOld->addZOT( valueOf(prob.getSolution(_i), density) );
prob.addMatrixOperator(*opL, _i, _i); prob.addMatrixOperator(opTime, _i, _i, probInstat.getInvTau());
prob.addVectorOperator(opTimeOld, _i, probInstat.getInvTau());
// <1/tau * u_i^old, v_i>
Op* opRhs = new Op; #if 0
opRhs->addZOT( valueOf(prob.getSolution(_i), density/tau) ); // <(u * nabla)u_i^old, v_i>
prob.addVectorOperator(*opRhs, _i); For<0, DOW>::loop([&](auto const _j)
{
// <p, d_i(v_i)> auto opNonlin = Op::create();
Op* opB = new Op; opNonlin->addZOT( derivativeOf(prob.getSolution(_i), _j, density) );
opB->addFOT( constant(1.0), _i, GRD_PSI ); prob.addMatrixOperator(opNonlin, _i, _j);
prob.addMatrixOperator(*opB, _i, DOW); });
#else
// <d_i(u_i), q>
Op* opDiv = new Op;
opDiv->addFOT( constant(1.0), _i, GRD_PHI );
prob.addMatrixOperator(*opDiv, DOW, _i);
// <(u^old * nabla)u_i, v_i> // <(u^old * nabla)u_i, v_i>
// NOTE: only simple linearization of nonlin-term, since gradientOf() not yet implemented
For<0, DOW>::loop([&](auto const _j) For<0, DOW>::loop([&](auto const _j)
{ {
Op* opNonlin = new Op; auto opNonlin = Op::create();
opNonlin->addFOT( valueOf(prob.getSolution(_j), density), _j, GRD_PHI ); opNonlin->addFOT( valueOf(prob.getSolution(_j), density), _j, GRD_PHI );
prob.addMatrixOperator(*opNonlin, _i, _i); prob.addMatrixOperator(opNonlin, _i, _i);
}); });
#endif
// <viscosity*grad(u_i), grad(v_i)>
auto opL = Op::create();
opL->addSOT( viscosity );
prob.addMatrixOperator(opL, _i, _i);
// <p, d_i(v_i)>
auto opP = Op::create();
opP->addFOT( 1.0, _i, GRD_PSI );
prob.addMatrixOperator(opP, _i, DOW);
// <d_i(u_i), q>
auto opDiv = Op::create();
opDiv->addFOT( 1.0, _i, GRD_PHI );
prob.addMatrixOperator(opDiv, DOW, _i);
}); });
// define boundary regions // define boundary regions
...@@ -90,23 +104,10 @@ int main(int argc, char** argv) ...@@ -90,23 +104,10 @@ int main(int argc, char** argv)
prob.addDirichletBC(left, 0, 0, zero); prob.addDirichletBC(left, 0, 0, zero);
prob.addDirichletBC(left, 1, 1, parabolic); prob.addDirichletBC(left, 1, 1, parabolic);
// set initial values for the solver (maybe not necessary)
*prob.getSolution() = 0.0; *prob.getSolution() = 0.0;
double t = 0.0; AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo);
for (t = adaptInfo.getStartTime(); adapt.adapt();
t < adaptInfo.getEndTime();
t+= adaptInfo.getTimestep())
{
adaptInfo.setTime(t);
AMDIS_MSG("Timestep t = " << t);
prob.writeFiles(adaptInfo);
// assemble and solve system
prob.buildAfterCoarsen(adaptInfo, Flag(0));
prob.solve(adaptInfo);
}
// output solution // output solution
prob.writeFiles(adaptInfo); prob.writeFiles(adaptInfo);
......
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