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.lookup("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(readScalar(rhoDict.lookup("value")));
32 
33  rhoPtr.reset
34  (
35  new volScalarField
36  (
37  rhoIO,
38  mesh,
40  (
41  "rho",
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 
69 
70  const dictionary& EDict(mechanicalProperties.subDict("E"));
71  word EType(EDict.lookup("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(readScalar(EDict.lookup("value")));
87 
88  EPtr.reset
89  (
90  new volScalarField
91  (
92  EHeader,
93  mesh,
95  (
96  "Erho",
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.lookup("type"));
138 
139  if (nuType == "uniform")
140  {
141  scalar nuValue(readScalar(nuDict.lookup("value")));
142  nuPtr.reset
143  (
144  new volScalarField
145  (
146  nuIO,
147  mesh,
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 
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  Switch planeStress(mechanicalProperties.lookup("planeStress"));
188 
189  if (planeStress)
190  {
191  Info<< "Plane Stress\n" << endl;
192 
193  lambda = nu*E/((1.0 + nu)*(1.0 - nu));
194  threeK = E/(1.0 - nu);
195  }
196  else
197  {
198  Info<< "Plane Strain\n" << endl;
199  }
#define readScalar
Definition: doubleScalar.C:38
IOobject EHeader("E", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
autoPtr< volScalarField > EPtr
Info<< "Reading mechanical properties\"<< 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.lookup("type"));autoPtr< volScalarField > rhoPtr
IOobject nuIO("nu", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
dynamicFvMesh & mesh
autoPtr< volScalarField > nuPtr
word nuType(nuDict.lookup("type"))
const dictionary & EDict(mechanicalProperties.subDict("E"))
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const dictionary & nuDict(mechanicalProperties.subDict("nu"))
const dimensionedScalar mu
Atomic mass unit.
word EType(EDict.lookup("type"))
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensionedScalar lambda(laminarTransport.lookup("lambda"))
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
messageStream Info
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
IOobject rhoIO("rho", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
volScalarField & nu