Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Condições de Contorno de Dirichlet

LNCC - Laboratório Nacional de Computação Científica

Após a montagem do sistema global, precisamos impor as condições de contorno de Dirichlet antes de resolver o sistema linear.

Problema

O sistema montado é:

Au=b\mathbf{A} \mathbf{u} = \mathbf{b}

Para condições de contorno não-homogêneas u=gu = g nos nós de fronteira, precisamos:

  1. Fixar os valores de ui=giu_i = g_i para nós iΩi \in \partial\Omega

  2. Modificar o sistema para acomodar esses valores conhecidos

Métodos de Imposição

Método 1: Eliminação Direta

Separe os graus de liberdade em:

O sistema pode ser particionado:

[AFFAFDADFADD][uFuD]=[bFbD]\begin{bmatrix} \mathbf{A}_{\mathcal{FF}} & \mathbf{A}_{\mathcal{FD}} \\ \mathbf{A}_{\mathcal{DF}} & \mathbf{A}_{\mathcal{DD}} \end{bmatrix} \begin{bmatrix} \mathbf{u}_{\mathcal{F}} \\ \mathbf{u}_{\mathcal{D}} \end{bmatrix} = \begin{bmatrix} \mathbf{b}_{\mathcal{F}} \\ \mathbf{b}_{\mathcal{D}} \end{bmatrix}

Resolvemos apenas:

AFFuF=bFAFDuD\mathbf{A}_{\mathcal{FF}} \mathbf{u}_{\mathcal{F}} = \mathbf{b}_{\mathcal{F}} - \mathbf{A}_{\mathcal{FD}} \mathbf{u}_{\mathcal{D}}

Método 2: Penalização

Modifique as linhas correspondentes aos nós de Dirichlet:

A[i,:]=[0,,0,1,0,,0],b[i]=giA[i, :] = [0, \ldots, 0, 1, 0, \ldots, 0], \quad b[i] = g_i

onde o 1 está na posição (i,i)(i, i).

Alternativamente, use um valor grande α1\alpha \gg 1:

A[i,i]=α,b[i]=αgiA[i, i] = \alpha, \quad b[i] = \alpha g_i

Método 3: Substituição de Linhas e Colunas (Usado no fempack)

Para cada nó ii com condição de Dirichlet ui=giu_i = g_i:

  1. Modifique a linha ii:

    • A[i,j]=0A[i, j] = 0 para jij \neq i

    • A[i,i]=1A[i, i] = 1

    • b[i]=gib[i] = g_i

  2. Modifique a coluna ii nas outras linhas:

    • Para jij \neq i: b[j]=b[j]A[j,i]gib[j] = b[j] - A[j, i] \cdot g_i

    • Para jij \neq i: A[j,i]=0A[j, i] = 0

Isso garante que:

Algoritmo de Imposição

Para cada nó i com condição de Dirichlet u_i = g_i:
    # Ajustar outras linhas
    Para cada j != i:
        b[j] -= A[j, i] * g_i
        A[j, i] = 0

    # Modificar linha i
    A[i, :] = 0
    A[i, i] = 1
    b[i] = g_i

Identificação dos Nós de Fronteira

Para malhas estruturadas ou simples, os nós de fronteira podem ser identificados por:

Para malhas gerais, pode-se usar uma tolerância:

na fronteira    xxbnd<ϵ\text{na fronteira} \iff |\mathbf{x} - \mathbf{x}_{\text{bnd}}| < \epsilon

Exemplo 1D

Sistema original com 4 nós:

1h[1100121001210011][u0u1u2u3]=[b0b1b2b3]\frac{1}{h} \begin{bmatrix} 1 & -1 & 0 & 0 \\ -1 & 2 & -1 & 0 \\ 0 & -1 & 2 & -1 \\ 0 & 0 & -1 & 1 \end{bmatrix} \begin{bmatrix} u_0 \\ u_1 \\ u_2 \\ u_3 \end{bmatrix} = \begin{bmatrix} b_0 \\ b_1 \\ b_2 \\ b_3 \end{bmatrix}

Impondo u0=g0u_0 = g_0 e u3=g3u_3 = g_3:

  1. Modificar linha 0 e ajustar coluna 0:

    • Linha 1: b1b1A[1,0]g0=b1+1hg0b_1 \leftarrow b_1 - A[1,0] \cdot g_0 = b_1 + \frac{1}{h} g_0

  2. Modificar linha 3 e ajustar coluna 3:

    • Linha 2: b2b2A[2,3]g3=b2+1hg3b_2 \leftarrow b_2 - A[2,3] \cdot g_3 = b_2 + \frac{1}{h} g_3

Sistema resultante:

[100002/h1/h001/h2/h00001][u0u1u2u3]=[g0b1+g0/hb2+g3/hg3]\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 2/h & -1/h & 0 \\ 0 & -1/h & 2/h & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} u_0 \\ u_1 \\ u_2 \\ u_3 \end{bmatrix} = \begin{bmatrix} g_0 \\ b_1 + g_0/h \\ b_2 + g_3/h \\ g_3 \end{bmatrix}

Implementação no fempack

O módulo fempack.bcs fornece:

Exemplo:

from fempack.bcs import apply_dirichlet_bc

# Aplicar u = 0 em toda a fronteira
A_bc, b_bc = apply_dirichlet_bc(A, b, mesh, lambda x: 0.0)

# Resolver sistema modificado
u = spsolve(A_bc, b_bc)