dune-grid-glue  2.4.0
psurfacemerge.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
14 #ifndef DUNE_GRIDGLUE_MERGING_PSURFACEMERGE_HH
15 #define DUNE_GRIDGLUE_MERGING_PSURFACEMERGE_HH
16 
17 #warning PSurfaceMerge is deprecated. Please use ContactMerge or OverlappingMerge instead.
18 
19 #include <memory>
20 
21 #include <dune/common/shared_ptr.hh>
22 
25 
26 #if HAVE_PSURFACE
27 #include <psurface/DirectionFunction.h>
28 #else
29 // forward declaration of PSurface classes
30 template <int dim, typename ctype> class DirectionFunction;
31 // switch off the macro that contains (in certain versions) the psurface namespace prefix
32 #define PSURFACE_NAMESPACE
33 #endif
34 
35 namespace Dune {
36 namespace GridGlue {
37 
38 #if HAVE_PSURFACE
39 namespace Implementation {
40 
41 template<typename Vector>
43  : public Dune::VirtualFunction<Vector, Vector>
44 {
45  using ctype = typename Vector::field_type;
46  const static unsigned int dim = Vector::dimension;
47  using DF = typename PSURFACE_NAMESPACE DirectionFunction<dim, ctype>;
48  using ADF = typename PSURFACE_NAMESPACE AnalyticDirectionFunction<dim, ctype>;
49 
50  std::shared_ptr<const ADF> m_direction;
51 
52 public:
53  PSurfaceDirectionFunctionAdapter(const std::shared_ptr<const DF> direction)
54  : m_direction(std::dynamic_pointer_cast<const ADF>(direction))
55  {
56  if (!m_direction)
57  DUNE_THROW(Dune::Exception, "Only psurface's AnalyticDirectionFunction is supported.");
58  }
59 
60  void evaluate(const Vector& x, Vector& y) const override
61  {
62  PSURFACE_NAMESPACE StaticVector<ctype, dim> x_, y_;
63  for (std::size_t i = 0; i < dim; ++i)
64  x_[i] = x[i];
65  y_ = (*m_direction)(x_);
66  for (std::size_t i = 0; i < dim; ++i)
67  y[i] = y_[i];
68  }
69 };
70 
71 } /* namespace Implementation */
72 #endif
73 
74 template<int dim, int dimworld, typename T = double, typename = void>
76 
83 template<int dim, int dimworld, typename T>
84 class PSurfaceMerge<dim, dimworld, T>
85  : public ContactMerge<dimworld, T>
86 {
88 
89  static_assert(dim+1 == dimworld, "The PSurfaceMerger only supports dim==dimworld and dim+1==dimworld");
90 
91 public:
93  typedef T ctype;
94 
96  typedef Dune::FieldVector<T, dimworld> WorldCoords;
97 
99  typedef Dune::FieldVector<T, dim> LocalCoords;
100 
101 private:
102 #if HAVE_PSURFACE
103 
106  std::shared_ptr<const Dune::VirtualFunction<WorldCoords, WorldCoords> > psurfaceDomainDirections_;
107 
116  std::shared_ptr<const Dune::VirtualFunction<WorldCoords, WorldCoords> > psurfaceTargetDirections_;
117 #endif
118 
119 public:
120 
121  PSurfaceMerge(const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype>* domainDirections,
122  const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype>* targetDirections)
123  : PSurfaceMerge(Dune::stackobject_to_shared_ptr(*domainDirections), Dune::stackobject_to_shared_ptr(*targetDirections))
124  { /* Nothing. */ }
125 
126  PSurfaceMerge(std::shared_ptr<const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype> > domainDirections = nullptr,
127  std::shared_ptr<const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype> > targetDirections = nullptr)
128  {
129  this->minNormalAngle(0.0);
130  this->enableFallback(true);
131  setSurfaceDirections(domainDirections, targetDirections);
132  }
133 
134  using Base::setSurfaceDirections;
135 
145  void setSurfaceDirections(const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype>* domainDirections,
146  const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype>* targetDirections)
147  {
148  setSurfaceDirections(Dune::stackobject_to_shared_ptr(*domainDirections), Dune::stackobject_to_shared_ptr(*targetDirections));
149  }
150 
151  void setSurfaceDirections(std::shared_ptr<const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype> > domainDirections,
152  std::shared_ptr<const PSURFACE_NAMESPACE DirectionFunction<dimworld,ctype> > targetDirections)
153  {
154 #if HAVE_PSURFACE
156  psurfaceDomainDirections_ = domainDirections ? std::make_shared<Adapter>(domainDirections) : nullptr;
157  psurfaceTargetDirections_ = targetDirections ? std::make_shared<Adapter>(domainDirections) : nullptr;
158 
159  this->setSurfaceDirections(psurfaceDomainDirections_.get(), psurfaceTargetDirections_.get());
160 #endif
161  }
162 };
163 
164 template<int dimworld, typename T>
165 class PSurfaceMerge<dimworld, dimworld, T>
166  : public OverlappingMerge<dimworld, dimworld, dimworld, T>
167 {
168  /* Nothing. */
169 };
170 
171 } /* namespace GridGlue */
172 } /* namespace Dune */
173 
174 #endif // DUNE_GRIDGLUE_MERGING_PSURFACEMERGE_HH
Dune::FieldVector< T, dim > LocalCoords
the coordinate type used in this interface
Definition: psurfacemerge.hh:99
void evaluate(const Vector &x, Vector &y) const override
Definition: psurfacemerge.hh:60
Computing overlapping grid intersections for grids of different dimensions.
Definition: overlappingmerge.hh:34
Definition: gridglue.hh:33
void setSurfaceDirections(const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > *domainDirections, const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > *targetDirections)
Set surface direction functions.
Definition: psurfacemerge.hh:145
PSurfaceDirectionFunctionAdapter(const std::shared_ptr< const DF > direction)
Definition: psurfacemerge.hh:53
STL namespace.
Dune::FieldVector< T, dimworld > WorldCoords
the coordinate type used in this interface
Definition: psurfacemerge.hh:96
PSurfaceMerge(const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > *domainDirections, const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > *targetDirections)
Definition: psurfacemerge.hh:121
PSurfaceMerge(std::shared_ptr< const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > > domainDirections=nullptr, std::shared_ptr< const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > > targetDirections=nullptr)
Definition: psurfacemerge.hh:126
Merge two codimension-1 surfaces that may be a positive distance apart.
Definition: contactmerge.hh:39
void setSurfaceDirections(std::shared_ptr< const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > > domainDirections, std::shared_ptr< const PSURFACE_NAMESPACE DirectionFunction< dimworld, ctype > > targetDirections)
Definition: psurfacemerge.hh:151
Merge two grid boundary surfaces that may be a positive distance apart.
Definition: psurfacemerge.hh:75
T ctype
the numeric type used in this interface
Definition: psurfacemerge.hh:89