FEMClass`

By Edgar Camacho Cota
Universidad Nacional Autonoma de Mexico (UNAM)
ecc@mira.labvis.unam.mx
June 2000.

Example 2 :
Solve
Log[ f'[x] ] + Sin[ f'[x] ] + f[x] = 0,  f[0] = 1

Pre-Process

This load the package

Needs[ "FEMClass`"]

this create the mesh

myMalla = 
      NewMalla[L2, {{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8}, {
            8, 9}}, {{0}, {(1/20)}, {(1/10)}, {(1/10) + (1/20)}, {(2/10)}, {
            (2/10) + (1/20)}, {(3/10)}, {(3/10) + (1/20)}, {(4/10)}}]

this graph the mesh

GrafMalla[myMalla]

this apply restriccions to f[0]=1

myRes = NewRestricciones[Flatten[{(f[D0, #1] == 1&)/@{1}}], {f}]

myCampo = NewCampoEF[L2C0, myMalla]

Principal Process

ao = CreaArgOmega[myCampo, myRes];

this perform the integrals over each element in the domain

ieo = 
      IntegralesElementalesOmega[myCampo, myRes, 
        ao, {#1 (Log[(∂_x) #2] + Sin[(∂_x) #2] + #2)
                &}, {x}];

ito = IntegralesTotales[ieo];

it = ito;

si = SistemaIncompleto[it];

sc = SistemaCompleto[si, myRes];

this expresion form a expresion for the initial values for the variables to find

varIni = 
      Transpose[{
          Incognitas[myCampo, myRes], {0.00000005, 0.0000001, 0.000001, 
            0.00001, 0.0001, 0.001, 0.01, 0.1, 0.5}}]

this transform all the f[a,b] expressions in the form fab, in order to FindRoth works fine

f[a_, b_] := ToExpression["f"<>ToString[a]<>ToString[b]]

s = 
      FindRoot[Evaluate[sc], Evaluate[Sequence@@varIni], 
        MaxIterations -> 100]

Post-Process

this plot the solution

GrafCampo[myCampo, f, s]

ff = 
      Interpolation[
        Transpose[{Flatten[Coords[myMalla]], 
              Union[Flatten[(GL[#1, f]&)/@Elementos[myCampo]]]}] /. s, 
        InterpolationOrder -> 1]

this plot the residual

Plot[Log[ff'[x]]+Sin[ff'[x]]+ff[x],{x, 0, (2/5)},PlotRange -> All]