libsurf
Programmer's Documentation

nstelements.h (r6227/r5626)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_NSTELEMENTS_H
16 #define SURF_NSTELEMENTS_H
17 
18 #include <genua/smatrix.h>
19 #include <genua/element.h>
20 
21 typedef enum { NstCMASS=101,
22  NstCONM,
23  NstCELAS,
24  NstCBEAM,
25  NstCTRIA3,
26  NstCTRIAR,
27  NstCTRIA6,
28  NstCQUAD4,
29  NstCQUADR,
30  NstCQUAD8,
31  NstCHEXA,
32  NstCTETRA,
33  NstRBAR,
34  NstRBE2,
35  NstMPC,
36  NstUndefined } NstTypeId;
37 
38 typedef enum { NstGrounded=0,
39  NstTransX=1,
40  NstTransY=2,
41  NstTransZ=3,
42  NstRotX=4,
43  NstRotY=5,
44  NstRotZ=6,
45  NstNoDof } NstDof;
46 
47 class NstMesh;
48 
49 #define PID_DONT_USE NotFound
50 
57 {
58 public:
59 
61  NstElementBase(const NstMesh *m) : msh(m), propid(1), matcid(0) {}
62 
64  NstElementBase() : msh(0), propid(1), matcid(0) {}
65 
67  virtual ~NstElementBase() {}
68 
70  uint pid() const {return propid;}
71 
73  void pid(uint p) {propid = p;}
74 
76  uint mcid() const {return matcid;}
77 
79  void mcid(uint m) {matcid = m;}
80 
82  void mesh(const NstMesh *m) {msh = m;}
83 
85  const NstMesh & mesh() const {return *msh;}
86 
88  void index2gid(const Element & e, uint vg[]) const;
89 
91  static void indexOffsets(int gidoffset, int eidoffset);
92 
93 protected:
94 
96  static int s_vixoffset;
97 
99  static int s_eixoffset;
100 
101 private:
102 
104  const NstMesh *msh;
105 
107  uint propid, matcid;
108 };
109 
115 {
116 public:
117 
119  NstScalarMass(const NstMesh *m, uint a, uint b) : Line2Element(a,b),
120  NstElementBase(m), mss(0.0)
121  {
122  vdof[0] = vdof[1] = 1;
123  }
124 
126  void dof(NstDof da, NstDof db) {
127  vdof[0] = uint(da);
128  vdof[1] = uint(db);
129  }
130 
132  Real mass() const {return mss;}
133 
135  void mass(Real m) {mss = m;}
136 
138  uint idtype() const {return uint(NstCMASS);}
139 
141  void nstwrite(std::ostream & os) const;
142 
143 private:
144 
146  uint vdof[2];
147 
149  Real mss;
150 };
151 
156 class NstConMass : public PointElement, public NstElementBase
157 {
158 public:
159 
161  NstConMass(const NstMesh *m, uint a) :
162  PointElement(a), NstElementBase(m), mss(0.0) {}
163 
165  Real mass() const {return mss;}
166 
168  void mass(Real m) {mss = m;}
169 
171  void setJ(const Mtx33 & J) {mj = J;}
172 
174  const Vct3 & offset() const {return poff;}
175 
177  void offset(const Vct3 & p) {poff = p;}
178 
180  uint idtype() const {return uint(NstCONM);}
181 
183  void nstwrite(std::ostream & os) const;
184 
185 private:
186 
188  Real mss;
189 
191  Mtx33 mj;
192 
194  Vct3 poff;
195 };
196 
201 class NstSpring : public Line2Element, public NstElementBase
202 {
203 public:
204 
206  NstSpring(const NstMesh *m, uint a, uint b) : Line2Element(a,b),
207  NstElementBase(m), mk(0.0)
208  {
209  vdof[0] = vdof[1] = 1;
210  }
211 
213  void dof(NstDof da, NstDof db) {
214  vdof[0] = uint(da);
215  vdof[1] = uint(db);
216  }
217 
219  Real stiffness() const {return mk;}
220 
222  void stiffness(Real k) {mk = k;}
223 
225  uint idtype() const {return uint(NstCELAS);}
226 
228  void nstwrite(std::ostream & os) const;
229 
230 private:
231 
233  uint vdof[2];
234 
236  Real mk;
237 };
238 
244 {
245 public:
246 
248  NstRigidBar(const NstMesh *m, uint a, uint b) :
249  Line2Element(a,b), NstElementBase(m), cna(0), cnb(0), cma(0), cmb(0) {}
250 
252  void components(uint na, uint nb, uint ma, uint mb) {
253  cna = na; cnb = nb; cma = ma; cmb = mb;
254  }
255 
257  uint idtype() const {return uint(NstRBAR);}
258 
260  void nstwrite(std::ostream & os) const;
261 
262 private:
263 
265  uint cna, cnb, cma, cmb;
266 };
267 
273 {
274 public:
275 
277  NstSimpleMpc(const NstMesh *m, uint a, uint b) :
278  Line2Element(a,b), NstElementBase(m), sid(1)
279  {
280  std::fill(adof, adof+6, NotFound);
281  std::fill(bdof, bdof+6, NotFound);
282  }
283 
285  void setid(uint s) {sid = s;}
286 
288  void constrain(NstDof ad, Real ac, NstDof bd, Real bc) {
289  adof[0] = uint(ad);
290  bdof[0] = uint(bd);
291  acf[0] = ac;
292  bcf[0] = bc;
293  }
294 
296  void constrain(uint c, NstDof ad, Real ac, NstDof bd, Real bc) {
297  assert(c < 6);
298  adof[c] = uint(ad);
299  bdof[c] = uint(bd);
300  acf[c] = ac;
301  bcf[c] = bc;
302  }
303 
305  uint idtype() const {return uint(NstMPC);}
306 
308  void nstwrite(std::ostream & os) const;
309 
310 private:
311 
313  Real acf[6], bcf[6];
314 
316  uint adof[6], bdof[6], sid;
317 };
318 
323 class NstBeam : public Line2Element, public NstElementBase
324 {
325 public:
326 
328  NstBeam(const NstMesh *m, uint a, uint b) :
329  Line2Element(a,b), NstElementBase(m) {}
330 
332  void orientation(const Vct3 & o) {orn = o;}
333 
335  uint idtype() const {return uint(NstCBEAM);}
336 
338  void nstwrite(std::ostream & os) const;
339 
340 private:
341 
343  Vct3 orn;
344 };
345 
350 class NstTria3 : public Tri3Element, public NstElementBase
351 {
352 public:
353 
355  NstTria3(const NstMesh *m, uint a, uint b, uint c) :
356  Tri3Element(a,b,c), NstElementBase(m) {}
357 
359  uint idtype() const {return uint(NstCTRIA3);}
360 
362  void nstwrite(std::ostream & os) const;
363 };
364 
369 class NstTriaR : public Tri3Element, public NstElementBase
370 {
371 public:
372 
374  NstTriaR(const NstMesh *m, uint a, uint b, uint c) :
375  Tri3Element(a,b,c), NstElementBase(m) {}
376 
378  uint idtype() const {return uint(NstCTRIAR);}
379 
381  void nstwrite(std::ostream & os) const;
382 };
383 
388 class NstTria6 : public Tri6Element, public NstElementBase
389 {
390 public:
391 
393  NstTria6(const NstMesh *m, const uint v[]) :
394  Tri6Element(v), NstElementBase(m) {}
395 
397  uint idtype() const {return uint(NstCTRIA6);}
398 
400  void nstwrite(std::ostream & os) const;
401 };
402 
407 class NstQuad4 : public Quad4Element, public NstElementBase
408 {
409 public:
410 
412  NstQuad4(const NstMesh *m, uint a, uint b, uint c, uint d) :
413  Quad4Element(a,b,c,d), NstElementBase(m) {}
414 
416  uint idtype() const {return uint(NstCQUAD4);}
417 
419  void nstwrite(std::ostream & os) const;
420 };
421 
426 class NstQuadR : public Quad4Element, public NstElementBase
427 {
428 public:
429 
431  NstQuadR(const NstMesh *m, uint a, uint b, uint c, uint d) :
432  Quad4Element(a,b,c,d), NstElementBase(m) {}
433 
435  uint idtype() const {return uint(NstCQUADR);}
436 
438  void nstwrite(std::ostream & os) const;
439 };
440 
445 class NstQuad8 : public Quad8Element, public NstElementBase
446 {
447 public:
448 
450  NstQuad8(const NstMesh *m, uint v[]) : Quad8Element(v), NstElementBase(m) {}
451 
453  uint idtype() const {return uint(NstCQUAD8);}
454 
456  void nstwrite(std::ostream & os) const;
457 };
458 
463 class NstHexa : public HexElement, public NstElementBase
464 {
465 public:
466 
468  NstHexa(const NstMesh *m, uint v[], uint nv=20) : HexElement(v, nv), NstElementBase(m) {}
469 
471  uint idtype() const {return uint(NstCHEXA);}
472 
474  void nstwrite(std::ostream & os) const;
475 };
476 
481 class NstTetra : public TetraElement, public NstElementBase
482 {
483 public:
484 
486  NstTetra(const NstMesh *m, uint v[], uint nv=10) : TetraElement(v, nv), NstElementBase(m) {}
487 
489  uint idtype() const {return uint(NstCTETRA);}
490 
492  void nstwrite(std::ostream & os) const;
493 };
494 
503 class NstRigidBody2 : public Element, public NstElementBase
504 {
505 public:
506 
508  NstRigidBody2(const NstMesh *m, uint c, const Indices & v) :
509  Element(), NstElementBase(m), vi(v), cm(c)
510  {
511  Element::changeBase(&vi[0]);
512  }
513 
515  uint idtype() const {return uint(NstRBE2);}
516 
518  void nstwrite(std::ostream & os) const;
519 
521  uint add2viz(MeshFields & m) const;
522 
524  uint indepNode() const {assert(vi.size() > 1); return vi[1];}
525 
527  uint ndep() const {return vi.empty() ? 0 : vi.size()-1;}
528 
530  uint depNode(uint k) const {assert(k+1 < vi.size()); return vi[k+1];}
531 
532 private:
533 
535  Indices vi;
536 
538  uint cm;
539 };
540 
541 
542 #endif
543 
544 
Real mss
scalar mass
Definition: nstelements.h:188
Nastran mesh.
Definition: nstmesh.h:35
NstQuadR(const NstMesh *m, uint a, uint b, uint c, uint d)
construct with reference to node
Definition: nstelements.h:431
uint idtype() const
return id code
Definition: nstelements.h:359
NstTetra(const NstMesh *m, uint v[], uint nv=10)
construct with reference to nodes
Definition: nstelements.h:486
Rigid-body element of type RBE2.
Definition: nstelements.h:503
uint vdof[2]
dofs to attach to
Definition: nstelements.h:146
uint idtype() const
return id code
Definition: nstelements.h:435
NstQuad8(const NstMesh *m, uint v[])
construct with reference to nodes
Definition: nstelements.h:450
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:160
Mtx33 mj
inertia matrix
Definition: nstelements.h:191
uint idtype() const
return id code
Definition: nstelements.h:335
NstElementBase()
initialize undefined element
Definition: nstelements.h:64
NstRigidBar(const NstMesh *m, uint a, uint b)
construct with geometry
Definition: nstelements.h:248
Triangular shell element : CTRIAR.
Definition: nstelements.h:369
Real stiffness() const
access stiffness value
Definition: nstelements.h:219
static int s_eixoffset
element index offset for output only
Definition: nstelements.h:99
void changeBase(uint *p)
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:42
uint cna
component numbers
Definition: nstelements.h:265
static int s_vixoffset
vertex index offset for output only
Definition: nstelements.h:96
Quadrilateral shell element : CQUAD8.
Definition: nstelements.h:445
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:200
NstTria6(const NstMesh *m, const uint v[])
construct with reference to node
Definition: nstelements.h:393
uint idtype() const
return id code
Definition: nstelements.h:397
void dof(NstDof da, NstDof db)
set dofs
Definition: nstelements.h:213
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:100
void setid(uint s)
assign to set-id s
Definition: nstelements.h:285
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:67
uint idtype() const
return id code
Definition: nstelements.h:257
NstScalarMass(const NstMesh *m, uint a, uint b)
construct with reference to node
Definition: nstelements.h:119
NstQuad4(const NstMesh *m, uint a, uint b, uint c, uint d)
construct with reference to node
Definition: nstelements.h:412
Hexahedral element solid element : CHEXA.
Definition: nstelements.h:463
uint idtype() const
return id code
Definition: nstelements.h:515
virtual ~NstElementBase()
intended as base class
Definition: nstelements.h:67
void mesh(const NstMesh *m)
attach to mesh
Definition: nstelements.h:82
NstConMass(const NstMesh *m, uint a)
construct with reference to node
Definition: nstelements.h:161
void index2gid(const Element &e, uint vg[]) const
convert index to GID
Definition: nstelements.cpp:25
uint propid
property id and material coordinate system
Definition: nstelements.h:107
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:53
uint mcid() const
access material coordinate system
Definition: nstelements.h:76
uint idtype() const
return id code
Definition: nstelements.h:378
Vct3 orn
beam orientation vector
Definition: nstelements.h:343
NstBeam(const NstMesh *m, uint a, uint b)
construct with reference to node
Definition: nstelements.h:328
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:187
uint idtype() const
return id code
Definition: nstelements.h:225
uint add2viz(MeshFields &m) const
draw as lines
Definition: nstelements.cpp:292
uint vdof[2]
dofs to attach to
Definition: nstelements.h:233
Triangular shell element : CTRIA6.
Definition: nstelements.h:388
Vct3 poff
offset
Definition: nstelements.h:194
void setJ(const Mtx33 &J)
set rotational inertia
Definition: nstelements.h:171
Indices vi
mesh vertex indices (not gids)
Definition: nstelements.h:535
void stiffness(Real k)
access mass value
Definition: nstelements.h:222
uint pid() const
access property id
Definition: nstelements.h:70
Real mk
stiffness value
Definition: nstelements.h:236
uint indepNode() const
independent node (first in nastran card)
Definition: nstelements.h:524
uint idtype() const
return id code
Definition: nstelements.h:416
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:214
void constrain(NstDof ad, Real ac, NstDof bd, Real bc)
define single equation
Definition: nstelements.h:288
uint idtype() const
return id code
Definition: nstelements.h:180
Scalar mass element : CMASS2.
Definition: nstelements.h:114
Beam element : CBEAM.
Definition: nstelements.h:323
void components(uint na, uint nb, uint ma, uint mb)
set component DOF codes
Definition: nstelements.h:252
void orientation(const Vct3 &o)
change orientation
Definition: nstelements.h:332
Real acf[6]
coefficients of constraint equation
Definition: nstelements.h:313
void dof(NstDof da, NstDof db)
set dofs
Definition: nstelements.h:126
NstTriaR(const NstMesh *m, uint a, uint b, uint c)
construct with reference to node
Definition: nstelements.h:374
uint idtype() const
return id code
Definition: nstelements.h:489
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:268
uint adof[6]
set id and DOFs to constrain
Definition: nstelements.h:316
uint idtype() const
return id code
Definition: nstelements.h:138
Quadrilateral shell element : CQUADR.
Definition: nstelements.h:426
Rigid bar element: RBAR.
Definition: nstelements.h:243
NstSpring(const NstMesh *m, uint a, uint b)
construct with reference to node
Definition: nstelements.h:206
void pid(uint p)
set property id
Definition: nstelements.h:73
Quadrilateral shell element : CQUAD4.
Definition: nstelements.h:407
Concentrated mass element : CONM2.
Definition: nstelements.h:156
NstElementBase(const NstMesh *m)
default construction
Definition: nstelements.h:61
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:148
void mass(Real m)
access mass value
Definition: nstelements.h:135
NstTria3(const NstMesh *m, uint a, uint b, uint c)
construct with reference to node
Definition: nstelements.h:355
const NstMesh & mesh() const
access parent mesh
Definition: nstelements.h:85
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:125
uint idtype() const
return id code
Definition: nstelements.h:471
NstHexa(const NstMesh *m, uint v[], uint nv=20)
construct with reference to nodes
Definition: nstelements.h:468
uint depNode(uint k) const
dependent node k
Definition: nstelements.h:530
MPC pseudo-element for two points.
Definition: nstelements.h:272
uint idtype() const
return id code
Definition: nstelements.h:453
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:136
const Vct3 & offset() const
access offset coordinates
Definition: nstelements.h:174
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:244
void constrain(uint c, NstDof ad, Real ac, NstDof bd, Real bc)
define up to six equations
Definition: nstelements.h:296
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:174
uint cm
component numbers of depedent grid points
Definition: nstelements.h:538
void nstwrite(std::ostream &os) const
append to text stream
Definition: nstelements.cpp:78
void mcid(uint m)
set property id
Definition: nstelements.h:79
Real mass() const
access mass value
Definition: nstelements.h:132
Real mss
mass value
Definition: nstelements.h:149
NstSimpleMpc(const NstMesh *m, uint a, uint b)
construct with geometry
Definition: nstelements.h:277
NstRigidBody2(const NstMesh *m, uint c, const Indices &v)
construct: v[0] is the number of nodes, v[1] the independent node
Definition: nstelements.h:508
void mass(Real m)
access mass value
Definition: nstelements.h:168
Base class for NASTRAN finite elements.
Definition: nstelements.h:56
const NstMesh * msh
pointer to parent mesh
Definition: nstelements.h:104
static void indexOffsets(int gidoffset, int eidoffset)
change id offsets for writing
Definition: nstelements.cpp:34
uint ndep() const
number of dependent nodes
Definition: nstelements.h:527
Scalar spring element : CELAS2.
Definition: nstelements.h:201
Tetrahedral element solid element : CTETRA.
Definition: nstelements.h:481
uint idtype() const
return id code
Definition: nstelements.h:305
void offset(const Vct3 &p)
set coordinate offset
Definition: nstelements.h:177
Triangular shell element : CTRIA3.
Definition: nstelements.h:350
Real mass() const
access mass value
Definition: nstelements.h:165
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5