Skip to content

Commit b8595db

Browse files
authored
Allowed setting viscosity in primalBC (#249)
* Added the capability to change mu and nu in primalBC. * Fixed a bug.
1 parent f28e271 commit b8595db

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/adjoint/DAField/DAField.C

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,64 @@ void DAField::setPrimalBoundaryConditions(const label printInfo)
598598
const IOMRFZoneListDF& MRF = db.lookupObject<IOMRFZoneListDF>("MRFProperties");
599599
scalar& omega = const_cast<scalar&>(MRF.getOmegaRef());
600600
omega = omegaNew;
601+
602+
if (printInfo)
603+
{
604+
Info << "Setting MRF omega to " << omegaNew << endl;
605+
}
606+
607+
continue;
608+
}
609+
else if (bcKey == "transport:nu")
610+
{
611+
// change the nu field
612+
scalar nu = bcDict.getScalar("transport:nu");
613+
volScalarField& nuField = const_cast<volScalarField&>(
614+
db.lookupObject<volScalarField>("nu"));
615+
forAll(nuField, cellI)
616+
{
617+
nuField[cellI] = nu;
618+
}
619+
forAll(nuField.boundaryField(), patchI)
620+
{
621+
forAll(nuField.boundaryField()[patchI], faceI)
622+
{
623+
nuField.boundaryFieldRef()[patchI][faceI] = nu;
624+
}
625+
}
626+
nuField.correctBoundaryConditions();
627+
628+
if (printInfo)
629+
{
630+
Info << "Setting transportProperties nu to " << nu << endl;
631+
}
632+
633+
continue;
634+
}
635+
else if (bcKey == "thermo:mu")
636+
{
637+
// change the nu field
638+
scalar mu = bcDict.getScalar("thermo:mu");
639+
volScalarField& muField = const_cast<volScalarField&>(
640+
db.lookupObject<volScalarField>("thermo:mu"));
641+
forAll(muField, cellI)
642+
{
643+
muField[cellI] = mu;
644+
}
645+
forAll(muField.boundaryField(), patchI)
646+
{
647+
forAll(muField.boundaryField()[patchI], faceI)
648+
{
649+
muField.boundaryFieldRef()[patchI][faceI] = mu;
650+
}
651+
}
652+
muField.correctBoundaryConditions();
653+
654+
if (printInfo)
655+
{
656+
Info << "Setting thermalphysicalProperties mu to " << mu << endl;
657+
}
658+
601659
continue;
602660
}
603661

tests/runTests_DARhoSimpleCFoam.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"k0": {"variable": "k", "patches": ["inout"], "value": [k0]},
5454
"omega0": {"variable": "omega", "patches": ["inout"], "value": [omega0]},
5555
"useWallFunction": True,
56+
"thermo:mu": 1.8e-5
5657
},
5758
"primalVarBounds": {
5859
"UMax": 1000.0,

tests/runTests_DASimpleFoam.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"k0": {"variable": "k", "patches": ["inout"], "value": [k0]},
5252
"omega0": {"variable": "omega", "patches": ["inout"], "value": [omega0]},
5353
"useWallFunction": False,
54+
"transport:nu": 1.5e-5
5455
},
5556
"fvSource": {
5657
"disk1": {

0 commit comments

Comments
 (0)