readMechanicalProperties.H
Go to the documentation of this file.
1 Info<< "Reading mechanical properties\n" << endl;
2
3 IOdictionary mechanicalProperties
4 (
5 IOobject
6 (
7 "mechanicalProperties",
8 runTime.constant(),
9 mesh,
10 IOobject::MUST_READ_IF_MODIFIED,
11 IOobject::NO_WRITE
12 )
13 );
14
15 const dictionary& rhoDict(mechanicalProperties.subDict("rho"));
16 word rhoType(rhoDict.get<word>("type"));
17
18 autoPtr<volScalarField> rhoPtr;
19
20 IOobject rhoIO
21 (
22 "rho",
23 runTime.timeName(0),
24 mesh,
25 IOobject::NO_READ,
26 IOobject::NO_WRITE
27 );
28
29 if (rhoType == "uniform")
30 {
31 scalar rhoValue(rhoDict.get<scalar>("value"));
32
33 rhoPtr.reset
34 (
35 new volScalarField
36 (
37 rhoIO,
38 mesh,
39 dimensionedScalar
40 (
41 "rho",
42 dimMass/dimVolume,
43 rhoValue
44 )
45 )
46 );
47 }
48 else if (rhoType == "field")
49 {
50 rhoIO.readOpt(IOobject::MUST_READ);
51
52 rhoPtr.reset
53 (
54 new volScalarField
55 (
56 rhoIO,
57 mesh
58 )
59 );
60 }
61 else
62 {
64 << "Valid type entries are uniform or field for rho"
65 << abort(FatalError);
66 }
67
68 volScalarField& rho = rhoPtr();
69
70 const dictionary& EDict(mechanicalProperties.subDict("E"));
71 word EType(EDict.get<word>("type"));
72
73 autoPtr<volScalarField> EPtr;
74
75 IOobject EHeader
76 (
77 "E",
78 runTime.timeName(0),
79 mesh,
80 IOobject::NO_READ,
81 IOobject::NO_WRITE
82 );
83
84 if (EType == "uniform")
85 {
86 scalar rhoEValue(EDict.get<scalar>("value"));
87
88 EPtr.reset
89 (
90 new volScalarField
91 (
92 EHeader,
93 mesh,
94 dimensionedScalar
95 (
96 "Erho",
97 dimMass/dimLength/sqr(dimTime),
98 rhoEValue
99 )
100 )
101 );
102 }
103 else if (EType == "field")
104 {
105 EHeader.readOpt(IOobject::MUST_READ);
106
107 EPtr.reset
108 (
109 new volScalarField
110 (
111 EHeader,
112 mesh
113 )
114 );
115 }
116 else
117 {
119 << "Valid type entries are uniform or field for E"
120 << abort(FatalError);
121 }
122
123 volScalarField& rhoE = EPtr();
124
125 autoPtr<volScalarField> nuPtr;
126
127 IOobject nuIO
128 (
129 "nu",
130 runTime.timeName(0),
131 mesh,
132 IOobject::NO_READ,
133 IOobject::NO_WRITE
134 );
135
136 const dictionary& nuDict(mechanicalProperties.subDict("nu"));
137 word nuType(nuDict.get<word>("type"));
138
139 if (nuType == "uniform")
140 {
141 scalar nuValue(nuDict.get<scalar>("value"));
142 nuPtr.reset
143 (
144 new volScalarField
145 (
146 nuIO,
147 mesh,
148 dimensionedScalar
149 (
150 "nu",
151 dimless,
152 nuValue
153 )
154 )
155 );
156 }
157 else if (nuType == "field")
158 {
159 nuIO.readOpt(IOobject::MUST_READ);
160 nuPtr.reset
161 (
162 new volScalarField
163 (
164 nuIO,
165 mesh
166 )
167 );
168 }
169 else
170 {
172 << "Valid type entries are uniform or field for nu"
173 << abort(FatalError);
174 }
175
176 volScalarField& nu = nuPtr();
177
178 Info<< "Normalising E : E/rho\n" << endl;
179 volScalarField E(rhoE/rho);
180
181 Info<< "Calculating Lame's coefficients\n" << endl;
182
183 volScalarField mu(E/(2.0*(1.0 + nu)));
184 volScalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
185 volScalarField threeK(E/(1.0 - 2.0*nu));
186
187 if (mechanicalProperties.get<bool>("planeStress"))
188 {
189 Info<< "Plane Stress\n" << endl;
190
191 lambda = nu*E/((1.0 + nu)*(1.0 - nu));
192 threeK = E/(1.0 - nu);
193 }
194 else
195 {
196 Info<< "Plane Strain\n" << endl;
197 }
const volScalarField & mu
dynamicFvMesh & mesh
engineTime & runTime
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
const dictionary & EDict(mechanicalProperties.subDict("E"))
const dictionary & nuDict(mechanicalProperties.subDict("nu"))
volScalarField & rho
Info<< "Reading mechanical properties\n"<< endl;IOdictionary mechanicalProperties(IOobject("mechanicalProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE));const dictionary &rhoDict(mechanicalProperties.subDict("rho"));word rhoType(rhoDict.get< word >("type"));autoPtr< volScalarField > rhoPtr
IOobject EHeader("E", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
autoPtr< volScalarField > EPtr
volScalarField & rhoE
word EType(EDict.get< word >("type"))
autoPtr< volScalarField > nuPtr
volScalarField & nu
IOobject rhoIO("rho", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
IOobject nuIO("nu", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
word nuType(nuDict.get< word >("type"))
dimensionedScalar lambda("lambda", dimTime/sqr(dimLength), laminarTransport)