diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f52a06db113728f2b80f48b8c1726f4ecf7ed0ba..1ebe1f0a56a61f6fd0914bc789d07f573cd7ff66 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -set(SOURCE_FILES +set(SW_SOURCE_FILES assemblers.cc enumparser.cc hdf5/frictionalboundary-writer.cc @@ -19,6 +19,12 @@ set(SOURCE_FILES time-stepping/state.cc vtk.cc ) +set(UGW_SOURCE_FILES + assemblers.cc # FIXME + sand-wedge-data/mygrid.cc + uniform-grid-writer.cc + vtk.cc +) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/sand-wedge-data") dune_symlink_to_source_files(FILES @@ -28,18 +34,23 @@ dune_symlink_to_source_files(FILES "sand-wedge-data/parset-3D.cfg") foreach(_dim 2 3) - set(_target sand-wedge-${_dim}D) - add_executable(${_target} ${SOURCE_FILES}) - add_dune_ug_flags(${_target}) + set(_sw_target sand-wedge-${_dim}D) + set(_ugw_target uniform-grid-writer-${_dim}D) + + add_executable(${_sw_target} ${SW_SOURCE_FILES}) + add_executable(${_ugw_target} ${UGW_SOURCE_FILES}) + add_dune_ug_flags(${_sw_target}) + add_dune_ug_flags(${_ugw_target}) - set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) + set_property(TARGET ${_sw_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) + target_link_libraries(${_sw_target} ${Boost_FILESYSTEM_LIBRARY}) + target_link_libraries(${_sw_target} ${Boost_SYSTEM_LIBRARY}) - target_link_libraries(${_target} ${Boost_FILESYSTEM_LIBRARY}) - target_link_libraries(${_target} ${Boost_SYSTEM_LIBRARY}) + set_property(TARGET ${_sw_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${HDF5_INCLUDE_DIR}) + target_link_libraries(${_sw_target} ${HDF5_LIBRARIES}) - set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${HDF5_INCLUDE_DIR}) - target_link_libraries(${_target} ${HDF5_LIBRARIES}) - set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS "MY_DIM=${_dim}") + set_property(TARGET ${_sw_target} APPEND PROPERTY COMPILE_DEFINITIONS "MY_DIM=${_dim}") + set_property(TARGET ${_ugw_target} APPEND PROPERTY COMPILE_DEFINITIONS "MY_DIM=${_dim}") endforeach() # Mark UG as required diff --git a/src/uniform-grid-writer.cc b/src/uniform-grid-writer.cc new file mode 100644 index 0000000000000000000000000000000000000000..1fe4223929e00c2884e53095eff3c9cfeacf7587 --- /dev/null +++ b/src/uniform-grid-writer.cc @@ -0,0 +1,63 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <cmath> +#include <exception> +#include <iostream> + +#include <dune/common/exceptions.hh> +// #include <dune/common/parametertree.hh> +// #include <dune/common/parametertreeparser.hh> + +#include "assemblers.hh" +#include "diameter.hh" +#include "gridselector.hh" +#include "sand-wedge-data/mygrid.hh" +#include "vtk.hh" + +size_t const dims = MY_DIM; +size_t const refinements = 5; // FIXME? + +int main(int argc, char *argv[]) { + try { + // Dune::ParameterTree parset; + // Dune::ParameterTreeParser::readOptions(argc, argv, parset); + + using GridView = Grid::LeafGridView; + using MyAssembler = MyAssembler<GridView, dims>; + + GridConstructor<Grid> gridConstructor; + auto grid = gridConstructor.getGrid(); + + // refine uniformly! + for (size_t refinement = 0; refinement < refinements; ++refinement) + grid->globalRefine(1); + + double minDiameter = std::numeric_limits<double>::infinity(); + double maxDiameter = 0.0; + for (auto &&e : elements(grid->leafGridView())) { + auto const geometry = e.geometry(); + auto const diam = diameter(geometry); + minDiameter = std::min(minDiameter, diam); + maxDiameter = std::max(maxDiameter, diam); + } + std::cout << "min diameter: " << minDiameter << std::endl; + std::cout << "max diameter: " << maxDiameter << std::endl; + + auto const leafView = grid->leafGridView(); + auto const leafVertexCount = leafView.size(dims); + + std::cout << "Number of DOFs: " << leafVertexCount << std::endl; + + MyAssembler const myAssembler(leafView); + MyVTKWriter<typename MyAssembler::VertexBasis, + typename MyAssembler::CellBasis> const + vtkWriter(myAssembler.cellBasis, myAssembler.vertexBasis, "obs"); + vtkWriter.writeGrid(); + } catch (Dune::Exception &e) { + Dune::derr << "Dune reported error: " << e << std::endl; + } catch (std::exception &e) { + std::cerr << "Standard exception: " << e.what() << std::endl; + } +} diff --git a/src/vtk.cc b/src/vtk.cc index 53ab2b2c0656b6801705979a00b4202d6341b4dd..082af7714fc3d6e14ccfcf0a1f7ded8c6ce0c79f 100644 --- a/src/vtk.cc +++ b/src/vtk.cc @@ -46,4 +46,13 @@ void MyVTKWriter<VertexBasis, CellBasis>::write( writer.write(filename.c_str(), Dune::VTK::appendedraw); } +template <class VertexBasis, class CellBasis> +void MyVTKWriter<VertexBasis, CellBasis>::writeGrid() const { + Dune::VTKWriter<typename VertexBasis::GridView> writer( + vertexBasis.getGridView()); + + std::string const filename = prefix + "_grid"; + writer.write(filename.c_str(), Dune::VTK::appendedraw); +} + #include "vtk_tmpl.cc" diff --git a/src/vtk.hh b/src/vtk.hh index c851514c88b164fd0311663c427c3e96576477e2..733c0d8f25eaa9452661ac783de34ef491d1d0dd 100644 --- a/src/vtk.hh +++ b/src/vtk.hh @@ -15,5 +15,7 @@ template <class VertexBasis, class CellBasis> class MyVTKWriter { template <class Vector, class ScalarVector> void write(size_t record, Vector const &u, Vector const &v, ScalarVector const &alpha, ScalarVector const &stress) const; + + void writeGrid() const; }; #endif