FEDEM Model Database  R8.0
Source code of the FEDEM model database
FmHasDOFsBase.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FM_HAS_DOFS_BASE_H
9 #define FM_HAS_DOFS_BASE_H
10 
12 #include "vpmDB/FmDofLoad.H"
13 #include "vpmDB/FmDofMotion.H"
14 
15 
17 {
19 
20 public:
21 
22  // Load and Prescribed Motion management
23 
24  bool setLoadAtDOF (int dof, FmDofLoad* load, bool forceReplace = false);
25  bool setMotionAtDOF(int dof, FmDofMotion* pm, bool forceReplace = false);
26 
27  FmDofLoad* getLoadAtDOF(int dof, bool createIfNone = false);
28  virtual FmDofMotion* getMotionAtDOF(int dof, bool createIfNone = false);
29 
30  int getLoadBaseID (int dof) const;
31  int getMotionBaseID(int dof) const;
32 
33  void releaseLoadAtDOF (int dof);
34  void releaseMotionAtDOF(int dof);
35 
36  int atWhatDOF(const FmDofLoad* load) const;
37  int atWhatDOF(const FmDofMotion* pm) const;
38 
39  virtual void initAfterResolve();
40 
41  // DOF management
42 
43  enum DOFType {
44  X_TRANS = 0,
45  Y_TRANS = 1,
46  Z_TRANS = 2,
47  X_ROT = 3,
48  Y_ROT = 4,
49  Z_ROT = 5,
50  MAX_DOF = 6
51  };
52 
53  enum DOFStatus {
60  };
61 
63  FFaEnumEntry( FREE, "FREE");
64  FFaEnumEntry( FIXED, "FIXED");
65  FFaEnumEntry( PRESCRIBED, "PRESCRIBED");
66  FFaEnumEntry( FREE_DYNAMICS, "FREE_DYNAMICS");
67  FFaEnumEntry( SPRING_CONSTRAINED, "SPRING_CONSTRAINED");
68  FFaEnumEntry( SPRING_DYNAMICS, "SPRING_CONSTR_DYN");
70  };
71 
72  friend std::ostream& operator<<(std::ostream& s, const std::vector<DOFStatusEnum>& obj);
73  friend std::istream& operator>>(std::istream& s, std::vector<DOFStatusEnum>& obj);
74 
75  void getDOFs(IntVec& dofs) const;
76 
77  bool setStatusForAllDOFs(bool fixed);
78  bool setStatusForDOF(int dof, int status);
79  int getStatusCode(int dof) const; // 0=fixed, 1=free, 2=additional BC
80 
81  virtual bool setStatusForDOF(int dof, DOFStatus status) = 0;
82  virtual DOFStatus getStatusOfDOF(int dof) const = 0;
83  virtual bool isLegalDOF(int dof) const = 0;
84  virtual bool hasConstraints(bool fixedOnly = false) const = 0;
85  virtual bool isSuppressed() const = 0;
86 
87  virtual void setInitVel(int dof, double vel) = 0;
88  double getInitVel(int dof, bool includeFixed = false) const;
89  double getInitAcc(int dof, bool includeFixed = false) const;
90 
91  virtual void updateChildrenDisplayTopology();
92 
93 protected:
94  FmHasDOFsBase();
95  virtual ~FmHasDOFsBase();
96 
97  void completeInitDOFs();
98  void completeInitDOF(int i, const std::string& dofName);
99 
100  virtual bool cloneLocal(FmBase* obj, int depth);
101 
104 
107 
110 };
111 
112 #endif
#define FFaEnumEntryEnd
Defines the end of an enum mapping definition.
Definition: FFaEnum.H:237
#define FFaEnumEntry(Value, Text)
Adds one entry to the current enum mapping definition.
Definition: FFaEnum.H:234
static std::array< std::string, 6 > dof
Definition: FmJointBase.C:111
std::vector< int > IntVec
Convenience type alias.
Definition: FFaFieldContainer.H:45
Base parent class for the model data structure entries.
Definition: FmBase.H:37
Definition: FmDofLoad.H:17
Definition: FmDofMotion.H:18
Definition: FmHasDOFsBase.H:17
virtual bool cloneLocal(FmBase *obj, int depth)
Clones the data fields of *obj into *this.
Definition: FmHasDOFsBase.C:272
int atWhatDOF(const FmDofLoad *load) const
Definition: FmHasDOFsBase.C:219
virtual void initAfterResolve()
Hook for initialisation after resolving cross references.
Definition: FmHasDOFsBase.C:260
void releaseMotionAtDOF(int dof)
Definition: FmHasDOFsBase.C:171
virtual DOFStatus getStatusOfDOF(int dof) const =0
virtual ~FmHasDOFsBase()
Definition: FmHasDOFsBase.C:45
FFaReference< FmDofMotion > myMotions[MAX_DOF]
Definition: FmHasDOFsBase.H:103
virtual void setInitVel(int dof, double vel)=0
virtual bool setStatusForDOF(int dof, DOFStatus status)=0
int getLoadBaseID(int dof) const
Definition: FmHasDOFsBase.C:130
double getInitAcc(int dof, bool includeFixed=false) const
Definition: FmHasDOFsBase.C:250
bool setLoadAtDOF(int dof, FmDofLoad *load, bool forceReplace=false)
Definition: FmHasDOFsBase.C:57
void getDOFs(IntVec &dofs) const
Definition: FmHasDOFsBase.C:177
friend std::ostream & operator<<(std::ostream &s, const std::vector< DOFStatusEnum > &obj)
bool setMotionAtDOF(int dof, FmDofMotion *pm, bool forceReplace=false)
Definition: FmHasDOFsBase.C:86
virtual void updateChildrenDisplayTopology()
Definition: FmHasDOFsBase.C:307
FFaReference< FmDofLoad > myLoads[MAX_DOF]
Definition: FmHasDOFsBase.H:102
virtual FmDofMotion * getMotionAtDOF(int dof, bool createIfNone=false)
Definition: FmHasDOFsBase.C:140
virtual bool isLegalDOF(int dof) const =0
bool setStatusForDOF(int dof, int status)
Definition: FmHasDOFsBase.C:187
int getStatusCode(int dof) const
Definition: FmHasDOFsBase.C:204
virtual bool hasConstraints(bool fixedOnly=false) const =0
void completeInitDOFs()
Definition: FmHasDOFsBase.C:25
FFaField< DoubleVec > initAcc
Definition: FmHasDOFsBase.H:109
void completeInitDOF(int i, const std::string &dofName)
Definition: FmHasDOFsBase.C:35
int getMotionBaseID(int dof) const
Definition: FmHasDOFsBase.C:155
FFaField< FFaReferenceBase * > myLoadFields[MAX_DOF]
Definition: FmHasDOFsBase.H:105
DOFType
Definition: FmHasDOFsBase.H:43
@ Z_TRANS
Definition: FmHasDOFsBase.H:46
@ X_TRANS
Definition: FmHasDOFsBase.H:44
@ X_ROT
Definition: FmHasDOFsBase.H:47
@ Y_TRANS
Definition: FmHasDOFsBase.H:45
@ Y_ROT
Definition: FmHasDOFsBase.H:48
@ Z_ROT
Definition: FmHasDOFsBase.H:49
@ MAX_DOF
Definition: FmHasDOFsBase.H:50
double getInitVel(int dof, bool includeFixed=false) const
Definition: FmHasDOFsBase.C:240
FFaField< FFaReferenceBase * > myMotionFields[MAX_DOF]
Definition: FmHasDOFsBase.H:106
FmDofLoad * getLoadAtDOF(int dof, bool createIfNone=false)
Definition: FmHasDOFsBase.C:115
virtual bool isSuppressed() const =0
friend std::istream & operator>>(std::istream &s, std::vector< DOFStatusEnum > &obj)
DOFStatus
Definition: FmHasDOFsBase.H:53
@ FIXED
Definition: FmHasDOFsBase.H:55
@ SPRING_CONSTRAINED
Definition: FmHasDOFsBase.H:58
@ FREE_DYNAMICS
Definition: FmHasDOFsBase.H:57
@ SPRING_DYNAMICS
Definition: FmHasDOFsBase.H:59
@ FREE
Definition: FmHasDOFsBase.H:54
@ PRESCRIBED
Definition: FmHasDOFsBase.H:56
FFaEnumMapping(DOFStatus)
Definition: FmHasDOFsBase.H:62
bool setStatusForAllDOFs(bool fixed)
Definition: FmHasDOFsBase.C:194
FFaField< DoubleVec > initVel
Definition: FmHasDOFsBase.H:108
void releaseLoadAtDOF(int dof)
Definition: FmHasDOFsBase.C:165
FmHasDOFsBase()
Definition: FmHasDOFsBase.C:16
Definition: FmIsPositionedBase.H:31