G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsC1SurfEdge.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 #include <gsUnstructuredSplines/src/gsC1SurfBasisEdge.h>
18 
19 #include <gsUnstructuredSplines/src/gsC1SurfGluingData.h>
20 
21 namespace gismo
22 {
23 template<short_t d, class T>
24 class gsC1SurfEdge
25 {
26 
27 private:
28 
30  typedef memory::shared_ptr<gsC1SurfEdge> Ptr;
31 
33  typedef memory::unique_ptr<gsC1SurfEdge> uPtr;
34 
35 
36 public:
38  ~gsC1SurfEdge() { }
39 
40  gsC1SurfEdge(const gsMultiPatch<T> & mp, const boundaryInterface & item){
41  auxGeom.push_back(gsG1AuxiliaryPatch<d,T>(mp.patch(item.first().patch), item.first().patch));
42  auxGeom.push_back(gsG1AuxiliaryPatch<d,T>(mp.patch(item.second().patch), item.second().patch));
43  m_item = item;
44  }
45 
46  gsC1SurfEdge(const gsMultiPatch<T> & sp, const patchSide & item){
47  auxGeom.push_back(gsG1AuxiliaryPatch<d,T>(sp.patch(item.patch), item.patch));
48  }
49 
50  void computeG1InterfaceBasis()
51  {
52  basisEdgeResult.clear();
53 
54  gsMultiPatch<T> mp_init;
55  mp_init.addPatch(auxGeom[0].getPatch());// Right -> 0 ====> v along the interface
56  mp_init.addPatch(auxGeom[1].getPatch()); // Left -> 1 ====> u along the interface
57 
58  reparametrizeInterface(m_item);
59  gsMultiPatch<T> test_mp; // auxGeom contains now the reparametrized geometry
60  test_mp.addPatch(auxGeom[0].getPatch());
61  test_mp.addPatch(auxGeom[1].getPatch());
62  gsMultiBasis<T> test_mb(test_mp);
63  gsMultiPatch<T> g1Basis_0, g1Basis_1;
64 
65  gsC1SurfGluingData<T> g1BasisEdge(test_mp, test_mb);
66  gsC1SurfBasisEdge<T> g1BasisEdge_0(test_mp.patch(0), test_mb.basis(0), 1, false, g1BasisEdge);
67  gsC1SurfBasisEdge<T> g1BasisEdge_1(test_mp.patch(1), test_mb.basis(1), 0, false, g1BasisEdge);
68  g1BasisEdge_0.setG1BasisEdge(g1Basis_0);
69  g1BasisEdge_1.setG1BasisEdge(g1Basis_1);
70 
71  gsMatrix<T> points(1,5);
72  points << 0.0, 0.25, 0.5, 0.75, 1.0;
73  gsMatrix<T> alphaL = g1BasisEdge.evalAlpha_L(points);
74  gsMatrix<T> alphaR = g1BasisEdge.evalAlpha_R(points);
75  gsMatrix<T> betaL = g1BasisEdge.evalBeta_L(points);
76  gsMatrix<T> betaR = g1BasisEdge.evalBeta_R(points);
77  gsMatrix<T> beta = g1BasisEdge.evalBeta(points);
78 
79 // Patch 0 -> Right
80  auxGeom[0].parametrizeBasisBack(g1Basis_0);
81 // Patch 1 -> Left
82  auxGeom[1].parametrizeBasisBack(g1Basis_1);
83 
84  basisEdgeResult.push_back(auxGeom[0].getG1Basis());
85  basisEdgeResult.push_back(auxGeom[1].getG1Basis());
86  }
87 
88  void computeG1BoundaryBasis(const index_t boundaryInd)
89  {
90  basisEdgeResult.clear();
91 
92  reparametrizeBoundary(boundaryInd);
93  gsMultiPatch<T> test_mp(auxGeom[0].getPatch());
94  gsMultiBasis<T> test_mb(test_mp);
95  gsMultiPatch<T> g1Basis_edge;
96 
97  gsC1SurfGluingData<T> bdyGD; // Empty constructor creates the sol and solBeta in a suitable way to manage the GD on the boundary
98  gsC1SurfBasisEdge<T> g1BasisEdge(test_mp, test_mb, 1, true, bdyGD);
99  g1BasisEdge.setG1BasisEdge(g1Basis_edge);
100 
101  auxGeom[0].parametrizeBasisBack(g1Basis_edge);
102 
103  basisEdgeResult.push_back(auxGeom[0].getG1Basis());
104  }
105 
106  gsG1AuxiliaryPatch<d,T> & getSinglePatch(const index_t i)
107  {
108  return auxGeom[i];
109  }
110 
111  std::vector<gsMultiPatch<T>> getBasis(){return basisEdgeResult;}
112 
113 protected:
114 
115  // Store temp solution
116  std::vector<gsMultiPatch<T>> basisEdgeResult;
117 
118  std::vector<gsG1AuxiliaryPatch<d,T>> auxGeom;
119 
120  // Need for avoiding the computeTopology
121  boundaryInterface m_item;
122 
123 private:
124 
125  // Compute topology
126  // After computeTopology() the patches will have the same patch-index as the position-index in auxGeom
127  // EXAMPLE: global patch-index-order inside auxGeom: [2, 3, 4, 1, 0]
128  // in auxTop: 2->0, 3->1, 4->2, 1->3, 0->4
129  void computeAuxTopology();
130 
131  void reparametrizeInterface(const boundaryInterface & item);
132 
133  void reparametrizeBoundary(index_t side);
134 
135 
136 }; // Class gsC1SurfEdge
137 
138 } // namespace gismo
139 
140 #ifndef GISMO_BUILD_LIB
141 #include GISMO_HPP_HEADER(gsC1SurfEdge.hpp)
142 #endif
index_t addPatch(typename gsGeometry< T >::uPtr g)
Add a patch from a gsGeometry&lt;T&gt;::uPtr.
Definition: gsMultiPatch.hpp:210
Struct which represents a certain side of a patch.
Definition: gsBoundary.h:231
#define index_t
Definition: gsConfig.h:32
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
patchSide & second()
second, returns the second patchSide of this interface
Definition: gsBoundary.h:782
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
Reparametrize one Patch.
index_t patch
The index of the patch.
Definition: gsBoundary.h:234
patchSide & first()
first, returns the first patchSide of this interface
Definition: gsBoundary.h:776