readThermalProperties.H
Go to the documentation of this file.
1 Info<< "Reading thermal properties\n" << endl;
2 
3 IOdictionary thermalProperties
4 (
5  IOobject
6  (
7  "thermalProperties",
8  runTime.constant(),
9  mesh,
10  IOobject::MUST_READ_IF_MODIFIED,
11  IOobject::NO_WRITE
12  )
13 );
14 
15 Switch thermalStress(thermalProperties.lookup("thermalStress"));
16 
17 volScalarField threeKalpha
18 (
19  IOobject
20  (
21  "threeKalpha",
22  runTime.timeName(),
23  mesh,
24  IOobject::NO_READ,
25  IOobject::NO_WRITE
26  ),
27  mesh,
28  dimensionedScalar(dimensionSet(0, 2, -2 , -1, 0), 0)
29 );
30 
31 
33 (
34  IOobject
35  (
36  "DT",
37  runTime.timeName(),
38  mesh,
39  IOobject::NO_READ,
40  IOobject::NO_WRITE
41  ),
42  mesh,
43  dimensionedScalar(dimensionSet(0, 2, -1 , 0, 0), 0)
44 );
45 
46 
47 // Cache "k" for use in thermal BCs
48 autoPtr<volScalarField> rhoKPtr;
49 
50 if (thermalStress)
51 {
52  IOobject CIO
53  (
54  "C",
55  runTime.timeName(0),
56  mesh,
57  IOobject::NO_READ,
58  IOobject::NO_WRITE
59  );
60 
61  autoPtr<volScalarField> CPtr;
62 
63  const dictionary& CDict(thermalProperties.subDict("C"));
64  word CType(CDict.lookup("type"));
65  if (CType == "uniform")
66  {
67  scalar CValue(readScalar(CDict.lookup("value")));
68 
69  CPtr.reset
70  (
71  new volScalarField
72  (
73  CIO,
74  mesh,
76  (
77  dimensionSet(0, 2, -2 , -1, 0),
78  CValue
79  )
80  )
81  );
82 
83  }
84  else if (CType == "field")
85  {
86  CIO.readOpt() = IOobject::MUST_READ;
87 
88  CPtr.reset
89  (
90  new volScalarField
91  (
92  CIO,
93  mesh
94  )
95  );
96  }
97  else
98  {
100  << "Valid type entries are uniform or field for C"
101  << abort(FatalError);
102  }
103 
104  volScalarField& C = CPtr();
105 
106  IOobject rhoKIO
107  (
108  "k",
109  runTime.timeName(0),
110  mesh,
111  IOobject::NO_READ,
112  IOobject::NO_WRITE
113  );
114 
115  const dictionary& kDict(thermalProperties.subDict("k"));
116  word kType(kDict.lookup("type"));
117  if (kType == "uniform")
118  {
119  scalar rhoKValue(readScalar(kDict.lookup("value")));
120 
121  rhoKPtr.reset
122  (
123  new volScalarField
124  (
125  rhoKIO,
126  mesh,
128  (
129  dimensionSet(1, 1, -3 , -1, 0),
130  rhoKValue
131  )
132  )
133  );
134 
135  }
136  else if (kType == "field")
137  {
138  rhoKIO.readOpt() = IOobject::MUST_READ;
139 
140  rhoKPtr.reset
141  (
142  new volScalarField
143  (
144  rhoKIO,
145  mesh
146  )
147  );
148  }
149  else
150  {
152  << "Valid type entries are uniform or field for K"
153  << abort(FatalError);
154  }
155 
156  volScalarField& rhoK = rhoKPtr();
157 
158  autoPtr<volScalarField> alphaPtr;
159 
160  IOobject alphaIO
161  (
162  "alpha",
163  runTime.timeName(0),
164  mesh,
165  IOobject::NO_READ,
166  IOobject::NO_WRITE
167  );
168 
169 
170  const dictionary& alphaDict(thermalProperties.subDict("alpha"));
171  word alphaType(alphaDict.lookup("type"));
172 
173  if (alphaType == "uniform")
174  {
175  scalar alphaValue(readScalar(alphaDict.lookup("value")));
176  alphaPtr.reset
177  (
178  new volScalarField
179  (
180  alphaIO,
181  mesh,
183  (
185  alphaValue
186  )
187  )
188  );
189  }
190  else if (alphaType == "field")
191  {
192  alphaIO.readOpt() = IOobject::MUST_READ;
193 
194  alphaPtr.reset
195  (
196  new volScalarField
197  (
198  alphaIO,
199  mesh
200  )
201  );
202  }
203  else
204  {
206  << "Valid type entries are uniform or field for alpha"
207  << abort(FatalError);
208  }
209 
210  volScalarField& alpha = alphaPtr();
211 
212  Info<< "Normalising k : k/rho\n" << endl;
213  volScalarField k(rhoK/rho);
214 
215  Info<< "Calculating thermal coefficients\n" << endl;
216 
217  threeKalpha = threeK*alpha;
218  DT = k/C;
219 }
#define readScalar
Definition: doubleScalar.C:38
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
engineTime & runTime
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
label k
Boltzmann constant.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dynamicFvMesh & mesh
Info<< "Reading thermal properties\"<< endl;IOdictionary thermalProperties(IOobject("thermalProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE));Switch thermalStress(thermalProperties.lookup("thermalStress"));volScalarField threeKalpha(IOobject("threeKalpha", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(dimensionSet(0, 2, -2, -1, 0), 0));volScalarField DT(IOobject("DT", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), mesh, dimensionedScalar(dimensionSet(0, 2, -1, 0, 0), 0));autoPtr< volScalarField > rhoKPtr
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:52
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
messageStream Info
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))