def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) T, U, transportProperties, DT, phi = _createFields(runTime, mesh) simple = man.simpleControl(mesh) ref.ext_Info() << "\nCalculating scalar transport\n" << ref.nl CoNum, meanCoNum = ref.CourantNo(mesh, phi, runTime) while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl while simple.correctNonOrthogonal(): ref.solve( ref.fvm.ddt(T) + ref.fvm.div(phi, T) - ref.fvm.laplacian(DT, T)) pass runTime.write() pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) T, transportProperties, DT = _createFields( runTime, mesh ) simple = man.simpleControl( mesh ) ref.ext_Info() << "\nCalculating temperature distribution\n" << ref.nl while runTime.loop() : ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl for nonOrth in range( simple.nNonOrthCorr() + 1 ): ref.solve( ref.fvm.ddt( T ) - ref.fvm.laplacian( DT, T ) ) pass write( runTime, mesh, T ) ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \ " ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) T, U, transportProperties, DT, phi = _createFields( runTime, mesh ) simple = man.simpleControl( mesh ) ref.ext_Info() << "\nCalculating scalar transport\n" << ref.nl CoNum, meanCoNum = ref.CourantNo( mesh, phi, runTime ) while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl for nonOrth in range ( simple.nNonOrthCorr() + 1 ): ref.solve( ref.fvm.ddt( T ) + ref.fvm.div( phi, T ) - ref.fvm.laplacian( DT, T ) ) pass runTime.write() pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) T, transportProperties, DT = _createFields(runTime, mesh) simple = man.simpleControl(mesh) ref.ext_Info() << "\nCalculating temperature distribution\n" << ref.nl while runTime.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl while simple.correctNonOrthogonal(): ref.solve(ref.fvm.ddt(T) - ref.fvm.laplacian(DT, T)) pass write(runTime, mesh, T) ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \ " ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) g = readGravitationalAcceleration(runTime, mesh) pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, \ pRefCell, pRefValue, initialMass, totalVolume = createFields( runTime, mesh, g ) radiation = man.radiation.createRadiationModel(pThermo) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl(mesh) ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl p_rgh.storePrevIter() rho.storePrevIter() UEqn = fun_Ueqn(simple, mesh, rho, U, phi, turbulence, ghf, p_rgh) fun_hEqn(pThermo, rho, p, h, phi, radiation, turbulence) cumulativeContErr = fun_pEqn(mesh, runTime, simple, pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr, initialMass) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime( ) << " s" << " ClockTime = " << runTime.elapsedClockTime( ) << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) p, Urel, phi, pRefCell, pRefValue, laminarTransport, turbulence, SRF, sources = createFields( runTime, mesh) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl(mesh) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl # --- Pressure-velocity SIMPLE corrector UrelEqn = fun_UrelEqn(Urel, phi, turbulence, p, sources, SRF) cumulativeContErr = fun_pEqn(mesh, runTime, simple, Urel, phi, turbulence, p, UrelEqn, pRefCell, pRefValue, cumulativeContErr, sources) turbulence.correct() Uabs = None if runTime.outputTime(): Uabs = ref.volVectorField( ref.IOobject(ref.word("Uabs"), ref.fileName(runTime.timeName()), mesh, ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE), Urel() + SRF.U()) # mixed calculations pass runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \ << " ClockTime = " << runTime.elapsedClockTime() << " s" \ << ref.nl << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) g = readGravitationalAcceleration(runTime, mesh) T, p_rgh, U, phi, laminarTransport, turbulence, rhok, \ kappat, gh, ghf, p, pRefCell, pRefValue, beta, TRef, Pr, Prt = createFields( runTime, mesh, g ) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl(mesh) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl p_rgh.storePrevIter() # Pressure-velocity SIMPLE corrector UEqn = fun_UEqn(mesh, simple, U, phi, turbulence, p, rhok, p_rgh, ghf) fun_TEqn(phi, turbulence, kappat, T, rhok, beta, TRef, Prt, Pr) cumulativeContErr = fun_pEqn(mesh, runTime, simple, p, rhok, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \ << " ClockTime = " << runTime.elapsedClockTime() << " s" \ << ref.nl << ref.nl pass pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) p, Urel, phi, pRefCell, pRefValue, laminarTransport, turbulence, SRF, sources = createFields( runTime, mesh ) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl (mesh) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl # --- Pressure-velocity SIMPLE corrector UrelEqn = fun_UrelEqn( Urel, phi, turbulence, p, sources, SRF ) cumulativeContErr = fun_pEqn( mesh, runTime, simple, Urel, phi, turbulence, p, UrelEqn, pRefCell, pRefValue, cumulativeContErr, sources ) turbulence.correct() Uabs = None if runTime.outputTime(): Uabs = ref.volVectorField( ref.IOobject( ref.word( "Uabs" ), ref.fileName( runTime.timeName() ), mesh, ref.IOobject.NO_READ, ref.IOobject.AUTO_WRITE ), Urel() + SRF.U() ) # mixed calculations pass runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \ << " ClockTime = " << runTime.elapsedClockTime() << " s" \ << ref.nl << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime=man.createTime( args ) mesh = man.createMesh( runTime ) g = readGravitationalAcceleration( runTime, mesh ); T, p_rgh, U, phi, laminarTransport, turbulence, rhok, \ kappat, gh, ghf, p, pRefCell, pRefValue, beta, TRef, Pr, Prt = createFields( runTime, mesh, g ) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl( mesh ) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl p_rgh.storePrevIter() # Pressure-velocity SIMPLE corrector UEqn = fun_UEqn( mesh, simple, U, phi, turbulence, p, rhok, p_rgh, ghf ) fun_TEqn( phi, turbulence, kappat, T, rhok, beta, TRef, Prt, Pr ) cumulativeContErr = fun_pEqn( mesh, runTime, simple, p, rhok, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr ) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \ << " ClockTime = " << runTime.elapsedClockTime() << " s" \ << ref.nl << ref.nl pass pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) g = readGravitationalAcceleration( runTime, mesh ) pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, \ pRefCell, pRefValue, initialMass, totalVolume = createFields( runTime, mesh, g ) radiation = man.radiation.createRadiationModel( pThermo ) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl( mesh ) ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl p_rgh.storePrevIter() rho.storePrevIter() UEqn = fun_Ueqn( simple, mesh, rho, U, phi, turbulence, ghf, p_rgh ) fun_hEqn( pThermo, rho, p, h, phi, radiation, turbulence ) cumulativeContErr = fun_pEqn( mesh, runTime, simple, pThermo, rho, p, h, psi, U, phi, turbulence, gh, ghf, p_rgh, UEqn, pRefCell, pRefValue, cumulativeContErr, initialMass) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence, sources = createFields( runTime, mesh) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl(mesh) mrfZones = man.MRFZones(mesh) mrfZones.correctBoundaryVelocity(U) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl # --- Pressure-velocity SIMPLE corrector UEqn = fun_UEqn(U, phi, turbulence, p, sources, mrfZones) cumulativeContErr = fun_pEqn(mesh, runTime, simple, U, phi, turbulence, p, UEqn, mrfZones, pRefCell, pRefValue, cumulativeContErr, sources) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \ << " ClockTime = " << runTime.elapsedClockTime() << " s" \ << ref.nl << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) simple = man.simpleControl( mesh ) thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, rhoMax, rhoMin = _createFields( runTime, mesh, simple ) mrfZones, pZones, pressureImplicitPorosity, nUCorr = createZones( mesh, U, simple ) cumulativeContErr = ref.initContinuityErrs() ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop() : ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl # Pressure-velocity SIMPLE corrector UEqn, trAU, trTU = _UEqn( phi, U, p, rho, turbulence, mrfZones, pZones, pressureImplicitPorosity, nUCorr ) _hEqn( U, phi, h, turbulence, rho, p, thermo, pZones ) cumulativeContErr = _pEqn( runTime,mesh, UEqn, rho, thermo, psi, U, p, phi, trTU, trAU, mrfZones, \ pRefCell, pRefValue, pressureImplicitPorosity, cumulativeContErr, simple, rhoMin, rhoMax ) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \ " ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) simple = man.simpleControl( mesh ) thermo, rho, p, h, psi, U, phi, pRefCell, pRefValue, turbulence, initialMass, rhoMax, rhoMin = _createFields( runTime, mesh, simple ) cumulativeContErr = ref.initContinuityErrs() ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop() : ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl # Pressure-velocity SIMPLE corrector UEqn = _UEqn( phi, U, p, rho, turbulence ) cumulativeContErr = _pEqn( runTime,mesh, UEqn, rho, thermo, psi, U, p, phi, \ pRefCell, pRefValue, cumulativeContErr, simple, rhoMin, rhoMax ) _hEqn( U, phi, h, turbulence, rho, p, thermo ) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << \ " ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) simple = man.simpleControl( mesh ) p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence = create_fields( runTime, mesh ) pZones, pressureImplicitPorosity, nUCorr = createPorousZones( mesh, simple ) cumulativeContErr = ref.initContinuityErrs() ref.ext_Info()<< "\nStarting time loop\n" << ref.nl while simple.loop() : ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl p.storePrevIter() UEqn, trTU, trAU = fun_UEqn( mesh, phi, U, p, turbulence, pZones, nUCorr, pressureImplicitPorosity ) cumulativeContErr = fun_pEqn( mesh, simple, p, U, trTU, trAU, UEqn, phi, runTime, pressureImplicitPorosity, \ cumulativeContErr, pRefCell, pRefValue, ) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << ref.nl << ref.nl pass ref.ext_Info() << "End\n" import os return os.EX_OK
def main_standalone( argc, argv ): args = ref.setRootCase( argc, argv ) runTime = man.createTime( args ) mesh = man.createMesh( runTime ) p, U, phi, pRefCell, pRefValue, laminarTransport, turbulence,sources = createFields( runTime, mesh ) cumulativeContErr = ref.initContinuityErrs() simple = man.simpleControl (mesh) mrfZones = man.MRFZones( mesh ) mrfZones.correctBoundaryVelocity( U) # * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * # ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl # --- Pressure-velocity SIMPLE corrector UEqn = fun_UEqn( U, phi, turbulence, p, sources, mrfZones ) cumulativeContErr = fun_pEqn( mesh, runTime, simple, U, phi, turbulence, p, UEqn, mrfZones, pRefCell, pRefValue, cumulativeContErr, sources ) turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" \ << " ClockTime = " << runTime.elapsedClockTime() << " s" \ << ref.nl << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) p, U, phi, pa, Ua, phia, alpha, laminarTransport, turbulence, zeroSensitivity, zeroAlpha, \ lambda_, alphaMax, inletCells, pRefCell, pRefValue, paRefCell, paRefValue = createFields( runTime, mesh ) cumulativeContErr = ref.initContinuityErrs() cumulativeAdjointContErr = initAdjointContinuityErrs() simple = man.simpleControl(mesh) ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl laminarTransport.lookup(ref.word("lambda")) >> lambda_ alpha += mesh.fieldRelaxationFactor(ref.word("alpha")) * (( (alpha + lambda_ * (Ua & U)).ext_max(zeroAlpha)).ext_min(alphaMax) - alpha) zeroCells(alpha, inletCells) UEqn = ref.fvm.div(phi, U) + turbulence.divDevReff(U) + ref.fvm.Sp( alpha, U) UEqn.relax() ref.solve(UEqn == -ref.fvc.grad(p)) p.ext_boundaryField().updateCoeffs() rAU = 1.0 / UEqn.A() U << rAU * UEqn.H() phi << (ref.fvc.interpolate(U) & mesh.Sf()) ref.adjustPhi(phi, U, p) while simple.correctNonOrthogonal(): pEqn = ref.fvm.laplacian(rAU, p) == ref.fvc.div(phi) pEqn.setReference(pRefCell, pRefValue) pEqn.solve() if simple.finalNonOrthogonalIter(): phi -= pEqn.flux() pass pass cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh, cumulativeContErr) # Explicitly relax pressure for momentum corrector p.relax() # Momentum corrector U -= rAU * ref.fvc.grad(p) U.correctBoundaryConditions() # Adjoint Pressure-velocity SIMPLE corrector # Adjoint Momentum predictor adjointTransposeConvection = (ref.fvc.grad(Ua) & U) # adjointTransposeConvection = ref.fvc.reconstruct( mesh.magSf() * ( ref.fvc.snGrad( Ua ) & ref.fvc.interpolate( U ) ) ) zeroCells(adjointTransposeConvection, inletCells) UaEqn = ref.fvm.div( -phi, Ua) - adjointTransposeConvection + turbulence.divDevReff( Ua) + ref.fvm.Sp(alpha, Ua) UaEqn.relax() ref.solve(UaEqn == -ref.fvc.grad(pa)) pa.ext_boundaryField().updateCoeffs() rAUa = 1.0 / UaEqn.A() Ua << rAUa * UaEqn.H() UaEqn.clear() phia << (ref.fvc.interpolate(Ua) & mesh.Sf()) ref.adjustPhi(phia, Ua, pa) # Non-orthogonal pressure corrector loop while simple.correctNonOrthogonal(): paEqn = ref.fvm.laplacian(rAUa, pa) == ref.fvc.div(phia) paEqn.setReference(paRefCell, paRefValue) paEqn.solve() if simple.finalNonOrthogonalIter(): phia -= paEqn.flux() pass pass cumulativeAdjointContErr = adjointContinuityErrs( runTime, mesh, phia, cumulativeAdjointContErr) # Explicitly relax pressure for adjoint momentum corrector pa.relax() # Adjoint momentum corrector Ua -= rAUa * ref.fvc.grad(pa) Ua.correctBoundaryConditions() turbulence.correct() runTime.write() ref.ext_Info()<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n\n" \ << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK
def main_standalone(argc, argv): args = ref.setRootCase(argc, argv) runTime = man.createTime(args) mesh = man.createMesh(runTime) p, U, phi, pa, Ua, phia, alpha, laminarTransport, turbulence, zeroSensitivity, zeroAlpha, lambda_, alphaMax, inletCells, pRefCell, pRefValue, paRefCell, paRefValue = createFields( runTime, mesh ) cumulativeContErr = ref.initContinuityErrs() cumulativeAdjointContErr = initAdjointContinuityErrs() simple = man.simpleControl(mesh) ref.ext_Info() << "\nStarting time loop\n" << ref.nl while simple.loop(): ref.ext_Info() << "Time = " << runTime.timeName() << ref.nl << ref.nl laminarTransport.lookup(ref.word("lambda")) >> lambda_ alpha += mesh.fieldRelaxationFactor(ref.word("alpha")) * ( ((alpha + lambda_ * (Ua & U)).ext_max(zeroAlpha)).ext_min(alphaMax) - alpha ) zeroCells(alpha, inletCells) UEqn = ref.fvm.div(phi, U) + turbulence.divDevReff(U) + ref.fvm.Sp(alpha, U) UEqn.relax() ref.solve(UEqn == -ref.fvc.grad(p)) p.ext_boundaryField().updateCoeffs() rAU = 1.0 / UEqn.A() U << rAU * UEqn.H() phi << (ref.fvc.interpolate(U) & mesh.Sf()) ref.adjustPhi(phi, U, p) while simple.correctNonOrthogonal(): pEqn = ref.fvm.laplacian(rAU, p) == ref.fvc.div(phi) pEqn.setReference(pRefCell, pRefValue) pEqn.solve() if simple.finalNonOrthogonalIter(): phi -= pEqn.flux() pass pass cumulativeContErr = ref.ContinuityErrs(phi, runTime, mesh, cumulativeContErr) # Explicitly relax pressure for momentum corrector p.relax() # Momentum corrector U -= rAU * ref.fvc.grad(p) U.correctBoundaryConditions() # Adjoint Pressure-velocity SIMPLE corrector # Adjoint Momentum predictor adjointTransposeConvection = ref.fvc.grad(Ua) & U # adjointTransposeConvection = ref.fvc.reconstruct( mesh.magSf() * ( ref.fvc.snGrad( Ua ) & ref.fvc.interpolate( U ) ) ) zeroCells(adjointTransposeConvection, inletCells) UaEqn = ref.fvm.div(-phi, Ua) - adjointTransposeConvection + turbulence.divDevReff(Ua) + ref.fvm.Sp(alpha, Ua) UaEqn.relax() ref.solve(UaEqn == -ref.fvc.grad(pa)) pa.ext_boundaryField().updateCoeffs() rAUa = 1.0 / UaEqn.A() Ua << rAUa * UaEqn.H() UaEqn.clear() phia << (ref.fvc.interpolate(Ua) & mesh.Sf()) ref.adjustPhi(phia, Ua, pa) # Non-orthogonal pressure corrector loop while simple.correctNonOrthogonal(): paEqn = ref.fvm.laplacian(rAUa, pa) == ref.fvc.div(phia) paEqn.setReference(paRefCell, paRefValue) paEqn.solve() if simple.finalNonOrthogonalIter(): phia -= paEqn.flux() pass pass cumulativeAdjointContErr = adjointContinuityErrs(runTime, mesh, phia, cumulativeAdjointContErr) # Explicitly relax pressure for adjoint momentum corrector pa.relax() # Adjoint momentum corrector Ua -= rAUa * ref.fvc.grad(pa) Ua.correctBoundaryConditions() turbulence.correct() runTime.write() ref.ext_Info() << "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n\n" << ref.nl pass ref.ext_Info() << "End\n" << ref.nl import os return os.EX_OK