MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
modelns.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/modelns.cc,v 1.49 2017/01/12 14:46:09 masarati Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2017
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 
32 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <limits>
35 #include <cfloat>
36 #include <limits>
37 
38 #include "modelns.h"
39 #include "strnode.h"
40 #include "matvecexp.h"
41 #include "Rot.hh"
42 
43 enum IDX_t {
44  IDX1 = 1,
45  IDX2 = 2,
46  IDX3 = 3,
49 };
50 
51 static const char *
53 {
54  switch (IDX) {
55  case NORM:
56  return "";
57 
58  case SQUARE:
59  return "2";
60 
61  case IDX1:
62  return "<1>";
63 
64  case IDX2:
65  return "<2>";
66 
67  case IDX3:
68  return "<3>";
69  }
70 
72 }
73 
74 enum when_t {
75  CURR = 0,
76  PREV = 1
77 };
78 
79 static const char *
81 {
82  switch (when) {
83  case CURR:
84  return "";
85 
86  case PREV:
87  return "_prev";
88 
89  }
90 
92 }
93 
94 /*
95  * Computes the position of a structural node
96  */
97 template <IDX_t IDX, when_t when>
98 static int
100 {
101  ASSERT(args.size() == 1 + 1 + 1);
102  ASSERT(args[0]->Type() == MathParser::AT_REAL);
103  ASSERT(args[1]->Type() == MathParser::AT_INT);
104  ASSERT(args[2]->Type() == MathParser::AT_PRIVATE);
105 
106  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
107  ASSERT(out != 0);
108 
109  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
110  ASSERT(arg1 != 0);
111  ASSERT((*arg1)() >= 0);
112 
113  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[2]);
114  ASSERT(dm != 0);
115 
116  unsigned uLabel = unsigned((*arg1)());
117 
118  const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
119  if (pNode == 0) {
120  silent_cerr("model::position" << when2str(when) << IDX2str(IDX)
121  << "(" << uLabel << "): "
122  "unable to find StructNode(" << uLabel << ")"
123  << std::endl);
125  }
126 
127  Vec3 x;
128  switch (when) {
129  case CURR:
130  x = pNode->GetXCurr();
131  break;
132 
133  case PREV:
134  x = pNode->GetXPrev();
135  break;
136  }
137 
138  switch (IDX) {
139  case NORM:
140  *out = x.Norm();
141  break;
142 
143  case SQUARE:
144  *out = x.Dot();
145  break;
146 
147  default:
148  *out = x(IDX);
149  break;
150  }
151 
152  return 0;
153 }
154 
155 /*
156  * Computes the distance between two structural nodes
157  */
158 template <IDX_t IDX, when_t when>
159 static int
161 {
162  ASSERT(args.size() == 1 + 2 + 1);
163  ASSERT(args[0]->Type() == MathParser::AT_REAL);
164  ASSERT(args[1]->Type() == MathParser::AT_INT);
165  ASSERT(args[2]->Type() == MathParser::AT_INT);
166  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
167 
168  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
169  ASSERT(out != 0);
170 
171  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
172  ASSERT(arg1 != 0);
173  ASSERT((*arg1)() >= 0);
174 
175  MathParser::MathArgInt_t *arg2 = dynamic_cast<MathParser::MathArgInt_t *>(args[2]);
176  ASSERT(arg2 != 0);
177  ASSERT((*arg2)() >= 0);
178 
179  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[3]);
180  ASSERT(dm != 0);
181 
182  unsigned uLabel1 = unsigned((*arg1)());
183  unsigned uLabel2 = unsigned((*arg2)());
184 
185  const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
186  if (pNode1 == 0) {
187  silent_cerr("model::distance" << when2str(when) << IDX2str(IDX)
188  << "(" << uLabel1 << "," << uLabel2 << "): "
189  "unable to find StructNode(" << uLabel1 << ")"
190  << std::endl);
192  }
193 
194  const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
195  if (pNode2 == 0) {
196  silent_cerr("model::distance" << when2str(when) << IDX2str(IDX)
197  << "(" << uLabel1 << "," << uLabel2 << "): "
198  "unable to find StructNode(" << uLabel2 << ")"
199  << std::endl);
201  }
202 
203  Vec3 d;
204  switch (when) {
205  case CURR:
206  d = pNode2->GetXCurr() - pNode1->GetXCurr();
207  break;
208 
209  case PREV:
210  d = pNode2->GetXPrev() - pNode1->GetXPrev();
211  break;
212  }
213 
214  switch (IDX) {
215  case NORM:
216  *out = d.Norm();
217  break;
218 
219  case SQUARE:
220  *out = d.Dot();
221  break;
222 
223  default:
224  *out = d(IDX);
225  break;
226  }
227 
228  return 0;
229 }
230 
231 /*
232  * Computes the components of the direction between two structural nodes
233  */
234 template <IDX_t IDX, when_t when>
235 static int
237 {
238  ASSERT(args.size() == 1 + 2 + 1);
239  ASSERT(args[0]->Type() == MathParser::AT_REAL);
240  ASSERT(args[1]->Type() == MathParser::AT_INT);
241  ASSERT(args[2]->Type() == MathParser::AT_INT);
242  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
243 
244  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
245  ASSERT(out != 0);
246 
247  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
248  ASSERT(arg1 != 0);
249  ASSERT((*arg1)() >= 0);
250 
251  MathParser::MathArgInt_t *arg2 = dynamic_cast<MathParser::MathArgInt_t *>(args[2]);
252  ASSERT(arg2 != 0);
253  ASSERT((*arg2)() >= 0);
254 
255  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[3]);
256  ASSERT(dm != 0);
257 
258  unsigned uLabel1 = unsigned((*arg1)());
259  unsigned uLabel2 = unsigned((*arg2)());
260 
261  const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
262  if (pNode1 == 0) {
263  silent_cerr("model::unitvec" << when2str(when) << IDX2str(IDX)
264  << "(" << uLabel1 << "," << uLabel2 << "): "
265  "unable to find StructNode(" << uLabel1 << ")"
266  << std::endl);
268  }
269 
270  const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
271  if (pNode2 == 0) {
272  silent_cerr("model::unitvec" << when2str(when) << IDX2str(IDX)
273  << "(" << uLabel1 << "," << uLabel2 << "): "
274  "unable to find StructNode(" << uLabel2 << ")"
275  << std::endl);
277  }
278 
279  Vec3 d;
280  switch (when) {
281  case CURR:
282  d = pNode2->GetXCurr() - pNode1->GetXCurr();
283  break;
284 
285  case PREV:
286  d = pNode2->GetXPrev() - pNode1->GetXPrev();
287  break;
288  }
289 
290  doublereal dd = d.Norm();
291  if (dd <= std::numeric_limits<doublereal>::epsilon()) {
292  silent_cerr("model::unitvec" << when2str(when) << IDX2str(IDX)
293  << "(" << uLabel1 << "," << uLabel2 << "): "
294  "null distance"
295  << std::endl);
297  }
298 
299  switch (IDX) {
300  default:
301  *out = d(IDX)/dd;
302  break;
303  }
304 
305  return 0;
306 }
307 
308 /*
309  * Computes the orientation of a structural node
310  */
311 template <IDX_t IDX, when_t when>
312 static int
314 {
315  ASSERT(args.size() == 1 + 1 + 1);
316  ASSERT(args[0]->Type() == MathParser::AT_REAL);
317  ASSERT(args[1]->Type() == MathParser::AT_INT);
318  ASSERT(args[2]->Type() == MathParser::AT_PRIVATE);
319 
320  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
321  ASSERT(out != 0);
322 
323  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
324  ASSERT(arg1 != 0);
325  ASSERT((*arg1)() >= 0);
326 
327  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[2]);
328  ASSERT(dm != 0);
329 
330  unsigned uLabel = unsigned((*arg1)());
331 
332  const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
333  if (pNode == 0) {
334  silent_cerr("model::angle" << when2str(when) << IDX2str(IDX)
335  << "(" << uLabel << "): "
336  "unable to find StructNode(" << uLabel << ")"
337  << std::endl);
339  }
340 
341  Vec3 phi;
342  switch (when) {
343  case CURR:
344  phi = RotManip::VecRot(pNode->GetRCurr());
345  break;
346 
347  case PREV:
348  phi = RotManip::VecRot(pNode->GetRPrev());
349  break;
350  }
351 
352  switch (IDX) {
353  case NORM:
354  *out = phi.Norm();
355  break;
356 
357  default:
358  *out = phi(IDX);
359  break;
360  }
361 
362  return 0;
363 }
364 
365 /*
366  * Computes the orientation between two structural nodes
367  */
368 template <IDX_t IDX, when_t when>
369 static int
371 {
372  ASSERT(args.size() == 1 + 2 + 1);
373  ASSERT(args[0]->Type() == MathParser::AT_REAL);
374  ASSERT(args[1]->Type() == MathParser::AT_INT);
375  ASSERT(args[2]->Type() == MathParser::AT_INT);
376  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
377 
378  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
379  ASSERT(out != 0);
380 
381  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
382  ASSERT(arg1 != 0);
383  ASSERT((*arg1)() >= 0);
384 
385  MathParser::MathArgInt_t *arg2 = dynamic_cast<MathParser::MathArgInt_t *>(args[2]);
386  ASSERT(arg2 != 0);
387  ASSERT((*arg2)() >= 0);
388 
389  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[3]);
390  ASSERT(dm != 0);
391 
392  unsigned uLabel1 = unsigned((*arg1)());
393  unsigned uLabel2 = unsigned((*arg2)());
394 
395  const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
396  if (pNode1 == 0) {
397  silent_cerr("model::anglerel" << when2str(when) << IDX2str(IDX)
398  << "(" << uLabel1 << "," << uLabel2 << "): "
399  "unable to find StructNode(" << uLabel1 << ")"
400  << std::endl);
402  }
403 
404  const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
405  if (pNode2 == 0) {
406  silent_cerr("model::anglerel" << when2str(when) << IDX2str(IDX)
407  << "(" << uLabel1 << "," << uLabel2 << "): "
408  "unable to find StructNode(" << uLabel2 << ")"
409  << std::endl);
411  }
412 
413  Vec3 phi;
414  switch (when) {
415  case CURR:
416  phi = RotManip::VecRot(pNode1->GetRCurr().MulTM(pNode2->GetRCurr()));
417  break;
418 
419  case PREV:
420  phi = RotManip::VecRot(pNode1->GetRPrev().MulTM(pNode2->GetRPrev()));
421  break;
422  }
423 
424  switch (IDX) {
425  case NORM:
426  *out = phi.Norm();
427  break;
428 
429  default:
430  *out = phi(IDX);
431  break;
432  }
433 
434  return 0;
435 }
436 
437 /*
438  * Computes the velocity of a structural node
439  */
440 template <IDX_t IDX, when_t when>
441 static int
443 {
444  ASSERT(args.size() == 1 + 1 + 1);
445  ASSERT(args[0]->Type() == MathParser::AT_REAL);
446  ASSERT(args[1]->Type() == MathParser::AT_INT);
447  ASSERT(args[2]->Type() == MathParser::AT_PRIVATE);
448 
449  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
450  ASSERT(out != 0);
451 
452  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
453  ASSERT(arg1 != 0);
454  ASSERT((*arg1)() >= 0);
455 
456  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[2]);
457  ASSERT(dm != 0);
458 
459  unsigned uLabel = unsigned((*arg1)());
460 
461  const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
462  if (pNode == 0) {
463  silent_cerr("model::velocity" << when2str(when) << IDX2str(IDX)
464  << "(" << uLabel << "): "
465  "unable to find StructNode(" << uLabel << ")"
466  << std::endl);
468  }
469 
470  Vec3 v;
471  switch (when) {
472  case CURR:
473  v = pNode->GetVCurr();
474  break;
475 
476  case PREV:
477  v = pNode->GetVPrev();
478  break;
479  }
480 
481  switch (IDX) {
482  case NORM:
483  *out = v.Norm();
484  break;
485 
486  case SQUARE:
487  *out = v.Dot();
488  break;
489 
490  default:
491  *out = v(IDX);
492  break;
493  }
494 
495  return 0;
496 }
497 
498 /*
499  * Computes the relative velocity between two structural nodes
500  */
501 template <IDX_t IDX, when_t when>
502 static int
504 {
505  ASSERT(args.size() == 1 + 2 + 1);
506  ASSERT(args[0]->Type() == MathParser::AT_REAL);
507  ASSERT(args[1]->Type() == MathParser::AT_INT);
508  ASSERT(args[2]->Type() == MathParser::AT_INT);
509  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
510 
511  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
512  ASSERT(out != 0);
513 
514  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
515  ASSERT(arg1 != 0);
516  ASSERT((*arg1)() >= 0);
517 
518  MathParser::MathArgInt_t *arg2 = dynamic_cast<MathParser::MathArgInt_t *>(args[2]);
519  ASSERT(arg2 != 0);
520  ASSERT((*arg2)() >= 0);
521 
522  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[3]);
523  ASSERT(dm != 0);
524 
525  unsigned uLabel1 = unsigned((*arg1)());
526  unsigned uLabel2 = unsigned((*arg2)());
527 
528  const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
529  if (pNode1 == 0) {
530  silent_cerr("model::vrel" << when2str(when) << IDX2str(IDX)
531  << "(" << uLabel1 << "," << uLabel2 << "): "
532  "unable to find StructNode(" << uLabel1 << ")"
533  << std::endl);
535  }
536 
537  const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
538  if (pNode2 == 0) {
539  silent_cerr("model::vrel" << when2str(when) << IDX2str(IDX)
540  << "(" << uLabel1 << "," << uLabel2 << "): "
541  "unable to find StructNode(" << uLabel2 << ")"
542  << std::endl);
544  }
545 
546  Vec3 v;
547  switch (when) {
548  case CURR:
549  v = pNode2->GetVCurr() - pNode1->GetVCurr();
550  break;
551 
552  case PREV:
553  v = pNode2->GetVCurr() - pNode1->GetVPrev();
554  break;
555  }
556 
557  switch (IDX) {
558  case NORM:
559  *out = v.Norm();
560  break;
561 
562  case SQUARE:
563  *out = v.Dot();
564  break;
565 
566  default:
567  *out = v(IDX);
568  break;
569  }
570 
571  return 0;
572 }
573 
574 /*
575  * Computes the angular velocity of a structural node
576  */
577 template <IDX_t IDX, when_t when>
578 static int
580 {
581  ASSERT(args.size() == 1 + 1 + 1);
582  ASSERT(args[0]->Type() == MathParser::AT_REAL);
583  ASSERT(args[1]->Type() == MathParser::AT_INT);
584  ASSERT(args[2]->Type() == MathParser::AT_PRIVATE);
585 
586  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
587  ASSERT(out != 0);
588 
589  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
590  ASSERT(arg1 != 0);
591  ASSERT((*arg1)() >= 0);
592 
593  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[2]);
594  ASSERT(dm != 0);
595 
596  unsigned uLabel = unsigned((*arg1)());
597 
598  const StructNode *pNode = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel);
599  if (pNode == 0) {
600  silent_cerr("model::angvel" << when2str(when) << IDX2str(IDX)
601  << "(" << uLabel << "): "
602  "unable to find StructNode(" << uLabel << ")"
603  << std::endl);
605  }
606 
607  Vec3 w;
608  switch (when) {
609  case CURR:
610  w = pNode->GetWCurr();
611  break;
612 
613  case PREV:
614  w = pNode->GetWPrev();
615  break;
616  }
617 
618  switch (IDX) {
619  case NORM:
620  *out = w.Norm();
621  break;
622 
623  case SQUARE:
624  *out = w.Dot();
625  break;
626 
627  default:
628  *out = w(IDX);
629  break;
630  }
631 
632  return 0;
633 }
634 
635 /*
636  * Computes the relative angular velocity between two structural nodes
637  */
638 template <IDX_t IDX, when_t when>
639 static int
641 {
642  ASSERT(args.size() == 1 + 2 + 1);
643  ASSERT(args[0]->Type() == MathParser::AT_REAL);
644  ASSERT(args[1]->Type() == MathParser::AT_INT);
645  ASSERT(args[2]->Type() == MathParser::AT_INT);
646  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
647 
648  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
649  ASSERT(out != 0);
650 
651  MathParser::MathArgInt_t *arg1 = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
652  ASSERT(arg1 != 0);
653  ASSERT((*arg1)() >= 0);
654 
655  MathParser::MathArgInt_t *arg2 = dynamic_cast<MathParser::MathArgInt_t *>(args[2]);
656  ASSERT(arg2 != 0);
657  ASSERT((*arg2)() >= 0);
658 
659  ModelNameSpace::MathArgDM *dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[3]);
660  ASSERT(dm != 0);
661 
662  unsigned uLabel1 = unsigned((*arg1)());
663  unsigned uLabel2 = unsigned((*arg2)());
664 
665  const StructNode *pNode1 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel1);
666  if (pNode1 == 0) {
667  silent_cerr("model::angvrel" << when2str(when) << IDX2str(IDX)
668  << "(" << uLabel1 << "," << uLabel2 << "): "
669  "unable to find StructNode(" << uLabel1 << ")"
670  << std::endl);
672  }
673 
674  const StructNode *pNode2 = (*dm)()->pFindNode<const StructNode, Node::STRUCTURAL>(uLabel2);
675  if (pNode2 == 0) {
676  silent_cerr("model::angvrel" << when2str(when) << IDX2str(IDX)
677  << "(" << uLabel1 << "," << uLabel2 << "): "
678  "unable to find StructNode(" << uLabel2 << ")"
679  << std::endl);
681  }
682 
683  Vec3 w;
684  switch (when) {
685  case CURR:
686  w = pNode2->GetWCurr() - pNode1->GetWCurr();
687  break;
688 
689  case PREV:
690  w = pNode2->GetWPrev() - pNode1->GetWPrev();
691  break;
692  }
693 
694  switch (IDX) {
695  case NORM:
696  *out = w.Norm();
697  break;
698 
699  case SQUARE:
700  *out = w.Dot();
701  break;
702 
703  default:
704  *out = w(IDX);
705  break;
706  }
707 
708  return 0;
709 }
710 
711 /*
712  * Computes the value of a drive
713  */
714 template <bool p>
715 static int
717 {
718  ASSERT(args.size() == 1 + 2 + 2);
719  ASSERT(args[0]->Type() == MathParser::AT_REAL);
720  ASSERT(args[1]->Type() == MathParser::AT_INT);
721  ASSERT(args[2]->Type() == MathParser::AT_REAL);
722  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
723  ASSERT(args[4]->Type() == MathParser::AT_PRIVATE);
724 
725  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
726  ASSERT(out != 0);
727 
728  MathParser::MathArgReal_t *arg_val = dynamic_cast<MathParser::MathArgReal_t *>(args[2]);
729  ASSERT(arg_val != 0);
730 
731  ModelNameSpace::MathArgDCPtr *arg_ptr = dynamic_cast<ModelNameSpace::MathArgDCPtr *>(args[3]);
732  ASSERT(arg_ptr != 0);
733  const DriveCaller *pDC = (*arg_ptr)();
734  if (pDC == 0) {
735  MathParser::MathArgInt_t *arg_label = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
736  ASSERT(arg_label != 0);
737  ASSERT((*arg_label)() >= 0);
738 
739  unsigned uLabel = unsigned((*arg_label)());
740 
741  ModelNameSpace::MathArgDM *arg_dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[4]);
742  ASSERT(arg_dm != 0);
743 
744  pDC = (*arg_dm)()->GetMBDynParser().GetDrive(uLabel);
745  if (pDC == 0) {
746  silent_cerr("model::drive(" << uLabel << ") not available"
747  << std::endl);
749  }
750 
751  if (p) {
752  if (!pDC->bIsDifferentiable()) {
753  silent_cerr("model::drivep(" << uLabel << ") not differentiable"
754  << std::endl);
756  }
757  }
758 
759  if (arg_label->IsFlag(MathParser::AF_CONST)) {
760  (*arg_ptr)() = pDC;
761  }
762  }
763 
764  doublereal val = (*arg_val)();
765  if (p) {
766  ASSERT(pDC->bIsDifferentiable());
767 
768  *out = pDC->dGetP(val);
769 
770  } else {
771  *out = pDC->dGet(val);
772  }
773 
774  return 0;
775 }
776 
777 /*
778  * Computes the value of a scalar function
779  */
780 static int
782 {
783  ASSERT(args.size() == 1 + 2 + 1);
784  ASSERT(args[0]->Type() == MathParser::AT_REAL);
785  ASSERT(args[1]->Type() == MathParser::AT_REAL);
786  ASSERT(args[2]->Type() == MathParser::AT_INT);
787  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
788 
789  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
790  ASSERT(out != 0);
791 
792  MathParser::MathArgReal_t *arg1 = dynamic_cast<MathParser::MathArgReal_t *>(args[1]);
793  ASSERT(arg1 != 0);
794  doublereal v = (*arg1)();
795 
796  MathParser::MathArgInt_t *arg2 = dynamic_cast<MathParser::MathArgInt_t *>(args[2]);
797  ASSERT(arg2 != 0);
798  int order = (*arg2)();
799  ASSERT(order >= 0);
800 
801  ModelNameSpace::MathArgSF *sf = dynamic_cast<ModelNameSpace::MathArgSF *>(args[3]);
802  ASSERT(sf != 0);
803 
804  if (order < 0 || order > 1) {
805  silent_cerr("model::sf invalid derivative order " << order << std::endl);
807  }
808 
809  if (order == 0) {
810  *out = (*(*sf)())(v);
811 
812  } else {
813  const DifferentiableScalarFunction *dsf = dynamic_cast<const DifferentiableScalarFunction *>((*sf)());
814  if (dsf == 0) {
815  silent_cerr("model::sf "
816  "order=" << order << " only allowed "
817  "with differentiable scalar functions"
818  << std::endl);
820  }
821 
822  *out = dsf->ComputeDiff(v, order);
823  }
824 
825  return 0;
826 }
827 
828 /*
829  * Computes the value of a node's private data
830  */
831 static int
833 {
834  ASSERT(args.size() == 1 + 2 + 4);
835  ASSERT(args[0]->Type() == MathParser::AT_REAL);
836  ASSERT(args[1]->Type() == MathParser::AT_INT);
837  ASSERT(args[2]->Type() == MathParser::AT_STRING);
838  ASSERT(args[3]->Type() == MathParser::AT_PRIVATE);
839  ASSERT(args[4]->Type() == MathParser::AT_PRIVATE);
840  ASSERT(args[5]->Type() == MathParser::AT_PRIVATE);
841  ASSERT(args[6]->Type() == MathParser::AT_PRIVATE);
842 
843  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
844  ASSERT(out != 0);
845 
846  unsigned int idx = 0;
847  ModelNameSpace::MathArgSEIdx *arg_idx = dynamic_cast<ModelNameSpace::MathArgSEIdx *>(args[5]);
848  ASSERT(arg_idx != 0);
849 
850  ModelNameSpace::MathArgSEPtr *arg_ptr = dynamic_cast<ModelNameSpace::MathArgSEPtr *>(args[4]);
851  ASSERT(arg_ptr != 0);
852  const SimulationEntity *pNode = (*arg_ptr)();
853 
854  if (pNode == 0) {
855  MathParser::MathArgInt_t *arg_label = dynamic_cast<MathParser::MathArgInt_t *>(args[1]);
856  ASSERT(arg_label != 0);
857  int iLabel = (*arg_label)();
858 
859  MathParser::MathArgString_t *arg_val = dynamic_cast<MathParser::MathArgString_t *>(args[2]);
860  ASSERT(arg_val != 0);
861  std::string v = (*arg_val)();
862 
863  ModelNameSpace::MathArgNode *arg_type = dynamic_cast<ModelNameSpace::MathArgNode *>(args[3]);
864  ASSERT(arg_type != 0);
865  Node::Type type = (*arg_type)();
866 
867  ModelNameSpace::MathArgDM *arg_dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[6]);
868  ASSERT(arg_dm != 0);
869  const DataManager *pDM = (*arg_dm)();
870 
871  if (iLabel < 0) {
872  silent_cerr("model::node: invalid node label " << iLabel << std::endl);
874  }
875  unsigned uLabel = unsigned(iLabel);
876 
877  pNode = pDM->pFindNode(type, uLabel);
878  if (pNode == 0) {
879  silent_cerr("model::node: unable to find " << psNodeNames[type] << "(" << uLabel << ")" << std::endl);
881  }
882 
883  idx = pNode->iGetPrivDataIdx(v.c_str());
884  if (idx == 0) {
885  silent_cerr("model::node: " << psNodeNames[type] << "(" << dynamic_cast<const Node *>(pNode)->GetLabel() << "): invalid private data \"" << v << "\"" << std::endl);
887  }
888 
889  if (arg_label->IsFlag(MathParser::AF_CONST)) {
890  (*arg_ptr)() = pNode;
891 
892  /* NOTE: only set idx if node label is const,
893  * otherwise a different node could have a different idx
894  * for the same string */
895  if (arg_val->IsFlag(MathParser::AF_CONST)) {
896  (*arg_idx)() = idx;
897  }
898  }
899 
900  } else {
901  idx = (*arg_idx)();
902 
903  /* NOTE: pNode is saved, so we presume it was constant;
904  * apparently, idx was not constant, and we need to recompute it */
905  if (idx == 0) {
906  ASSERT(!arg_idx->IsFlag(MathParser::AF_CONST));
907 
908  MathParser::MathArgString_t *arg_val = dynamic_cast<MathParser::MathArgString_t *>(args[2]);
909  ASSERT(arg_val != 0);
910  std::string v = (*arg_val)();
911 
912  idx = pNode->iGetPrivDataIdx(v.c_str());
913  if (idx == 0) {
914  ModelNameSpace::MathArgNode *arg_type = dynamic_cast<ModelNameSpace::MathArgNode *>(args[3]);
915  ASSERT(arg_type != 0);
916  Node::Type type = (*arg_type)();
917 
918  silent_cerr("model::node: " << psNodeNames[type] << "(" << dynamic_cast<const Node *>(pNode)->GetLabel() << "): invalid private data \"" << v << "\"" << std::endl);
920  }
921  }
922  }
923 
924  *out = pNode->dGetPrivData(idx);
925 
926  return 0;
927 }
928 
929 /*
930  * Computes the value of an element's private data
931  */
932 template <bool unique>
933 static int
935 {
936  ASSERT(args.size() == 1 + 2 - unique + 4);
937 
938  static const unsigned int out_idx = 0;
939  static const unsigned int val_idx = 2 - (unique ? 1 : 0);
940  static const unsigned int type_idx = 3 - (unique ? 1 : 0);
941  static const unsigned int ptr_idx = 4 - (unique ? 1 : 0);
942  static const unsigned int idx_idx = 5 - (unique ? 1 : 0);
943  static const unsigned int dm_idx = 6 - (unique ? 1 : 0);
944 
945  ASSERT(args[out_idx]->Type() == MathParser::AT_REAL);
946  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[out_idx]);
947  ASSERT(out != 0);
948 
949  unsigned int idx = 0;
950  ModelNameSpace::MathArgSEIdx *arg_idx = dynamic_cast<ModelNameSpace::MathArgSEIdx *>(args[idx_idx]);
951  ASSERT(arg_idx != 0);
952 
953  ModelNameSpace::MathArgSEPtr *arg_ptr = dynamic_cast<ModelNameSpace::MathArgSEPtr *>(args[ptr_idx]);
954  ASSERT(arg_ptr != 0);
955  const SimulationEntity *pElem = (*arg_ptr)();
956 
957  if (pElem == 0) {
958  unsigned uLabel(-1);
959  bool bLabelConst(true);
960  if (!unique) {
961  static const unsigned int label_idx = 1; // undefined if unique == true
962 
963  ASSERT(args[label_idx]->Type() == MathParser::AT_INT);
964  MathParser::MathArgInt_t *arg_label = dynamic_cast<MathParser::MathArgInt_t *>(args[label_idx]);
965  ASSERT(arg_label != 0);
966  int iLabel = (*arg_label)();
967  if (iLabel < 0) {
968  silent_cerr("model::element: invalid element label " << iLabel << std::endl);
970  }
971  uLabel = unsigned(iLabel);
972  bLabelConst = arg_label->IsFlag(MathParser::AF_CONST);
973  }
974 
975  ASSERT(args[val_idx]->Type() == MathParser::AT_STRING);
976  MathParser::MathArgString_t *arg_val = dynamic_cast<MathParser::MathArgString_t *>(args[val_idx]);
977  ASSERT(arg_val != 0);
978  std::string v = (*arg_val)();
979 
980  ASSERT(args[type_idx]->Type() == MathParser::AT_PRIVATE);
981  ModelNameSpace::MathArgElem *arg_elem = dynamic_cast<ModelNameSpace::MathArgElem *>(args[type_idx]);
982  ASSERT(arg_elem != 0);
983  Elem::Type type = (*arg_elem)();
984 
985  ASSERT(args[dm_idx]->Type() == MathParser::AT_PRIVATE);
986  ModelNameSpace::MathArgDM *arg_dm = dynamic_cast<ModelNameSpace::MathArgDM *>(args[dm_idx]);
987  ASSERT(arg_dm != 0);
988  const DataManager *pDM = (*arg_dm)();
989 
990  pElem = pDM->pFindElem(type, uLabel);
991  if (pElem == 0) {
992  if (unique) {
993  silent_cerr("model::element: unable to find " << psElemNames[type] << std::endl);
994 
995  } else {
996  silent_cerr("model::element: unable to find " << psElemNames[type] << "(" << uLabel << ")" << std::endl);
997  }
999  }
1000 
1001  idx = pElem->iGetPrivDataIdx(v.c_str());
1002  if (idx == 0) {
1003  if (unique) {
1004  silent_cerr("model::element: " << psElemNames[type] << ": invalid private data \"" << v << "\"" << std::endl);
1005 
1006  } else {
1007  silent_cerr("model::element: " << psElemNames[type] << "(" << dynamic_cast<const Elem *>(pElem)->GetLabel() << "): invalid private data \"" << v << "\"" << std::endl);
1008  }
1010  }
1011 
1012  if (unique || bLabelConst) {
1013  (*arg_ptr)() = pElem;
1014 
1015  /* NOTE: only set idx if element label is const,
1016  * otherwise a different element could have a different idx
1017  * for the same string */
1018  if (arg_val->IsFlag(MathParser::AF_CONST)) {
1019  (*arg_idx)() = idx;
1020  }
1021  }
1022 
1023  } else {
1024  idx = (*arg_idx)();
1025 
1026  /* NOTE: pElem is saved, so we presume it was constant;
1027  * apparently, idx was not constant, and we need to recompute it */
1028  if (idx == 0) {
1029  ASSERT(!arg_idx->IsFlag(MathParser::AF_CONST));
1030 
1031  MathParser::MathArgString_t *arg_val = dynamic_cast<MathParser::MathArgString_t *>(args[val_idx]);
1032  ASSERT(arg_val != 0);
1033  std::string v = (*arg_val)();
1034 
1035  idx = pElem->iGetPrivDataIdx(v.c_str());
1036  if (idx == 0) {
1037  ModelNameSpace::MathArgElem *arg_type = dynamic_cast<ModelNameSpace::MathArgElem *>(args[type_idx]);
1038  ASSERT(arg_type != 0);
1039  Elem::Type type = (*arg_type)();
1040 
1041  if (unique) {
1042  silent_cerr("model::element: " << psElemNames[type] << ": invalid private data \"" << v << "\"" << std::endl);
1043 
1044  } else {
1045  silent_cerr("model::element: " << psElemNames[type] << "(" << dynamic_cast<const Elem *>(pElem)->GetLabel() << "): invalid private data \"" << v << "\"" << std::endl);
1046  }
1048  }
1049  }
1050  }
1051 
1052  *out = pElem->dGetPrivData(idx);
1053 
1054  return 0;
1055 }
1056 
1057 /*
1058  * Computes the value of the current simulation entity's private data
1059  */
1060 static int
1062 {
1063  ASSERT(args.size() == 1 + 1 + 2);
1064 
1065  ASSERT(args[0]->Type() == MathParser::AT_REAL);
1066  MathParser::MathArgReal_t *out = dynamic_cast<MathParser::MathArgReal_t *>(args[0]);
1067  ASSERT(out != 0);
1068 
1069  ASSERT(args[1]->Type() == MathParser::AT_STRING);
1070  MathParser::MathArgString_t *arg_name = dynamic_cast<MathParser::MathArgString_t *>(args[1]);
1071  ASSERT(arg_name != 0);
1072  const std::string& name = (*arg_name)();
1073 
1074  ASSERT(args[2]->Type() == MathParser::AT_PRIVATE);
1075  ModelNameSpace::MathArgMNS *arg_mns = dynamic_cast<ModelNameSpace::MathArgMNS *>(args[2]);
1076  ASSERT(arg_mns != 0);
1077  const ModelNameSpace *pMNS = (*arg_mns)();
1078 
1079  TypedValue value;
1080  if (!pMNS->GetCurrData(name, value)) {
1081  silent_cerr("model::current(" << name << ") not defined" << std::endl);
1083  }
1084 
1085  *out = value.GetReal();
1086 
1087  return 0;
1088 }
1089 
1091 : MathParser::NameSpace("model"), pDM(pDM)
1092 {
1094 
1095  // position
1096  f = new MathParser::MathFunc_t;
1097  f->fname = "position";
1098  f->ns = this;
1099  f->args.resize(1 + 1 + 1);
1100  f->args[0] = new MathParser::MathArgReal_t;
1101  f->args[1] = new MathParser::MathArgInt_t;
1102  f->args[2] = new MathArgDM(pDM);
1103  f->f = position<NORM, CURR>;
1104  f->t = 0;
1105 
1106  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1107  silent_cerr("model namespace: "
1108  "unable to insert handler "
1109  "for function " << f->fname << std::endl);
1111  }
1112 
1113  // position2
1114  f = new MathParser::MathFunc_t;
1115  f->fname = "position2";
1116  f->ns = this;
1117  f->args.resize(1 + 1 + 1);
1118  f->args[0] = new MathParser::MathArgReal_t;
1119  f->args[1] = new MathParser::MathArgInt_t;
1120  f->args[2] = new MathArgDM(pDM);
1121  f->f = position<SQUARE, CURR>;
1122  f->t = 0;
1123 
1124  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1125  silent_cerr("model namespace: "
1126  "unable to insert handler "
1127  "for function " << f->fname << std::endl);
1129  }
1130 
1131  // xposition
1132  f = new MathParser::MathFunc_t;
1133  f->fname = "xposition";
1134  f->ns = this;
1135  f->args.resize(1 + 1 + 1);
1136  f->args[0] = new MathParser::MathArgReal_t;
1137  f->args[1] = new MathParser::MathArgInt_t;
1138  f->args[2] = new MathArgDM(pDM);
1139  f->f = position<IDX1, CURR>;
1140  f->t = 0;
1141 
1142  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1143  silent_cerr("model namespace: "
1144  "unable to insert handler "
1145  "for function " << f->fname << std::endl);
1147  }
1148 
1149  // yposition
1150  f = new MathParser::MathFunc_t;
1151  f->fname = "yposition";
1152  f->ns = this;
1153  f->args.resize(1 + 1 + 1);
1154  f->args[0] = new MathParser::MathArgReal_t;
1155  f->args[1] = new MathParser::MathArgInt_t;
1156  f->args[2] = new MathArgDM(pDM);
1157  f->f = position<IDX2, CURR>;
1158  f->t = 0;
1159 
1160  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1161  silent_cerr("model namespace: "
1162  "unable to insert handler "
1163  "for function " << f->fname << std::endl);
1165  }
1166 
1167  // zposition
1168  f = new MathParser::MathFunc_t;
1169  f->fname = "zposition";
1170  f->ns = this;
1171  f->args.resize(1 + 1 + 1);
1172  f->args[0] = new MathParser::MathArgReal_t;
1173  f->args[1] = new MathParser::MathArgInt_t;
1174  f->args[2] = new MathArgDM(pDM);
1175  f->f = position<IDX3, CURR>;
1176  f->t = 0;
1177 
1178  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1179  silent_cerr("model namespace: "
1180  "unable to insert handler "
1181  "for function " << f->fname << std::endl);
1183  }
1184 
1185  // distance
1186  f = new MathParser::MathFunc_t;
1187  f->fname = "distance";
1188  f->ns = this;
1189  f->args.resize(1 + 2 + 1);
1190  f->args[0] = new MathParser::MathArgReal_t;
1191  f->args[1] = new MathParser::MathArgInt_t;
1192  f->args[2] = new MathParser::MathArgInt_t;
1193  f->args[3] = new MathArgDM(pDM);
1194  f->f = distance<NORM, CURR>;
1195  f->t = 0;
1196 
1197  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1198  silent_cerr("model namespace: "
1199  "unable to insert handler "
1200  "for function " << f->fname << std::endl);
1202  }
1203 
1204  // distance2
1205  f = new MathParser::MathFunc_t;
1206  f->fname = "distance2";
1207  f->ns = this;
1208  f->args.resize(1 + 2 + 1);
1209  f->args[0] = new MathParser::MathArgReal_t;
1210  f->args[1] = new MathParser::MathArgInt_t;
1211  f->args[2] = new MathParser::MathArgInt_t;
1212  f->args[3] = new MathArgDM(pDM);
1213  f->f = distance<SQUARE, CURR>;
1214  f->t = 0;
1215 
1216  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1217  silent_cerr("model namespace: "
1218  "unable to insert handler "
1219  "for function " << f->fname << std::endl);
1221  }
1222 
1223  // xdistance
1224  f = new MathParser::MathFunc_t;
1225  f->fname = "xdistance";
1226  f->ns = this;
1227  f->args.resize(1 + 2 + 1);
1228  f->args[0] = new MathParser::MathArgReal_t;
1229  f->args[1] = new MathParser::MathArgInt_t;
1230  f->args[2] = new MathParser::MathArgInt_t;
1231  f->args[3] = new MathArgDM(pDM);
1232  f->f = distance<IDX1, CURR>;
1233  f->t = 0;
1234 
1235  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1236  silent_cerr("model namespace: "
1237  "unable to insert handler "
1238  "for function " << f->fname << std::endl);
1240  }
1241 
1242  // ydistance
1243  f = new MathParser::MathFunc_t;
1244  f->fname = "ydistance";
1245  f->ns = this;
1246  f->args.resize(1 + 2 + 1);
1247  f->args[0] = new MathParser::MathArgReal_t;
1248  f->args[1] = new MathParser::MathArgInt_t;
1249  f->args[2] = new MathParser::MathArgInt_t;
1250  f->args[3] = new MathArgDM(pDM);
1251  f->f = distance<IDX2, CURR>;
1252  f->t = 0;
1253 
1254  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1255  silent_cerr("model namespace: "
1256  "unable to insert handler "
1257  "for function " << f->fname << std::endl);
1259  }
1260 
1261  // zdistance
1262  f = new MathParser::MathFunc_t;
1263  f->fname = "zdistance";
1264  f->ns = this;
1265  f->args.resize(1 + 2 + 1);
1266  f->args[0] = new MathParser::MathArgReal_t;
1267  f->args[1] = new MathParser::MathArgInt_t;
1268  f->args[2] = new MathParser::MathArgInt_t;
1269  f->args[3] = new MathArgDM(pDM);
1270  f->f = distance<IDX3, CURR>;
1271  f->t = 0;
1272 
1273  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1274  silent_cerr("model namespace: "
1275  "unable to insert handler "
1276  "for function " << f->fname << std::endl);
1278  }
1279 
1280  // xunitvec
1281  f = new MathParser::MathFunc_t;
1282  f->fname = "xunitvec";
1283  f->ns = this;
1284  f->args.resize(1 + 2 + 1);
1285  f->args[0] = new MathParser::MathArgReal_t;
1286  f->args[1] = new MathParser::MathArgInt_t;
1287  f->args[2] = new MathParser::MathArgInt_t;
1288  f->args[3] = new MathArgDM(pDM);
1289  f->f = unitvec<IDX1, CURR>;
1290  f->t = 0;
1291 
1292  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1293  silent_cerr("model namespace: "
1294  "unable to insert handler "
1295  "for function " << f->fname << std::endl);
1297  }
1298 
1299  // yunitvec
1300  f = new MathParser::MathFunc_t;
1301  f->fname = "yunitvec";
1302  f->ns = this;
1303  f->args.resize(1 + 2 + 1);
1304  f->args[0] = new MathParser::MathArgReal_t;
1305  f->args[1] = new MathParser::MathArgInt_t;
1306  f->args[2] = new MathParser::MathArgInt_t;
1307  f->args[3] = new MathArgDM(pDM);
1308  f->f = unitvec<IDX2, CURR>;
1309  f->t = 0;
1310 
1311  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1312  silent_cerr("model namespace: "
1313  "unable to insert handler "
1314  "for function " << f->fname << std::endl);
1316  }
1317 
1318  // zunitvec
1319  f = new MathParser::MathFunc_t;
1320  f->fname = "zunitvec";
1321  f->ns = this;
1322  f->args.resize(1 + 2 + 1);
1323  f->args[0] = new MathParser::MathArgReal_t;
1324  f->args[1] = new MathParser::MathArgInt_t;
1325  f->args[2] = new MathParser::MathArgInt_t;
1326  f->args[3] = new MathArgDM(pDM);
1327  f->f = unitvec<IDX3, CURR>;
1328  f->t = 0;
1329 
1330  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1331  silent_cerr("model namespace: "
1332  "unable to insert handler "
1333  "for function " << f->fname << std::endl);
1335  }
1336 
1337  // angle
1338  f = new MathParser::MathFunc_t;
1339  f->fname = "angle";
1340  f->ns = this;
1341  f->args.resize(1 + 1 + 1);
1342  f->args[0] = new MathParser::MathArgReal_t;
1343  f->args[1] = new MathParser::MathArgInt_t;
1344  f->args[2] = new MathArgDM(pDM);
1345  f->f = angle<NORM, CURR>;
1346  f->t = 0;
1347 
1348  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1349  silent_cerr("model namespace: "
1350  "unable to insert handler "
1351  "for function " << f->fname << std::endl);
1353  }
1354 
1355  // xangle
1356  f = new MathParser::MathFunc_t;
1357  f->fname = "xangle";
1358  f->ns = this;
1359  f->args.resize(1 + 1 + 1);
1360  f->args[0] = new MathParser::MathArgReal_t;
1361  f->args[1] = new MathParser::MathArgInt_t;
1362  f->args[2] = new MathArgDM(pDM);
1363  f->f = angle<IDX1, CURR>;
1364  f->t = 0;
1365 
1366  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1367  silent_cerr("model namespace: "
1368  "unable to insert handler "
1369  "for function " << f->fname << std::endl);
1371  }
1372 
1373  // yangle
1374  f = new MathParser::MathFunc_t;
1375  f->fname = "yangle";
1376  f->ns = this;
1377  f->args.resize(1 + 1 + 1);
1378  f->args[0] = new MathParser::MathArgReal_t;
1379  f->args[1] = new MathParser::MathArgInt_t;
1380  f->args[2] = new MathArgDM(pDM);
1381  f->f = angle<IDX2, CURR>;
1382  f->t = 0;
1383 
1384  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1385  silent_cerr("model namespace: "
1386  "unable to insert handler "
1387  "for function " << f->fname << std::endl);
1389  }
1390 
1391  // zangle
1392  f = new MathParser::MathFunc_t;
1393  f->fname = "zangle";
1394  f->ns = this;
1395  f->args.resize(1 + 1 + 1);
1396  f->args[0] = new MathParser::MathArgReal_t;
1397  f->args[1] = new MathParser::MathArgInt_t;
1398  f->args[2] = new MathArgDM(pDM);
1399  f->f = angle<IDX3, CURR>;
1400  f->t = 0;
1401 
1402  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1403  silent_cerr("model namespace: "
1404  "unable to insert handler "
1405  "for function " << f->fname << std::endl);
1407  }
1408 
1409  // anglerel
1410  f = new MathParser::MathFunc_t;
1411  f->fname = "anglerel";
1412  f->ns = this;
1413  f->args.resize(1 + 2 + 1);
1414  f->args[0] = new MathParser::MathArgReal_t;
1415  f->args[1] = new MathParser::MathArgInt_t;
1416  f->args[2] = new MathParser::MathArgInt_t;
1417  f->args[3] = new MathArgDM(pDM);
1418  f->f = anglerel<NORM, CURR>;
1419  f->t = 0;
1420 
1421  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1422  silent_cerr("model namespace: "
1423  "unable to insert handler "
1424  "for function " << f->fname << std::endl);
1426  }
1427 
1428  // xanglerel
1429  f = new MathParser::MathFunc_t;
1430  f->fname = "xanglerel";
1431  f->ns = this;
1432  f->args.resize(1 + 2 + 1);
1433  f->args[0] = new MathParser::MathArgReal_t;
1434  f->args[1] = new MathParser::MathArgInt_t;
1435  f->args[2] = new MathParser::MathArgInt_t;
1436  f->args[3] = new MathArgDM(pDM);
1437  f->f = anglerel<IDX1, CURR>;
1438  f->t = 0;
1439 
1440  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1441  silent_cerr("model namespace: "
1442  "unable to insert handler "
1443  "for function " << f->fname << std::endl);
1445  }
1446 
1447  // yanglerel
1448  f = new MathParser::MathFunc_t;
1449  f->fname = "yanglerel";
1450  f->ns = this;
1451  f->args.resize(1 + 2 + 1);
1452  f->args[0] = new MathParser::MathArgReal_t;
1453  f->args[1] = new MathParser::MathArgInt_t;
1454  f->args[2] = new MathParser::MathArgInt_t;
1455  f->args[3] = new MathArgDM(pDM);
1456  f->f = anglerel<IDX2, CURR>;
1457  f->t = 0;
1458 
1459  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1460  silent_cerr("model namespace: "
1461  "unable to insert handler "
1462  "for function " << f->fname << std::endl);
1464  }
1465 
1466  // zanglerel
1467  f = new MathParser::MathFunc_t;
1468  f->fname = "zanglerel";
1469  f->ns = this;
1470  f->args.resize(1 + 2 + 1);
1471  f->args[0] = new MathParser::MathArgReal_t;
1472  f->args[1] = new MathParser::MathArgInt_t;
1473  f->args[2] = new MathParser::MathArgInt_t;
1474  f->args[3] = new MathArgDM(pDM);
1475  f->f = anglerel<IDX3, CURR>;
1476  f->t = 0;
1477 
1478  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1479  silent_cerr("model namespace: "
1480  "unable to insert handler "
1481  "for function " << f->fname << std::endl);
1483  }
1484 
1485  // velocity
1486  f = new MathParser::MathFunc_t;
1487  f->fname = "velocity";
1488  f->ns = this;
1489  f->args.resize(1 + 1 + 1);
1490  f->args[0] = new MathParser::MathArgReal_t;
1491  f->args[1] = new MathParser::MathArgInt_t;
1492  f->args[2] = new MathArgDM(pDM);
1493  f->f = velocity<NORM, CURR>;
1494  f->t = 0;
1495 
1496  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1497  silent_cerr("model namespace: "
1498  "unable to insert handler "
1499  "for function " << f->fname << std::endl);
1501  }
1502 
1503  // velocity2
1504  f = new MathParser::MathFunc_t;
1505  f->fname = "velocity2";
1506  f->ns = this;
1507  f->args.resize(1 + 1 + 1);
1508  f->args[0] = new MathParser::MathArgReal_t;
1509  f->args[1] = new MathParser::MathArgInt_t;
1510  f->args[2] = new MathArgDM(pDM);
1511  f->f = velocity<SQUARE, CURR>;
1512  f->t = 0;
1513 
1514  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1515  silent_cerr("model namespace: "
1516  "unable to insert handler "
1517  "for function " << f->fname << std::endl);
1519  }
1520 
1521  // xvelocity
1522  f = new MathParser::MathFunc_t;
1523  f->fname = "xvelocity";
1524  f->ns = this;
1525  f->args.resize(1 + 1 + 1);
1526  f->args[0] = new MathParser::MathArgReal_t;
1527  f->args[1] = new MathParser::MathArgInt_t;
1528  f->args[2] = new MathArgDM(pDM);
1529  f->f = velocity<IDX1, CURR>;
1530  f->t = 0;
1531 
1532  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1533  silent_cerr("model namespace: "
1534  "unable to insert handler "
1535  "for function " << f->fname << std::endl);
1537  }
1538 
1539  // yvelocity
1540  f = new MathParser::MathFunc_t;
1541  f->fname = "yvelocity";
1542  f->ns = this;
1543  f->args.resize(1 + 1 + 1);
1544  f->args[0] = new MathParser::MathArgReal_t;
1545  f->args[1] = new MathParser::MathArgInt_t;
1546  f->args[2] = new MathArgDM(pDM);
1547  f->f = velocity<IDX2, CURR>;
1548  f->t = 0;
1549 
1550  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1551  silent_cerr("model namespace: "
1552  "unable to insert handler "
1553  "for function " << f->fname << std::endl);
1555  }
1556 
1557  // zvelocity
1558  f = new MathParser::MathFunc_t;
1559  f->fname = "zvelocity";
1560  f->ns = this;
1561  f->args.resize(1 + 1 + 1);
1562  f->args[0] = new MathParser::MathArgReal_t;
1563  f->args[1] = new MathParser::MathArgInt_t;
1564  f->args[2] = new MathArgDM(pDM);
1565  f->f = velocity<IDX3, CURR>;
1566  f->t = 0;
1567 
1568  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1569  silent_cerr("model namespace: "
1570  "unable to insert handler "
1571  "for function " << f->fname << std::endl);
1573  }
1574 
1575  // vrel
1576  f = new MathParser::MathFunc_t;
1577  f->fname = "vrel";
1578  f->ns = this;
1579  f->args.resize(1 + 2 + 1);
1580  f->args[0] = new MathParser::MathArgReal_t;
1581  f->args[1] = new MathParser::MathArgInt_t;
1582  f->args[2] = new MathParser::MathArgInt_t;
1583  f->args[3] = new MathArgDM(pDM);
1584  f->f = vrel<NORM, CURR>;
1585  f->t = 0;
1586 
1587  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1588  silent_cerr("model namespace: "
1589  "unable to insert handler "
1590  "for function " << f->fname << std::endl);
1592  }
1593 
1594  // vrel2
1595  f = new MathParser::MathFunc_t;
1596  f->fname = "vrel2";
1597  f->ns = this;
1598  f->args.resize(1 + 2 + 1);
1599  f->args[0] = new MathParser::MathArgReal_t;
1600  f->args[1] = new MathParser::MathArgInt_t;
1601  f->args[2] = new MathParser::MathArgInt_t;
1602  f->args[3] = new MathArgDM(pDM);
1603  f->f = vrel<SQUARE, CURR>;
1604  f->t = 0;
1605 
1606  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1607  silent_cerr("model namespace: "
1608  "unable to insert handler "
1609  "for function " << f->fname << std::endl);
1611  }
1612 
1613  // xvrel
1614  f = new MathParser::MathFunc_t;
1615  f->fname = "xvrel";
1616  f->ns = this;
1617  f->args.resize(1 + 2 + 1);
1618  f->args[0] = new MathParser::MathArgReal_t;
1619  f->args[1] = new MathParser::MathArgInt_t;
1620  f->args[2] = new MathParser::MathArgInt_t;
1621  f->args[3] = new MathArgDM(pDM);
1622  f->f = vrel<IDX1, CURR>;
1623  f->t = 0;
1624 
1625  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1626  silent_cerr("model namespace: "
1627  "unable to insert handler "
1628  "for function " << f->fname << std::endl);
1630  }
1631 
1632  // yvrel
1633  f = new MathParser::MathFunc_t;
1634  f->fname = "yvrel";
1635  f->ns = this;
1636  f->args.resize(1 + 2 + 1);
1637  f->args[0] = new MathParser::MathArgReal_t;
1638  f->args[1] = new MathParser::MathArgInt_t;
1639  f->args[2] = new MathParser::MathArgInt_t;
1640  f->args[3] = new MathArgDM(pDM);
1641  f->f = vrel<IDX2, CURR>;
1642  f->t = 0;
1643 
1644  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1645  silent_cerr("model namespace: "
1646  "unable to insert handler "
1647  "for function " << f->fname << std::endl);
1649  }
1650 
1651  // zvrel
1652  f = new MathParser::MathFunc_t;
1653  f->fname = "zvrel";
1654  f->ns = this;
1655  f->args.resize(1 + 2 + 1);
1656  f->args[0] = new MathParser::MathArgReal_t;
1657  f->args[1] = new MathParser::MathArgInt_t;
1658  f->args[2] = new MathParser::MathArgInt_t;
1659  f->args[3] = new MathArgDM(pDM);
1660  f->f = vrel<IDX3, CURR>;
1661  f->t = 0;
1662 
1663  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1664  silent_cerr("model namespace: "
1665  "unable to insert handler "
1666  "for function " << f->fname << std::endl);
1668  }
1669 
1670  // angvel
1671  f = new MathParser::MathFunc_t;
1672  f->fname = "angvel";
1673  f->ns = this;
1674  f->args.resize(1 + 1 + 1);
1675  f->args[0] = new MathParser::MathArgReal_t;
1676  f->args[1] = new MathParser::MathArgInt_t;
1677  f->args[2] = new MathArgDM(pDM);
1678  f->f = angvel<NORM, CURR>;
1679  f->t = 0;
1680 
1681  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1682  silent_cerr("model namespace: "
1683  "unable to insert handler "
1684  "for function " << f->fname << std::endl);
1686  }
1687 
1688  // angvel
1689  f = new MathParser::MathFunc_t;
1690  f->fname = "angvel2";
1691  f->ns = this;
1692  f->args.resize(1 + 1 + 1);
1693  f->args[0] = new MathParser::MathArgReal_t;
1694  f->args[1] = new MathParser::MathArgInt_t;
1695  f->args[2] = new MathArgDM(pDM);
1696  f->f = angvel<SQUARE, CURR>;
1697  f->t = 0;
1698 
1699  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1700  silent_cerr("model namespace: "
1701  "unable to insert handler "
1702  "for function " << f->fname << std::endl);
1704  }
1705 
1706  // xangvel
1707  f = new MathParser::MathFunc_t;
1708  f->fname = "xangvel";
1709  f->ns = this;
1710  f->args.resize(1 + 1 + 1);
1711  f->args[0] = new MathParser::MathArgReal_t;
1712  f->args[1] = new MathParser::MathArgInt_t;
1713  f->args[2] = new MathArgDM(pDM);
1714  f->f = angvel<IDX1, CURR>;
1715  f->t = 0;
1716 
1717  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1718  silent_cerr("model namespace: "
1719  "unable to insert handler "
1720  "for function " << f->fname << std::endl);
1722  }
1723 
1724  // yangvel
1725  f = new MathParser::MathFunc_t;
1726  f->fname = "yangvel";
1727  f->ns = this;
1728  f->args.resize(1 + 1 + 1);
1729  f->args[0] = new MathParser::MathArgReal_t;
1730  f->args[1] = new MathParser::MathArgInt_t;
1731  f->args[2] = new MathArgDM(pDM);
1732  f->f = angvel<IDX2, CURR>;
1733  f->t = 0;
1734 
1735  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1736  silent_cerr("model namespace: "
1737  "unable to insert handler "
1738  "for function " << f->fname << std::endl);
1740  }
1741 
1742  // zangvel
1743  f = new MathParser::MathFunc_t;
1744  f->fname = "zangvel";
1745  f->ns = this;
1746  f->args.resize(1 + 1 + 1);
1747  f->args[0] = new MathParser::MathArgReal_t;
1748  f->args[1] = new MathParser::MathArgInt_t;
1749  f->args[2] = new MathArgDM(pDM);
1750  f->f = angvel<IDX3, CURR>;
1751  f->t = 0;
1752 
1753  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1754  silent_cerr("model namespace: "
1755  "unable to insert handler "
1756  "for function " << f->fname << std::endl);
1758  }
1759 
1760  // angvrel
1761  f = new MathParser::MathFunc_t;
1762  f->fname = "angvrel";
1763  f->ns = this;
1764  f->args.resize(1 + 2 + 1);
1765  f->args[0] = new MathParser::MathArgReal_t;
1766  f->args[1] = new MathParser::MathArgInt_t;
1767  f->args[2] = new MathParser::MathArgInt_t;
1768  f->args[3] = new MathArgDM(pDM);
1769  f->f = angvrel<NORM, CURR>;
1770  f->t = 0;
1771 
1772  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1773  silent_cerr("model namespace: "
1774  "unable to insert handler "
1775  "for function " << f->fname << std::endl);
1777  }
1778 
1779  // angvrel2
1780  f = new MathParser::MathFunc_t;
1781  f->fname = "angvrel2";
1782  f->ns = this;
1783  f->args.resize(1 + 2 + 1);
1784  f->args[0] = new MathParser::MathArgReal_t;
1785  f->args[1] = new MathParser::MathArgInt_t;
1786  f->args[2] = new MathParser::MathArgInt_t;
1787  f->args[3] = new MathArgDM(pDM);
1788  f->f = angvrel<SQUARE, CURR>;
1789  f->t = 0;
1790 
1791  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1792  silent_cerr("model namespace: "
1793  "unable to insert handler "
1794  "for function " << f->fname << std::endl);
1796  }
1797 
1798  // xangvrel
1799  f = new MathParser::MathFunc_t;
1800  f->fname = "xangvrel";
1801  f->ns = this;
1802  f->args.resize(1 + 2 + 1);
1803  f->args[0] = new MathParser::MathArgReal_t;
1804  f->args[1] = new MathParser::MathArgInt_t;
1805  f->args[2] = new MathParser::MathArgInt_t;
1806  f->args[3] = new MathArgDM(pDM);
1807  f->f = angvrel<IDX1, CURR>;
1808  f->t = 0;
1809 
1810  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1811  silent_cerr("model namespace: "
1812  "unable to insert handler "
1813  "for function " << f->fname << std::endl);
1815  }
1816 
1817  // yangvrel
1818  f = new MathParser::MathFunc_t;
1819  f->fname = "yangvrel";
1820  f->ns = this;
1821  f->args.resize(1 + 2 + 1);
1822  f->args[0] = new MathParser::MathArgReal_t;
1823  f->args[1] = new MathParser::MathArgInt_t;
1824  f->args[2] = new MathParser::MathArgInt_t;
1825  f->args[3] = new MathArgDM(pDM);
1826  f->f = angvrel<IDX2, CURR>;
1827  f->t = 0;
1828 
1829  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1830  silent_cerr("model namespace: "
1831  "unable to insert handler "
1832  "for function " << f->fname << std::endl);
1834  }
1835 
1836  // zangvrel
1837  f = new MathParser::MathFunc_t;
1838  f->fname = "zangvrel";
1839  f->ns = this;
1840  f->args.resize(1 + 2 + 1);
1841  f->args[0] = new MathParser::MathArgReal_t;
1842  f->args[1] = new MathParser::MathArgInt_t;
1843  f->args[2] = new MathParser::MathArgInt_t;
1844  f->args[3] = new MathArgDM(pDM);
1845  f->f = angvrel<IDX3, CURR>;
1846  f->t = 0;
1847 
1848  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1849  silent_cerr("model namespace: "
1850  "unable to insert handler "
1851  "for function " << f->fname << std::endl);
1853  }
1854 
1855  // position_prev
1856  f = new MathParser::MathFunc_t;
1857  f->fname = "position_prev";
1858  f->ns = this;
1859  f->args.resize(1 + 1 + 1);
1860  f->args[0] = new MathParser::MathArgReal_t;
1861  f->args[1] = new MathParser::MathArgInt_t;
1862  f->args[2] = new MathArgDM(pDM);
1863  f->f = position<NORM, PREV>;
1864  f->t = 0;
1865 
1866  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1867  silent_cerr("model namespace: "
1868  "unable to insert handler "
1869  "for function " << f->fname << std::endl);
1871  }
1872 
1873  // position2_prev
1874  f = new MathParser::MathFunc_t;
1875  f->fname = "position2_prev";
1876  f->ns = this;
1877  f->args.resize(1 + 1 + 1);
1878  f->args[0] = new MathParser::MathArgReal_t;
1879  f->args[1] = new MathParser::MathArgInt_t;
1880  f->args[2] = new MathArgDM(pDM);
1881  f->f = position<SQUARE, PREV>;
1882  f->t = 0;
1883 
1884  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1885  silent_cerr("model namespace: "
1886  "unable to insert handler "
1887  "for function " << f->fname << std::endl);
1889  }
1890 
1891  // xposition_prev
1892  f = new MathParser::MathFunc_t;
1893  f->fname = "xposition_prev";
1894  f->ns = this;
1895  f->args.resize(1 + 1 + 1);
1896  f->args[0] = new MathParser::MathArgReal_t;
1897  f->args[1] = new MathParser::MathArgInt_t;
1898  f->args[2] = new MathArgDM(pDM);
1899  f->f = position<IDX1, PREV>;
1900  f->t = 0;
1901 
1902  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1903  silent_cerr("model namespace: "
1904  "unable to insert handler "
1905  "for function " << f->fname << std::endl);
1907  }
1908 
1909  // yposition_prev
1910  f = new MathParser::MathFunc_t;
1911  f->fname = "yposition_prev";
1912  f->ns = this;
1913  f->args.resize(1 + 1 + 1);
1914  f->args[0] = new MathParser::MathArgReal_t;
1915  f->args[1] = new MathParser::MathArgInt_t;
1916  f->args[2] = new MathArgDM(pDM);
1917  f->f = position<IDX2, PREV>;
1918  f->t = 0;
1919 
1920  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1921  silent_cerr("model namespace: "
1922  "unable to insert handler "
1923  "for function " << f->fname << std::endl);
1925  }
1926 
1927  // zposition_prev
1928  f = new MathParser::MathFunc_t;
1929  f->fname = "zposition_prev";
1930  f->ns = this;
1931  f->args.resize(1 + 1 + 1);
1932  f->args[0] = new MathParser::MathArgReal_t;
1933  f->args[1] = new MathParser::MathArgInt_t;
1934  f->args[2] = new MathArgDM(pDM);
1935  f->f = position<IDX3, PREV>;
1936  f->t = 0;
1937 
1938  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1939  silent_cerr("model namespace: "
1940  "unable to insert handler "
1941  "for function " << f->fname << std::endl);
1943  }
1944 
1945  // distance_prev
1946  f = new MathParser::MathFunc_t;
1947  f->fname = "distance_prev";
1948  f->ns = this;
1949  f->args.resize(1 + 2 + 1);
1950  f->args[0] = new MathParser::MathArgReal_t;
1951  f->args[1] = new MathParser::MathArgInt_t;
1952  f->args[2] = new MathParser::MathArgInt_t;
1953  f->args[3] = new MathArgDM(pDM);
1954  f->f = distance<NORM, PREV>;
1955  f->t = 0;
1956 
1957  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1958  silent_cerr("model namespace: "
1959  "unable to insert handler "
1960  "for function " << f->fname << std::endl);
1962  }
1963 
1964  // distance2_prev
1965  f = new MathParser::MathFunc_t;
1966  f->fname = "distance2_prev";
1967  f->ns = this;
1968  f->args.resize(1 + 2 + 1);
1969  f->args[0] = new MathParser::MathArgReal_t;
1970  f->args[1] = new MathParser::MathArgInt_t;
1971  f->args[2] = new MathParser::MathArgInt_t;
1972  f->args[3] = new MathArgDM(pDM);
1973  f->f = distance<SQUARE, PREV>;
1974  f->t = 0;
1975 
1976  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1977  silent_cerr("model namespace: "
1978  "unable to insert handler "
1979  "for function " << f->fname << std::endl);
1981  }
1982 
1983  // xdistance_prev
1984  f = new MathParser::MathFunc_t;
1985  f->fname = "xdistance_prev";
1986  f->ns = this;
1987  f->args.resize(1 + 2 + 1);
1988  f->args[0] = new MathParser::MathArgReal_t;
1989  f->args[1] = new MathParser::MathArgInt_t;
1990  f->args[2] = new MathParser::MathArgInt_t;
1991  f->args[3] = new MathArgDM(pDM);
1992  f->f = distance<IDX1, PREV>;
1993  f->t = 0;
1994 
1995  if (!func.insert(funcType::value_type(f->fname, f)).second) {
1996  silent_cerr("model namespace: "
1997  "unable to insert handler "
1998  "for function " << f->fname << std::endl);
2000  }
2001 
2002  // ydistance_prev
2003  f = new MathParser::MathFunc_t;
2004  f->fname = "ydistance_prev";
2005  f->ns = this;
2006  f->args.resize(1 + 2 + 1);
2007  f->args[0] = new MathParser::MathArgReal_t;
2008  f->args[1] = new MathParser::MathArgInt_t;
2009  f->args[2] = new MathParser::MathArgInt_t;
2010  f->args[3] = new MathArgDM(pDM);
2011  f->f = distance<IDX2, PREV>;
2012  f->t = 0;
2013 
2014  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2015  silent_cerr("model namespace: "
2016  "unable to insert handler "
2017  "for function " << f->fname << std::endl);
2019  }
2020 
2021  // zdistance_prev
2022  f = new MathParser::MathFunc_t;
2023  f->fname = "zdistance_prev";
2024  f->ns = this;
2025  f->args.resize(1 + 2 + 1);
2026  f->args[0] = new MathParser::MathArgReal_t;
2027  f->args[1] = new MathParser::MathArgInt_t;
2028  f->args[2] = new MathParser::MathArgInt_t;
2029  f->args[3] = new MathArgDM(pDM);
2030  f->f = distance<IDX3, PREV>;
2031  f->t = 0;
2032 
2033  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2034  silent_cerr("model namespace: "
2035  "unable to insert handler "
2036  "for function " << f->fname << std::endl);
2038  }
2039 
2040  // xunitvec_prev
2041  f = new MathParser::MathFunc_t;
2042  f->fname = "xunitvec_prev";
2043  f->ns = this;
2044  f->args.resize(1 + 2 + 1);
2045  f->args[0] = new MathParser::MathArgReal_t;
2046  f->args[1] = new MathParser::MathArgInt_t;
2047  f->args[2] = new MathParser::MathArgInt_t;
2048  f->args[3] = new MathArgDM(pDM);
2049  f->f = unitvec<IDX1, PREV>;
2050  f->t = 0;
2051 
2052  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2053  silent_cerr("model namespace: "
2054  "unable to insert handler "
2055  "for function " << f->fname << std::endl);
2057  }
2058 
2059  // yunitvec_prev
2060  f = new MathParser::MathFunc_t;
2061  f->fname = "yunitvec_prev";
2062  f->ns = this;
2063  f->args.resize(1 + 2 + 1);
2064  f->args[0] = new MathParser::MathArgReal_t;
2065  f->args[1] = new MathParser::MathArgInt_t;
2066  f->args[2] = new MathParser::MathArgInt_t;
2067  f->args[3] = new MathArgDM(pDM);
2068  f->f = unitvec<IDX2, PREV>;
2069  f->t = 0;
2070 
2071  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2072  silent_cerr("model namespace: "
2073  "unable to insert handler "
2074  "for function " << f->fname << std::endl);
2076  }
2077 
2078  // zunitvec_prev
2079  f = new MathParser::MathFunc_t;
2080  f->fname = "zunitvec_prev";
2081  f->ns = this;
2082  f->args.resize(1 + 2 + 1);
2083  f->args[0] = new MathParser::MathArgReal_t;
2084  f->args[1] = new MathParser::MathArgInt_t;
2085  f->args[2] = new MathParser::MathArgInt_t;
2086  f->args[3] = new MathArgDM(pDM);
2087  f->f = unitvec<IDX3, PREV>;
2088  f->t = 0;
2089 
2090  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2091  silent_cerr("model namespace: "
2092  "unable to insert handler "
2093  "for function " << f->fname << std::endl);
2095  }
2096 
2097  // angle_prev
2098  f = new MathParser::MathFunc_t;
2099  f->fname = "angle_prev";
2100  f->ns = this;
2101  f->args.resize(1 + 1 + 1);
2102  f->args[0] = new MathParser::MathArgReal_t;
2103  f->args[1] = new MathParser::MathArgInt_t;
2104  f->args[2] = new MathArgDM(pDM);
2105  f->f = angle<NORM, PREV>;
2106  f->t = 0;
2107 
2108  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2109  silent_cerr("model namespace: "
2110  "unable to insert handler "
2111  "for function " << f->fname << std::endl);
2113  }
2114 
2115  // xangle_prev
2116  f = new MathParser::MathFunc_t;
2117  f->fname = "xangle_prev";
2118  f->ns = this;
2119  f->args.resize(1 + 1 + 1);
2120  f->args[0] = new MathParser::MathArgReal_t;
2121  f->args[1] = new MathParser::MathArgInt_t;
2122  f->args[2] = new MathArgDM(pDM);
2123  f->f = angle<IDX1, PREV>;
2124  f->t = 0;
2125 
2126  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2127  silent_cerr("model namespace: "
2128  "unable to insert handler "
2129  "for function " << f->fname << std::endl);
2131  }
2132 
2133  // yangle_prev
2134  f = new MathParser::MathFunc_t;
2135  f->fname = "yangle_prev";
2136  f->ns = this;
2137  f->args.resize(1 + 1 + 1);
2138  f->args[0] = new MathParser::MathArgReal_t;
2139  f->args[1] = new MathParser::MathArgInt_t;
2140  f->args[2] = new MathArgDM(pDM);
2141  f->f = angle<IDX2, PREV>;
2142  f->t = 0;
2143 
2144  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2145  silent_cerr("model namespace: "
2146  "unable to insert handler "
2147  "for function " << f->fname << std::endl);
2149  }
2150 
2151  // zangle_prev
2152  f = new MathParser::MathFunc_t;
2153  f->fname = "zangle_prev";
2154  f->ns = this;
2155  f->args.resize(1 + 1 + 1);
2156  f->args[0] = new MathParser::MathArgReal_t;
2157  f->args[1] = new MathParser::MathArgInt_t;
2158  f->args[2] = new MathArgDM(pDM);
2159  f->f = angle<IDX3, PREV>;
2160  f->t = 0;
2161 
2162  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2163  silent_cerr("model namespace: "
2164  "unable to insert handler "
2165  "for function " << f->fname << std::endl);
2167  }
2168 
2169  // anglerel_prev
2170  f = new MathParser::MathFunc_t;
2171  f->fname = "anglerel_prev";
2172  f->ns = this;
2173  f->args.resize(1 + 2 + 1);
2174  f->args[0] = new MathParser::MathArgReal_t;
2175  f->args[1] = new MathParser::MathArgInt_t;
2176  f->args[2] = new MathParser::MathArgInt_t;
2177  f->args[3] = new MathArgDM(pDM);
2178  f->f = anglerel<NORM, PREV>;
2179  f->t = 0;
2180 
2181  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2182  silent_cerr("model namespace: "
2183  "unable to insert handler "
2184  "for function " << f->fname << std::endl);
2186  }
2187 
2188  // xanglerel_prev
2189  f = new MathParser::MathFunc_t;
2190  f->fname = "xanglerel_prev";
2191  f->ns = this;
2192  f->args.resize(1 + 2 + 1);
2193  f->args[0] = new MathParser::MathArgReal_t;
2194  f->args[1] = new MathParser::MathArgInt_t;
2195  f->args[2] = new MathParser::MathArgInt_t;
2196  f->args[3] = new MathArgDM(pDM);
2197  f->f = anglerel<IDX1, PREV>;
2198  f->t = 0;
2199 
2200  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2201  silent_cerr("model namespace: "
2202  "unable to insert handler "
2203  "for function " << f->fname << std::endl);
2205  }
2206 
2207  // yanglerel_prev
2208  f = new MathParser::MathFunc_t;
2209  f->fname = "yanglerel_prev";
2210  f->ns = this;
2211  f->args.resize(1 + 2 + 1);
2212  f->args[0] = new MathParser::MathArgReal_t;
2213  f->args[1] = new MathParser::MathArgInt_t;
2214  f->args[2] = new MathParser::MathArgInt_t;
2215  f->args[3] = new MathArgDM(pDM);
2216  f->f = anglerel<IDX2, PREV>;
2217  f->t = 0;
2218 
2219  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2220  silent_cerr("model namespace: "
2221  "unable to insert handler "
2222  "for function " << f->fname << std::endl);
2224  }
2225 
2226  // zanglerel_prev
2227  f = new MathParser::MathFunc_t;
2228  f->fname = "zanglerel_prev";
2229  f->ns = this;
2230  f->args.resize(1 + 2 + 1);
2231  f->args[0] = new MathParser::MathArgReal_t;
2232  f->args[1] = new MathParser::MathArgInt_t;
2233  f->args[2] = new MathParser::MathArgInt_t;
2234  f->args[3] = new MathArgDM(pDM);
2235  f->f = anglerel<IDX3, PREV>;
2236  f->t = 0;
2237 
2238  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2239  silent_cerr("model namespace: "
2240  "unable to insert handler "
2241  "for function " << f->fname << std::endl);
2243  }
2244 
2245  // velocity_prev
2246  f = new MathParser::MathFunc_t;
2247  f->fname = "velocity_prev";
2248  f->ns = this;
2249  f->args.resize(1 + 1 + 1);
2250  f->args[0] = new MathParser::MathArgReal_t;
2251  f->args[1] = new MathParser::MathArgInt_t;
2252  f->args[2] = new MathArgDM(pDM);
2253  f->f = velocity<NORM, PREV>;
2254  f->t = 0;
2255 
2256  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2257  silent_cerr("model namespace: "
2258  "unable to insert handler "
2259  "for function " << f->fname << std::endl);
2261  }
2262 
2263  // velocity2_prev
2264  f = new MathParser::MathFunc_t;
2265  f->fname = "velocity2_prev";
2266  f->ns = this;
2267  f->args.resize(1 + 1 + 1);
2268  f->args[0] = new MathParser::MathArgReal_t;
2269  f->args[1] = new MathParser::MathArgInt_t;
2270  f->args[2] = new MathArgDM(pDM);
2271  f->f = velocity<SQUARE, PREV>;
2272  f->t = 0;
2273 
2274  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2275  silent_cerr("model namespace: "
2276  "unable to insert handler "
2277  "for function " << f->fname << std::endl);
2279  }
2280 
2281  // xvelocity_prev
2282  f = new MathParser::MathFunc_t;
2283  f->fname = "xvelocity_prev";
2284  f->ns = this;
2285  f->args.resize(1 + 1 + 1);
2286  f->args[0] = new MathParser::MathArgReal_t;
2287  f->args[1] = new MathParser::MathArgInt_t;
2288  f->args[2] = new MathArgDM(pDM);
2289  f->f = velocity<IDX1, PREV>;
2290  f->t = 0;
2291 
2292  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2293  silent_cerr("model namespace: "
2294  "unable to insert handler "
2295  "for function " << f->fname << std::endl);
2297  }
2298 
2299  // yvelocity_prev
2300  f = new MathParser::MathFunc_t;
2301  f->fname = "yvelocity_prev";
2302  f->ns = this;
2303  f->args.resize(1 + 1 + 1);
2304  f->args[0] = new MathParser::MathArgReal_t;
2305  f->args[1] = new MathParser::MathArgInt_t;
2306  f->args[2] = new MathArgDM(pDM);
2307  f->f = velocity<IDX2, PREV>;
2308  f->t = 0;
2309 
2310  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2311  silent_cerr("model namespace: "
2312  "unable to insert handler "
2313  "for function " << f->fname << std::endl);
2315  }
2316 
2317  // zvelocity_prev
2318  f = new MathParser::MathFunc_t;
2319  f->fname = "zvelocity_prev";
2320  f->ns = this;
2321  f->args.resize(1 + 1 + 1);
2322  f->args[0] = new MathParser::MathArgReal_t;
2323  f->args[1] = new MathParser::MathArgInt_t;
2324  f->args[2] = new MathArgDM(pDM);
2325  f->f = velocity<IDX3, PREV>;
2326  f->t = 0;
2327 
2328  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2329  silent_cerr("model namespace: "
2330  "unable to insert handler "
2331  "for function " << f->fname << std::endl);
2333  }
2334 
2335  // vrel_prev
2336  f = new MathParser::MathFunc_t;
2337  f->fname = "vrel_prev";
2338  f->ns = this;
2339  f->args.resize(1 + 2 + 1);
2340  f->args[0] = new MathParser::MathArgReal_t;
2341  f->args[1] = new MathParser::MathArgInt_t;
2342  f->args[2] = new MathParser::MathArgInt_t;
2343  f->args[3] = new MathArgDM(pDM);
2344  f->f = vrel<NORM, PREV>;
2345  f->t = 0;
2346 
2347  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2348  silent_cerr("model namespace: "
2349  "unable to insert handler "
2350  "for function " << f->fname << std::endl);
2352  }
2353 
2354  // vrel2_prev
2355  f = new MathParser::MathFunc_t;
2356  f->fname = "vrel2_prev";
2357  f->ns = this;
2358  f->args.resize(1 + 2 + 1);
2359  f->args[0] = new MathParser::MathArgReal_t;
2360  f->args[1] = new MathParser::MathArgInt_t;
2361  f->args[2] = new MathParser::MathArgInt_t;
2362  f->args[3] = new MathArgDM(pDM);
2363  f->f = vrel<SQUARE, PREV>;
2364  f->t = 0;
2365 
2366  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2367  silent_cerr("model namespace: "
2368  "unable to insert handler "
2369  "for function " << f->fname << std::endl);
2371  }
2372 
2373  // xvrel_prev
2374  f = new MathParser::MathFunc_t;
2375  f->fname = "xvrel_prev";
2376  f->ns = this;
2377  f->args.resize(1 + 2 + 1);
2378  f->args[0] = new MathParser::MathArgReal_t;
2379  f->args[1] = new MathParser::MathArgInt_t;
2380  f->args[2] = new MathParser::MathArgInt_t;
2381  f->args[3] = new MathArgDM(pDM);
2382  f->f = vrel<IDX1, PREV>;
2383  f->t = 0;
2384 
2385  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2386  silent_cerr("model namespace: "
2387  "unable to insert handler "
2388  "for function " << f->fname << std::endl);
2390  }
2391 
2392  // yvrel_prev
2393  f = new MathParser::MathFunc_t;
2394  f->fname = "yvrel_prev";
2395  f->ns = this;
2396  f->args.resize(1 + 2 + 1);
2397  f->args[0] = new MathParser::MathArgReal_t;
2398  f->args[1] = new MathParser::MathArgInt_t;
2399  f->args[2] = new MathParser::MathArgInt_t;
2400  f->args[3] = new MathArgDM(pDM);
2401  f->f = vrel<IDX2, PREV>;
2402  f->t = 0;
2403 
2404  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2405  silent_cerr("model namespace: "
2406  "unable to insert handler "
2407  "for function " << f->fname << std::endl);
2409  }
2410 
2411  // zvrel_prev
2412  f = new MathParser::MathFunc_t;
2413  f->fname = "zvrel_prev";
2414  f->ns = this;
2415  f->args.resize(1 + 2 + 1);
2416  f->args[0] = new MathParser::MathArgReal_t;
2417  f->args[1] = new MathParser::MathArgInt_t;
2418  f->args[2] = new MathParser::MathArgInt_t;
2419  f->args[3] = new MathArgDM(pDM);
2420  f->f = vrel<IDX3, PREV>;
2421  f->t = 0;
2422 
2423  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2424  silent_cerr("model namespace: "
2425  "unable to insert handler "
2426  "for function " << f->fname << std::endl);
2428  }
2429 
2430  // angvel_prev
2431  f = new MathParser::MathFunc_t;
2432  f->fname = "angvel_prev";
2433  f->ns = this;
2434  f->args.resize(1 + 1 + 1);
2435  f->args[0] = new MathParser::MathArgReal_t;
2436  f->args[1] = new MathParser::MathArgInt_t;
2437  f->args[2] = new MathArgDM(pDM);
2438  f->f = angvel<NORM, PREV>;
2439  f->t = 0;
2440 
2441  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2442  silent_cerr("model namespace: "
2443  "unable to insert handler "
2444  "for function " << f->fname << std::endl);
2446  }
2447 
2448  // angvel_prev
2449  f = new MathParser::MathFunc_t;
2450  f->fname = "angvel2_prev";
2451  f->ns = this;
2452  f->args.resize(1 + 1 + 1);
2453  f->args[0] = new MathParser::MathArgReal_t;
2454  f->args[1] = new MathParser::MathArgInt_t;
2455  f->args[2] = new MathArgDM(pDM);
2456  f->f = angvel<SQUARE, PREV>;
2457  f->t = 0;
2458 
2459  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2460  silent_cerr("model namespace: "
2461  "unable to insert handler "
2462  "for function " << f->fname << std::endl);
2464  }
2465 
2466  // xangvel_prev
2467  f = new MathParser::MathFunc_t;
2468  f->fname = "xangvel_prev";
2469  f->ns = this;
2470  f->args.resize(1 + 1 + 1);
2471  f->args[0] = new MathParser::MathArgReal_t;
2472  f->args[1] = new MathParser::MathArgInt_t;
2473  f->args[2] = new MathArgDM(pDM);
2474  f->f = angvel<IDX1, PREV>;
2475  f->t = 0;
2476 
2477  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2478  silent_cerr("model namespace: "
2479  "unable to insert handler "
2480  "for function " << f->fname << std::endl);
2482  }
2483 
2484  // yangvel_prev
2485  f = new MathParser::MathFunc_t;
2486  f->fname = "yangvel_prev";
2487  f->ns = this;
2488  f->args.resize(1 + 1 + 1);
2489  f->args[0] = new MathParser::MathArgReal_t;
2490  f->args[1] = new MathParser::MathArgInt_t;
2491  f->args[2] = new MathArgDM(pDM);
2492  f->f = angvel<IDX2, PREV>;
2493  f->t = 0;
2494 
2495  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2496  silent_cerr("model namespace: "
2497  "unable to insert handler "
2498  "for function " << f->fname << std::endl);
2500  }
2501 
2502  // zangvel_prev
2503  f = new MathParser::MathFunc_t;
2504  f->fname = "zangvel_prev";
2505  f->ns = this;
2506  f->args.resize(1 + 1 + 1);
2507  f->args[0] = new MathParser::MathArgReal_t;
2508  f->args[1] = new MathParser::MathArgInt_t;
2509  f->args[2] = new MathArgDM(pDM);
2510  f->f = angvel<IDX3, PREV>;
2511  f->t = 0;
2512 
2513  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2514  silent_cerr("model namespace: "
2515  "unable to insert handler "
2516  "for function " << f->fname << std::endl);
2518  }
2519 
2520  // angvrel_prev
2521  f = new MathParser::MathFunc_t;
2522  f->fname = "angvrel_prev";
2523  f->ns = this;
2524  f->args.resize(1 + 2 + 1);
2525  f->args[0] = new MathParser::MathArgReal_t;
2526  f->args[1] = new MathParser::MathArgInt_t;
2527  f->args[2] = new MathParser::MathArgInt_t;
2528  f->args[3] = new MathArgDM(pDM);
2529  f->f = angvrel<NORM, PREV>;
2530  f->t = 0;
2531 
2532  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2533  silent_cerr("model namespace: "
2534  "unable to insert handler "
2535  "for function " << f->fname << std::endl);
2537  }
2538 
2539  // angvrel2_prev
2540  f = new MathParser::MathFunc_t;
2541  f->fname = "angvrel2_prev";
2542  f->ns = this;
2543  f->args.resize(1 + 2 + 1);
2544  f->args[0] = new MathParser::MathArgReal_t;
2545  f->args[1] = new MathParser::MathArgInt_t;
2546  f->args[2] = new MathParser::MathArgInt_t;
2547  f->args[3] = new MathArgDM(pDM);
2548  f->f = angvrel<SQUARE, PREV>;
2549  f->t = 0;
2550 
2551  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2552  silent_cerr("model namespace: "
2553  "unable to insert handler "
2554  "for function " << f->fname << std::endl);
2556  }
2557 
2558  // xangvrel_prev
2559  f = new MathParser::MathFunc_t;
2560  f->fname = "xangvrel_prev";
2561  f->ns = this;
2562  f->args.resize(1 + 2 + 1);
2563  f->args[0] = new MathParser::MathArgReal_t;
2564  f->args[1] = new MathParser::MathArgInt_t;
2565  f->args[2] = new MathParser::MathArgInt_t;
2566  f->args[3] = new MathArgDM(pDM);
2567  f->f = angvrel<IDX1, PREV>;
2568  f->t = 0;
2569 
2570  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2571  silent_cerr("model namespace: "
2572  "unable to insert handler "
2573  "for function " << f->fname << std::endl);
2575  }
2576 
2577  // yangvrel_prev
2578  f = new MathParser::MathFunc_t;
2579  f->fname = "yangvrel_prev";
2580  f->ns = this;
2581  f->args.resize(1 + 2 + 1);
2582  f->args[0] = new MathParser::MathArgReal_t;
2583  f->args[1] = new MathParser::MathArgInt_t;
2584  f->args[2] = new MathParser::MathArgInt_t;
2585  f->args[3] = new MathArgDM(pDM);
2586  f->f = angvrel<IDX2, PREV>;
2587  f->t = 0;
2588 
2589  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2590  silent_cerr("model namespace: "
2591  "unable to insert handler "
2592  "for function " << f->fname << std::endl);
2594  }
2595 
2596  // zangvrel_prev
2597  f = new MathParser::MathFunc_t;
2598  f->fname = "zangvrel_prev";
2599  f->ns = this;
2600  f->args.resize(1 + 2 + 1);
2601  f->args[0] = new MathParser::MathArgReal_t;
2602  f->args[1] = new MathParser::MathArgInt_t;
2603  f->args[2] = new MathParser::MathArgInt_t;
2604  f->args[3] = new MathArgDM(pDM);
2605  f->f = angvrel<IDX3, PREV>;
2606  f->t = 0;
2607 
2608  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2609  silent_cerr("model namespace: "
2610  "unable to insert handler "
2611  "for function " << f->fname << std::endl);
2613  }
2614 
2615  // drive
2616  f = new MathParser::MathFunc_t;
2617  f->fname = "drive";
2618  f->ns = this;
2619  f->args.resize(1 + 2 + 2);
2620  f->args[0] = new MathParser::MathArgReal_t;
2621  f->args[1] = new MathParser::MathArgInt_t;
2622  f->args[2] = new MathParser::MathArgReal_t;
2623  f->args[3] = new MathArgDCPtr(0);
2624  f->args[4] = new MathArgDM(pDM);
2625  f->f = drive<false>;
2626  f->t = 0;
2627 
2628  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2629  silent_cerr("model namespace: "
2630  "unable to insert handler "
2631  "for function " << f->fname << std::endl);
2633  }
2634 
2635  // drivep
2636  f = new MathParser::MathFunc_t;
2637  f->fname = "drivep";
2638  f->ns = this;
2639  f->args.resize(1 + 2 + 2);
2640  f->args[0] = new MathParser::MathArgReal_t;
2641  f->args[1] = new MathParser::MathArgInt_t;
2642  f->args[2] = new MathParser::MathArgReal_t;
2643  f->args[3] = new MathArgDCPtr(0);
2644  f->args[4] = new MathArgDM(pDM);
2645  f->f = drive<true>;
2646  f->t = 0;
2647 
2648  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2649  silent_cerr("model namespace: "
2650  "unable to insert handler "
2651  "for function " << f->fname << std::endl);
2653  }
2654 
2655  // current simulation entity function
2656  f = new MathParser::MathFunc_t;
2657  f->fname = "current";
2658  f->ns = this;
2659  f->args.resize(1 + 1 + 1);
2660  f->args[0] = new MathParser::MathArgReal_t;
2661  f->args[1] = new MathParser::MathArgString_t;
2662  f->args[2] = new MathArgMNS(this);
2663  f->f = model_curr;
2664  f->t = 0;
2665 
2666  if (!func.insert(funcType::value_type(f->fname, f)).second) {
2667  silent_cerr("model namespace: "
2668  "unable to insert handler "
2669  "for function " << f->fname << std::endl);
2671  }
2672 
2673  // scalar functions
2674  sf_func.fname = "sf";
2675  sf_func.ns = this;
2676  sf_func.args.resize(1 + 2 + 1);
2680  sf_func.args[3] = new MathArgSF(0);
2681  sf_func.f = model_sf;
2682  sf_func.t = 0;
2683 
2684  // node functions
2685  node_func.fname = "node";
2686  node_func.ns = this;
2687  node_func.args.resize(1 + 2 + 4);
2692  node_func.args[4] = new MathArgSEPtr(0);
2693  node_func.args[5] = new MathArgSEIdx(0);
2694  node_func.args[6] = new MathArgDM(pDM);
2696  node_func.t = 0;
2697 
2698  // element functions
2699  elem_func.fname = "element";
2700  elem_func.ns = this;
2701  elem_func.args.resize(1 + 2 + 4);
2706  elem_func.args[4] = new MathArgSEPtr(0);
2707  elem_func.args[5] = new MathArgSEIdx(0);
2708  elem_func.args[6] = new MathArgDM(pDM);
2709  elem_func.f = model_elem<false>;
2710  elem_func.t = 0;
2711 
2712  // unique element functions
2713  unique_elem_func.fname = "uniqueElement";
2714  unique_elem_func.ns = this;
2715  unique_elem_func.args.resize(1 + 1 + 4);
2719  unique_elem_func.args[3] = new MathArgSEPtr(0);
2720  unique_elem_func.args[4] = new MathArgSEIdx(0);
2721  unique_elem_func.args[5] = new MathArgDM(pDM);
2722  unique_elem_func.f = model_elem<true>;
2723  unique_elem_func.t = 0;
2724 }
2725 
2727 {
2728  for (funcType::iterator f = func.begin(); f != func.end(); ++f) {
2729  delete f->second;
2730  }
2731 }
2732 
2733 bool
2734 ModelNameSpace::IsFunc(const std::string& fname) const
2735 {
2736  return FindFunc(fname);
2737 }
2738 
2739 bool
2740 ModelNameSpace::FindFunc(const std::string& fname, MathParser::MathFunc_t** fpp) const
2741 {
2742  static const std::string sf_prefix("sf::");
2743  if (fname.compare(0, sf_prefix.size(), sf_prefix) == 0) {
2744  std::string sfname(fname, sf_prefix.size());
2746 
2747  if (sf == 0) {
2748  silent_cerr("ModelNameSpace::FindFunc(" << fname << "): unable to find scalar function \"" << sfname << "\"" << std::endl);
2749  return false;
2750  }
2751 
2752  if (fpp) {
2754  *fpp = fp;
2755 
2756  (*dynamic_cast<MathArgSF *>(fp->args[3]))() = sf;
2757  }
2758 
2759  return true;
2760  }
2761 
2762  static const std::string node_prefix = "node::";
2763  if (fname.compare(0, node_prefix.size(), node_prefix) == 0) {
2764  std::string type(fname, node_prefix.size());
2765  const Node::Type t = str2nodetype(type.c_str());
2766  if (t == Node::UNKNOWN) {
2767  silent_cerr("ModelNameSpace::GetFunc(" << fname << "): unable to find node type \"" << type << "\"" << std::endl);
2768  return false;
2769  }
2770 
2771  if (fpp) {
2773  *fpp = fp;
2774 
2775  fp->fname += "::";
2776  fp->fname += type;
2777  (*dynamic_cast<MathParser::MathArgInt_t *>(fp->args[1]))() = -1;
2778  (*dynamic_cast<MathArgNode *>(fp->args[3]))() = t;
2779  }
2780 
2781  return true;
2782  }
2783 
2784  static const std::string elem_prefix = "element::";
2785  if (fname.compare(0, elem_prefix.size(), elem_prefix) == 0) {
2786  std::string type(fname, elem_prefix.size());
2787  Elem::Type t = str2elemtype(type.c_str());
2788  if (t == Elem::UNKNOWN) {
2789  silent_cerr("ModelNameSpace::GetFunc(" << fname << "): unable to find element type \"" << type << "\"" << std::endl);
2790  return false;
2791  }
2792 
2793  if (fpp) {
2794  MathParser::MathFunc_t* fp = 0;
2795 
2796  if (pDM->GetElemDataStructure(t).bIsUnique()) {
2798 
2799  (*dynamic_cast<MathArgElem *>(fp->args[2]))() = t;
2800 
2801  } else {
2803 
2804  (*dynamic_cast<MathParser::MathArgInt_t *>(fp->args[1]))() = -1;
2805  (*dynamic_cast<MathArgElem *>(fp->args[3]))() = t;
2806  }
2807 
2808  *fpp = fp;
2809 
2810  fp->fname += "::";
2811  fp->fname += type;
2812  }
2813 
2814  return true;
2815  }
2816 
2817  funcType::const_iterator i = func.find(fname);
2818 
2819  if (i != func.end()) {
2820  if (fpp) {
2821  MathParser::MathFunc_t* fp = new MathParser::MathFunc_t(*i->second);
2822  *fpp = fp;
2823  }
2824  return true;
2825  }
2826 
2827  return false;
2828 }
2829 
2831 ModelNameSpace::GetFunc(const std::string& fname) const
2832 {
2833  MathParser::MathFunc_t* fp = 0;
2834  FindFunc(fname, &fp);
2835  return fp;
2836 
2837 #if 0
2838  static const std::string sf_prefix("sf::");
2839  if (fname.compare(0, sf_prefix.size(), sf_prefix) == 0) {
2840  std::string sfname(fname, sf_prefix.size());
2842 
2843  if (sf == 0) {
2844  silent_cerr("ModelNameSpace::FindFunc(" << fname << "): unable to find scalar function \"" << sfname << "\"" << std::endl);
2846  }
2847 
2848  (*dynamic_cast<MathArgSF *>(sf_func.args[3]))() = sf;
2849 
2850  return const_cast<MathParser::MathFunc_t *>(&sf_func);
2851  }
2852 
2853  static const std::string node_prefix = "node::";
2854  if (fname.compare(0, node_prefix.size(), node_prefix) == 0) {
2855  std::string type(fname, node_prefix.size());
2856  const Node::Type t = str2nodetype(type.c_str());
2857  if (t == Node::UNKNOWN) {
2858  silent_cerr("ModelNameSpace::GetFunc(" << fname << "): unable to find node type \"" << type << "\"" << std::endl);
2860  }
2861 
2862  (*dynamic_cast<MathParser::MathArgInt_t *>(node_func.args[1]))() = -1;
2863  (*dynamic_cast<MathArgNode *>(node_func.args[3]))() = t;
2864 
2865  return const_cast<MathParser::MathFunc_t *>(&node_func);
2866  }
2867 
2868  static const std::string elem_prefix = "element::";
2869  if (fname.compare(0, elem_prefix.size(), elem_prefix) == 0) {
2870  std::string type(fname, elem_prefix.size());
2871  Elem::Type t = str2elemtype(type.c_str());
2872  if (t == Elem::UNKNOWN) {
2873  silent_cerr("ModelNameSpace::GetFunc(" << fname << "): unable to find element type \"" << type << "\"" << std::endl);
2875  }
2876 
2877  if (pDM->GetElemDataStructure(t).bIsUnique()) {
2878  (*dynamic_cast<MathArgElem *>(unique_elem_func.args[2]))() = t;
2879 
2880  return const_cast<MathParser::MathFunc_t *>(&unique_elem_func);
2881 
2882  } else {
2883  (*dynamic_cast<MathParser::MathArgInt_t *>(elem_func.args[1]))() = -1;
2884  (*dynamic_cast<MathArgElem *>(elem_func.args[3]))() = t;
2885 
2886  return const_cast<MathParser::MathFunc_t *>(&elem_func);
2887  }
2888  }
2889 
2890  funcType::const_iterator i = func.find(fname);
2891 
2892  if (i != func.end()) {
2893  return i->second;
2894  }
2895 
2896  return 0;
2897 #endif
2898 }
2899 
2900 TypedValue
2902 {
2903 #if 0
2904  for (unsigned i = 0; i != args.size(); i++) {
2905  if (args[i]->Type() == MathParser::AT_PRIVATE) {
2906  MathArgDM *dm = dynamic_cast<MathArgDM *>(args[i]);
2907  if (dm) {
2908  (*dm)() = pDM;
2909  }
2910  }
2911  }
2912 #endif
2913 
2914  f->f(f->args);
2915 
2916  switch (f->args[0]->Type()) {
2917  case MathParser::AT_VOID:
2918  return TypedValue(0);
2919 
2920  case MathParser::AT_INT:
2921  return TypedValue((*dynamic_cast<MathParser::MathArgInt_t *>(f->args[0]))());
2922 
2923  case MathParser::AT_REAL:
2924  return TypedValue((*dynamic_cast<MathParser::MathArgReal_t *>(f->args[0]))());
2925 
2926  default:
2928  }
2929 }
2930 
2931 Table*
2933 {
2934  return 0;
2935 }
2936 
2937 bool
2938 ModelNameSpace::PushCurrData(const std::string& name, const TypedValue& value)
2939 {
2940  return currData.insert(currDataType::value_type(name, value)).second;
2941 }
2942 
2943 bool
2944 ModelNameSpace::PopCurrData(const std::string& name)
2945 {
2946  currDataType::iterator i = currData.find(name);
2947  if (i == currData.end()) {
2948  return false;
2949  }
2950 
2951  currData.erase(i);
2952 
2953  return true;
2954 }
2955 
2956 bool
2957 ModelNameSpace::GetCurrData(const std::string& name, TypedValue& value) const
2958 {
2959  currDataType::const_iterator i = currData.find(name);
2960  if (i == currData.end()) {
2961  return false;
2962  }
2963 
2964  value = i->second;
2965 
2966  return true;
2967 }
2968 
static int model_curr(const MathParser::MathArgs &args)
Definition: modelns.cc:1061
static int model_elem(const MathParser::MathArgs &args)
Definition: modelns.cc:934
static int velocity(const MathParser::MathArgs &args)
Definition: modelns.cc:442
MathArgPriv_t< Real, AT_REAL > MathArgReal_t
Definition: mathp.h:155
virtual const Vec3 & GetWPrev(void) const
Definition: strnode.h:1018
static int angle(const MathParser::MathArgs &args)
Definition: modelns.cc:313
bool PopCurrData(const std::string &name)
Definition: modelns.cc:2944
const BasicScalarFunction * GetScalarFunction(void)
Definition: mbpar.cc:2158
Elem::Type str2elemtype(const char *const s)
Definition: elem.cc:159
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
static int angvel(const MathParser::MathArgs &args)
Definition: modelns.cc:579
virtual const Mat3x3 & GetRCurr(void) const
Definition: strnode.h:1012
doublereal Norm(void) const
Definition: matvec3.h:263
doublereal Dot(const Vec3 &v) const
Definition: matvec3.h:243
funcType func
Definition: modelns.h:54
std::vector< MathArg_t * > MathArgs
Definition: mathp.h:158
virtual const Vec3 & GetXPrev(void) const
Definition: strnode.h:304
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: simentity.cc:142
static int anglerel(const MathParser::MathArgs &args)
Definition: modelns.cc:370
static int position(const MathParser::MathArgs &args)
Definition: modelns.cc:99
MathParser::MathArgPriv_t< Node::Type > MathArgNode
Definition: modelns.h:46
Definition: modelns.cc:75
Node::Type str2nodetype(const char *const s)
Definition: node.cc:94
MathParser::MathFunc_t unique_elem_func
Definition: modelns.h:59
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
virtual doublereal dGetP(const doublereal &dVar) const
Definition: drive.cc:499
static int vrel(const MathParser::MathArgs &args)
Definition: modelns.cc:503
const DataManager * pDM
Definition: modelns.h:40
enum @55 order
Elem * pFindElem(Elem::Type Typ, unsigned int uElem, unsigned int iDeriv) const
Definition: elman.cc:650
bool bIsUnique(void) const
Definition: dataman.h:583
static const char * when2str(when_t when)
Definition: modelns.cc:80
MathParser::MathFunc_t * GetFunc(const std::string &fname) const
Definition: modelns.cc:2831
MathFunc_f f
Definition: mathp.h:170
MathFuncTest_f t
Definition: mathp.h:171
Definition: modelns.cc:47
virtual bool bIsDifferentiable(void) const
Definition: drive.h:495
bool IsFunc(const std::string &fname) const
Definition: modelns.cc:2734
static int unitvec(const MathParser::MathArgs &args)
Definition: modelns.cc:236
DataManager * pDM
Definition: mbpar.h:252
MathParser::MathFunc_t node_func
Definition: modelns.h:57
bool GetCurrData(const std::string &name, TypedValue &value) const
Definition: modelns.cc:2957
virtual const Mat3x3 & GetRPrev(void) const
Definition: strnode.h:1000
virtual const Vec3 & GetVPrev(void) const
Definition: strnode.h:316
MathParser::MathArgPriv_t< const DataManager * > MathArgDM
Definition: modelns.h:43
MathParser::MathArgPriv_t< const BasicScalarFunction * > MathArgSF
Definition: modelns.h:45
Type
Definition: node.h:71
IDX_t
Definition: modelns.cc:43
TypedValue EvalFunc(MathParser::MathFunc_t *f) const
Definition: modelns.cc:2901
virtual const Vec3 & GetWCurr(void) const
Definition: strnode.h:1030
MathParser::MathFunc_t elem_func
Definition: modelns.h:58
Definition: modelns.cc:76
#define ASSERT(expression)
Definition: colamd.c:977
static const char * IDX2str(IDX_t IDX)
Definition: modelns.cc:52
virtual doublereal ComputeDiff(const doublereal x, const integer order=1) const =0
Mat3x3 MulTM(const Mat3x3 &m) const
Definition: matvec3.cc:500
virtual const Vec3 & GetXCurr(void) const
Definition: strnode.h:310
ModelNameSpace(const DataManager *pDM)
Definition: modelns.cc:1090
MathParser::MathArgPriv_t< const DriveCaller * > MathArgDCPtr
Definition: modelns.h:50
MathArgPriv_t< std::string, AT_STRING > MathArgString_t
Definition: mathp.h:156
MathParser::MathArgPriv_t< unsigned int > MathArgSEIdx
Definition: modelns.h:49
MathParser::MathArgPriv_t< const SimulationEntity * > MathArgSEPtr
Definition: modelns.h:48
Definition: modelns.cc:45
const DataManager::ElemDataStructure & GetElemDataStructure(Elem::Type Typ) const
Definition: dataman.h:661
virtual doublereal dGetPrivData(unsigned int i) const
Definition: simentity.cc:149
virtual doublereal dGet(const doublereal &dVar) const =0
virtual Table * GetTable(void)
Definition: modelns.cc:2932
const char * psNodeNames[]
Definition: enums.cc:372
static int model_node(const MathParser::MathArgs &args)
Definition: modelns.cc:832
NameSpace * ns
Definition: mathp.h:168
Type
Definition: elem.h:91
bool PushCurrData(const std::string &name, const TypedValue &value)
Definition: modelns.cc:2938
const char * psElemNames[]
Definition: enums.cc:39
when_t
Definition: modelns.cc:74
Definition: modelns.cc:46
static int model_sf(const MathParser::MathArgs &args)
Definition: modelns.cc:781
virtual const Vec3 & GetVCurr(void) const
Definition: strnode.h:322
MBDynParser & GetMBDynParser(void) const
Definition: dataman.h:342
MathParser::MathArgPriv_t< Elem::Type > MathArgElem
Definition: modelns.h:47
Definition: table.h:43
bool FindFunc(const std::string &fname, MathParser::MathFunc_t **fpp=0) const
Definition: modelns.cc:2740
static int angvrel(const MathParser::MathArgs &args)
Definition: modelns.cc:640
bool IsFlag(const MathParser::ArgFlag f) const
Definition: mathp.h:98
MathArgPriv_t< Int, AT_INT > MathArgInt_t
Definition: mathp.h:154
double doublereal
Definition: colamd.c:52
Definition: modelns.cc:44
static int distance(const MathParser::MathArgs &args)
Definition: modelns.cc:160
static int drive(const MathParser::MathArgs &args)
Definition: modelns.cc:716
~ModelNameSpace(void)
Definition: modelns.cc:2726
Node * pFindNode(Node::Type Typ, unsigned int uNode) const
Definition: nodeman.cc:179
MathParser::MathArgPriv_t< const ModelNameSpace * > MathArgMNS
Definition: modelns.h:44
std::string fname
Definition: mathp.h:167
MathParser::MathFunc_t sf_func
Definition: modelns.h:56
currDataType currData
Definition: modelns.h:62