diff --git a/src/Makefile.am b/src/Makefile.am index ba97418e4497b07df26f617d7144c000783c5e35..2e267a9767ec7a62e98b3f8cf49de2d54edf6e31 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,33 +4,64 @@ check_PROGRAMS = \ test-gradient-method bin_PROGRAMS = \ - one-body-sample + one-body-sample-2D \ + one-body-sample-3D -.PHONY: run-one-body-sample -run-one-body-sample: one-body-sample - libtool --mode execute ./one-body-sample +## 2D +.PHONY: run-one-body-sample-2D +run-one-body-sample-2D: one-body-sample-2D + libtool --mode execute ./one-body-sample-2D -.PHONY: run-one-body-sample-time -run-one-body-sample-time: one-body-sample - libtool --mode execute time ./one-body-sample >/dev/null +.PHONY: run-one-body-sample-2D-time +run-one-body-sample-2D-time: one-body-sample-2D + libtool --mode execute time ./one-body-sample-2D >/dev/null -.PHONY: run-one-body-sample-valgrind -run-one-body-sample-valgrind: one-body-sample - libtool --mode execute valgrind ./one-body-sample +.PHONY: run-one-body-sample-2D-valgrind +run-one-body-sample-2D-valgrind: one-body-sample-2D + libtool --mode execute valgrind ./one-body-sample-2D -.PHONY: run-one-body-sample-gdb -run-one-body-sample-gdb: one-body-sample - libtool --mode execute gdb ./one-body-sample +.PHONY: run-one-body-sample-2D-gdb +run-one-body-sample-2D-gdb: one-body-sample-2D + libtool --mode execute gdb ./one-body-sample-2D -one_body_sample_SOURCES = \ +one_body_sample_2D_SOURCES = \ assemblers.cc \ compute_state.cc \ compute_state_ruina.cc \ mysolver.cc \ one-body-sample.cc \ vtk.cc -one_body_sample_CPPFLAGS = \ - $(AM_CPPFLAGS) -Dsrcdir=\"$(srcdir)\" + +one_body_sample_2D_CPPFLAGS = \ + $(AM_CPPFLAGS) -Dsrcdir=\"$(srcdir)\" -DDIM=2 + +## 3D +.PHONY: run-one-body-sample-3D +run-one-body-sample-3D: one-body-sample-3D + libtool --mode execute ./one-body-sample-3D + +.PHONY: run-one-body-sample-3D-time +run-one-body-sample-3D-time: one-body-sample-3D + libtool --mode execute time ./one-body-sample-3D >/dev/null + +.PHONY: run-one-body-sample-3D-valgrind +run-one-body-sample-3D-valgrind: one-body-sample-3D + libtool --mode execute valgrind ./one-body-sample-3D + +.PHONY: run-one-body-sample-3D-gdb +run-one-body-sample-3D-gdb: one-body-sample-3D + libtool --mode execute gdb ./one-body-sample-3D + +one_body_sample_3D_SOURCES = \ + assemblers.cc \ + compute_state.cc \ + compute_state_ruina.cc \ + mysolver.cc \ + one-body-sample.cc \ + vtk.cc + +one_body_sample_3D_CPPFLAGS = \ + $(AM_CPPFLAGS) -Dsrcdir=\"$(srcdir)\" -DDIM=3 test_gradient_method_SOURCES = \ test-gradient-method.cc diff --git a/src/assemblers_tmpl.cc b/src/assemblers_tmpl.cc index 61fdb817c362613c5e3fcdb75447916b27c61aa9..19367f1a887d636e2cbcb12b84ff211a273ccace 100644 --- a/src/assemblers_tmpl.cc +++ b/src/assemblers_tmpl.cc @@ -1,3 +1,7 @@ +#ifndef DIM +#error DIM unset +#endif + #include <dune/common/fmatrix.hh> #include <dune/common/fvector.hh> // #include <dune/grid/yaspgrid.hh> @@ -5,65 +9,31 @@ #include <dune/fufem/functionspacebases/p1nodalbasis.hh> -// {{{ 2D -typedef Dune::FieldVector<double, 2> SmallVector2; -typedef Dune::FieldMatrix<double, 2, 2> SmallMatrix2; -typedef Dune::BCRSMatrix<SmallMatrix2> MatrixType2; -typedef Dune::BlockVector<SmallVector2> VectorType2; - -typedef Dune::ALUGrid<2, 2, Dune::simplex, Dune::nonconforming> GridType2; -// typedef Dune::YaspGrid<2> GridType2; -typedef GridType2::LeafGridView GridView2; -typedef P1NodalBasis<GridView2, double> P1Basis2; - -template void assemble_neumann<GridType2, GridView2, SmallVector2, P1Basis2>( - GridView2 const &gridView, P1Basis2 const &feBasis, - Dune::BitSetVector<1> const &neumannNodes, - Dune::BlockVector<SmallVector2> &f, - Dune::VirtualFunction<double, double> const &neumann, double time); - -template Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> -assemble_frictional<GridType2, GridView2, SmallVector2, P1Basis2>( - GridView2 const &gridView, P1Basis2 const &feBasis, - Dune::BitSetVector<1> const &frictionalNodes); - -template Dune::shared_ptr< - Dune::GlobalNonlinearity<VectorType2, MatrixType2> const> -assemble_nonlinearity<VectorType2, MatrixType2>( - Dune::ParameterTree const &parset, - Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> - nodalIntegrals, - Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> state, - double h); -// }}} - -// {{{ 3D -typedef Dune::FieldVector<double, 3> SmallVector3; -typedef Dune::FieldMatrix<double, 3, 3> SmallMatrix3; -typedef Dune::BCRSMatrix<SmallMatrix3> MatrixType3; -typedef Dune::BlockVector<SmallVector3> VectorType3; +typedef Dune::FieldVector<double, DIM> SmallVector; +typedef Dune::FieldMatrix<double, DIM, DIM> SmallMatrix; +typedef Dune::BCRSMatrix<SmallMatrix> MatrixType; +typedef Dune::BlockVector<SmallVector> VectorType; -typedef Dune::ALUGrid<3, 3, Dune::simplex, Dune::nonconforming> GridType3; -// typedef Dune::YaspGrid<3> GridType3; -typedef GridType3::LeafGridView GridView3; -typedef P1NodalBasis<GridView3, double> P1Basis3; +typedef Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming> GridType; +// typedef Dune::YaspGrid<DIM> GridType; +typedef GridType::LeafGridView GridView; +typedef P1NodalBasis<GridView, double> P1Basis; -template void assemble_neumann<GridType3, GridView3, SmallVector3, P1Basis3>( - GridView3 const &gridView, P1Basis3 const &feBasis, +template void assemble_neumann<GridType, GridView, SmallVector, P1Basis>( + GridView const &gridView, P1Basis const &feBasis, Dune::BitSetVector<1> const &neumannNodes, - Dune::BlockVector<SmallVector3> &f, + Dune::BlockVector<SmallVector> &f, Dune::VirtualFunction<double, double> const &neumann, double time); template Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> -assemble_frictional<GridType3, GridView3, SmallVector3, P1Basis3>( - GridView3 const &gridView, P1Basis3 const &feBasis, +assemble_frictional<GridType, GridView, SmallVector, P1Basis>( + GridView const &gridView, P1Basis const &feBasis, Dune::BitSetVector<1> const &frictionalNodes); template Dune::shared_ptr< - Dune::GlobalNonlinearity<VectorType3, MatrixType3> const> -assemble_nonlinearity<VectorType3, MatrixType3>( + Dune::GlobalNonlinearity<VectorType, MatrixType> const> +assemble_nonlinearity<VectorType, MatrixType>( Dune::ParameterTree const &parset, Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> nodalIntegrals, Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> state, double h); -// }}} diff --git a/src/mysolver_tmpl.cc b/src/mysolver_tmpl.cc index 44d1ab8ef56d01d4ec09f5cc2cc27a6624b3f749..e2ced974092c47d6adf2d34f72fd26a27b14390c 100644 --- a/src/mysolver_tmpl.cc +++ b/src/mysolver_tmpl.cc @@ -1,3 +1,7 @@ +#ifndef DIM +#error DIM unset +#endif + #include <dune/common/fmatrix.hh> #include <dune/common/fvector.hh> //#include <dune/grid/yaspgrid.hh> @@ -8,34 +12,16 @@ #include <dune/tectonic/myblockproblem.hh> #include <dune/tectonic/myconvexproblem.hh> -// {{{ 2D -typedef Dune::FieldVector<double, 2> SmallVector2; -typedef Dune::FieldMatrix<double, 2, 2> SmallMatrix2; -typedef Dune::BlockVector<SmallVector2> VectorType2; -typedef Dune::BCRSMatrix<SmallMatrix2> MatrixType2; - -typedef MyConvexProblem<MatrixType2, VectorType2> MyConvexProblemType2; -typedef MyBlockProblem<MyConvexProblemType2> MyBlockProblemType2; - -typedef Dune::ALUGrid<2, 2, Dune::simplex, Dune::nonconforming> GridType2; -// typedef Dune::YaspGrid<2> GridType2; - -template class MySolver<2, VectorType2, MatrixType2, GridType2, - MyBlockProblemType2>; -// }}} - -// {{{ 3D -typedef Dune::FieldVector<double, 3> SmallVector3; -typedef Dune::FieldMatrix<double, 3, 3> SmallMatrix3; -typedef Dune::BlockVector<SmallVector3> VectorType3; -typedef Dune::BCRSMatrix<SmallMatrix3> MatrixType3; +typedef Dune::FieldVector<double, DIM> SmallVector; +typedef Dune::FieldMatrix<double, DIM, DIM> SmallMatrix; +typedef Dune::BlockVector<SmallVector> VectorType; +typedef Dune::BCRSMatrix<SmallMatrix> MatrixType; -typedef MyConvexProblem<MatrixType3, VectorType3> MyConvexProblemType3; -typedef MyBlockProblem<MyConvexProblemType3> MyBlockProblemType3; +typedef MyConvexProblem<MatrixType, VectorType> MyConvexProblemType; +typedef MyBlockProblem<MyConvexProblemType> MyBlockProblemType; -typedef Dune::ALUGrid<3, 3, Dune::simplex, Dune::nonconforming> GridType3; -// typedef Dune::YaspGrid<3> GridType3; +typedef Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming> GridType; +// typedef Dune::YaspGrid<DIM> GridType; -template class MySolver<3, VectorType3, MatrixType3, GridType3, - MyBlockProblemType3>; -// }}} +template class MySolver<DIM, VectorType, MatrixType, GridType, + MyBlockProblemType>; diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 9ea4016b8468f7fe5c0d8d97fc9179433dc95aaa..2141c5c4a3378534e8a205f35bbafdfebe206c8c 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -10,6 +10,10 @@ #error srcdir unset #endif +#ifndef DIM +#error DIM unset +#endif + #ifndef HAVE_PYTHON #error Python is required #endif @@ -71,7 +75,7 @@ #include "enum_parser.cc" #include "enum_state_model.cc" -int const dim = 2; +int const dim = DIM; template <class GridView> void setup_boundary(GridView const &gridView, diff --git a/src/vtk_tmpl.cc b/src/vtk_tmpl.cc index 73bb323737f2e515847d2c59a68d9786650c2491..f1d50ca9608403dc3ec5c7937d23b74a874429fa 100644 --- a/src/vtk_tmpl.cc +++ b/src/vtk_tmpl.cc @@ -1,4 +1,6 @@ -#include "vtk.hh" +#ifndef DIM +#error DIM unset +#endif #include <dune/common/fmatrix.hh> #include <dune/common/fvector.hh> @@ -11,40 +13,18 @@ typedef Dune::BlockVector<Dune::FieldVector<double, 1>> SingletonVectorType; -// {{{ 2D -typedef Dune::FieldVector<double, 2> SmallVector2; -typedef Dune::FieldMatrix<double, 2, 2> SmallMatrix2; -typedef Dune::BlockVector<SmallVector2> VectorType2; - -typedef Dune::ALUGrid<2, 2, Dune::simplex, Dune::nonconforming> GridType2; -// typedef Dune::YaspGrid<2> GridType2; -typedef GridType2::LeafGridView GridView2; -typedef P1NodalBasis<GridView2, double> P1Basis2; -typedef P0Basis<GridView2, double> P0Basis2; - -template void writeVtk<P1Basis2, P0Basis2, VectorType2, SingletonVectorType, - GridView2>(P1Basis2 vertexBasis, - VectorType2 displacement, - SingletonVectorType state, P0Basis2 cellBasis, - SingletonVectorType stress, - GridView2 gridView, std::string filename); -// }}} - -// {{{ 3D -typedef Dune::FieldVector<double, 3> SmallVector3; -typedef Dune::FieldMatrix<double, 3, 3> SmallMatrix3; -typedef Dune::BlockVector<SmallVector3> VectorType3; - -typedef Dune::ALUGrid<3, 3, Dune::simplex, Dune::nonconforming> GridType3; -// typedef Dune::YaspGrid<3> GridType3; -typedef GridType3::LeafGridView GridView3; -typedef P1NodalBasis<GridView3, double> P1Basis3; -typedef P0Basis<GridView3, double> P0Basis3; - -template void writeVtk<P1Basis3, P0Basis3, VectorType3, SingletonVectorType, - GridView3>(P1Basis3 vertexBasis, - VectorType3 displacement, - SingletonVectorType state, P0Basis3 cellBasis, - SingletonVectorType stress, - GridView3 gridView, std::string filename); -// }}} +typedef Dune::FieldVector<double, DIM> SmallVector; +typedef Dune::FieldMatrix<double, DIM, DIM> SmallMatrix; +typedef Dune::BlockVector<SmallVector> VectorType; + +typedef Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming> GridType; +// typedef Dune::YaspGrid<> GridType; +typedef GridType::LeafGridView GridView; +typedef P1NodalBasis<GridView, double> P1Basis; +typedef P0Basis<GridView, double> MyP0Basis; + +template void writeVtk<P1Basis, MyP0Basis, VectorType, SingletonVectorType, + GridView>(P1Basis vertexBasis, VectorType displacement, + SingletonVectorType state, MyP0Basis cellBasis, + SingletonVectorType stress, GridView gridView, + std::string filename);