Commit 4d644e1e authored by Stenger, Florian's avatar Stenger, Florian
Browse files

v0.1.0

parent d73600d2
# We require version CMake version 3.1 to prevent issues
# with dune_enable_all_packages and older CMake versions.
cmake_minimum_required(VERSION 3.1)
project(dune-curvedsurfacegrid CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
string(REPLACE ${CMAKE_PROJECT_NAME} dune-common dune-common_DIR
${PROJECT_BINARY_DIR})
endif()
#find dune-common and set the module path
find_package(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules"
${dune-common_MODULE_PATH})
#include the dune macros
include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
dune_enable_all_packages()
add_subdirectory(src)
add_subdirectory(dune)
add_subdirectory(doc)
add_subdirectory(lib)
add_subdirectory(example)
add_subdirectory(cmake/modules)
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
Preparing the Sources
=========================
Additional to the software mentioned in README you'll need the
following programs installed on your system:
cmake >= 2.8.12
Getting started
---------------
If these preliminaries are met, you should run
dunecontrol all
which will find all installed dune modules as well as all dune modules
(not installed) which sources reside in a subdirectory of the current
directory. Note that if dune is not installed properly you will either
have to add the directory where the dunecontrol script resides (probably
./dune-common/bin) to your path or specify the relative path of the script.
Most probably you'll have to provide additional information to dunecontrol
(e. g. compilers, configure options) and/or make options.
The most convenient way is to use options files in this case. The files
define four variables:
CMAKE_FLAGS flags passed to cmake (during configure)
An example options file might look like this:
#use this options to configure and make if no other options are given
CMAKE_FLAGS=" \
-DCMAKE_CXX_COMPILER=g++-5 \
-DCMAKE_CXX_FLAGS='-Wall -pedantic' \
-DCMAKE_INSTALL_PREFIX=/install/path" #Force g++-5 and set compiler flags
If you save this information into example.opts you can pass the opts file to
dunecontrol via the --opts option, e. g.
dunecontrol --opts=example.opts all
More info
---------
See
dunecontrol --help
for further options.
The full build system is described in the dune-common/doc/buildsystem (Git version) or under share/doc/dune-common/buildsystem if you installed DUNE!
set(modules "DuneCurvedsurfacegridMacros.cmake")
install(FILES ${modules} DESTINATION ${DUNE_INSTALL_MODULEDIR})
#after surfacedistance/vtureader has been removed all of this can be deleted.
find_package(Boost COMPONENTS iostreams)
if(Boost_FOUND)
add_definitions(-DDCSG_BOOST_IOSTREAMS)
dune_register_package_flags(LIBRARIES Boost::iostreams)
endif()
find_package(ZLIB)
if(ZLIB_FOUND)
add_definitions(-DDCSG_ZLIB)
dune_register_package_flags(INCLUDE_DIRS ${ZLIB_INCLUDE_DIR} LIBRARIES ${ZLIB_LIBRARIES})
endif()
/* begin dune-curvedsurfacegrid
put the definitions for config.h specific to
your project here. Everything above will be
overwritten
*/
/* begin private */
/* Name of package */
#define PACKAGE "@DUNE_MOD_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@DUNE_MOD_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@DUNE_MOD_NAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@DUNE_MOD_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@DUNE_MOD_VERSION@"
/* end private */
/* Define to the version of dune-curvedsurfacegrid */
#define DUNE_CURVEDSURFACEGRID_VERSION "@DUNE_CURVEDSURFACEGRID_VERSION@"
/* Define to the major version of dune-curvedsurfacegrid */
#define DUNE_CURVEDSURFACEGRID_VERSION_MAJOR @DUNE_CURVEDSURFACEGRID_VERSION_MAJOR@
/* Define to the minor version of dune-curvedsurfacegrid */
#define DUNE_CURVEDSURFACEGRID_VERSION_MINOR @DUNE_CURVEDSURFACEGRID_VERSION_MINOR@
/* Define to the revision of dune-curvedsurfacegrid */
#define DUNE_CURVEDSURFACEGRID_VERSION_REVISION @DUNE_CURVEDSURFACEGRID_VERSION_REVISION@
/* end dune-curvedsurfacegrid
Everything below here will be overwritten
*/
add_subdirectory("doxygen")
# shortcut for creating the Doxyfile.in and Doxyfile
add_doxygen_target()
# This file contains local changes to the doxygen configuration
# please us '+=' to add file/directories to the lists
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT += @top_srcdir@/dune/
# see e.g. dune-grid for the examples of mainpage and modules
# INPUT += @srcdir@/mainpage \
# @srcdir@/modules
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
# EXCLUDE += @top_srcdir@/dune/curvedsurfacegrid/test
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
# EXAMPLE_PATH += @top_srcdir@/src
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
# IMAGE_PATH += @top_srcdir@/dune/curvedsurfacegrid/pics
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
CXX=@CXX@
CC=@CC@
DEPENDENCIES=@REQUIRES@
Name: @PACKAGE_NAME@
Version: @VERSION@
Description: dune-curvedsurfacegrid module
URL: http://dune-project.org/
Requires: dune-common dune-geometry dune-grid dune-curvilineargeometry
Libs: -L${libdir}
Cflags: -I${includedir}
################################
# Dune module information file #
################################
#Name of the module
Module: dune-curvedsurfacegrid
Version: 0.1.0
Maintainer: florian.stenger@tu-dresden.de
#depending on
Depends: dune-common dune-geometry dune-grid dune-curvilineargeometry
Suggests: dune-alugrid
add_subdirectory(curvedsurfacegrid)
add_subdirectory(surfacedistance)
set(HEADERS
backuprestore.hh
capabilities.hh
coordfunctionimplementations.hh
coordprovider.hh
curvedsurfacegrid.hh
datahandle.hh
declaration.hh
entity.hh
entityseed.hh
geometry.hh
grid.hh
gridfamily.hh
gridview.hh
idset.hh
indexsets.hh
intersection.hh
intersectioniterator.hh
iterator.hh
)
install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/curvedsurfacegrid)
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_CRVSRF_BACKUPRESTORE_HH
#define DUNE_CRVSRF_BACKUPRESTORE_HH
#include <dune/grid/common/backuprestore.hh>
#include <dune/curvedsurfacegrid/capabilities.hh>
namespace Dune
{
namespace crvsrf
{
// BackupRestoreFacilities
// -----------------------
template< class Grid, bool hasBackupRestoreFacilities = Capabilities::hasBackupRestoreFacilities< Grid > ::v >
class BackupRestoreFacilities
{};
template< class Grid >
class BackupRestoreFacilities< Grid, true >
{
typedef BackupRestoreFacilities< Grid, true > This;
protected:
BackupRestoreFacilities ()
{}
private:
BackupRestoreFacilities ( const This & );
This &operator= ( const This & );
protected:
const Grid &asImp () const
{
return static_cast< const Grid & >( *this );
}
Grid &asImp ()
{
return static_cast< Grid & >( *this );
}
};
} // namespace crvsrf
// BackupRestoreFacility for CurvedSurfaceGrid
// -------------------------------------------
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct BackupRestoreFacility< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > > //! $flo
{
typedef CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > Grid; //! $flo
typedef BackupRestoreFacility< HostGrid > HostBackupRestoreFacility;
static void backup ( const Grid &grid, const std::string &path, const std::string &fileprefix )
{
// notice: We should also backup the coordinate function
HostBackupRestoreFacility::backup( grid.hostGrid(), path, fileprefix );
}
static void backup ( const Grid &grid, const std::ostream &stream )
{
// notice: We should also backup the coordinate function
HostBackupRestoreFacility::backup( grid.hostGrid(), stream );
}
static Grid *restore ( const std::string &path, const std::string &fileprefix )
{
// notice: We should also restore the coordinate function
HostGrid *hostGrid = HostBackupRestoreFacility::restore( path, fileprefix );
CoordFunction *coordFunction = new CoordFunction();
return new Grid( hostGrid, coordFunction );
}
static Grid *restore ( const std::istream &stream )
{
// notice: We should also restore the coordinate function
HostGrid *hostGrid = HostBackupRestoreFacility::restore( stream );
CoordFunction *coordFunction = new CoordFunction();
return new Grid( hostGrid, coordFunction );
}
};
} // namespace Dune
#endif // #ifndef DUNE_CRVSRF_BACKUPRESTORE_HH
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_CRVSRF_CAPABILITIES_HH
#define DUNE_CRVSRF_CAPABILITIES_HH
#include <cassert>
#include <dune/common/hybridutilities.hh>
#include <dune/common/std/utility.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/grid/geometrygrid/capabilities.hh>
#include <dune/curvedsurfacegrid/declaration.hh>
namespace Dune
{
// Capabilities
// ------------
namespace Capabilities
{
// Capabilities from dune-grid
// ---------------------------
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct hasSingleGeometryType< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > >
{
static const bool v = hasSingleGeometryType< HostGrid > :: v;
static const unsigned int topologyId = hasSingleGeometryType< HostGrid > :: topologyId;
};
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim > //! $flo
struct hasEntity< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator >, codim >
{
static const bool v = true;
};
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim > //! $flo
struct hasEntityIterator< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator >, codim >
{
static const bool v = true;
};
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim > //! $flo
struct canCommunicate< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator >, codim >
{
static const bool v = canCommunicate< HostGrid, codim >::v && hasEntity< HostGrid, codim >::v;
};
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct hasBackupRestoreFacilities< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > >
{
static const bool v = hasBackupRestoreFacilities< HostGrid >::v;
};
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct isLevelwiseConforming< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > >
{
static const bool v = isLevelwiseConforming< HostGrid >::v;
};
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct isLeafwiseConforming< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > >
{
static const bool v = isLeafwiseConforming< HostGrid >::v;
};
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct threadSafe< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > >
{
static const bool v = false;
};
template< class HostGrid, class CoordFunction, int order, class Allocator > //! $flo
struct viewThreadSafe< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator > >
{
static const bool v = false;
};
// hasHostEntity
// -------------
//! obsolete (already defined in geometrygrid/capabilities.hh)
// template< class Grid, int codim >
// struct hasHostEntity;
//
// template< class Grid, int codim >
// struct hasHostEntity< const Grid, codim >
// {
// static const bool v = hasHostEntity< Grid, codim >::v;
// };
template< class HostGrid, class CoordFunction, int order, class Allocator, int codim > //! $flo
struct hasHostEntity< CurvedSurfaceGrid< HostGrid, CoordFunction, order, Allocator >, codim >
{
static const bool v = hasEntity< HostGrid, codim >::v;
};
// CodimCache
// ----------
//! obsolete (already defined in geometrygrid/capabilities.hh)
// template< class Grid >
// class CodimCache
// {
// static const int dimension = Grid::dimension;
//
// bool hasHostEntity_[ Grid::dimension + 1 ];
//
// CodimCache ()
// {
// Hybrid::forEach( Std::make_index_sequence< dimension+1 >{},
// [ & ]( auto i ){ hasHostEntity_[ i ] = Capabilities::hasHostEntity< Grid, i >::v; } );
// }
//
// static CodimCache &instance ()
// {
// static CodimCache singleton;
// return singleton;
// }
//
// public:
// static bool hasHostEntity ( int codim )
// {
// assert( (codim >= 0) && (codim <= dimension) );
// return instance().hasHostEntity_[ codim ];
// }
// };
} // namespace Capabilities
} // namespace Dune
#endif // #ifndef DUNE_CRVSRF_CAPABILITIES_HH
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_CRVSRF_COORDFUNCTIONIMPLEMENTATIONS_HH
#define DUNE_CRVSRF_COORDFUNCTIONIMPLEMENTATIONS_HH
#include <dune/curvedsurfacegrid/surfacedistance/surfacedistance.hh>
#include <dune/curvedsurfacegrid/surfacedistance/vtureader.hh>
#include <dune/grid/geometrygrid/coordfunction.hh>
namespace Dune
{
//SphereCoordFunction
struct SphereCoordFunction
: public AnalyticalCoordFunction<double, 3, 3, SphereCoordFunction>
{
//constrcutor
SphereCoordFunction(FieldVector<double, 3> center, double radius)
: center_(center), radius_(radius){}
//operator()
FieldVector<double, 3> operator()(FieldVector<double, 3> x) const{
FieldVector<double, 3> direction = x - center_;
double len = direction.two_norm();
for(int i = 0; i < 3; ++i) x[i] = center_[i] + direction[i] * radius_ / len;
return x;
}
private:
FieldVector<double, 3> center_;
double radius_;
};
//SurfaceDistanceCoordFunction
struct SurfaceDistanceCoordFunction
: public AnalyticalCoordFunction<double, 3, 3, SurfaceDistanceCoordFunction>
{
//constructor using vtu-reader to read "file"
SurfaceDistanceCoordFunction(const std::string &file, double expansion_width=-1.0, bool no_scaling=false){
surface_mesh = new crvsrf::Mesh(2, 3);
read_vtu_file(file, *surface_mesh);
backgrid = new crvsrf::BackGrid(*surface_mesh, expansion_width, no_scaling);
}
//constructor using a pre-loaded Dune-surface-mesh
/*!SurfaceDistanceCoordFunction(Grid &mesh, double expansion_width=-1.0, bool no_scaling=false){
surface_mesh = convert_dune_mesh_to_crvsrf::mesh...
backgrid = new BackGrid(*surface_mesh, expansion_width, no_scaling);
}*/
//destructor
~SurfaceDistanceCoordFunction(){
delete backgrid;
delete surface_mesh;
}
//operator()
FieldVector<double, 3> operator()(const FieldVector<double, 3> &x) const{
crvsrf::Vertex hit_vertex;
crvsrf::Vertex v(x[0], x[1], x[2]);
double dist = backgrid->distance_to_surface_3d(v, hit_vertex);
return {hit_vertex[0], hit_vertex[1], hit_vertex[2]};
}
//output_backgrid_dimensions
void output_backgrid_dimensions(){
backgrid->debug_output_dimensions();
}
private:
crvsrf::Mesh *surface_mesh;
crvsrf::BackGrid *backgrid;
};
} // namespace Dune
#endif // #ifndef DUNE_CRVSRF_COORDFUNCTIONIMPLEMENTATIONS_HH
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_CRVSRF_COORDPROVIDER_HH
#define DUNE_CRVSRF_COORDPROVIDER_HH
//!#include <dune/grid/geometrygrid/coordfunctioncaller.hh>
#include <array>
namespace Dune
{
namespace crvsrf
{
//! $flo
template< class Coordinate>
Coordinate edgeCenter(Coordinate gc1, const Coordinate &gc2)
{
for(typename Coordinate::size_type i = 0, end = gc1.size(); i < end; ++i)
{
gc1[i] = (gc1[i] + gc2[i]) / 2.0;
}
return gc1;
}
template< class Coordinate>
Coordinate edgeVertex(Coordinate gc1, const Coordinate &gc2, double factor)
{
for(typename Coordinate::size_type i = 0, end = gc1.size(); i < end; ++i)
{
gc1[i] = gc1[i] + (gc2[i] - gc1[i]) * factor;
}
return gc1;
}
template< class Coordinate>
Coordinate faceVertex(Coordinate gc1, const Coordinate &gc2, const Coordinate &gc3,
double coeff1, double coeff2, double coeff3)
{
for(typename Coordinate::size_type i = 0, end = gc1.size(); i < end; ++i)
{
gc1[i] = coeff1 * gc1[i] + coeff2 * gc2[i] + coeff3 * gc3[i];
}
return gc1;
}
//! $flo
// InterpolatoryVerticesGenerator
// ------------------------------