1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/aero/genfm.h,v 1.20 2017/01/12 14:45:58 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 #ifndef GENFM_H
33 #define GENFM_H
34 
35 /* Generic force/moment element based on table lookup */
36 /* originated from GARTEUR HC AG-16 activity to model generic aerodynamic
37  * forces related to rigid body motion as a function of dynamic pressure
38  * angle of attack and sideslip angle, with data provided by DLR for Bo105
39  * fuselage and tail empennages */
40 
41 #include "aerodyn.h"
42 
43 struct GenericAerodynamicData {
44 	std::string name;
45 
46 	bool bAlphaFirst;
47 
48 	/* angle of attack and sideslip angle datapoints number */
49 	int nAlpha;
50 	int nBeta;
51 
52 	std::vector<doublereal> Alpha;
53 	std::vector<doublereal> Beta;
54 
55 	struct GenericAerodynamicCoef {
56 		doublereal	dCoef[6];
57 
58 		GenericAerodynamicCoef(void);
59 		GenericAerodynamicCoef(const GenericAerodynamicCoef& c);
60 		GenericAerodynamicCoef operator + (const GenericAerodynamicCoef& c) const;
61 		GenericAerodynamicCoef operator - (const GenericAerodynamicCoef& c) const;
62 		GenericAerodynamicCoef operator * (const doublereal& d) const;
63 		GenericAerodynamicCoef operator / (const doublereal& d) const;
64 	};
65 
66 	std::vector<std::vector<GenericAerodynamicCoef> > Data;
67 };
68 
69 class GenericAerodynamicForce :
70 	virtual public Elem,
71 	public AerodynamicElem,
72 	public InitialAssemblyElem
73 {
74 protected:
75 	/* Node the forces are applied to */
76 	const StructNode* pNode;
77 	/* Reference surface and length used to dimensionalize
78 	 * non-dimensional coefficients */
79 	const doublereal dRefSurface;
80 	const doublereal dRefLength;
81 	const bool bAlphaFirst;
82 	/* Offset of aerodynamic center with respect to node position */
83 	const Vec3 tilde_f;
84 	/* orientation of aerodynamic reference frame with respect to node */
85 	const Mat3x3 tilde_Ra;	/* Rotaz. del sistema aerodinamico al nodo */
86 
87 	/* force and moment */
88 	Vec3 tilde_F;
89 	Vec3 tilde_M;
90 	Vec3 F;
91 	Vec3 M;
92 
93 	// persistent
94 	doublereal dAlpha, dBeta;
95 
96 	/* aerodynamic data */
97 	GenericAerodynamicData *pData;
98 
99 	/* Assemblaggio residuo */
100 	void AssVec(SubVectorHandler& WorkVec);
101 
102 public:
103 	GenericAerodynamicForce(unsigned int uLabel,
104 		const DofOwner *pDO,
105 		const StructNode* pN,
106 		const Vec3& fTmp, const Mat3x3& RaTmp,
107 		doublereal dS, doublereal dL, bool bAlphaFirst,
108 		GenericAerodynamicData *pData,
109 		flag fOut);
110 	virtual ~GenericAerodynamicForce(void);
111 
112 	/* Scrive il contributo dell'elemento al file di restart */
113 	virtual std::ostream& Restart(std::ostream& out) const;
114 
115 	/* Tipo dell'elemento (usato per debug ecc.) */
116 	virtual Elem::Type GetElemType(void) const;
117 
118 	/* funzioni proprie */
119 
120 	/* Dimensioni del workspace */
121 	virtual void
122 	WorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
123 
124 	/* assemblaggio jacobiano */
125 	virtual VariableSubMatrixHandler&
126 	AssJac(VariableSubMatrixHandler& WorkMat,
127 		doublereal dCoef,
128 		const VectorHandler& XCurr,
129 		const VectorHandler& XPrimeCurr);
130 
131 	/* assemblaggio residuo */
132 	virtual SubVectorHandler&
133 	AssRes(SubVectorHandler& WorkVec,
134 	       doublereal dCoef,
135 	       const VectorHandler& XCurr,
136 	       const VectorHandler& XPrimeCurr);
137 
138 	/*
139 	 * output; si assume che ogni tipo di elemento sappia, attraverso
140 	 * l'OutputHandler, dove scrivere il proprio output
141 	 */
142 	virtual void Output(OutputHandler& OH) const;
143 
144 	/* Dati privati */
145 	virtual unsigned int iGetNumPrivData(void) const;
146 	virtual unsigned int iGetPrivDataIdx(const char *s) const;
147 	virtual doublereal dGetPrivData(unsigned int i) const;
148 
149 	/* Numero di GDL iniziali */
150 	virtual unsigned int iGetInitialNumDof(void) const;
151 
152 	/* Dimensioni del workspace */
153 	virtual void
154 	InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
155 
156 	/* assemblaggio jacobiano */
157 	virtual VariableSubMatrixHandler&
158 	InitialAssJac(VariableSubMatrixHandler& WorkMat,
159 		const VectorHandler& XCurr);
160 
161 	/* assemblaggio residuo */
162 	virtual SubVectorHandler&
163 	InitialAssRes(SubVectorHandler& WorkVec,
164 		const VectorHandler& XCurr);
165 
166 	/* Tipo di elemento aerodinamico */
167 	virtual AerodynamicElem::Type GetAerodynamicElemType(void) const;
168 
169 	/*
170 	 * Fornisce il tipo e la label dei nodi che sono connessi all'elemento
171 	 * utile per l'assemblaggio della matrice di connessione fra i dofs
172 	 */
173 	virtual void
174 	GetConnectedNodes(std::vector<const Node *>& connectedNodes) const;
175 };
176 
177 extern Elem *
178 ReadGenericAerodynamicForce(DataManager* pDM, MBDynParser& HP,
179 	const DofOwner *pDO, unsigned int uLabel);
180 
181 /* GenericAerodynamicForce - end */
182 
183 #endif /* GENFM_H */
184 
185