CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Adjoint Convergence Problem (https://www.cfd-online.com/Forums/openfoam-solving/180924-adjoint-convergence-problem.html)

FlyBob91 December 3, 2016 10:16

Adjoint Convergence Problem
 
1 Attachment(s)
Hi to all,
i wrote my own adjoint solver and compiled it correcty. However i'm meeting some problem running my case because the residuals seem to converge but the solution literally explodes as you can see below

Code:

smoothSolver:  Solving for Uax, Initial residual = 4.39575174596e-05, Final residual = 4.16030919667e-08, No Iterations 2
smoothSolver:  Solving for Uay, Initial residual = 4.5057555084e-05, Final residual = 3.58842322767e-08, No Iterations 2
smoothSolver:  Solving for Uaz, Initial residual = 4.06676312041e-05, Final residual = 3.22296628924e-08, No Iterations 2
GAMG:  Solving for pa, Initial residual = 0.000212921685966, Final residual = 1.41332460912e-06, No Iterations 4
Adjoint continuity errors : sum local = 15942358.9466, global = 8202.0330787, cumulative = 9256411904.89


I try to use low relaxation factors but nothing change. I link my fvschemes and fvsolution files.
I also noticed others people have had a problem similar to mine, because the adjoint problem are very sensitive to the boundary conditions.

Code:

solvers
{
    "(p|pa)"
    {
        solver          GAMG;
        tolerance      1e-08;
        relTol          0.01;
        smoother        GaussSeidel;
        nPreSweeps      0;
        nPostSweeps    2;
        cacheAgglomeration true;
        nCellsInCoarsestLevel 10;
        agglomerator    faceAreaPair;
        mergeLevels    1;
    }

    "(U|Ua|k|epsilon)"
    {
        solver          smoothSolver;
        smoother        GaussSeidel;
        nSweeps        2;
        tolerance      1e-08;
        relTol          0.1;
    }
}

SIMPLE
{
    nNonOrthogonalCorrectors 0;
    pRefCell 0;
    pRefValue 0;
}

relaxationFactors
{
    fields
    {
        "(p|pa)"        0.1;
        alpha          0.1;
    }
    equations
    {
        "(U|Ua)"        0.1;
        "(k|epsilon)"  0.7;
    }
}

Code:

ddtSchemes
{
    default        steadyState;
}

gradSchemes
{
    default        Gauss linear;
}

divSchemes
{
    default        Gauss upwind;

    div(phi,U)      bounded Gauss upwind;
    div(phi,k)      bounded Gauss upwind;
    div(phi,epsilon) bounded Gauss upwind;
    div((nuEff*dev(T(grad(U))))) Gauss linear;

    div(-phi,Ua)    bounded Gauss upwind;
    div((nuEff*dev(T(grad(Ua))))) Gauss linear;
}

laplacianSchemes
{
    default        Gauss linear uncorrected;
}

interpolationSchemes
{
    default        linear;
}

snGradSchemes
{
    default        uncorrected;
}

fluxRequired
{
    default        no;
    p;
    pa;
}


Furthermore i read this thread

HTML Code:

http://www.cfd-online.com/Forums/openfoam-solving/103229-adjointshapeoptimizationfoam-checkerboarding-inlet.html
where sylvester suggest to use a " pseudo staggered grid approach" but i don't uderstand what he refers to.

The simulation type is a laminar and if you are interested in my code you can find it in a previuos thread

HTML Code:

http://www.cfd-online.com/Forums/openfoam-programming-development/180587-insert-dimensioned-salar.html
i link also my mesh quality

Code:

Create polyMesh for time = 0

Time = 0

Mesh stats
    points:          306516
    faces:            863850
    internal faces:  810150
    cells:            279000
    faces per cell:  6
    boundary patches: 4
    point zones:      0
    face zones:      0
    cell zones:      0

Overall number of cells of each type:
    hexahedra:    279000
    prisms:        0
    wedges:        0
    pyramids:      0
    tet wedges:    0
    tetrahedra:    0
    polyhedra:    0

Checking topology...
    Boundary definition OK.
    Cell to face addressing OK.
    Point usage OK.
    Upper triangular ordering OK.
    Face vertices OK.
    Number of regions: 1 (OK).

Checking patch topology for multiply connected surfaces...
    Patch              Faces    Points  Surface topology                 
    walls              52500    52619    ok (non-closed singly connected) 
    inlet1              300      336      ok (non-closed singly connected) 
    inlet2              300      336      ok (non-closed singly connected) 
    outlet              600      651      ok (non-closed singly connected) 

Checking geometry...
    Overall domain bounding box (-0.00015 -0.00165 0) (0.003 0.00165 0.0002)
    Mesh (non-empty, non-wedge) directions (1 1 1)
    Mesh (non-empty) directions (1 1 1)
    Boundary openness (-6.91724010847e-18 1.96638314844e-18 2.57097977866e-17) OK.
    Max cell openness = 1.29246970711e-16 OK.
    Max aspect ratio = 1 OK.
    Minimum face area = 1e-10. Maximum face area = 1e-10.  Face area magnitudes OK.
    Min volume = 1e-15. Max volume = 1e-15.  Total volume = 2.79000000001e-10.  Cell volumes OK.
    Mesh non-orthogonality Max: 0 average: 0
    Non-orthogonality check OK.
    Face pyramids OK.
    Max skewness = 1.25 OK.
    Coupled point location match (average 0) OK.

Mesh OK.


Any idea to solve the problem?

Thanks for help,
Roberto

Silver Silhouette April 27, 2017 05:02

Hello

I am currently running an airfoil optimization case using adjoint solver.
What I do is iteratively run the flow solver and adjoint solver without initializing. Is this correct?
Also after a certain number of iterations the adjoint solver or the flow solver doesnt seem to converge. Initially i try to bring down the under relaxation factor. This converges the case up to a few more iterations then starts diverging again. However the mesh doesnt seem to have failed or there doesn't seem to a flow separation. Can i drive my solution to convergence using any other methods??
Or since it is an optimization problem should i stop when the solution diverges?

Also how is it that you write your own code into the adjoint solver? What i am following is standard for pressure and second order for momentum for the adjoint solver


All times are GMT -4. The time now is 10:21.