summaryrefslogtreecommitdiff
blob: 007f845b2a04fd23b1bff8b0cf4fa379b919deee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
Index: src/LESmodels/compressible/SpalartAllmaras/SpalartAllmaras.C
===================================================================
--- src/LESmodels/compressible/SpalartAllmaras/SpalartAllmaras.C	(Revision 30)
+++ src/LESmodels/compressible/SpalartAllmaras/SpalartAllmaras.C	(Revision 408)
@@ -44,29 +44,38 @@
 
 
 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
 
 tmp<volScalarField> SpalartAllmaras::fv1() const
 {
     volScalarField chi3 = pow(nuTilda_/(mu()/rho()), 3);
-
     return chi3/(chi3 + pow(Cv1_, 3));
 }
 
 
 tmp<volScalarField> SpalartAllmaras::fv2() const
 {
     volScalarField chi = nuTilda_/(mu()/rho());
     return scalar(1) - chi/(scalar(1) + chi*fv1());
 }
 
 
 tmp<volScalarField> SpalartAllmaras::fw(const volScalarField& Stilda) const
 {
-    volScalarField r = nuTilda_/(Stilda*sqr(kappa_*dTilda_));
+    volScalarField r = min
+    (
+        nuTilda_
+       /(
+           max(Stilda, dimensionedScalar("SMALL", Stilda.dimensions(), SMALL))
+          *sqr(kappa_*dTilda_)
+        ),
+        scalar(10.0)
+    );
+    r.boundaryField() == 0.0;
+
     volScalarField g = r + Cw2_*(pow(r, 6) - r);
 
     return g*pow((1.0 + pow(Cw3_, 6))/(pow(g, 6) + pow(Cw3_, 6)), 1.0/6.0);
 }
 
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Index: src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C
===================================================================
--- src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C	(Revision 30)
+++ src/dynamicMesh/meshCut/meshModifiers/multiDirRefinement/multiDirRefinement.C	(Revision 408)
@@ -343,16 +343,16 @@
             }
         }
     }
 
 
     hexRefiner.setRefinement(consistentCells, meshMod);
 
-    // Use inflation
-    autoPtr<mapPolyMesh> morphMapPtr = meshMod.changeMesh(mesh, true, true);
+    // Change mesh, no inflation
+    autoPtr<mapPolyMesh> morphMapPtr = meshMod.changeMesh(mesh, false, true);
     const mapPolyMesh& morphMap = morphMapPtr();
 
     if (morphMap.hasMotionPoints())
     {
         mesh.movePoints(morphMap.preMotionPoints());
     }
 
@@ -365,47 +365,31 @@
     {
         Pout<< "multiDirRefinement : updated mesh at time "
             << mesh.time().timeName() << endl;
     }
 
     hexRefiner.updateMesh(morphMap);
 
-    // Take over split pattern from hex refiner. (should be empty at this
-    // point)
-
-    // From old cell label to index
-    Map<label> consistentSet(2*consistentCells.size());
-
-    forAll(consistentCells, i)
-    {
-        consistentSet.insert(consistentCells[i], i);
-    }
-
     // Collect all cells originating from same old cell (original + 7 extra)
 
-    addedCells_.setSize(consistentCells.size());
-    forAll(addedCells_, i)
+    forAll(consistentCells, i)
     {
-        addedCells_[i].setSize(8);
+        addedCells_[consistentCells[i]].setSize(8);
     }
-    labelList nAddedCells(consistentCells.size(), 0);
+    labelList nAddedCells(addedCells_.size(), 0);
 
     const labelList& cellMap = morphMap.cellMap();
 
     forAll(cellMap, cellI)
     {
         label oldCellI = cellMap[cellI];
 
-        Map<label>::const_iterator iter = consistentSet.find(oldCellI);
-
-        if (iter != consistentSet.end())
+        if (addedCells_[oldCellI].size() > 0)
         {
-            label index = iter();
-
-            addedCells_[nAddedCells[index]++] = cellI;
+            addedCells_[oldCellI][nAddedCells[oldCellI]++] = cellI;
         }
     }
 }
 
 
 void Foam::multiDirRefinement::refineAllDirs
 (

Index: src/OpenFOAM/db/error/error.H
===================================================================
--- src/OpenFOAM/db/error/error.H	(Revision 30)
+++ src/OpenFOAM/db/error/error.H	(Revision 408)
@@ -80,14 +80,17 @@
 
         //- Construct from title string
         error(const string& title);
 
         //- Construct from dictionary
         error(const dictionary& errDict);
 
+        //- Construct as copy
+        error(const error& err);
+
 
     // Destructor
 
         ~error();
 
 
     // Member functions
Index: src/OpenFOAM/db/error/error.C
===================================================================
--- src/OpenFOAM/db/error/error.C	(Revision 30)
+++ src/OpenFOAM/db/error/error.C	(Revision 408)
@@ -76,14 +76,28 @@
                "cannot open error stream"
             << endl;
         ::exit(1);
     }
 }
 
 
+error::error(const error& err)
+:
+    messageStream(err),
+    functionName_(err.functionName_),
+    sourceFileName_(err.sourceFileName_),
+    sourceFileLineNumber_(err.sourceFileLineNumber_),
+    abort_(err.abort_),
+    throwExceptions_(err.throwExceptions_),
+    messageStreamPtr_(new OStringStream(*err.messageStreamPtr_))
+{
+    //*messageStreamPtr_ << err.message();
+}
+
+
 error::~error()
 {
     delete messageStreamPtr_;
 }
 
 
 OSstream& error::operator()
@@ -251,14 +265,15 @@
     return os;
 }
 
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 // Global error definitions
 
-error FatalError ("--> FOAM FATAL ERROR : ");
+error FatalError("--> FOAM FATAL ERROR : ");
 
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
 } // End namespace Foam
 
 // ************************************************************************* //
+
Index: src/OpenFOAM/db/dictionary/dictionary.C
===================================================================
--- src/OpenFOAM/db/dictionary/dictionary.C	(Revision 30)
+++ src/OpenFOAM/db/dictionary/dictionary.C	(Revision 408)
@@ -119,14 +119,20 @@
     }
     else
     {
         return -1;
     }
 }
 
+// Clear the Dictionary
+void Foam::dictionary::clear()
+{
+    IDLList<entry>::clear();
+    hashedEntries_.clear();
+}
 
 // Find and return entry
 bool Foam::dictionary::found(const word& keyword) const
 {
     return hashedEntries_.found(keyword);
 }
 
Index: src/OpenFOAM/db/dictionary/dictionary.H
===================================================================
--- src/OpenFOAM/db/dictionary/dictionary.H	(Revision 30)
+++ src/OpenFOAM/db/dictionary/dictionary.H	(Revision 408)
@@ -126,14 +126,16 @@
 
         //- Return line number of first token in dictionary
         label startLineNumber() const;
 
         //- Return line number of last token in dictionary
         label endLineNumber() const;
 
+        //- Clear the dictionary
+        void clear();
 
         // Search and lookup
 
             //- Search dictionary for given keyword
             bool found(const word& keyword) const;
 
             //- Find and return an entry data stream
Index: src/OpenFOAM/db/IOstreams/StringStreams/OStringStream.H
===================================================================
--- src/OpenFOAM/db/IOstreams/StringStreams/OStringStream.H	(Revision 30)
+++ src/OpenFOAM/db/IOstreams/StringStreams/OStringStream.H	(Revision 408)
@@ -63,21 +63,41 @@
         (
             streamFormat format=ASCII,
             versionNumber version=currentVersion
         )
         :
             OSstream
             (
-                *(new std::ostringstream()),
+               *(new std::ostringstream()),
                 "OStringStream.sinkFile",
                 format,
                 version
             )
         {}
 
+        //- Construct as copy
+        OStringStream(const OStringStream& oss)
+        :
+            OSstream
+            (
+               *(
+                    new std::ostringstream
+                    (
+                        dynamic_cast<const std::ostringstream&>
+                        (
+                            oss.stream()
+                        ).str()
+                    )
+                ),
+                oss.name(),
+                oss.format(),
+                oss.version()
+            )
+        {}
+
 
     // Destructor
 
         ~OStringStream()
         {
             delete &dynamic_cast<std::ostringstream&>(stream());
         }
Index: src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H
===================================================================
--- src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H	(Revision 30)
+++ src/OpenFOAM/fields/pointPatchFields/pointPatchField/pointPatchFieldFunctions.H	(Revision 408)
@@ -214,32 +214,28 @@
 #undef BINARY_TYPE_OPERATOR_FT
 
 
 #define PRODUCT_OPERATOR(product, op, opFunc)                                 \
                                                                               \
 template                                                                      \
 <                                                                             \
-    template<class> class PatchField,                                         \
-    class pointPatch,                                                         \
     class Type1,                                                              \
     class Type2                                                               \
 >                                                                             \
 inline void opFunc                                                            \
 (                                                                             \
     pointPatchField                                                           \
     <typename product<Type1, Type2>::type>& f,                                \
     const pointPatchField<Type1>& f1,                                         \
     const pointPatchField<Type2>& f2                                          \
 )                                                                             \
 {}                                                                            \
                                                                               \
 template                                                                      \
 <                                                                             \
-    template<class> class PatchField,                                         \
-    class pointPatch,                                                         \
     class Type,                                                               \
     class Form,                                                               \
     class Cmpt,                                                               \
     int nCmpt                                                                 \
 >                                                                             \
 inline void opFunc                                                            \
 (                                                                             \
@@ -248,16 +244,14 @@
     const pointPatchField<Type>& f1,                                          \
     const VectorSpace<Form,Cmpt,nCmpt>& vs                                    \
 )                                                                             \
 {}                                                                            \
                                                                               \
 template                                                                      \
 <                                                                             \
-    template<class> class PatchField,                                         \
-    class pointPatch,                                                         \
     class Form,                                                               \
     class Cmpt,                                                               \
     int nCmpt,                                                                \
     class Type                                                                \
 >                                                                             \
 inline void opFunc                                                            \
 (                                                                             \
@@ -272,112 +266,99 @@
 PRODUCT_OPERATOR(crossProduct, ^, cross)
 PRODUCT_OPERATOR(innerProduct, &, dot)
 PRODUCT_OPERATOR(scalarProduct, &&, dotdot)
 
 #undef PRODUCT_OPERATOR
 
 
-template<template<class> class PatchField, class pointPatch>
-void hdual
+inline void hdual
 (
     pointPatchField<vector>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void hdual
+inline void hdual
 (
     pointPatchField<tensor>&,
     const pointPatchField<vector>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void diag
+inline void diag
 (
     pointPatchField<vector>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void tr
+inline void tr
 (
     pointPatchField<scalar>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void dev
+inline void dev
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void dev2
+inline void dev2
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void det
+inline void det
 (
     pointPatchField<scalar>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void inv
+inline void inv
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void symm
+inline void symm
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void twoSymm
+inline void twoSymm
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void skew
+inline void skew
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void eigenValues
+inline void eigenValues
 (
     pointPatchField<vector>&,
     const pointPatchField<tensor>&
 )
 {}
 
-template<template<class> class PatchField, class pointPatch>
-void eigenVectors
+inline void eigenVectors
 (
     pointPatchField<tensor>&,
     const pointPatchField<tensor>&
 )
 {}
 
 
Index: src/OpenFOAM/fields/Fields/symmTensorField/symmTensorField.C
===================================================================
--- src/OpenFOAM/fields/Fields/symmTensorField/symmTensorField.C	(Revision 30)
+++ src/OpenFOAM/fields/Fields/symmTensorField/symmTensorField.C	(Revision 408)
@@ -131,16 +131,15 @@
 
 template<>
 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
 (
     const tmp<tensorField>& ttf
 )
 {
-    tmp<Field<symmTensor> > ret =
-        transformFieldMask<symmTensor>(ttf());
+    tmp<Field<symmTensor> > ret = transformFieldMask<symmTensor>(ttf());
     ttf.clear();
     return ret;
 }
 
 
 template<>
 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
@@ -153,18 +152,15 @@
 
 template<>
 tmp<Field<symmTensor> > transformFieldMask<symmTensor>
 (
     const tmp<symmTensorField>& tstf
 )
 {
-    tmp<Field<symmTensor> > ret =
-        transformFieldMask<symmTensor>(tstf());
-    tstf.clear();
-    return ret;
+    return tstf;
 }
 
 
 // * * * * * * * * * * * * * * * global operators  * * * * * * * * * * * * * //
 
 UNARY_OPERATOR(vector, symmTensor, *, hdual)
 
Index: src/OpenFOAM/primitives/Tensor/TensorI.H
===================================================================
--- src/OpenFOAM/primitives/Tensor/TensorI.H	(Revision 30)
+++ src/OpenFOAM/primitives/Tensor/TensorI.H	(Revision 408)
@@ -358,14 +358,23 @@
         v1.x()*v2.x(), v1.x()*v2.y(), v1.x()*v2.z(),
         v1.y()*v2.x(), v1.y()*v2.y(), v1.y()*v2.z(),
         v1.z()*v2.x(), v1.z()*v2.y(), v1.z()*v2.z()
     );
 }
 
 
+//- Division of a vector by a tensor, i.e. dot-product with the tensor inverse
+template <class Cmpt>
+inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt> >::type
+operator/(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
+{
+    return inv(t) & v;
+}
+
+
 // * * * * * * * * * * * * * * * Global Functions  * * * * * * * * * * * * * //
 
 //- Return the trace of a tensor
 template <class Cmpt>
 inline Cmpt tr(const Tensor<Cmpt>& t)
 {
     return t.xx() + t.yy() + t.zz();
@@ -790,46 +799,30 @@
 //- Double-dot-product between a spherical tensor and a tensor
 template <class Cmpt>
 inline Cmpt
 operator&&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
 {
     return
     (
-        st1.xx()*t2.xx() + st1.xy()*t2.yx() + st1.xz()*t2.zx() +
-        st1.xx()*t2.xy() + st1.xy()*t2.yy() + st1.xz()*t2.zy() +
-        st1.xx()*t2.xz() + st1.xy()*t2.yz() + st1.xz()*t2.zz() +
-
-        st1.xy()*t2.xx() + st1.yy()*t2.yx() + st1.yz()*t2.zx() +
-        st1.xy()*t2.xy() + st1.yy()*t2.yy() + st1.yz()*t2.zy() +
-        st1.xy()*t2.xz() + st1.yy()*t2.yz() + st1.yz()*t2.zz() +
-
-        st1.xz()*t2.xx() + st1.yz()*t2.yx() + st1.zz()*t2.zx() +
-        st1.xz()*t2.xy() + st1.yz()*t2.yy() + st1.zz()*t2.zy() +
-        st1.xz()*t2.xz() + st1.yz()*t2.yz() + st1.zz()*t2.zz()
+        st1.xx()*t2.xx() + st1.xy()*t2.xy() + st1.xz()*t2.xz() +
+        st1.xy()*t2.yx() + st1.yy()*t2.yy() + st1.yz()*t2.yz() +
+        st1.xz()*t2.zx() + st1.yz()*t2.zy() + st1.zz()*t2.zz()
     );
 }
 
 
 //- Double-dot-product between a tensor and a spherical tensor
 template <class Cmpt>
 inline Cmpt
 operator&&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
 {
     return
     (
         t1.xx()*st2.xx() + t1.xy()*st2.xy() + t1.xz()*st2.xz() +
-        t1.xx()*st2.xy() + t1.xy()*st2.yy() + t1.xz()*st2.yz() +
-        t1.xx()*st2.xz() + t1.xy()*st2.yz() + t1.xz()*st2.zz() +
-
-        t1.yx()*st2.xx() + t1.yy()*st2.xy() + t1.yz()*st2.xz() +
         t1.yx()*st2.xy() + t1.yy()*st2.yy() + t1.yz()*st2.yz() +
-        t1.yx()*st2.xz() + t1.yy()*st2.yz() + t1.yz()*st2.zz() +
-
-        t1.zx()*st2.xx() + t1.zy()*st2.xy() + t1.zz()*st2.xz() +
-        t1.zx()*st2.xy() + t1.zy()*st2.yy() + t1.zz()*st2.yz() +
         t1.zx()*st2.xz() + t1.zy()*st2.yz() + t1.zz()*st2.zz()
     );
 }
 
 
 template<class Cmpt>
 class typeOfSum<SymmTensor<Cmpt>, Tensor<Cmpt> >

Index: src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C
===================================================================
--- src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C	(Revision 30)
+++ src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C	(Revision 408)
@@ -20,23 +20,18 @@
 
     You should have received a copy of the GNU General Public License
     along with OpenFOAM; if not, write to the Free Software Foundation,
     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 
 \*---------------------------------------------------------------------------*/
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Type>
-void fvMatrix<Type>::setComponentReference
+void Foam::fvMatrix<Type>::setComponentReference
 (
     const label patchi,
     const label facei,
     const direction cmpt,
     const scalar value
 )
 {
@@ -52,15 +47,18 @@
                *value;
         }
     }
 }
 
 
 template<class Type>
-lduMatrix::solverPerformance fvMatrix<Type>::solve(Istream& solverControls)
+Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
+(
+    Istream& solverControls
+)
 {
     if (debug)
     {
         Info<< "fvMatrix<Type>::solve(Istream& solverControls) : "
                "solving fvMatrix<Type>"
             << endl;
     }
@@ -70,15 +68,19 @@
         "fvMatrix<Type>::solve",
         psi_.name()
     );
 
     scalarField saveDiag = diag();
 
     Field<Type> source = source_;
-    addBoundarySource(source, false);
+
+    // At this point include the boundary source from the coupled boundaries.
+    // This is corrected for the implict part by updateMatrixInterfaces within
+    // the component loop.
+    addBoundarySource(source);
 
     typename Type::labelType validComponents
     (
         pow
         (
             psi_.mesh().directions(),
             pTraits<typename powProduct<Vector<label>, Type::rank>::type>::zero
@@ -105,14 +107,35 @@
         (
             internalCoeffs_.component(cmpt)
         );
 
         lduInterfaceFieldPtrsList interfaces = 
             psi_.boundaryField().interfaces();
 
+        // Use the initMatrixInterfaces and updateMatrixInterfaces to correct
+        // bouCoeffsCmpt for the explicit part of the coupled boundary
+        // conditions
+        initMatrixInterfaces
+        (
+            bouCoeffsCmpt,
+            interfaces,
+            psiCmpt,
+            sourceCmpt,
+            cmpt
+        );
+
+        updateMatrixInterfaces
+        (
+            bouCoeffsCmpt,
+            interfaces,
+            psiCmpt,
+            sourceCmpt,
+            cmpt
+        );
+
         lduMatrix::solverPerformance solverPerf;
 
         // Solver call
         solverPerf = lduMatrix::solver::New
         (
             psi_.name() + pTraits<Type>::componentNames[cmpt],
             *this,
@@ -140,35 +163,36 @@
     psi_.correctBoundaryConditions();
 
     return solverPerfVec;
 }
 
 
 template<class Type>
-autoPtr<typename fvMatrix<Type>::fvSolver> fvMatrix<Type>::solver()
+Foam::autoPtr<typename Foam::fvMatrix<Type>::fvSolver>
+Foam::fvMatrix<Type>::solver()
 {
     return solver(psi_.mesh().solver(psi_.name()));
 }
 
 template<class Type>
-lduMatrix::solverPerformance fvMatrix<Type>::fvSolver::solve()
+Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve()
 {
     return solve(psi_.mesh().solver(psi_.name()));
 }
 
 
 template<class Type>
-lduMatrix::solverPerformance fvMatrix<Type>::solve()
+Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve()
 {
     return solve(psi_.mesh().solver(psi_.name()));
 }
 
 
 template<class Type>
-tmp<Field<Type> > fvMatrix<Type>::residual() const
+Foam::tmp<Foam::Field<Type> > Foam::fvMatrix<Type>::residual() const
 {
     tmp<Field<Type> > tres(source_);
     Field<Type>& res = tres();
 
     addBoundarySource(res);
 
     // Loop over field components
@@ -198,12 +222,8 @@
         );
     }
 
     return tres;
 }
 
 
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
 // ************************************************************************* //
Index: src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C
===================================================================
--- src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C	(Revision 30)
+++ src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C	(Revision 408)
@@ -181,14 +181,15 @@
 )
 :
     fixedValueFvPatchField<Type>(ptf, iF),
     setAverage_(ptf.setAverage_),
     referenceCS_(ptf.referenceCS_),
     nearestVertex_(ptf.nearestVertex_),
     nearestVertexWeight_(ptf.nearestVertexWeight_),
+    fieldName_(ptf.fieldName_),
     sampleTimes_(ptf.sampleTimes_),
     startSampleTime_(ptf.startSampleTime_),
     startSampledValues_(ptf.startSampledValues_),
     startAverage_(ptf.startAverage_),
     endSampleTime_(ptf.endSampleTime_),
     endSampledValues_(ptf.endSampledValues_),
     endAverage_(ptf.endAverage_)
Index: src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C
===================================================================
--- src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C	(Revision 30)
+++ src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresVectors.C	(Revision 408)
@@ -150,15 +150,15 @@
         if (p.coupled())
         {
             forAll(pd, patchFacei)
             {
                 const vector& d = pd[patchFacei];
 
                 dd[faceCells[patchFacei]] +=
-                    (pw[patchFacei]*pMagSf[patchFacei]/magSqr(d))*sqr(d);
+                    ((1 - pw[patchFacei])*pMagSf[patchFacei]/magSqr(d))*sqr(d);
             }
         }
         else
         {
             forAll(pd, patchFacei)
             {
                 const vector& d = pd[patchFacei];

Index: src/turbulenceModels/compressible/kOmegaSST/kOmegaSST.C
===================================================================
--- src/turbulenceModels/compressible/kOmegaSST/kOmegaSST.C	(Revision 30)
+++ src/turbulenceModels/compressible/kOmegaSST/kOmegaSST.C	(Revision 408)
@@ -237,15 +237,15 @@
     {
         y_.correct();
         divU += fvc::div(mesh_.phi());
     }
 
     tmp<volTensorField> tgradU = fvc::grad(U_);
     volScalarField S2 = magSqr(symm(tgradU()));
-    volScalarField GbyMu = 2*mut_*(tgradU() && dev(symm(tgradU())));
+    volScalarField GbyMu = 2*(tgradU() && dev(symm(tgradU())));
     volScalarField G = mut_*GbyMu;
     tgradU.clear();
 
 #   include "kOmegaWallFunctionsI.H"
 
     volScalarField CDkOmega =
         (2*alphaOmega2)*(fvc::grad(k_) & fvc::grad(omega_))/omega_;
@@ -280,15 +280,15 @@
     // Turbulent kinetic energy equation
     tmp<fvScalarMatrix> kEqn
     (
         fvm::ddt(rho_, k_)
       + fvm::div(phi_, k_)
       - fvm::laplacian(DkEff(F1), k_)
      ==
-        min(G, c1*betaStar*k_*omega_)
+        min(G, (c1*betaStar)*rho_*k_*omega_)
       - fvm::SuSp(2.0/3.0*rho_*divU, k_)
       - fvm::Sp(rho_*betaStar*omega_, k_)
     );
 
     kEqn().relax();
     solve(kEqn);
     bound(k_, k0_);