Resumen: En este ejemplo se considera un problema relativo a la ecuación de ondas.
Sean
donde
Para calcular una solución aproximada, procedemos como sigue:
Discretizamos en tiempo tratando la variable
Cada problema estacionario se discretiza mediante el método de los elementos finitos sobre una triangulación dada, como en los ejemplos de problemas elípticos considerados con anterioridad.
Consideramos una partición uniforme del intervalo
Para cada
Denotamos
Para
Para
Para
se tiene la siguiente ecuación (aproximada)
O, equivalentemente,
Para cada
Tomar
Tomar
Para cada
Obsérvese que, para cada
El espacio natural para buscar la solución del problema
Obsérvese que todos los problemas
y que solo difieren en la forma lineal. En la resolución numérica, esto se traduce en el hecho de que todos los sistemas lineales a resolver tienen la misma matriz, que, por lo tanto, solo habrá que construir y factorizar la primera vez.
x//
// Problem Data
//
real RR = 5., rr = 1.; // Outer and inner radius
real T = 15.; // Final time
real a = 0.1, c = 0.5; // edp coefficients
func KGm = 0.1*(1.+x*x)*(1.+y*y); // Klein-Gordon function
func force = 0.; // External force
//func u0 = x*x - y*y; // Initial u
func u0 = x*x + y*y - 25.; // Initial u
func u1 = 0.; // Initial u_t
//
// Data for mesh and time discretization
//
int nxo = 200; // Discret. of the outer border
int nxi = 50; // Discret. of the inner border
int nt = 100; // Time steps
int LO = 7; // Label of outer border
int LI = 12; // Label of inner border
//
// Coefficients of stationary problems
//
real c2 = c*c;
real dt = T/nt;
real dt1 = 1./dt;
real dt2 = dt1*dt1;
real adt0 = a*dt1;
real adt1 = dt2 + adt0;
real adt2 = 2*dt2 + adt0;
//
// Mesh
//
border CO(t=0, 2*pi){x=RR*cos(t); y=RR*sin(t); label = LO;} // outer
border CI(t=0, 2*pi){x=rr*cos(t); y=rr*sin(t); label = LI;} // inner
plot( CO(nxo) + CI(-nxi), dim = 2, wait = true );
mesh Th = buildmesh( CO(nxo) + CI(-nxi) );
plot(Th, cmm = " Initial mesh ", wait = true);
//
// FE space
//
fespace Vh(Th, P1);
Vh u, v;
Vh uold2 = u0; // uold2 --> u^{i-2}
Vh uold1 = u0 + dt*u1; // uold1 --> u^{i-1}
Vh alpha = adt1 + KGm; // u coefficient = adt1+m(x)
Vh f = force;
Vh F; // RHS; to be defined at each iteration
//
// Linear stationary problems
//
problem StWave(u, v, init=1) =
int2d(Th)(alpha*u*v + c2*(dx(u)*dx(v)+dy(u)*dy(v)))
- int2d(Th)(F*v)
+ on(LI, u = 0.) + on(LO, u = 0.);
//
// Time iterates
//
plot(uold2, dim = 3, nbiso = 40, cmm = " Time t = "+ 0.,
value = true, fill = true, wait = true);
plot(uold1, dim = 3, nbiso = 40, cmm = " Time t = "+ dt,
value = true, fill = true, prev = true, wait=true);
real t;
for (int k = 2; k <= nt; k ++)
{
t = k*dt;
F = f + adt2 * uold1 - dt2 * uold2; // current RHS
StWave;
plot(u, dim = 3, nbiso = 40, cmm = " Time t = "+ t,
value = true, fill = true, prev = true, wait=true);
uold2 = uold1;
uold1 = u;
}
Partiendo del programa anterior, resolver el problema
Anna Doubova - Rosa Echevarría - Dpto. EDAN - Universidad de Sevilla