TexGen
Properties.cpp
Go to the documentation of this file.
1/*=============================================================================
2TexGen: Geometric textile modeller.
3Copyright (C) 2006 Martin Sherburn
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18=============================================================================*/
19
20#include "PrecompiledHeaders.h"
21#include "Properties.h"
22#include "DefaultProperties.h"
23using namespace TexGen;
24
25CProperties::CProperties()
26: m_YarnLinearDensity("kg/m")
27, m_FibreDensity("kg/m^3")
28, m_FibreArea("m^2")
29, m_FibreDiameter("m")
30, m_YoungsModulusX("MPa")
31, m_YoungsModulusY("MPa")
32, m_YoungsModulusZ("MPa")
33, m_ShearModulusXY("MPa")
34, m_ShearModulusXZ("MPa")
35, m_ShearModulusYZ("MPa")
36, m_AlphaX("/K")
37, m_AlphaY("/K")
38, m_AlphaZ("/K")
39, m_iFibresPerYarn(0)
40, m_CalculatedArea("m^2")
41{
43 //m_PoissonsRatioX = m_PoissonsRatioY = m_PoissonsRatioZ = 0.1;
44}
45
46CProperties::CProperties(TiXmlElement &Element)
47: m_YarnLinearDensity("kg/m")
48, m_FibreDensity("kg/m^3")
49, m_FibreArea("m^2")
50, m_FibreDiameter("m")
51, m_YoungsModulusX("MPa")
52, m_YoungsModulusY("MPa")
53, m_YoungsModulusZ("MPa")
54, m_ShearModulusXY("MPa")
55, m_ShearModulusXZ("MPa")
56, m_ShearModulusYZ("MPa")
57, m_AlphaX("/K")
58, m_AlphaY("/K")
59, m_AlphaZ("/K")
60, m_iFibresPerYarn(0)
61, m_CalculatedArea("m^2")
62{
63 m_YarnLinearDensity.ReadAttribute(Element, "YarnLinearDensity");
64 m_FibreDensity.ReadAttribute(Element, "FibreDensity");
65 m_FibreArea.ReadAttribute(Element, "FibreArea");
66 m_FibreDiameter.ReadAttribute(Element, "FibreDiameter");
67 Element.Attribute("FibresPerYarn", &m_iFibresPerYarn);
68 m_YoungsModulusX.ReadAttribute(Element, "YoungsModulus"); // Leave X as YoungsModulus so compatible with older versions
69 m_YoungsModulusY.ReadAttribute(Element, "YoungsModulusY");
70 m_YoungsModulusZ.ReadAttribute(Element, "YoungsModulusZ");
71 Element.Attribute("PoissonsRatio", &m_PoissonsRatioX);
72 Element.Attribute("PoissonsRatioY", &m_PoissonsRatioY);
73 Element.Attribute("PoissonsRatioZ", &m_PoissonsRatioZ);
74 m_ShearModulusXY.ReadAttribute(Element, "ShearModulusXY");
75 m_ShearModulusXZ.ReadAttribute(Element, "ShearModulusXZ");
76 m_ShearModulusYZ.ReadAttribute(Element, "ShearModulusYZ");
77 m_AlphaX.ReadAttribute(Element, "AlphaX");
78 m_AlphaY.ReadAttribute(Element, "AlphaY");
79 m_AlphaZ.ReadAttribute(Element, "AlphaZ");
80}
81
83{
84}
85
86void CProperties::PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
87{
88 m_YarnLinearDensity.WriteAttribute(Element, "YarnLinearDensity");
89 m_FibreDensity.WriteAttribute(Element, "FibreDensity");
90 m_FibreArea.WriteAttribute(Element, "FibreArea");
91 m_FibreDiameter.WriteAttribute(Element, "FibreDiameter");
93 Element.SetAttribute("FibresPerYarn", m_iFibresPerYarn);
94 m_YoungsModulusX.WriteAttribute(Element, "YoungsModulus");
95 m_YoungsModulusY.WriteAttribute(Element, "YoungsModulusY");
96 m_YoungsModulusZ.WriteAttribute(Element, "YoungsModulusZ");
97
98 if (m_PoissonsRatioX != 0.0 )
99 {
100 Element.SetAttribute("PoissonsRatio", stringify(m_PoissonsRatioX));
101 }
102 if ( m_PoissonsRatioY != 0.0 )
103 {
104 Element.SetAttribute("PoissonsRatioY", stringify(m_PoissonsRatioY));
105 }
106 if ( m_PoissonsRatioZ != 0.0 )
107 {
108 Element.SetAttribute("PoissonsRatioZ", stringify(m_PoissonsRatioZ));
109 }
110
111 m_ShearModulusXY.WriteAttribute(Element, "ShearModulusXY");
112 m_ShearModulusXZ.WriteAttribute(Element, "ShearModulusXZ");
113 m_ShearModulusYZ.WriteAttribute(Element, "ShearModulusYZ");
114
115 m_AlphaX.WriteAttribute(Element, "AlphaX");
116 m_AlphaY.WriteAttribute(Element, "AlphaY");
117 m_AlphaZ.WriteAttribute(Element, "AlphaZ");
118}
119
120void CProperties::SetYarnLinearDensity(double dValue, string Units)
121{
122 m_YarnLinearDensity.SetValue(dValue, Units);
123 if ( m_FibreDensity.IsSet() )
124 {
126 m_CalculatedArea.SetValue(dFibreArea, "m^2");
127 }
128}
129
130void CProperties::SetFibreDensity(double dValue, string Units)
131{
132 m_FibreDensity.SetValue(dValue, Units);
134 {
136 m_CalculatedArea.SetValue(dFibreArea, "m^2");
137 }
138}
139
140void CProperties::SetFibreArea(double dValue, string Units)
141{
142 m_FibreArea.SetValue(dValue, Units);
143}
144
145void CProperties::SetFibreDiameter(double dValue, string Units)
146{
147 m_FibreDiameter.SetValue(dValue, Units);
148 if ( m_iFibresPerYarn )
149 {
150 double dRadius = 0.5*m_FibreDiameter.GetSIValue();
151 double dFibreArea = PI * dRadius * dRadius * m_iFibresPerYarn;
152 m_CalculatedArea.SetValue(dFibreArea, "m^2");
153 }
154}
155
157{
158 m_iFibresPerYarn = iValue;
160 {
161 double dRadius = 0.5*m_FibreDiameter.GetSIValue();
162 double dFibreArea = PI * dRadius * dRadius * m_iFibresPerYarn;
163 m_CalculatedArea.SetValue(dFibreArea, "m^2");
164 }
165}
166
167void CProperties::SetYoungsModulus(double dValue, string Units)
168{
169 SetYoungsModulusX( dValue, Units );
170 SetYoungsModulusY( dValue, Units );
171 SetYoungsModulusZ( dValue, Units );
172}
173
174void CProperties::SetYoungsModulusX(double dValue, string Units)
175{
176 m_YoungsModulusX.SetValue(dValue, Units);
177}
178
179void CProperties::SetYoungsModulusY(double dValue, string Units)
180{
181 m_YoungsModulusY.SetValue(dValue, Units);
182}
183
184void CProperties::SetYoungsModulusZ(double dValue, string Units)
185{
186 m_YoungsModulusZ.SetValue(dValue, Units);
187}
188
189void CProperties::SetShearModulusXY(double dValue, string Units)
190{
191 m_ShearModulusXY.SetValue(dValue, Units);
192}
193
194void CProperties::SetShearModulusXZ(double dValue, string Units)
195{
196 m_ShearModulusXZ.SetValue(dValue, Units);
197}
198
199void CProperties::SetShearModulusYZ(double dValue, string Units)
200{
201 m_ShearModulusYZ.SetValue(dValue, Units);
202}
203
204void CProperties::SetAlphaX(double dValue, string Units)
205{
206 m_AlphaX.SetValue(dValue, Units);
207}
208
209void CProperties::SetAlphaY(double dValue, string Units)
210{
211 m_AlphaY.SetValue(dValue, Units);
212}
213
214void CProperties::SetAlphaZ(double dValue, string Units)
215{
216 m_AlphaZ.SetValue(dValue, Units);
217}
218
220{
221 SetPoissonsRatioX( dValue );
222 SetPoissonsRatioY( dValue );
223 SetPoissonsRatioZ( dValue );
224}
225
227{
228 m_PoissonsRatioX = dValue;
229}
230
232{
233 m_PoissonsRatioY = dValue;
234}
235
237{
238 m_PoissonsRatioZ = dValue;
239}
240
241double CProperties::GetYarnLinearDensity(string Units) const
242{
243 return m_YarnLinearDensity.GetValue(Units);
244}
245
246double CProperties::GetFibreDensity(string Units) const
247{
248 return m_FibreDensity.GetValue(Units);
249}
250
251double CProperties::GetFibreArea(string Units) const
252{
253 if (m_FibreArea.IsSet())
254 return m_FibreArea.GetValue(Units);
256 {
257 if ( m_CalculatedArea.IsSet() )
258 return m_CalculatedArea.GetValue(Units);
259 else
260 {
261 double dRadius = 0.5*m_FibreDiameter.GetSIValue();
262 double dFibreArea = PI * dRadius * dRadius * m_iFibresPerYarn;
263 return ConvertUnits(dFibreArea, "m^2", Units);
264 }
265 }
267 {
268 if ( m_CalculatedArea.IsSet() )
269 return m_CalculatedArea.GetValue(Units);
270 else
271 {
273 return ConvertUnits(dFibreArea, "m^2", Units);
274 }
275 }
276 return 0;
277}
278
279double CProperties::GetFibreDiameter(string Units) const
280{
281 return m_FibreDiameter.GetValue(Units);
282}
283
285{
286 return m_iFibresPerYarn;
287}
288
289double CProperties::GetYoungsModulusX( string Units) const
290{
291 return m_YoungsModulusX.GetValue(Units);
292}
293
294double CProperties::GetYoungsModulusY( string Units) const
295{
296 return m_YoungsModulusY.GetValue(Units);
297}
298
299double CProperties::GetYoungsModulusZ( string Units) const
300{
301 return m_YoungsModulusZ.GetValue(Units);
302}
303
304double CProperties::GetShearModulusXY( string Units) const
305{
306 return m_ShearModulusXY.GetValue(Units);
307}
308
309double CProperties::GetShearModulusXZ( string Units) const
310{
311 return m_ShearModulusXZ.GetValue(Units);
312}
313
314double CProperties::GetShearModulusYZ( string Units) const
315{
316 return m_ShearModulusYZ.GetValue(Units);
317}
318
319double CProperties::GetAlphaX( string Units) const
320{
321 return m_AlphaX.GetValue(Units);
322}
323
324double CProperties::GetAlphaY( string Units) const
325{
326 return m_AlphaY.GetValue(Units);
327}
328
329double CProperties::GetAlphaZ( string Units) const
330{
331 return m_AlphaZ.GetValue(Units);
332}
333
335{
336 return m_PoissonsRatioX;
337}
338
340{
341 return m_PoissonsRatioY;
342}
343
345{
346 return m_PoissonsRatioZ;
347}
348
350{
354
358
362
366}
367
368
369
370
371
372
373
374
375
376
377
378
#define YARN_POISSONX
#define YARN_ALPHAX
#define YARN_GXZ
#define YARN_GXY
#define YARN_POISSONY
#define YARN_GYZ
#define YARN_EY
#define YARN_EX
#define YARN_EZ
#define YARN_ALPHAY
#define YARN_POISSONZ
#define YARN_ALPHAZ
double GetShearModulusYZ(string Units="MPa") const
Definition: Properties.cpp:314
double GetAlphaZ(string Units="/K") const
Definition: Properties.cpp:329
CProperty m_AlphaX
Definition: Properties.h:208
int GetFibresPerYarn() const
Definition: Properties.cpp:284
void SetPoissonsRatioZ(double dValue)
Definition: Properties.cpp:236
void SetShearModulusXY(double dValue, string Units="MPa")
Set the Shear modulus for a yarn.
Definition: Properties.cpp:189
double GetYarnLinearDensity(string Units="kg/m") const
Definition: Properties.cpp:241
void SetAlphaX(double dValue, string Units="/K")
Set the coefficients of thermal expansion for a yarn.
Definition: Properties.cpp:204
CProperty m_AlphaY
Definition: Properties.h:209
void SetYoungsModulus(double dValue, string Units="MPa")
Set the Young's modulus for a yarn.
Definition: Properties.cpp:167
virtual void PopulateTiXmlElement(TiXmlElement &Element, OUTPUT_TYPE OutputType)
Used for saving data to XML.
Definition: Properties.cpp:86
void SetFibreArea(double dValue, string Units="m^2")
Set the area occupied by fibres in a yarn cross-section.
Definition: Properties.cpp:140
virtual ~CProperties(void)
Definition: Properties.cpp:82
void SetAlphaY(double dValue, string Units="/K")
Definition: Properties.cpp:209
double GetFibreDiameter(string Units="m") const
Definition: Properties.cpp:279
void SetFibresPerYarn(int iValue)
Set the number of fibres in a yarn.
Definition: Properties.cpp:156
void SetShearModulusYZ(double dValue, string Units="MPa")
Definition: Properties.cpp:199
double GetAlphaY(string Units="/K") const
Definition: Properties.cpp:324
void SetYoungsModulusY(double dValue, string Units="MPa")
Definition: Properties.cpp:179
CProperty m_YoungsModulusX
Definition: Properties.h:202
void SetAlphaZ(double dValue, string Units="/K")
Definition: Properties.cpp:214
void SetYarnLinearDensity(double dValue, string Units="kg/m")
Set the fibre linear density, i.e. the mass per unit length of fibre.
Definition: Properties.cpp:120
double GetYoungsModulusY(string Units="MPa") const
Definition: Properties.cpp:294
double GetPoissonsRatioY() const
Definition: Properties.cpp:339
CProperty m_YoungsModulusZ
Definition: Properties.h:204
void SetFibreDiameter(double dValue, string Units="m")
Set the fibre diameter.
Definition: Properties.cpp:145
void SetFibreDensity(double dValue, string Units="kg/m^3")
Set the fibre density, i.e. the mass per unit volume of fibre.
Definition: Properties.cpp:130
CProperty m_FibreDiameter
Definition: Properties.h:201
double GetPoissonsRatioZ() const
Definition: Properties.cpp:344
CProperty m_YarnLinearDensity
Definition: Properties.h:198
void SetPoissonsRatio(double dValue)
Set the Poisson's ratio for a yarn.
Definition: Properties.cpp:219
CProperty m_FibreDensity
Definition: Properties.h:199
double GetFibreArea(string Units="m^2") const
Get the area occupied by fibres given fibre diameter and number of fibres.
Definition: Properties.cpp:251
CProperty m_CalculatedArea
Definition: Properties.h:211
void SetDefaultProperties()
Set default properties as specified by DefaultProperties.h.
Definition: Properties.cpp:349
CProperty m_ShearModulusXY
Definition: Properties.h:205
double GetYoungsModulusX(string Units="MPa") const
Definition: Properties.cpp:289
double GetPoissonsRatioX() const
Definition: Properties.cpp:334
void SetShearModulusXZ(double dValue, string Units="MPa")
Definition: Properties.cpp:194
CProperty m_ShearModulusYZ
Definition: Properties.h:207
double GetAlphaX(string Units="/K") const
Definition: Properties.cpp:319
double GetShearModulusXZ(string Units="MPa") const
Definition: Properties.cpp:309
CProperty m_AlphaZ
Definition: Properties.h:210
void SetYoungsModulusX(double dValue, string Units="MPa")
Definition: Properties.cpp:174
void SetPoissonsRatioY(double dValue)
Definition: Properties.cpp:231
void SetPoissonsRatioX(double dValue)
Definition: Properties.cpp:226
double GetFibreDensity(string Units="kg/m^3") const
Definition: Properties.cpp:246
double GetYoungsModulusZ(string Units="MPa") const
Definition: Properties.cpp:299
CProperty m_FibreArea
Definition: Properties.h:200
double GetShearModulusXY(string Units="MPa") const
Definition: Properties.cpp:304
void SetYoungsModulusZ(double dValue, string Units="MPa")
Definition: Properties.cpp:184
CProperty m_YoungsModulusY
Definition: Properties.h:203
CProperty m_ShearModulusXZ
Definition: Properties.h:206
bool IsSet() const
Definition: Property.cpp:124
double GetValue(string Units) const
Definition: Property.cpp:56
void SetValue(double dValue, string Units)
Definition: Property.cpp:66
double GetSIValue() const
Definition: Property.cpp:61
void WriteAttribute(TiXmlElement &Element, string AttributeName)
Definition: Property.cpp:31
void ReadAttribute(TiXmlElement &Element, string AttributeName)
Definition: Property.cpp:40
#define PI
Definition: mymath.h:30
Namespace containing a series of customised math operations not found in the standard c++ library.
OUTPUT_TYPE
Definition: Misc.h:105
std::string stringify(const T &x, int iPrecision=12, bool bScientific=true)
Function to convert a value (e.g. int, double, etc...) to a string.
Definition: Misc.h:50
double ConvertUnits(double dValue, std::string SourceUnits, std::string TargetUnits)
Definition: Misc.cpp:63