/usr/include/dune/grid-glue/merging/contactmerge.hh is in libdune-grid-glue-dev 2.4.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/**
@file
@brief Merge two grid boundary surfaces that may be a positive distance apart
*/
#ifndef DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
#define DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <limits>
#include <memory>
#include <dune/common/fvector.hh>
#include <dune/common/function.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/bitsetvector.hh>
#include <dune/grid/common/grid.hh>
#include <dune/grid-glue/merging/standardmerge.hh>
#include <dune/grid-glue/gridglue.hh>
namespace Dune {
namespace GridGlue {
/** \brief Merge two codimension-1 surfaces that may be a positive distance apart
\tparam dimworld Dimension of the world coordinates.
\tparam T Type used for coordinates
*/
template<int dimworld, typename T = double>
class ContactMerge
: public StandardMerge<T,dimworld-1,dimworld-1,dimworld>
{
enum {dim = dimworld-1};
static_assert( dim==1 || dim==2,
"ContactMerge yet only handles the cases dim==1 and dim==2!");
typedef StandardMerge<T,dim,dim,dimworld> Base;
public:
/* E X P O R T E D T Y P E S A N D C O N S T A N T S */
/// @brief the numeric type used in this interface
typedef T ctype;
/// @brief the coordinate type used in this interface
typedef Dune::FieldVector<T, dimworld> WorldCoords;
/// @brief the coordinate type used in this interface
typedef Dune::FieldVector<T, dim> LocalCoords;
ContactMerge(const T allowedOverlap=T(0),
const Dune::VirtualFunction<WorldCoords,WorldCoords>* domainDirections = NULL,
const Dune::VirtualFunction<WorldCoords,WorldCoords>* targetDirections = NULL)
: domainDirections_(domainDirections), targetDirections_(targetDirections),
overlap_(allowedOverlap)
{}
/**
* @brief Set surface direction functions
*
* The matching of the geometries offers the possibility to specify a function for
* the exact evaluation of domain surface normals. If no such function is specified
* (default) normals are interpolated.
* @param value the new function (or NULL to unset the function)
*/
inline
void setSurfaceDirections(const Dune::VirtualFunction<WorldCoords,WorldCoords>* domainDirections,
const Dune::VirtualFunction<WorldCoords,WorldCoords>* targetDirections)
{
domainDirections_ = domainDirections;
targetDirections_ = targetDirections;
this->valid = false;
}
//! Set the allowed overlap of the surfaces.
void setOverlap(T overlap)
{
overlap_ = overlap;
}
//!Get the allowed overlap of the surfaces.
T getOverlap() const
{
return overlap_;
}
/**
* \brief set minimum angle in radians between normals at <code>x</code> and <code>Φ(x)</code>
*/
void minNormalAngle(T angle)
{
using std::cos;
maxNormalProduct_ = cos(angle);
}
/**
* \brief get minimum angle in radians between normals at <code>x</code> and <code>Φ(x)</code>
*/
T minNormalAngle() const
{
using std::acos;
return acos(maxNormalProduct_);
}
protected:
typedef typename StandardMerge<T,dimworld-1,dimworld-1,dimworld>::RemoteSimplicialIntersection RemoteSimplicialIntersection;
private:
/** \brief Vector field on the domain surface which prescribes the direction
in which the domain surface is projected onto the target surface
*/
const Dune::VirtualFunction<WorldCoords,WorldCoords>* domainDirections_;
std::vector<WorldCoords> nodalDomainDirections_;
/** \brief Vector field on the target surface which prescribes a 'forward'
direction.
We use the normals of the target side to increase projection
robustness. If these cannot be computed from the surface directly
(e.g. because it is not properly oriented), they can be given
explicitly through the targetDirections field.
*/
const Dune::VirtualFunction<WorldCoords,WorldCoords>* targetDirections_;
std::vector<WorldCoords> nodalTargetDirections_;
//! Allow some overlap, i.e. also look in the negative projection directions
T overlap_;
/**
* See Projection::m_max_normal_product
*/
T maxNormalProduct_ = T(-0.1);
/** \brief Compute the intersection between two overlapping elements
*
* The result is a set of simplices.
*/
void computeIntersections(const Dune::GeometryType& grid1ElementType,
const std::vector<Dune::FieldVector<T,dimworld> >& grid1ElementCorners,
std::bitset<(1<<dim)>& neighborIntersects1,
unsigned int grid1Index,
const Dune::GeometryType& grid2ElementType,
const std::vector<Dune::FieldVector<T,dimworld> >& grid2ElementCorners,
std::bitset<(1<<dim)>& neighborIntersects2,
unsigned int grid2Index,
std::vector<RemoteSimplicialIntersection>& intersections);
/**
* @copydoc StandardMerge<T,grid1Dim,grid2Dim,dimworld>::build
*/
protected:
void build(const std::vector<Dune::FieldVector<T,dimworld> >& grid1Coords,
const std::vector<unsigned int>& grid1Elements,
const std::vector<Dune::GeometryType>& grid1ElementTypes,
const std::vector<Dune::FieldVector<T,dimworld> >& grid2Coords,
const std::vector<unsigned int>& grid2Elements,
const std::vector<Dune::GeometryType>& grid2ElementTypes)
{
std::cout<<"ContactMerge building grid!\n";
// setup the nodal direction vectors
setupNodalDirections(grid1Coords, grid1Elements, grid1ElementTypes,
grid2Coords, grid2Elements, grid2ElementTypes);
Base::build(grid1Coords, grid1Elements, grid1ElementTypes,
grid2Coords, grid2Elements, grid2ElementTypes);
}
private:
//! Compute local coordinates of a corner
static LocalCoords localCornerCoords(int i, const Dune::GeometryType& gt)
{
const Dune::ReferenceElement<T,dim>& ref = Dune::ReferenceElements<T,dim>::general(gt);
return ref.position(i,dim);
}
protected:
//! Order the corners of the intersection polytope in cyclic order
void computeCyclicOrder(const std::vector<std::array<LocalCoords,2> >& polytopeCorners,
const LocalCoords& center, std::vector<int>& ordering) const;
//! Setup the direction vectors containing the directions for each vertex
void setupNodalDirections(const std::vector<WorldCoords>& coords1,
const std::vector<unsigned int>& elements1,
const std::vector<Dune::GeometryType>& elementTypes1,
const std::vector<WorldCoords>& coords2,
const std::vector<unsigned int>& elements2,
const std::vector<Dune::GeometryType>& elementTypes2);
//! If no direction field was specified compute the outer normal field
void computeOuterNormalField(const std::vector<WorldCoords>& coords,
const std::vector<unsigned int>& elements,
const std::vector<Dune::GeometryType>& elementTypes,
std::vector<WorldCoords>& normals);
//! Remove all multiples
void removeDoubles(std::vector<std::array<LocalCoords,2> >& polytopeCorners);
};
} /* namespace GridGlue */
} /* namespace Dune */
#include "contactmerge.cc"
#endif // DUNE_GRIDGLUE_MERGING_CONTACTMERGE_HH
|