59     const objectRegistry& db = 
mesh_.thisDb();
 
   60     PetscScalar* stateVecArray;
 
   61     VecGetArray(stateVec, &stateVecArray);
 
   70             for (label comp = 0; comp < 3; comp++)
 
  119                 assignValueCheckAD(stateVecArray[localIdx], state.boundaryField()[patchIdx][faceIdx]);
 
  123     VecRestoreArray(stateVec, &stateVecArray);
 
  149     const objectRegistry& db = 
mesh_.thisDb();
 
  158             for (label comp = 0; comp < 3; comp++)
 
  161                 state[cellI][comp] = states[localIdx];
 
  174             state[cellI] = states[localIdx];
 
  186             state[cellI] = states[localIdx];
 
  200                 state[faceI] = states[localIdx];
 
  207                 state.boundaryFieldRef()[patchIdx][faceIdx] = states[localIdx];
 
  236     const objectRegistry& db = 
mesh_.thisDb();
 
  245             for (label comp = 0; comp < 3; comp++)
 
  248                 states[localIdx] = state[cellI][comp];
 
  261             states[localIdx] = state[cellI];
 
  273             states[localIdx] = state[cellI];
 
  287                 states[localIdx] = state[faceI];
 
  294                 states[localIdx] = state.boundaryField()[patchIdx][faceIdx];
 
  323     const objectRegistry& db = 
mesh_.thisDb();
 
  324     const PetscScalar* stateVecArray;
 
  325     VecGetArrayRead(stateVec, &stateVecArray);
 
  334             for (label comp = 0; comp < 3; comp++)
 
  337                 state[cellI][comp] = stateVecArray[localIdx];
 
  350             state[cellI] = stateVecArray[localIdx];
 
  362             state[cellI] = stateVecArray[localIdx];
 
  376                 state[faceI] = stateVecArray[localIdx];
 
  383                 state.boundaryFieldRef()[patchIdx][faceIdx] = stateVecArray[localIdx];
 
  387     VecRestoreArrayRead(stateVec, &stateVecArray);
 
  414     pointField meshPoints(
mesh_.points());
 
  418         for (label comp = 0; comp < 3; comp++)
 
  421             meshPoints[pointI][comp] = volCoords[localIdx];
 
  426     fvMesh& 
mesh = 
const_cast<fvMesh&
>(
mesh_);
 
  427     mesh.movePoints(meshPoints);
 
  462     PetscScalar* xvVecArray;
 
  463     VecGetArray(xvVec, &xvVecArray);
 
  467         for (label comp = 0; comp < 3; comp++)
 
  474     VecRestoreArray(xvVec, &xvVecArray);
 
  501     const objectRegistry& db = 
mesh_.thisDb();
 
  502     PetscScalar* stateResVecArray;
 
  503     VecGetArray(resVec, &stateResVecArray);
 
  512             for (label comp = 0; comp < 3; comp++)
 
  561                 assignValueCheckAD(stateResVecArray[localIdx], stateRes.boundaryField()[patchIdx][faceIdx]);
 
  565     VecRestoreArray(resVec, &stateResVecArray);
 
  586             mesh_.time().timeName(),
 
  588             IOobject::READ_IF_PRESENT,
 
  592         dimensionedVector(
"U", dimensionSet(0, 1, -1, 0, 0, 0, 0), vector::zero),
 
  593         zeroGradientFvPatchField<vector>::typeName);
 
  594     forAll(
U.boundaryField(), patchI)
 
  596         if (
U.boundaryFieldRef()[patchI].type() == 
"pressureInletVelocity")
 
  620     if (
specialBCs.found(
"pressureInletVelocity"))
 
  623         volVectorField& 
U(
const_cast<volVectorField&
>(
 
  624             mesh_.thisDb().lookupObject<volVectorField>(
"U")));
 
  625         U.correctBoundaryConditions();
 
  663     const objectRegistry& db = 
mesh_.thisDb();
 
  665     label setTurbWallBCs = 0;
 
  666     label useWallFunction = 0;
 
  669     dictionary bcDict = 
allOptions.subDict(
"primalBC");
 
  671     forAll(bcDict.toc(), idxI)
 
  673         word bcKey = bcDict.toc()[idxI];
 
  675         if (bcKey == 
"useWallFunction")
 
  678             useWallFunction = bcDict.getLabel(
"useWallFunction");
 
  681         else if (bcKey == 
"MRF")
 
  684             scalar omegaNew = bcDict.getScalar(
"MRF");
 
  686             scalar& omega = 
const_cast<scalar&
>(
MRF.getOmegaRef());
 
  691                 Info << 
"Setting MRF omega to " << omegaNew << endl;
 
  696         else if (bcKey == 
"transport:nu")
 
  699             scalar nu = bcDict.getScalar(
"transport:nu");
 
  700             volScalarField& nuField = 
const_cast<volScalarField&
>(
 
  701                 db.lookupObject<volScalarField>(
"nu"));
 
  706             forAll(nuField.boundaryField(), patchI)
 
  708                 forAll(nuField.boundaryField()[patchI], faceI)
 
  710                     nuField.boundaryFieldRef()[patchI][faceI] = nu;
 
  713             nuField.correctBoundaryConditions();
 
  717                 Info << 
"Setting transportProperties nu to " << nu << endl;
 
  722         else if (bcKey == 
"thermo:mu")
 
  725             scalar 
mu = bcDict.getScalar(
"thermo:mu");
 
  726             volScalarField& muField = 
const_cast<volScalarField&
>(
 
  727                 db.lookupObject<volScalarField>(
"thermo:mu"));
 
  732             forAll(muField.boundaryField(), patchI)
 
  734                 forAll(muField.boundaryField()[patchI], faceI)
 
  736                     muField.boundaryFieldRef()[patchI][faceI] = 
mu;
 
  739             muField.correctBoundaryConditions();
 
  743                 Info << 
"Setting thermalphysicalProperties mu to " << 
mu << endl;
 
  749         dictionary bcSubDict = bcDict.subDict(bcKey);
 
  752         bcSubDict.readEntry<wordList>(
"patches", patches);
 
  753         word variable = bcSubDict.getWord(
"variable");
 
  755         bcSubDict.readEntry<scalarList>(
"value", value);
 
  760             word patch = patches[idxI];
 
  763             if (value.size() == 1)
 
  765                 if (!db.foundObject<volScalarField>(variable))
 
  769                         Info << variable << 
" not found, skip it." << endl;
 
  774                 volScalarField& state(
const_cast<volScalarField&
>(
 
  775                     db.lookupObject<volScalarField>(variable)));
 
  779                     Info << 
"Setting primal boundary conditions..." << endl;
 
  780                     Info << 
"Setting " << variable << 
" = " << value[0] << 
" at " << patch << endl;
 
  783                 label patchI = 
mesh_.boundaryMesh().findPatchID(patch);
 
  786                 if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
  788                     if (state.boundaryFieldRef()[patchI].type() == 
"fixedValue")
 
  790                         forAll(state.boundaryFieldRef()[patchI], faceI)
 
  792                             state.boundaryFieldRef()[patchI][faceI] = value[0];
 
  795                     else if (state.boundaryFieldRef()[patchI].type() == 
"inletOutlet" 
  796                              || state.boundaryFieldRef()[patchI].type() == 
"outletInlet")
 
  799                         forAll(state.boundaryFieldRef()[patchI], faceI)
 
  801                             state.boundaryFieldRef()[patchI][faceI] = value[0];
 
  804                         mixedFvPatchField<scalar>& inletOutletPatch =
 
  805                             refCast<mixedFvPatchField<scalar>>(state.boundaryFieldRef()[patchI]);
 
  807                         inletOutletPatch.refValue() = value[0];
 
  809                     else if (state.boundaryFieldRef()[patchI].type() == 
"fixedGradient")
 
  811                         fixedGradientFvPatchField<scalar>& patchBC =
 
  812                             refCast<fixedGradientFvPatchField<scalar>>(state.boundaryFieldRef()[patchI]);
 
  813                         scalarField& grad = 
const_cast<scalarField&
>(patchBC.gradient());
 
  816                             grad[idxI] = value[0];
 
  821                         FatalErrorIn(
"") << 
"only support fixedValues, inletOutlet, " 
  822                                          << 
"outletInlet, fixedGradient!" << abort(FatalError);
 
  826             else if (value.size() == 3)
 
  828                 if (!db.foundObject<volVectorField>(variable))
 
  832                         Info << variable << 
" not found, skip it." << endl;
 
  837                 volVectorField& state(
const_cast<volVectorField&
>(
 
  838                     db.lookupObject<volVectorField>(variable)));
 
  840                 vector valVec = {value[0], value[1], value[2]};
 
  843                     Info << 
"Setting primal boundary conditions..." << endl;
 
  844                     Info << 
"Setting " << variable << 
" = (" << value[0] << 
" " 
  845                          << value[1] << 
" " << value[2] << 
") at " << patch << endl;
 
  848                 label patchI = 
mesh_.boundaryMesh().findPatchID(patch);
 
  851                 if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
  853                     if (state.boundaryFieldRef()[patchI].type() == 
"fixedValue")
 
  855                         forAll(state.boundaryFieldRef()[patchI], faceI)
 
  857                             state.boundaryFieldRef()[patchI][faceI] = valVec;
 
  860                     else if (state.boundaryFieldRef()[patchI].type() == 
"inletOutlet" 
  861                              || state.boundaryFieldRef()[patchI].type() == 
"outletInlet")
 
  864                         forAll(state.boundaryFieldRef()[patchI], faceI)
 
  866                             state.boundaryFieldRef()[patchI][faceI] = valVec;
 
  869                         mixedFvPatchField<vector>& inletOutletPatch =
 
  870                             refCast<mixedFvPatchField<vector>>(state.boundaryFieldRef()[patchI]);
 
  871                         inletOutletPatch.refValue() = valVec;
 
  873                     else if (state.boundaryFieldRef()[patchI].type() == 
"fixedGradient")
 
  875                         fixedGradientFvPatchField<vector>& patchBC =
 
  876                             refCast<fixedGradientFvPatchField<vector>>(state.boundaryFieldRef()[patchI]);
 
  877                         vectorField& grad = 
const_cast<vectorField&
>(patchBC.gradient());
 
  880                             grad[idxI][0] = value[0];
 
  881                             grad[idxI][1] = value[1];
 
  882                             grad[idxI][2] = value[2];
 
  887                         FatalErrorIn(
"") << 
"only support fixedValues, inletOutlet, " 
  888                                          << 
"fixedGradient, and tractionDisplacement!" 
  889                                          << abort(FatalError);
 
  895                 FatalErrorIn(
"") << 
"value should be a list of either 1 (scalar) " 
  896                                  << 
"or 3 (vector) elements" << abort(FatalError);
 
  905         IOdictionary turbDict(
 
  907                 "turbulenceProperties",
 
  908                 mesh_.time().constant(),
 
  914         dictionary coeffDict(turbDict.subDict(
"RAS"));
 
  915         word turbModelType = word(coeffDict[
"RASModel"]);
 
  919         wordReList SAModelWordReList {
 
  920             {
"SpalartAllmaras.*", wordRe::REGEX}};
 
  921         wordRes SAModelWordRes(SAModelWordReList);
 
  924         if (db.foundObject<volScalarField>(
"nut"))
 
  927             volScalarField& nut(
const_cast<volScalarField&
>(
 
  928                 db.lookupObject<volScalarField>(
"nut")));
 
  930             forAll(nut.boundaryField(), patchI)
 
  932                 if (
mesh_.boundaryMesh()[patchI].type() == 
"wall")
 
  936                         Info << 
"Setting nut wall BC for " 
  937                              << 
mesh_.boundaryMesh()[patchI].name() << 
". ";
 
  943                         if (SAModelWordRes(turbModelType))
 
  945                             nut.boundaryFieldRef().set(
 
  947                                 fvPatchField<scalar>::New(
 
  948                                     "nutUSpaldingWallFunction",
 
  949                                     mesh_.boundary()[patchI],
 
  954                                 Info << 
"BCType=nutUSpaldingWallFunction" << endl;
 
  959                             nut.boundaryFieldRef().set(
 
  961                                 fvPatchField<scalar>::New(
 
  963                                     mesh_.boundary()[patchI],
 
  968                                 Info << 
"BCType=nutkWallFunction" << endl;
 
  974                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
  976                             scalar wallVal = nut[0];
 
  977                             forAll(nut.boundaryFieldRef()[patchI], faceI)
 
  980                                 nut.boundaryFieldRef()[patchI][faceI] = wallVal;
 
  986                         nut.boundaryFieldRef().set(
 
  988                             fvPatchField<scalar>::New(
 
  989                                 "nutLowReWallFunction",
 
  990                                 mesh_.boundary()[patchI],
 
  995                             Info << 
"BCType=nutLowReWallFunction" << endl;
 
 1000                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1002                             forAll(nut.boundaryFieldRef()[patchI], faceI)
 
 1005                                 nut.boundaryFieldRef()[patchI][faceI] = 1e-14;
 
 1014         if (db.foundObject<volScalarField>(
"k"))
 
 1017             volScalarField& 
k(
const_cast<volScalarField&
>(
 
 1018                 db.lookupObject<volScalarField>(
"k")));
 
 1020             forAll(
k.boundaryField(), patchI)
 
 1022                 if (
mesh_.boundaryMesh()[patchI].type() == 
"wall")
 
 1026                         Info << 
"Setting k wall BC for " 
 1027                              << 
mesh_.boundaryMesh()[patchI].name() << 
". ";
 
 1030                     if (useWallFunction)
 
 1033                         k.boundaryFieldRef().set(
 
 1035                             fvPatchField<scalar>::New(
"kqRWallFunction", 
mesh_.boundary()[patchI], 
k));
 
 1039                             Info << 
"BCType=kqRWallFunction" << endl;
 
 1044                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1046                             scalar wallVal = 
k[0];
 
 1047                             forAll(
k.boundaryFieldRef()[patchI], faceI)
 
 1049                                 k.boundaryFieldRef()[patchI][faceI] = wallVal; 
 
 1055                         k.boundaryFieldRef().set(
 
 1057                             fvPatchField<scalar>::New(
"fixedValue", 
mesh_.boundary()[patchI], 
k));
 
 1061                             Info << 
"BCType=fixedValue" << endl;
 
 1066                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1068                             forAll(
k.boundaryFieldRef()[patchI], faceI)
 
 1070                                 k.boundaryFieldRef()[patchI][faceI] = 1e-14; 
 
 1079         if (db.foundObject<volScalarField>(
"omega"))
 
 1082             volScalarField& omega(
const_cast<volScalarField&
>(
 
 1083                 db.lookupObject<volScalarField>(
"omega")));
 
 1085             forAll(omega.boundaryField(), patchI)
 
 1087                 if (
mesh_.boundaryMesh()[patchI].type() == 
"wall")
 
 1091                         Info << 
"Setting omega wall BC for " 
 1092                              << 
mesh_.boundaryMesh()[patchI].name() << 
". ";
 
 1096                     omega.boundaryFieldRef().set(
 
 1098                         fvPatchField<scalar>::New(
"omegaWallFunction", 
mesh_.boundary()[patchI], omega));
 
 1102                         Info << 
"BCType=omegaWallFunction" << endl;
 
 1107                     if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1109                         scalar wallVal = omega[0];
 
 1110                         forAll(omega.boundaryFieldRef()[patchI], faceI)
 
 1112                             omega.boundaryFieldRef()[patchI][faceI] = wallVal; 
 
 1120         if (db.foundObject<volScalarField>(
"epsilon"))
 
 1123             volScalarField& epsilon(
const_cast<volScalarField&
>(
 
 1124                 db.lookupObject<volScalarField>(
"epsilon")));
 
 1126             forAll(epsilon.boundaryField(), patchI)
 
 1128                 if (
mesh_.boundaryMesh()[patchI].type() == 
"wall")
 
 1133                         Info << 
"Setting epsilon wall BC for " 
 1134                              << 
mesh_.boundaryMesh()[patchI].name() << 
". ";
 
 1137                     if (useWallFunction)
 
 1139                         epsilon.boundaryFieldRef().set(
 
 1141                             fvPatchField<scalar>::New(
"epsilonWallFunction", 
mesh_.boundary()[patchI], epsilon));
 
 1145                             Info << 
"BCType=epsilonWallFunction" << endl;
 
 1150                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1152                             scalar wallVal = epsilon[0];
 
 1153                             forAll(epsilon.boundaryFieldRef()[patchI], faceI)
 
 1155                                 epsilon.boundaryFieldRef()[patchI][faceI] = wallVal; 
 
 1161                         epsilon.boundaryFieldRef().set(
 
 1163                             fvPatchField<scalar>::New(
"fixedValue", 
mesh_.boundary()[patchI], epsilon));
 
 1167                             Info << 
"BCType=fixedValue" << endl;
 
 1172                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1174                             forAll(epsilon.boundaryFieldRef()[patchI], faceI)
 
 1176                                 epsilon.boundaryFieldRef()[patchI][faceI] = 1e-14; 
 
 1187         if (db.foundObject<volScalarField>(
"alphat"))
 
 1190             volScalarField& 
alphat(
const_cast<volScalarField&
>(
 
 1191                 db.lookupObject<volScalarField>(
"alphat")));
 
 1195                 if (
mesh_.boundaryMesh()[patchI].type() == 
"wall")
 
 1200                         Info << 
"Setting alphat wall BC for " 
 1201                              << 
mesh_.boundaryMesh()[patchI].name();
 
 1204                     if (useWallFunction)
 
 1207                         if (
mesh_.thisDb().foundObject<incompressible::turbulenceModel>(incompressible::turbulenceModel::propertiesName))
 
 1210                             alphat.boundaryFieldRef().set(
 
 1212                                 fvPatchField<scalar>::New(
"incompressible::alphatWallFunction", 
mesh_.boundary()[patchI], 
alphat));
 
 1216                                 Info << 
"BCType=incompressible::alphatWallFunction. Default Prt=0.85" << endl;
 
 1219                         else if (
mesh_.thisDb().foundObject<compressible::turbulenceModel>(compressible::turbulenceModel::propertiesName))
 
 1223                             alphat.boundaryFieldRef().set(
 
 1225                                 fvPatchField<scalar>::New(
"compressible::alphatWallFunction", 
mesh_.boundary()[patchI], 
alphat));
 
 1229                                 Info << 
"BCType=compressible::alphatWallFunction. Default Prt=0.85" << endl;
 
 1234                             FatalErrorIn(
"") << 
"turbModelType_ not valid!" << abort(FatalError);
 
 1239                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1241                             scalar wallVal = 
alphat[0];
 
 1244                                 alphat.boundaryFieldRef()[patchI][faceI] = wallVal; 
 
 1250                         alphat.boundaryFieldRef().set(
 
 1252                             fvPatchField<scalar>::New(
"fixedValue", 
mesh_.boundary()[patchI], 
alphat));
 
 1256                             Info << 
"BCType=fixedValue" << endl;
 
 1261                         if (
mesh_.boundaryMesh()[patchI].size() > 0)
 
 1265                                 alphat.boundaryFieldRef()[patchI][faceI] = 1e-14;