G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsPanelCreator.hpp
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsMultiPatch.h>
17 #include <gsNurbs/gsKnotVector.h>
19 
20 namespace gismo
21 {
22 
23 /*
24  @brief Class gsPanelCreator provides some simple examples of panels with B-splines
25 */
26 
27 template<class T>
28 gsMultiPatch<T> gsPanelCreator<T>::Plate(T const & Lp, T const & Wp, T const & x, T const & y, T const & z)
29 {
30  gsMultiPatch<T> result;
31 
32  gsKnotVector<T> KV (0,1,0,2) ;
33  gsMatrix<T> C(4,3) ;
34 
35  C.row(0)<< x ,y ,z;
36  C.row(1)<< Lp+x ,y ,z;
37  C.row(2)<< x ,Wp+y ,z;
38  C.row(3)<< Lp+x ,Wp+y ,z;
39 
40  result.addPatch(gsTensorBSpline<2,T>(KV,KV, give(C)));
41  return result;
42  // return TensorBSpline2Ptr(new gsTensorBSpline<2,T>(KV,KV, give(C)));
43 }
44 
45 template<class T>
46 gsMultiPatch<T> gsPanelCreator<T>::Strip(T const & Lb, T const & Hw, T const & x, T const & y, T const & z)
47 {
48  gsMultiPatch<T> result;
49 
50  gsKnotVector<T> KV (0,1,0,2) ;
51  gsMatrix<T> C(4,3) ;
52 
53  C.row(0)<< x, y ,z;
54  C.row(1)<< Lb+x,y ,z;
55  C.row(2)<< x ,y ,Hw+z;
56  C.row(3)<< Lb+x,y ,Hw+z;
57 
58  result.addPatch(gsTensorBSpline<2,T>(KV,KV, give(C)));
59  return result;
60  // return TensorBSpline2Ptr(new );
61 }
62 
63 template <class T>
64 gsMultiPatch<T> gsPanelCreator<T>::IBeam(T const & Lb, T const & Hw, T const & Wf, T const & x, T const & y, T const & z)
65 {
66  gsMultiPatch<T> result;
67  gsMultiPatch<T> tmp;
68 
69  // Web
70  tmp = Strip(Lb,Hw,0,0,-Hw/2.);
71  result.addPatch(tmp.patch(0));
72 
73  tmp = Plate(Lb,Wf/2.,0,0,Hw/2.);
74  result.addPatch(tmp.patch(0));
75 
76  tmp = Plate(Lb,Wf/2.,0,-Wf/2.,Hw/2.);
77  result.addPatch(tmp.patch(0));
78 
79  tmp = Plate(Lb,Wf/2.,0,0,-Hw/2.);
80  result.addPatch(tmp.patch(0));
81 
82  tmp = Plate(Lb,Wf/2.,0,-Wf/2.,-Hw/2.);
83  result.addPatch(tmp.patch(0));
84 
85  for (size_t p = 0; p!=result.nPatches(); p++)
86  {
87  result.patch(p).coefs().col(0).array() += x;
88  result.patch(p).coefs().col(1).array() += y;
89  result.patch(p).coefs().col(2).array() += z;
90  }
91 
92  result.computeTopology();
93  result.addAutoBoundaries();
94  return result;
95 }
96 
97 template <class T>
98 gsMultiPatch<T> gsPanelCreator<T>::TBeam(T const & Lb, T const & Hw, T const & Wf, T const & x, T const & y, T const & z)
99 {
100  gsMultiPatch<T> result;
101  gsMultiPatch<T> tmp;
102 
103  // Web
104  tmp = Strip(Lb,Hw,0,0,0);
105  result.addPatch(tmp.patch(0));
106 
107  // Flange, left
108  tmp = Plate(Lb,Wf/2,0,0,Hw);
109  result.addPatch(tmp.patch(0));
110 
111  // Flange, right
112  tmp = Plate(Lb,Wf/2,0,-Wf/2,Hw);
113  result.addPatch(tmp.patch(0));
114 
115  for (size_t p = 0; p!=result.nPatches(); p++)
116  {
117  result.patch(p).coefs().col(0).array() += x;
118  result.patch(p).coefs().col(1).array() += y;
119  result.patch(p).coefs().col(2).array() += z;
120  }
121 
122  result.computeTopology();
123 
124  // result.addInterface(&result.patch(0),4,&result.patch(1),1);
125  // result.addInterface(&result.patch(0),4,&result.patch(2),2);
126  // result.addInterface(&result.patch(1),1,&result.patch(2),2);
127 
128  result.addAutoBoundaries();
129  return result;
130 }
131 
132 template <class T>
133 gsMultiPatch<T> gsPanelCreator<T>::LBeam(T const & Lb, T const & Hw, T const & Wf, T const & x, T const & y, T const & z)
134 {
135  gsMultiPatch<T> result;
136  gsMultiPatch<T> tmp;
137 
138  // Web
139  tmp = Strip(Lb,Hw,0,0,0);
140  for (size_t p=0; p!=tmp.nPatches(); p++)
141  result.addPatch(tmp.patch(p));
142 
143  // Flange, left
144  tmp = Plate(Lb,Wf,0,0,Hw);
145  for (size_t p=0; p!=tmp.nPatches(); p++)
146  result.addPatch(tmp.patch(p));
147 
148  for (size_t p = 0; p!=result.nPatches(); p++)
149  {
150  result.patch(p).coefs().col(0).array() += x;
151  result.patch(p).coefs().col(1).array() += y;
152  result.patch(p).coefs().col(2).array() += z;
153  }
154 
155  result.addInterface(&result.patch(0),4,&result.patch(1),1);
156 
157  result.addAutoBoundaries();
158 
159  return result;
160 }
161 
162 template <class T>
163 gsMultiPatch<T> gsPanelCreator<T>::PanelT(T const & Lp, T const & Wp, T const & Hw, T const & Wf, T const & x, T const & y, T const & z)
164 
165 {
166  gsMultiPatch<T> result;
167  gsMultiPatch<T> tmp;
168 
169  // Base plate, left
170  // Flange, left
171  tmp = Plate(Lp,Wp/2,0,0,0);
172  for (size_t p=0; p!=tmp.nPatches(); p++)
173  result.addPatch(tmp.patch(p));
174 
175  // Base plate, right
176  tmp = Plate(Lp,Wp/2,0,-Wp/2,0);
177  for (size_t p=0; p!=tmp.nPatches(); p++)
178  result.addPatch(tmp.patch(p));
179 
180  // T-Beam
181  gsMultiPatch<> beam = TBeam(Lp,Hw,Wf);
182 
183  for (size_t p=0; p!=beam.nPatches(); p++)
184  result.addPatch(beam.patch(p));
185 
186  for (size_t p = 0; p!=result.nPatches(); p++)
187  {
188  result.patch(p).coefs().col(0).array() += x;
189  result.patch(p).coefs().col(1).array() += y;
190  result.patch(p).coefs().col(2).array() += z;
191  }
192 
193  // result.addInterface(&result.patch(1),2,&result.patch(0),1);
194  // result.addInterface(&result.patch(2),3,&result.patch(0),1);
195  // result.addInterface(&result.patch(2),4,&result.patch(3),1);
196  // result.addInterface(&result.patch(2),4,&result.patch(4),2);
197 
198  result.computeTopology();
199  result.addAutoBoundaries();
200 
201  return result;
202 }
203 
204 template <class T>
205 gsMultiPatch<T> gsPanelCreator<T>::PanelStrip(T const & Lp, T const & Wp, T const & Hw, T const & x, T const & y, T const & z)
206 {
207  gsMultiPatch<T> result, tmp;
208  std::vector<gsMultiPatch<T>> panels(3);
209  panels.at(0) = Plate(Lp,Wp/2,0,0,0);
210  panels.at(1) = Plate(Lp,Wp/2,0,-Wp/2.,0);
211  panels.at(2) = Strip(Lp,Hw);
212 
213  for (typename std::vector<gsMultiPatch<T>>::iterator it = panels.begin(); it!=panels.end(); it++)
214  for (size_t p = 0; p!=it->nPatches(); p++)
215  result.addPatch(it->patch(p));
216 
217  for (size_t p = 0; p!=result.nPatches(); p++)
218  {
219  result.patch(p).coefs().col(0).array() += x;
220  result.patch(p).coefs().col(1).array() += y;
221  result.patch(p).coefs().col(2).array() += z;
222  }
223 
224  result.computeTopology();
225  result.addAutoBoundaries();
226  return result;
227 }
228 
229 template <class T>
230 gsMultiPatch<T> gsPanelCreator<T>::PanelL(T const & Lp, T const & Wp, T const & Hw, T const & Wf, T const & x, T const & y, T const & z)
231 {
232  gsMultiPatch<T> result, tmp;
233  std::vector<gsMultiPatch<T>> panels(4);
234  panels.at(0) = Plate(Lp,Wp/2,0,-Wp/2.,0);
235  panels.at(1) = Plate(Lp,Wf,0,0,0);
236  panels.at(2) = Plate(Lp,Wp/2-Wf,0,Wf,0);
237 
238  // L-stiffener
239  panels.at(3) = LBeam(Lp,Hw,Wf);
240  for (typename std::vector<gsMultiPatch<T>>::iterator it = panels.begin(); it!=panels.end(); it++)
241  for (size_t p = 0; p!=it->nPatches(); p++)
242  result.addPatch(it->patch(p));
243 
244  for (size_t p = 0; p!=result.nPatches(); p++)
245  {
246  result.patch(p).coefs().col(0).array() += x;
247  result.patch(p).coefs().col(1).array() += y;
248  result.patch(p).coefs().col(2).array() += z;
249  }
250 
251  result.computeTopology();
252  result.addAutoBoundaries();
253  return result;
254 }
255 
256 template <class T>
257 gsMultiPatch<T> gsPanelCreator<T>::PlateGirderL(T const & Lp, T const & Wp, T const & Hwg, T const & Wfg, T const & Hws, T const & Wfs, T const & x, T const & y, T const & z)
258 {
259  gsMultiPatch<T> result, tmp;
260 
261  // make sub panels
262  std::vector<gsMultiPatch<T>> panels(14);
263  panels.at(0) = Plate(Lp/2.,Wp/2., 0., -Wp/2., 0.);
264  panels.at(1) = Plate(Lp/2.,Wfs, 0., 0., 0.);
265  panels.at(2) = Plate(Lp/2.,Wp/2.-Wfs, 0., Wfs, 0.);
266  panels.at(3) = Plate(Lp/2.,Wp/2., -Lp/2., -Wp/2., 0.);
267  panels.at(4) = Plate(Lp/2.,Wfs, -Lp/2., 0., 0.);
268  panels.at(5) = Plate(Lp/2.,Wp/2.-Wfs, -Lp/2., Wfs, 0.);
269 
270  panels.at(6) = LBeam(Lp/2.,Hws,Wfs,0);
271  panels.at(7) = LBeam(Lp/2.,Hws,Wfs,-Lp/2.);
272 
273  panels.at(8) = TBeam(Wfs, Hwg-Hws,Wfg,0,0,Hws);
274  panels.at(9) = TBeam(Wp/2.-Wfs,Hwg-Hws,Wfg,0,0,Hws);
275  panels.at(10) = TBeam(Wp/2., Hwg-Hws,Wfg,0,0,Hws);
276 
277  for (size_t p = 0; p!=panels[8].nPatches(); p++)
278  {
279  panels[8].patch(p).coefs().col(0).swap(panels[8].patch(p).coefs().col(1));
280  // panels[8].patch(p).coefs().col(1).array() -= Wp / 2.;
281  }
282  for (size_t p = 0; p!=panels[9].nPatches(); p++)
283  {
284  panels[9].patch(p).coefs().col(0).swap(panels[9].patch(p).coefs().col(1));
285  panels[9].patch(p).coefs().col(1).array() += Wfs;
286  }
287  for (size_t p = 0; p!=panels[10].nPatches(); p++)
288  {
289  panels[10].patch(p).coefs().col(0).swap(panels[10].patch(p).coefs().col(1));
290  panels[10].patch(p).coefs().col(1).array() -= Wp / 2.;
291  }
292 
293 
294  panels.at(11) = Strip(Wfs, Hws);
295  panels.at(12) = Strip(Wp/2.-Wfs,Hws);
296  panels.at(13) = Strip(Wp/2., Hws);
297  for (size_t p = 0; p!=panels[11].nPatches(); p++)
298  {
299  panels[11].patch(p).coefs().col(0).swap(panels[11].patch(p).coefs().col(1));
300  // panels[11].patch(p).coefs().col(1).array() -= Wp / 2.;
301  }
302  for (size_t p = 0; p!=panels[12].nPatches(); p++)
303  {
304  panels[12].patch(p).coefs().col(0).swap(panels[12].patch(p).coefs().col(1));
305  panels[12].patch(p).coefs().col(1).array() += Wfs;
306  }
307  for (size_t p = 0; p!=panels[13].nPatches(); p++)
308  {
309  panels[13].patch(p).coefs().col(0).swap(panels[13].patch(p).coefs().col(1));
310  panels[13].patch(p).coefs().col(1).array() -= Wp / 2.;
311  }
312 
313 
314  for (typename std::vector<gsMultiPatch<T>>::iterator it = panels.begin(); it!=panels.end(); it++)
315  for (size_t p = 0; p!=it->nPatches(); p++)
316  result.addPatch(it->patch(p));
317 
318 
319  result.computeTopology();
320  result.addAutoBoundaries();
321 
322  return result;
323 }
324 
325 } // namespace gismo
Knot vector for B-splines.
Represents a tensor-product B-spline patch.
S give(S &x)
Definition: gsMemory.h:266
Provides declaration of the MultiPatch class.