// File: /workspace/github_cpp_makefile_star2_O2/FR13ndSDP[P]NHT/main.cpp
// Function: main
int main()
{
    clock_t start_t,end_t;
    start_t = clock();

    Parameters P;
    P.readParameters("controlDict");

    int  cnt=0;
    double Tw = 15, TWall = 0;
    Vec position(P.N,0),T(P.N,0),aW(P.N,0),aP(P.N,0),aE(P.N,0),Su(P.N,0);

    if (P.uS == 1)
    {
        cout << "unsteady calculate, solver:" << P.solver << endl;
        initialize(P.N, P.L, Tw, P.TA, P.A1, P.K, T, position);
        P.Coeff(aW,aP,aE);

        cout << "input a Wall temperature:"<<endl;
        cin >> TWall;

        while (Tw >= TWall)
        {
            P.getSource(Su, T);
            T = solve(aW, aP, aE, Su, P.solver, P.P);
            // calculaet wall temperature
            Tw = (2*P.K/(P.L/P.N)*T[0]+P.A1*P.TA)/(P.A1+2*P.K/(P.L/P.N));
            cnt++;
        }
        cout << "time = " << cnt*P.dt << " Tw = " << Tw << endl;
        P.outputFile(position, T);
    }
    else
    {
        cout << "steady calculate, solver:" << P.solver << endl;
        initialize(P.N, P.L, Tw, P.TA, P.A1, P.K, T, position);
        P.Coeff(aW, aP, aE);
        P.getSource(Su, T);
        T = solve(aW, aP, aE, Su, P.solver, P.P);
        // check out flux conservation
        double fluxA = (P.TA - T[0])/(1/P.A1 + P.L/P.N/(2*P.K));
        double fluxB = (-P.TB + T[P.N - 1])/(1/P.A2 + P.L/P.N/(2*P.K));
        cout << "flux in left: "<< fluxA << " flux in right: "<< fluxB << endl;

        P.outputFile(position, T);
    }
    end_t = clock();
    cout << "time consumption:" << (double)(end_t - start_t)/CLOCKS_PER_SEC << "s" << endl;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2e8, %rsp            # imm = 0x2E8
callq 0x2130
movq %rax, -0x108(%rbp)
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
callq 0x2fc8
leaq 0x2b3e(%rip), %rsi      # 0x5038
movq %rbx, %rdi
callq 0x30ac
andq $0x0, -0xb8(%rbp)
movslq -0x190(%rbp), %rsi
leaq -0x50(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0xd0(%rbp), %rdi
leaq -0xb0(%rbp), %rcx
callq 0x2d7e
movslq -0x190(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0x50(%rbp), %rdi
leaq -0x98(%rbp), %rcx
callq 0x2d7e
movslq -0x190(%rbp), %rsi
leaq -0x98(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0xb0(%rbp), %rdi
leaq -0x80(%rbp), %rcx
callq 0x2d7e
movslq -0x190(%rbp), %rsi
leaq -0x80(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0x98(%rbp), %rdi
leaq -0x68(%rbp), %rcx
callq 0x2d7e
movslq -0x190(%rbp), %rsi
leaq -0x68(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0x80(%rbp), %rdi
leaq -0x1a8(%rbp), %rcx
callq 0x2d7e
movslq -0x190(%rbp), %rsi
leaq -0x1a8(%rbp), %rdx
andq $0x0, (%rdx)
leaq -0x68(%rbp), %rdi
leaq -0x31(%rbp), %rcx
callq 0x2d7e
cmpl $0x1, -0x18c(%rbp)
jne 0x27e3
movq 0x49e7(%rip), %rdi      # 0x6fc8
leaq 0x2a5c(%rip), %rsi      # 0x5044
callq 0x21c0
leaq -0x128(%rbp), %rsi
movq %rax, %rdi
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
movl (%rbx), %edi
movsd 0x18(%rbx), %xmm0
movsd 0x40(%rbx), %xmm2
movsd 0x20(%rbx), %xmm3
movsd 0x38(%rbx), %xmm4
movsd 0x29fe(%rip), %xmm1     # 0x5020
leaq -0x50(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x245c
leaq -0xb0(%rbp), %rsi
leaq -0x98(%rbp), %rdx
leaq -0x80(%rbp), %rcx
movq %rbx, %rdi
callq 0x3716
movq 0x4975(%rip), %rdi      # 0x6fc8
leaq 0x2a06(%rip), %rsi      # 0x5060
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
movq 0x496a(%rip), %rdi      # 0x6fd8
leaq -0xb8(%rbp), %rsi
callq 0x2120
xorl %r15d, %r15d
movsd 0x299b(%rip), %xmm2     # 0x5020
ucomisd -0xb8(%rbp), %xmm2
jb 0x2abc
leaq -0x190(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x3864
leaq -0x220(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2dde
leaq -0x288(%rbp), %rdi
leaq -0x270(%rbp), %r14
leaq -0x258(%rbp), %rbx
leaq -0x308(%rbp), %r12
leaq -0x1a8(%rbp), %r13
leaq -0x98(%rbp), %rsi
callq 0x2dde
movq %r14, %rdi
leaq -0x80(%rbp), %rsi
callq 0x2dde
movq %rbx, %rdi
leaq -0x68(%rbp), %rsi
callq 0x2dde
movl %r15d, -0x30(%rbp)
movq %r12, %rdi
leaq -0x128(%rbp), %rsi
callq 0x2200
movq %r12, %r15
movsd -0x140(%rbp), %xmm0
movq %r13, %rdi
leaq -0x220(%rbp), %rsi
leaq -0x288(%rbp), %r12
movq %r12, %rdx
movq %r13, %r14
leaq -0x270(%rbp), %r13
movq %r13, %rcx
movq %rbx, %r8
movq %r15, %r9
callq 0x40e6
leaq -0x50(%rbp), %rdi
movq %r14, %rsi
callq 0x2f5c
movq %r14, %rdi
callq 0x2e7e
movq %r15, %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2e7e
movq %r13, %rdi
callq 0x2e7e
movq %r12, %rdi
callq 0x2e7e
leaq -0x220(%rbp), %rdi
callq 0x2e7e
movsd -0x158(%rbp), %xmm2
addsd %xmm2, %xmm2
cvtsi2sdl -0x190(%rbp), %xmm0
movsd -0x178(%rbp), %xmm1
divsd %xmm0, %xmm1
divsd %xmm1, %xmm2
movsd -0x170(%rbp), %xmm0
movq -0x50(%rbp), %rax
movsd -0x150(%rbp), %xmm1
mulsd %xmm0, %xmm1
addsd %xmm2, %xmm0
mulsd (%rax), %xmm2
addsd %xmm1, %xmm2
divsd %xmm0, %xmm2
movl -0x30(%rbp), %r15d
incl %r15d
jmp 0x2685
movq 0x47de(%rip), %rdi      # 0x6fc8
leaq 0x2855(%rip), %rsi      # 0x5046
callq 0x21c0
leaq -0x128(%rbp), %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
leaq -0x190(%rbp), %r14
movl (%r14), %edi
movsd 0x18(%r14), %xmm0
movsd 0x40(%r14), %xmm2
movsd 0x20(%r14), %xmm3
movsd 0x38(%r14), %xmm4
movsd 0x27e6(%rip), %xmm1     # 0x5020
leaq -0x50(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
callq 0x245c
leaq -0xb0(%rbp), %rsi
leaq -0x98(%rbp), %rdx
leaq -0x80(%rbp), %rcx
movq %r14, %rdi
callq 0x3716
leaq -0x190(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x3864
leaq -0x208(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x2dde
leaq -0x1f0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2dde
leaq -0x1d8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x2dde
leaq -0x1c0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2dde
leaq -0x240(%rbp), %rdi
movq %rbx, %rsi
callq 0x2200
movsd -0x140(%rbp), %xmm0
leaq -0x1a8(%rbp), %rdi
leaq -0x208(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
leaq -0x1d8(%rbp), %rcx
leaq -0x1c0(%rbp), %r8
leaq -0x240(%rbp), %r9
callq 0x40e6
leaq -0x50(%rbp), %rbx
leaq -0x1a8(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2f5c
movq %r14, %rdi
callq 0x2e7e
leaq -0x240(%rbp), %rdi
callq 0x20c0
leaq -0x1c0(%rbp), %rdi
callq 0x2e7e
leaq -0x1d8(%rbp), %rdi
callq 0x2e7e
leaq -0x1f0(%rbp), %rdi
callq 0x2e7e
leaq -0x208(%rbp), %rdi
callq 0x2e7e
movsd -0x150(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movq (%rbx), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x178(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x170(%rbp), %xmm0
movsd %xmm0, -0xf0(%rbp)
movslq -0x190(%rbp), %rbx
movsd -0x158(%rbp), %xmm0
movsd %xmm0, -0xe8(%rbp)
movsd -0x8(%rax,%rbx,8), %xmm0
subsd -0x148(%rbp), %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd 0x2659(%rip), %xmm0     # 0x5028
divsd -0x168(%rbp), %xmm0
movsd %xmm0, -0xd8(%rbp)
movq 0x45e2(%rip), %rdi      # 0x6fc8
leaq 0x269c(%rip), %rsi      # 0x5089
callq 0x21c0
cvtsi2sd %ebx, %xmm0
movsd -0x30(%rbp), %xmm1
divsd %xmm0, %xmm1
movsd -0xe8(%rbp), %xmm0
addsd %xmm0, %xmm0
divsd %xmm0, %xmm1
movsd -0x100(%rbp), %xmm0
subsd -0xf8(%rbp), %xmm0
movsd 0x2601(%rip), %xmm2     # 0x5028
divsd -0xf0(%rbp), %xmm2
movsd %xmm1, -0x30(%rbp)
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x264d(%rip), %rsi      # 0x5098
movq %rax, %rdi
callq 0x21c0
movsd -0x30(%rbp), %xmm1
addsd -0xd8(%rbp), %xmm1
movsd -0xe0(%rbp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x20d0
leaq -0x2b8(%rbp), %rbx
leaq -0xd0(%rbp), %rsi
movq %rbx, %rdi
callq 0x2dde
leaq -0x2a0(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2dde
leaq -0x190(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3642
jmp 0x2b48
movsd %xmm2, -0x30(%rbp)
movq 0x4500(%rip), %rdi      # 0x6fc8
leaq 0x25ab(%rip), %rsi      # 0x507a
callq 0x21c0
cvtsi2sd %r15d, %xmm0
mulsd -0x180(%rbp), %xmm0
movq %rax, %rdi
callq 0x2240
leaq 0x2592(%rip), %rsi      # 0x5082
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x2240
movq %rax, %rdi
callq 0x20d0
leaq -0x2e8(%rbp), %rbx
leaq -0xd0(%rbp), %rsi
movq %rbx, %rdi
callq 0x2dde
leaq -0x2d0(%rbp), %r14
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2dde
leaq -0x190(%rbp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x3642
movq %r14, %rdi
callq 0x2e7e
movq %rbx, %rdi
callq 0x2e7e
callq 0x2130
movq %rax, %rbx
movq 0x4461(%rip), %rdi      # 0x6fc8
leaq 0x253b(%rip), %rsi      # 0x50a9
callq 0x21c0
subq -0x108(%rbp), %rbx
cvtsi2sd %rbx, %xmm0
divsd 0x24a9(%rip), %xmm0     # 0x5030
movq %rax, %rdi
callq 0x2240
leaq 0x2525(%rip), %rsi      # 0x50bb
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
callq 0x20d0
leaq -0x68(%rbp), %rdi
callq 0x2e7e
leaq -0x80(%rbp), %rdi
callq 0x2e7e
leaq -0x98(%rbp), %rdi
callq 0x2e7e
leaq -0xb0(%rbp), %rdi
callq 0x2e7e
leaq -0x50(%rbp), %rdi
callq 0x2e7e
leaq -0xd0(%rbp), %rdi
callq 0x2e7e
leaq -0x190(%rbp), %rdi
callq 0x309e
xorl %eax, %eax
addq $0x2e8, %rsp            # imm = 0x2E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x2d0(%rbp), %rdi
callq 0x2e7e
jmp 0x2c19
movq %rax, %rbx
leaq -0x2e8(%rbp), %rdi
jmp 0x2d25
movq %rax, %rbx
leaq -0x2a0(%rbp), %rdi
callq 0x2e7e
jmp 0x2c39
movq %rax, %rbx
leaq -0x2b8(%rbp), %rdi
jmp 0x2d25
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
callq 0x20c0
jmp 0x2c59
movq %rax, %rbx
leaq -0x1c0(%rbp), %rdi
callq 0x2e7e
jmp 0x2c6a
movq %rax, %rbx
leaq -0x1d8(%rbp), %rdi
callq 0x2e7e
jmp 0x2c7b
movq %rax, %rbx
leaq -0x1f0(%rbp), %rdi
callq 0x2e7e
jmp 0x2c8c
movq %rax, %rbx
leaq -0x208(%rbp), %rdi
jmp 0x2d25
jmp 0x2d16
movq %rax, %rbx
jmp 0x2d33
movq %rax, %rbx
jmp 0x2d3c
movq %rax, %rbx
jmp 0x2d48
movq %rax, %rbx
jmp 0x2d54
movq %rax, %rbx
jmp 0x2d5d
jmp 0x2cc4
movq %rax, %rbx
jmp 0x2d69
jmp 0x2d16
jmp 0x2d16
movq %rax, %rbx
jmp 0x2d06
movq %rax, %rbx
jmp 0x2cfa
movq %rax, %rbx
jmp 0x2cee
movq %rax, %rbx
leaq -0x308(%rbp), %rdi
callq 0x20c0
leaq -0x258(%rbp), %rdi
callq 0x2e7e
leaq -0x270(%rbp), %rdi
callq 0x2e7e
leaq -0x288(%rbp), %rdi
callq 0x2e7e
jmp 0x2d1e
jmp 0x2d16
movq %rax, %rbx
jmp 0x2d2a
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x2e7e
leaq -0x68(%rbp), %rdi
callq 0x2e7e
leaq -0x80(%rbp), %rdi
callq 0x2e7e
leaq -0x98(%rbp), %rdi
callq 0x2e7e
leaq -0xb0(%rbp), %rdi
callq 0x2e7e
leaq -0x50(%rbp), %rdi
callq 0x2e7e
leaq -0xd0(%rbp), %rdi
callq 0x2e7e
leaq -0x190(%rbp), %rdi
callq 0x309e
movq %rbx, %rdi
callq 0x2290
nop