Free Electron
mechanicsAS.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __mechanics_mechanicsAS_h__
8 #define __mechanics_mechanicsAS_h__
9 
10 #include "math/math.h"
11 #include "shape/shape.h"
12 
13 namespace fe
14 {
15 namespace ext
16 {
17 
18 class FE_DL_EXPORT AsFrame :
19  public AccessorSet,
20  public Initialize<AsFrame>
21 {
22  public:
23  void initialize(void)
24  {
25  //add(location, FE_SPEC("spc:location", "spatial location, possibly embedded in transform"));
26  add(transform, FE_SPEC("spc:transform", "spatial transform"));
27  //scope()->enforce("spc:transform", "spc:location");
28  //scope()->within("", "spc:location", "spc:transform", 3*sizeof(SpatialVector));
29  }
30 #if 0
31 virtual void populate(sp<Layout> spLayout)
32  {
33  AccessorSet::populate(spLayout);
34 
35  // embed location within transform
36  scope()->within(spLayout->name(), "spc:location",
37  "spc:transform", 3*sizeof(SpatialVector));
38  }
39 #endif
40  /// translation within transform
41  //Accessor<SpatialVector> location;
42  /// transform
43  Accessor<SpatialTransform> transform;
44 };
45 
46 class FE_DL_EXPORT AsChildFrame:
47  public AsFrame,
48  public Initialize<AsChildFrame>
49 {
50  public:
51  void initialize(void)
52  {
53  add(parent, FE_SPEC("frame:parent", "parent record"));
54  }
55  Accessor<Record> parent;
56 };
57 
58 class FE_DL_EXPORT AsMark:
59  public AccessorSet,
60  public Initialize<AsMark>
61 {
62  public:
63  void initialize(void)
64  {
65  add(mark, FE_SPEC("generic:mark", "transient mark for algorithm usage"));
66  }
67  Accessor<bool> mark;
68 };
69 
70 class FE_DL_EXPORT AsGenericInt:
71  public AccessorSet,
72  public Initialize<AsGenericInt>
73 {
74  public:
75  void initialize(void)
76  {
77  add(integer, FE_SPEC("generic:i_0", "transient generic integer"));
78  }
79  Accessor<int> integer;
80 };
81 
82 class FE_DL_EXPORT AsZYXTFrame:
83  public AsChildFrame,
84  public Initialize<AsZYXTFrame>
85 {
86  public:
87  void initialize(void)
88  {
89  add(zyx, FE_SPEC("frame:zyx", "Euler angle rotations in ZYX order"));
90  add(t, FE_SPEC("frame:t", "translation"));
91  }
92  Accessor<SpatialVector> zyx;
93  Accessor<SpatialVector> t;
94 };
95 
96 class FE_DL_EXPORT AsRelativeFrame:
97  public AsChildFrame,
98  public Initialize<AsRelativeFrame>
99 {
100  public:
101  void initialize(void)
102  {
103  add(bound, FE_SPEC("frame:bound", "whether frame has been bound to the parent"));
104  add(reference, FE_SPEC("frame:reference", "reference frame to use for binding, relative to parent"));
105  add(delta, FE_SPEC("frame:delta", "the transform representing the binding"));
106  }
107  Accessor<bool> bound;
108  Accessor<Record> reference;
109  Accessor<SpatialTransform> delta;
110 };
111 
112 class FE_DL_EXPORT AsBodyFrame :
113  public AsFrame,
114  public Initialize<AsBodyFrame>
115 {
116  public:
117  void initialize(void)
118  {
119  add(component, FE_SPEC("component", "a generic component"));
120  }
121  Accessor< sp<Component> > component;
122 };
123 
124 class FE_DL_EXPORT AsWeightedPoint :
125  public AccessorSet,
126  public Initialize<AsWeightedPoint>
127 {
128  public:
129  void initialize(void)
130  {
131  add(weight, FE_SPEC("spc:weight", "weight of a point"));
132  add(point, FE_SPEC("spc:point", "spatial point"));
133  }
134  Accessor< Real > weight;
135  Accessor< Record > point;
136 };
137 
138 class FE_DL_EXPORT AsBarycentricPoint :
139  public AccessorSet,
140  public Initialize<AsBarycentricPoint>
141 {
142  public:
143  void initialize(void)
144  {
145  add(location, FE_SPEC("spc:location", "location of a point defined with weighted points"));
146  add(velocity, FE_SPEC("spc:velocity", "velocity of a point defined with weighted points"));
147  add(weightedPoints, FE_SPEC("spc:weightedPoints", "collection of weighted points"));
148  }
149  Accessor<SpatialVector> location;
150  Accessor<SpatialVector> velocity;
151  Accessor< sp<RecordGroup> > weightedPoints;
152 };
153 
154 typedef enum
155 {
156  e_forcePoint = (int)(1 << 0),
157  e_solverParticle = (int)(1 << 1),
158  e_barycentricPoint = (int)(1 << 2)
159 } pointType;
160 
161 class FE_DL_EXPORT AsExplicitPointType :
162  public AccessorSet,
163  public Initialize<AsExplicitPointType>
164 {
165  public:
166  void initialize(void)
167  {
168  add(type, FE_USE("spc:pointType"));
169  }
170  Accessor<int> type;
171 };
172 
173 
174 class FE_DL_EXPORT AsLocatedFrame :
175  public AsFrame,
176  public Initialize<AsLocatedFrame>
177 {
178  public:
179  void initialize(void)
180  {
181  add(locator0, FE_USE("bdy:locator0"));
182  add(locator1, FE_USE("bdy:locator1"));
183  add(locator2, FE_USE("bdy:locator2"));
184  add(offset, FE_USE("bdy:offset"));
185  }
186  /// locator reference point
187  Accessor<Record> locator0;
188  /// locator reference point
189  Accessor<Record> locator1;
190  /// locator reference point
191  Accessor<Record> locator2;
192  /// locator offset
193  Accessor<SpatialVector> offset;
194 
195 };
196 
197 
198 class FE_DL_EXPORT AsPhysicalFrame :
199  public AsFrame,
200  public Initialize<AsPhysicalFrame>
201 {
202  public:
203  void initialize(void)
204  {
205  add(force, FE_USE("bdy:force"));
206  add(torque, FE_USE("bdy:torque"));
207 
208 #if 1
209  m_asBodyFrame.bind(scope());
210  m_asLocatedFrame.bind(scope());
211  m_asForcePoint.bind(scope());
212  m_asChildFrame.bind(scope());
213 #endif
214  }
215  Accessor<SpatialVector> force;
216  Accessor<SpatialVector> torque;
217 
218  /// velocity inferred from either a BodyFrame or LocatedFrame
219  SpatialVector velocity(Record r_frame,
220  const SpatialVector &a_worldLocation);
221  private:
222  AsBodyFrame m_asBodyFrame;
223  AsLocatedFrame m_asLocatedFrame;
224  AsForcePoint m_asForcePoint;
225  AsChildFrame m_asChildFrame;
226 };
227 
228 
229 #if 0
230 // sort of an example of a virtual attribute
231 inline SpatialVector AsPhysicalFrame::velocity(Record r_frame, const SpatialVector &a_worldLocation)
232 {
233  SpatialVector velocity;
234  //m_asBodyFrame.bind(r_frame.layout()->scope());
235  if(m_asBodyFrame.check(r_frame))
236  {
237  sp<BodyI> spBody(m_asBodyFrame.component(r_frame));
238  if(spBody.isValid())
239  {
240  spBody->getVelocity(velocity, a_worldLocation);
241  }
242  return velocity;
243  }
244 
245  //m_asLocatedFrame.bind(r_frame.layout()->scope());
246  //m_asForcePoint.bind(r_frame.layout()->scope());
247  if(m_asLocatedFrame.check(r_frame))
248  {
249  Record r_locator0 = m_asLocatedFrame.locator0(r_frame);
250  if(!r_locator0.isValid() || !m_asForcePoint.check(r_locator0))
251  {
252  return velocity;
253  }
254  Record r_locator1 = m_asLocatedFrame.locator1(r_frame);
255  if(!r_locator1.isValid() || !m_asForcePoint.check(r_locator1))
256  {
257  return velocity;
258  }
259  Record r_locator2 = m_asLocatedFrame.locator2(r_frame);
260  if(!r_locator2.isValid() || !m_asForcePoint.check(r_locator2))
261  {
262  return velocity;
263  }
264 
265  Real h = 0.00001;
266 
267  SpatialTransform t0_inv;
268  invert(t0_inv, m_asLocatedFrame.transform(r_frame));
269 
270  SpatialVector loc;
271  transformVector(t0_inv, a_worldLocation, loc);
272 
273  SpatialTransform t1;
274  const SpatialVector &x0 = m_asForcePoint.location(r_locator0);
275  const SpatialVector &x1 = m_asForcePoint.location(r_locator1);
276  const SpatialVector &x2 = m_asForcePoint.location(r_locator2);
277  const SpatialVector &v0 = m_asForcePoint.velocity(r_locator0);
278  const SpatialVector &v1 = m_asForcePoint.velocity(r_locator1);
279  const SpatialVector &v2 = m_asForcePoint.velocity(r_locator2);
280  const SpatialVector &offset = m_asLocatedFrame.offset(r_frame);
281  makeFrame(t1, x0+v0*h, x1+v1*h, x2+v2*h, offset);
282  SpatialTransform t1_inv;
283  invert(t1_inv, t1);
284 
285  SpatialVector worldLocation1;
286  transformVector(t1, loc, worldLocation1);
287 
288  velocity = (worldLocation1 - a_worldLocation) / h;
289  return velocity;
290  }
291 
292  //m_asZYXTFrame.bind(r_frame.layout()->scope());
293  if(m_asChildFrame.check(r_frame))
294  {
295  Record r_parent = m_asChildFrame.parent(r_frame);
296 
297  if(r_parent.isValid())
298  {
299  velocity = this->velocity(r_parent, a_worldLocation);
300  }
301  }
302 
303  return velocity;
304 }
305 #endif
306 
307 
308 #if 0
309 class FE_DL_EXPORT AsTire :
310  public AccessorSet,
311  public Initialize<AsTire>
312 {
313  public:
314  void initialize(void)
315  {
316  add(frame, FE_USE("spc:frame"));
317  add(radius, FE_USE("bdy:radius"));
318  add(stiffness, FE_USE("mat:stiffness"));
319  add(damping, FE_USE("mat:damping"));
320  add(grip, FE_USE("mat:grip"));
321  }
322  /// Frame Record
323  Accessor<Record> frame;
324  ///
325  Accessor<Real> radius;
326  ///
327  Accessor<Real> stiffness;
328  ///
329  Accessor<Real> damping;
330  ///
331  Accessor<Real> grip;
332 };
333 
334 class FE_DL_EXPORT AsNaiveTire :
335  public AsTire,
336  public Initialize<AsNaiveTire>
337 {
338  public:
339  void initialize(void)
340  {
341  add(is, FE_USE("tire:naive"));
342  }
343  Accessor<void> is;
344 };
345 
346 class FE_DL_EXPORT AsNaiveTireData :
347  public AsNaiveTire,
348  public Initialize<AsNaiveTireData>
349 {
350  public:
351  void initialize(void)
352  {
353  add(inContact, FE_USE("naive_tire:inContact"));
354  add(component, FE_USE("component"));
355  add(thrust, FE_USE("naive_tire:thrust"));
356  add(sidethrust, FE_USE("naive_tire:sidethrust"));
357  add(contactRecord, FE_USE("naive_tire:contact"));
358  }
359  /// Frame Record
360  Accessor<bool> inContact;
361  /// Single point contact location
362  Accessor< sp<Component> > component;
363  /// external applied force
364  Accessor<Real> thrust;
365  /// external applied force
366  Accessor<Real> sidethrust;
367  /// contact record
368  Accessor<Record> contactRecord;
369 };
370 #endif
371 
372 
373 #if 0
374 class FE_DL_EXPORT AsPointCloud :
375  public AccessorSet,
376  public Initialize<AsPointCloud>
377 {
378  public:
379  void initialize(void)
380  {
381  add(points, FE_USE("bdy:points"));
382  }
383  /// collection of points
384  Accessor< sp<RecordGroup> > points;
385 };
386 #endif
387 
388 
389 
390 class FE_DL_EXPORT AsRod :
391  public AccessorSet,
392  public Initialize<AsRod>
393 {
394  public:
395  void initialize(void)
396  {
397  add(radius, FE_USE("bdy:radius"));
398  add(length, FE_USE("bdy:length"));
399  add(material, FE_USE("bdy:material"));
400  }
401  /// physical body dimension, not bounding volume
402  Accessor<Real> radius;
403  /// physical body dimension
404  Accessor<Real> length;
405  /// homogenous material
406  Accessor<Record> material;
407 };
408 
409 #if 0
410 class FE_DL_EXPORT AsWheel :
411  public AccessorSet,
412  public Initialize<AsWheel>
413 {
414  public:
415  void initialize(void)
416  {
417  add(radius, FE_USE("bdy:radius"));
418  add(width, FE_USE("bdy:width"));
419  }
420  /// physical body dimension, not bounding volume
421  Accessor<Real> radius;
422  /// physical body dimension
423  Accessor<Real> width;
424 };
425 #endif
426 
427 class FE_DL_EXPORT AsFrameConstraint :
428  public AccessorSet,
429  public Initialize<AsFrameConstraint>
430 {
431  public:
432  void initialize(void)
433  {
434  add(frame, FE_USE("constraint:frame"));
435  add(point, FE_USE("constraint:point"));
436  }
437  /// frame to constrain to
438  Accessor<Record> frame;
439  /// point to constrain
440  Accessor<Record> point;
441 };
442 
443 #if 1
444 class FE_DL_EXPORT AsChild :
445  public AccessorSet,
446  public Initialize<AsChild>
447 {
448  public:
449  void initialize(void)
450  {
451  add(parent, FE_USE("bdy:parent"));
452  add(local, FE_USE("spc:local"));
453  }
454  Accessor<Record> parent;
455  Accessor<SpatialTransform> local;
456 };
457 #endif
458 
459 #if 0
460 class FE_DL_EXPORT AsTube :
461  public AccessorSet,
462  public Initialize<AsTube>
463 {
464  public:
465  void initialize(void)
466  {
467  add(radius, FE_USE("bdy:radius"));
468  add(thickness, FE_USE("bdy:thickness"));
469  add(length, FE_USE("bdy:length"));
470  add(material, FE_USE("bdy:material"));
471  }
472  /// physical body dimension, not bounding volume
473  Accessor<Real> radius;
474  /// physical body dimension
475  Accessor<Real> thickness;
476  /// physical body dimension
477  Accessor<Real> length;
478  /// homogenous material
479  Accessor<Record> material;
480 };
481 #endif
482 
483 // TODO: rename AsHinge to AsJoint
484 class FE_DL_EXPORT AsHinge :
485  public AccessorSet,
486  public Initialize<AsHinge>
487 {
488  public:
489  void initialize(void)
490  {
491  add(anchor, FE_USE("jnt:anchor"));
492  add(axis, FE_USE("spc:direction"));
493  add(left, FE_USE("pair:left"));
494  add(right, FE_USE("pair:right"));
495  }
496  /// location of anchor point
497  Accessor<Record> anchor;
498  /// axis of hinge
499  Accessor<SpatialVector> axis;
500  /// connected body
501  Accessor<WeakRecord> left;
502  /// connected body
503  Accessor<WeakRecord> right;
504 };
505 
506 class FE_DL_EXPORT AsMaterial :
507  public AccessorSet,
508  public Initialize<AsMaterial>
509 {
510  public:
511  void initialize(void)
512  {
513  add(density, FE_USE("mat:density"));
514  }
515  /// density
516  Accessor<Real> density;
517 };
518 
519 
520 #if 0
521 class FE_DL_EXPORT AsForcePair :
522  public AccessorSet,
523  public Initialize<AsForcePair>
524 {
525  public:
526  void initialize(void)
527  {
528  add(a, FE_USE("pair:left"));
529  add(b, FE_USE("pair:right"));
530  }
531 };
532 #endif
533 
534 class FE_DL_EXPORT AsPointThrust :
535  public AccessorSet,
536  public Initialize<AsPointThrust>
537 {
538  public:
539  void initialize(void)
540  {
541  add(point, FE_USE("spc:point"));
542  add(force, FE_USE("sim:force"));
543  }
544  Accessor<Record> point;
545  Accessor<SpatialVector> force;
546 };
547 
548 
549 class FE_DL_EXPORT AsRadialFake :
550  public AccessorSet,
551  public Initialize<AsRadialFake>
552 {
553  public:
554  void initialize(void)
555  {
556  add(r0, FE_USE("pair:left"));
557  add(r1, FE_USE("pair:right"));
558  add(r2, FE_USE("fake:r2"));
559  add(r3, FE_USE("fake:r3"));
560  add(anchor, FE_USE("fake:anchor"));
561  add(stiffness, FE_USE("mat:stiffness"));
562  }
563 
564  /// connected point
565  Accessor<WeakRecord> r0;
566  /// connected point
567  Accessor<WeakRecord> r1;
568  /// connected point
569  Accessor<WeakRecord> r2;
570  /// connected point
571  Accessor<WeakRecord> r3;
572  /// connected point
573  Accessor<WeakRecord> anchor;
574  /// stiffness
575  Accessor<Real> stiffness;
576 
577 };
578 
579 class FE_DL_EXPORT AsDifferential :
580  public AccessorSet,
581  public Initialize<AsDifferential>
582 {
583  public:
584  void initialize(void)
585  {
586  add(shaft, FE_USE("diff:shaft"));
587  add(mount, FE_USE("diff:mount"));
588  add(left, FE_USE("pair:left"));
589  add(right, FE_USE("pair:right"));
590  add(flags, FE_USE("mat:flags"));
591  }
592  /// connected fix frame (chassis)
593  Accessor<WeakRecord> mount;
594  /// connected drive shaft
595  Accessor<WeakRecord> shaft;
596  /// connected left halfshaft
597  Accessor<WeakRecord> left;
598  /// connected right halfshaft
599  Accessor<WeakRecord> right;
600  /// flags
601  Accessor<int> flags;
602 };
603 
604 #define FE_DIFF_LOCKED (int)(1 << 0)
605 #define FE_DIFF_OPEN (int)(1 << 1)
606 #define FE_DIFF_HLSD (int)(1 << 2)
607 #define FE_DIFF_VLSD (int)(1 << 3)
608 
609 /// Basic Hooke's law linear spring
610 class FE_DL_EXPORT AsLinearSpring :
611  public AccessorSet,
612  public Initialize<AsLinearSpring>
613 {
614  public:
615  void initialize(void)
616  {
617  add(left, FE_USE("pair:left"));
618  add(right, FE_USE("pair:right"));
619  add(length, FE_USE("bdy:length"));
620  add(stiffness, FE_USE("mat:stiffness"));
621  add(damping, FE_USE("mat:damping"));
622  }
623  /// connected point
625  /// connected point
627  /// rest length
629  /// stiffness
631  /// damping
633 };
634 
635 #define FE_LSF_NOCOMPRESS (int)(1 << 0)
636 #define FE_LSF_XIGNORE (int)(1 << 1)
637 #define FE_LSF_YIGNORE (int)(1 << 2)
638 #define FE_LSF_ZIGNORE (int)(1 << 3)
639 #define FE_LSF_PULLCOMPRESS (int)(1 << 4)
640 #define FE_LSF_OFFSET_MODE (int)(1 << 5)
641 
642 class FE_DL_EXPORT AsLinearSpringExtended :
643  public AsLinearSpring,
644  public Initialize<AsLinearSpringExtended>
645 {
646  public:
647  void initialize(void)
648  {
649  add(flags, FE_USE("mat:flags"));
650  }
651  Accessor<int> flags;
652 };
653 
654 
655 class FE_DL_EXPORT AsLinearSpringForceReturn :
656  public AccessorSet,
657  public Initialize<AsLinearSpringForceReturn>
658 {
659  public:
660  void initialize(void)
661  {
662  add(spring, FE_USE("lsf:spring"));
663  }
664  Accessor<void*> spring;
665 };
666 
667 
668 ///
669 class FE_DL_EXPORT AsLinearSpringDelta :
670  public AsLinearSpring,
671  public Initialize<AsLinearSpringDelta>
672 {
673  public:
674  void initialize(void)
675  {
676  add(a, FE_USE("quad:a"));
677  add(b, FE_USE("quad:b"));
678  add(c, FE_USE("quad:c"));
679  add(d, FE_USE("quad:d"));
680  add(stiffness, FE_USE("mat:stiffness"));
681  add(damping, FE_USE("mat:damping"));
682  add(is, FE_USE("is:linsprdelta"));
683  }
688  /// stiffness
689  Accessor<Real> stiffness;
690  /// damping
691  Accessor<Real> damping;
692  Accessor<void> is;
693 };
694 
695 
696 class FE_DL_EXPORT AsLinearSpringDeltaData :
697  public AccessorSet,
698  public Initialize<AsLinearSpringDeltaData>
699 {
700  public:
701  void initialize(void)
702  {
703  add(abSpring, FE_USE("pair:left"));
704  add(cdSpring, FE_USE("pair:right"));
705  }
706  Accessor<WeakRecord> abSpring;
707  Accessor<WeakRecord> cdSpring;
708 };
709 
710 /// For bending element based on Volino 2006 bending model
711 class FE_DL_EXPORT AsBend :
712  public AccessorSet,
713  public Initialize<AsBend>
714 {
715  public:
716  void initialize(void)
717  {
718  add(a, FE_USE("quad:a"));
719  add(b, FE_USE("quad:b"));
720  add(c, FE_USE("quad:c"));
721  add(d, FE_USE("quad:d"));
722  add(stiffness, FE_USE("mat:stiffness"));
723  add(damping, FE_USE("mat:damping"));
724  add(is, FE_USE("is:bend"));
725  }
726  /// connected tip point -- A is opposite across axis from B
728  /// connected tip point -- B is opposite across axis from A
730  /// connected tip point -- CD is axis
732  /// connected tip point -- CD is axis
734  /// stiffness
736  /// damping
738  Accessor<void> is;
739 };
740 
741 class FE_DL_EXPORT AsLinearBend :
742  public AsBend,
743  public Initialize<AsLinearBend>
744 {
745  public:
746  void initialize(void)
747  {
748  add(length, FE_USE("bend:length"));
749  add(alpha, FE_USE("bend:alpha"));
750  add(lambda, FE_USE("bend:lambda"));
751  add(gamma, FE_USE("bend:gamma"));
752 
753  add(bendJacobians, FE_USE("bdy:bendJacobians"));
754  }
755  /// rest curvature 'length' per Volino 2006
756  Accessor<Real> length;
757  /// Volino 2006 alpha
758  Accessor<Vector4> alpha;
759  /// Volino 2006 lambda
760  Accessor<Real> lambda;
761  /// Volino 2006 gamma
762  Accessor<Real> gamma;
763  /// Bend Jacobian Object
764  Accessor< sp<Component> > bendJacobians;
765 };
766 
767 /* face is a quad for now. While I think of ti as the more pure
768  surface element, for RL cases at the time of this writing,
769  there is a slight performance and packaging/memory upside to using
770  quads */
771 class FE_DL_EXPORT AsFace :
772  public AccessorSet,
773  public Initialize<AsFace>
774 {
775  public:
776  void initialize(void)
777  {
778  add(a, FE_USE("face:a"));
779  add(b, FE_USE("face:b"));
780  add(c, FE_USE("face:c"));
781  add(d, FE_USE("face:d"));
782  }
783  /// vertex
785  /// vertex
787  /// vertex
789  /// vertex
791 };
792 
793 class FE_DL_EXPORT AsFacePressure :
794  public AsFace,
795  public Initialize<AsFacePressure>
796 {
797  public:
798  void initialize(void)
799  {
800  add(pressure, FE_USE("face:pressure"));
801  }
802  /// pressure
803  Accessor<Real> pressure;
804 };
805 
806 class FE_DL_EXPORT AsFaceStrain :
807  public AsFace,
808  public Initialize<AsFaceStrain>
809 {
810  public:
811  void initialize(void)
812  {
813  add(angle, FE_USE("face:angle"));
814  add(stiffness, FE_USE("mat:uv_stiffness"));
815  add(damping, FE_USE("mat:uv_damping"));
816  add(poisson, FE_USE("mat:poisson"));
817  add(shear, FE_USE("mat:uv_shear_stiffness"));
818  }
819  /// angle of cords/fibers/grain
820  Accessor<Real> angle;
821  /// uv stiffness
822  Accessor<Vector2> stiffness;
823  /// uv damping
824  Accessor<Vector2> damping;
825  /// poisson ratio
826  Accessor<Real> poisson;
827  /// uv shear modulus
828  Accessor<Real> shear;
829 };
830 
831 
832 class FE_DL_EXPORT AsStrand :
833  public AccessorSet,
834  public Initialize<AsStrand>
835 {
836  public:
837  void initialize(void)
838  {
839  add(a, FE_USE("strand:a"));
840  add(b, FE_USE("strand:b"));
841  add(c, FE_USE("strand:c"));
842  add(stiffness, FE_USE("mat:stiffness"));
843  add(damping, FE_USE("mat:damping"));
844  add(is, FE_USE("strand:bend"));
845  }
846  /// connected tip point
848  /// connected tip point
850  /// connected tip point
852  /// stiffness
853  Accessor<Real> stiffness;
854  /// damping
855  Accessor<Real> damping;
856 
857  // to distinct from AsDotElement
858  Accessor<void> is;
859 };
860 
861 
862 class FE_DL_EXPORT AsDotElement :
863  public AccessorSet,
864  public Initialize<AsDotElement>
865 {
866  public:
867  void initialize(void)
868  {
869  add(a, FE_USE("strand:a"));
870  add(b, FE_USE("strand:b"));
871  add(c, FE_USE("strand:c"));
872  add(stiffness, FE_USE("mat:stiffness"));
873  add(damping, FE_USE("mat:damping"));
874  add(restdot, FE_USE("strand:restdot"));
875  }
876  /// connected tip point
878  /// connected tip point
880  /// connected tip point
882  /// stiffness
883  Accessor<Real> stiffness;
884  /// damping
885  Accessor<Real> damping;
886  /// rest dot
887  Accessor<Real> restdot;
888 };
889 
890 
891 class FE_DL_EXPORT AsLinearStrand :
892  public AsStrand,
893  public Initialize<AsLinearStrand>
894 {
895  public:
896  void initialize(void)
897  {
898  add(length, FE_USE("bend:length"));
899  add(alpha, FE_USE("bend:alpha"));
900  add(lambda, FE_USE("bend:lambda"));
901  add(gamma, FE_USE("bend:gamma"));
902 
903  add(bendJacobians, FE_USE("bdy:bendJacobians"));
904  }
905  Accessor<Real> length;
906  Accessor<Vector4> alpha;
907  Accessor<Real> lambda;
908  Accessor<Real> gamma;
909  Accessor< sp<Component> > bendJacobians;
910 };
911 
912 class FE_DL_EXPORT AsStrandTwist :
913  public AccessorSet,
914  public Initialize<AsStrandTwist>
915 {
916  public:
917  void initialize(void)
918  {
919  add(a, FE_USE("strand:a"));
920  add(b, FE_USE("strand:b"));
921  add(c, FE_USE("strand:c"));
922  add(d, FE_USE("strand:d"));
923  add(stiffness, FE_USE("mat:rotStiffness"));
924  add(damping, FE_USE("mat:rotDamping"));
925  }
930  Accessor<Real> stiffness;
931  Accessor<Real> damping;
932 };
933 
934 class FE_DL_EXPORT AsLinearStrandTwist:
935  public AsStrandTwist,
936  public Initialize<AsLinearStrandTwist>
937 {
938  public:
939  void initialize(void)
940  {
941  add(length, FE_USE("bend:length"));
942  add(alpha, FE_USE("bend:alpha"));
943  add(lambda, FE_USE("bend:lambda"));
944  add(gamma, FE_USE("bend:gamma"));
945 
946  add(jacobians, FE_USE("bdy:bendJacobians"));
947  }
948  Accessor<Real> length;
949  Accessor<Vector4> alpha;
950  Accessor<Real> lambda;
951  Accessor<Real> gamma;
952  Accessor< sp<Component> > jacobians;
953 };
954 
955 class FE_DL_EXPORT AsElastic:
956  public AccessorSet,
957  public Initialize<AsElastic>
958 {
959  public:
960  void initialize(void)
961  {
962  add(stiffness, FE_USE("mat:stiffness"));
963  }
964  Accessor<Real> stiffness;
965 };
966 
967 // jammed in here for liquid sandbox demo
968 class FE_DL_EXPORT AsLiquidSand:
969  public AccessorSet,
970  public Initialize<AsLiquidSand>
971 {
972  public:
973  void initialize(void)
974  {
975  add(hardRadius, FE_USE("liquid:hardRadius"));
976  add(attractRate, FE_USE("liquid:attractRate"));
977  }
978  Accessor<Real> hardRadius;
979  Accessor<Real> attractRate;
980 };
981 
982 class FE_DL_EXPORT AsHasChannel:
983  public AccessorSet,
984  public Initialize<AsHasChannel>
985 {
986  public:
987  void initialize(void)
988  {
989  add(name, FE_USE("channel:name"));
990  }
991  Accessor<String> name;
992 };
993 
994 class FE_DL_EXPORT AsDrivenHinge:
995  public AccessorSet,
996  public Initialize<AsDrivenHinge>
997 {
998  public:
999  void initialize(void)
1000  {
1001  add(angle, FE_USE("jnt:angle"));
1002  add(stiffness, FE_USE("mat:rotStiffness"));
1003  add(damping, FE_USE("mat:rotDamping"));
1004  }
1005  Accessor<Real> angle;
1006  Accessor<Real> stiffness;
1007  Accessor<Real> damping;
1008 };
1009 
1010 class FE_DL_EXPORT ContactRV : public RecordView
1011 {
1012  public:
1013  ContactRV(void) { setName("ContactRV"); }
1014 virtual void addFunctors(void)
1015  {
1016  add(frame, FE_USE("spc:frame"));
1017  add(location, FE_USE("spc:location"));
1018  add(velocity, FE_USE("spc:velocity"));
1019  add(normal, FE_USE("spc:normal"));
1020  add(depth, FE_USE("spc:depth"));
1021  add(stiffness, FE_USE("mat:stiffness"));
1022  add(damping, FE_USE("mat:damping"));
1023  add(group, FE_USE("group"));
1024  add(transient, FE_USE("generic:mark"));
1025  }
1026  Functor<Record> frame;
1027  Functor<SpatialVector> location;
1028  Functor<SpatialVector> velocity;
1029  Functor<SpatialVector> normal;
1030  Functor<Real> depth;
1031  Functor<Real> stiffness;
1032  Functor<Real> damping;
1033  Functor< sp<RecordGroup> > group;
1034  Functor<bool> transient;
1035 };
1036 
1037 
1038 class FE_DL_EXPORT AsRelocate :
1039  public AsFrame,
1040  public Initialize<AsRelocate>
1041 {
1042  public:
1043  void initialize(void)
1044  {
1045  add(group, FE_USE("group"));
1046  }
1047  Accessor< sp<RecordGroup> > group;
1048 };
1049 
1050 class FE_DL_EXPORT AsReferenceFrame :
1051  public AsFrame,
1052  public Initialize<AsReferenceFrame>
1053 {
1054  public:
1055  void initialize(void)
1056  {
1057  add(is, FE_USE("sim:refframe"));
1058  }
1059  Accessor<void> is;
1060 };
1061 
1062 class FE_DL_EXPORT AsSmoothedParticle :
1063  public AsParticle, public AsBounded,
1064  public Initialize<AsSmoothedParticle>
1065 {
1066  public:
1067  void initialize(void)
1068  {
1069  add(density, FE_USE("sim:density"));
1070  add(heat, FE_USE("sim:heat"));
1071  add(heatAccumulator,FE_USE("sim:heat_accum"));
1072  }
1073  // density
1074  Accessor<Real> density;
1075  Accessor<Real> heat;
1076  Accessor<Real> heatAccumulator;
1077 };
1078 
1079 class FE_DL_EXPORT AsActuator :
1080  public AccessorSet,
1081  public Initialize<AsActuator>
1082 {
1083  public:
1084  void initialize(void)
1085  {
1086  add(transform, FE_USE("liquid:transform"));
1087  add(velocity, FE_USE("liquid:velocity"));
1088  add(spin, FE_USE("liquid:spin"));
1089  add(radius, FE_USE("liquid:radius"));
1090  add(mode, FE_USE("liquid:mode"));
1091  }
1092 
1093  /// location, rotation, scale
1094  Accessor<SpatialTransform> transform;
1095 
1096  // velocity might be useful to make interaction robust
1097  Accessor<SpatialVector> velocity;
1098 
1099  // axis and magnitude of 'spin'
1101 
1102  // radius of influence
1103  Accessor<Real> radius;
1104 
1105  // mode (attract, repulse, other)
1106  Accessor<int> mode;
1107 
1108 };
1109 
1110 } /* namespace */
1111 } /* namespace */
1112 
1113 
1114 #endif /* __mechanics_mechanicsAS_h__ */
1115 
1116 
Accessor< WeakRecord > c
connected tip point – CD is axis
Definition: mechanicsAS.h:731
Set of accessors.
Definition: AccessorSet.h:18
Accessor< Real > stiffness
stiffness
Definition: mechanicsAS.h:630
Basic Hooke&#39;s law linear spring.
Definition: mechanicsAS.h:610
kernel
Definition: namespace.dox:3
Matrix< 4, 4, T > & invert(Matrix< 4, 4, T > &a_inverted, const Matrix< 4, 4, T > &a_matrix)
4x4 full matrix inversion
Definition: Matrix.h:1033
Accessor< WeakRecord > left
connected point
Definition: mechanicsAS.h:624
Accessor< Real > damping
damping
Definition: mechanicsAS.h:632
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
Accessor< WeakRecord > right
connected point
Definition: mechanicsAS.h:626
Accessor< Real > length
rest length
Definition: mechanicsAS.h:628
particle in physical space
Definition: shapeAS.h:58
Accessor< WeakRecord > b
connected tip point – B is opposite across axis from A
Definition: mechanicsAS.h:729
Accessor< WeakRecord > a
connected tip point – A is opposite across axis from B
Definition: mechanicsAS.h:727
possible bounding area/volume attributes
Definition: shapeAS.h:148
Bindable collection of accessor Functors.
Definition: RecordView.h:106
For bending element based on Volino 2006 bending model.
Definition: mechanicsAS.h:711
Accessor< WeakRecord > d
connected tip point – CD is axis
Definition: mechanicsAS.h:733
Accessor< Real > damping
damping
Definition: mechanicsAS.h:737
Accessor< Real > stiffness
stiffness
Definition: mechanicsAS.h:735