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  zeroGradientFvPatchField<scalar>::typeName
46  )
47  );
48  }
49  else if (rhoType == "field")
50  {
51  rhoIO.readOpt() = IOobject::MUST_READ;
52 
53  rhoPtr.reset
54  (
55  new volScalarField
56  (
57  rhoIO,
58  mesh
59  )
60  );
61  }
62  else
63  {
65  << "Valid type entries are uniform or field for rho"
66  << abort(FatalError);
67  }
68 
70 
71  const dictionary& EDict(mechanicalProperties.subDict("E"));
72  word EType(EDict.lookup("type"));
73 
74  autoPtr<volScalarField> EPtr;
75 
76  IOobject EHeader
77  (
78  "E",
79  runTime.timeName(0),
80  mesh,
81  IOobject::NO_READ,
82  IOobject::NO_WRITE
83  );
84 
85  if (EType == "uniform")
86  {
87  scalar rhoEValue(readScalar(EDict.lookup("value")));
88 
89  EPtr.reset
90  (
91  new volScalarField
92  (
93  EHeader,
94  mesh,
96  (
97  "Erho",
99  rhoEValue
100  ),
101  zeroGradientFvPatchField<scalar>::typeName
102  )
103  );
104  }
105  else if (EType == "field")
106  {
107  EHeader.readOpt() = IOobject::MUST_READ;
108 
109  EPtr.reset
110  (
111  new volScalarField
112  (
113  EHeader,
114  mesh
115  )
116  );
117  }
118  else
119  {
121  << "Valid type entries are uniform or field for E"
122  << abort(FatalError);
123  }
124 
126 
127  autoPtr<volScalarField> nuPtr;
128 
129  IOobject nuIO
130  (
131  "nu",
132  runTime.timeName(0),
133  mesh,
134  IOobject::NO_READ,
135  IOobject::NO_WRITE
136  );
137 
138  const dictionary& nuDict(mechanicalProperties.subDict("nu"));
139  word nuType(nuDict.lookup("type"));
140 
141  if (nuType == "uniform")
142  {
143  scalar nuValue(readScalar(nuDict.lookup("value")));
144  nuPtr.reset
145  (
146  new volScalarField
147  (
148  nuIO,
149  mesh,
151  (
152  "nu",
153  dimless,
154  nuValue
155  ),
156  zeroGradientFvPatchField<scalar>::typeName
157  )
158  );
159  }
160  else if (nuType == "field")
161  {
162  nuIO.readOpt() = IOobject::MUST_READ;
163  nuPtr.reset
164  (
165  new volScalarField
166  (
167  nuIO,
168  mesh
169  )
170  );
171  }
172  else
173  {
175  << "Valid type entries are uniform or field for nu"
176  << abort(FatalError);
177  }
178 
180 
181  Info<< "Normalising E : E/rho\n" << endl;
183 
184  Info<< "Calculating Lame's coefficients\n" << endl;
185 
186  volScalarField mu(E/(2.0*(1.0 + nu)));
187  volScalarField lambda(nu*E/((1.0 + nu)*(1.0 - 2.0*nu)));
188  volScalarField threeK(E/(1.0 - 2.0*nu));
189 
190  Switch planeStress(mechanicalProperties.lookup("planeStress"));
191 
192  if (planeStress)
193  {
194  Info<< "Plane Stress\n" << endl;
195 
196  lambda = nu*E/((1.0 + nu)*(1.0 - nu));
197  threeK = E/(1.0 - nu);
198  }
199  else
200  {
201  Info<< "Plane Strain\n" << endl;
202  }
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
nuType
word nuType(nuDict.lookup("type"))
Foam::constant::physicoChemical::mu
const dimensionedScalar mu
Atomic mass unit.
Definition: createFields.H:13
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
rho
volScalarField & rho
Definition: readMechanicalProperties.H:69
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
rhoIO
IOobject rhoIO("rho", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
nuPtr
autoPtr< volScalarField > nuPtr
Definition: readMechanicalProperties.H:127
EDict
const dictionary & EDict(mechanicalProperties.subDict("E"))
nu
volScalarField & nu
Definition: readMechanicalProperties.H:179
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
EHeader
IOobject EHeader("E", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
Foam::Info
messageStream Info
nuDict
const dictionary & nuDict(mechanicalProperties.subDict("nu"))
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
EType
word EType(EDict.lookup("type"))
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
rhoE
volScalarField & rhoE
Definition: readMechanicalProperties.H:125
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
readScalar
#define readScalar
Definition: doubleScalar.C:38
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
rhoPtr
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.lookup("type"));autoPtr< volScalarField > rhoPtr
Definition: readMechanicalProperties.H:18
EPtr
autoPtr< volScalarField > EPtr
Definition: readMechanicalProperties.H:74
nuIO
IOobject nuIO("nu", runTime.timeName(0), mesh, IOobject::NO_READ, IOobject::NO_WRITE)
lambda
dimensionedScalar lambda(laminarTransport.lookup("lambda"))