> |
Fp:=subs("N"=N,
proc(n0,nf,uu::Vector, uu_old::Vector, deltA::float, tnew::float, F1::Vector)
local h::float,left::float,right::float,top::float,bot::float,i::integer,j::integer,ind::integer;
h:=1.0/"N":
for i from n0 to nf do
for j from 1 to "N" do
ind:=i+(j-1)*"N":
if i = 1 then left:=0: else left:=(0.5*uu[ind]+uu_old[ind]-0.5*uu[ind-1]-uu_old[ind-1])/h:end:
if i = "N" then right:=-0.1: else right:=(0.5*uu[ind+1]+uu_old[ind+1]-0.5*uu[ind]-uu_old[ind])/h:end:
if j = 1 then bot:=0: else bot:=(0.5*uu[ind]+uu_old[ind]-0.5*uu[ind-"N"]-uu_old[ind-"N"])/h:end:
if j = "N" then top:=-0.1: else top:=(0.5*uu[ind+"N"]+uu_old[ind+"N"]-0.5*uu[ind]-uu_old[ind])/h:end:
F1[ind]:=uu[ind]-deltA*(right+top-left-bot)/h+deltA*(0.5*uu[ind]+uu_old[ind])^2;
#print(F1);
od:od:
end proc);
|
> |
F:=subs("N"=N,
proc(uu::Vector, uu_old::Vector, deltA::float, tnew::float, F1::Vector)
local h::float,left::float,right::float,top::float,bot::float,i::integer,j::integer,ind::integer;
Fp(1,"N",uu,uu_old,deltA,tnew,F1);
end proc);
|
> |
FpDistribute := proc(n0,nf,uu::Vector, uu_old::Vector, deltA::float, tnew::float, F1::Vector)
local nmid;
if 20 < nf - n0 then
#nmid := floor(1/2*nf - 1/2*n0) + i_low;
nmid:=iquo(n0+nf,2);
Continue(null,
Task = [FpDistribute, n0,nmid,uu,uu_old,deltA,tnew,F1],
Task = [FpDistribute,nmid,nf,uu,uu_old,deltA,tnew,F1]);
else
Fp(n0,nf,uu,uu_old,deltA,tnew,F1); end if;
end proc;
|
> |
Fparallel:=subs("N"=N,
proc(uu::Vector, uu_old::Vector, deltA::float, tnew::float, F1::Vector)
local h::float,left::float,right::float,top::float,bot::float,i::integer,j::integer,ind::integer;
Start(FpDistribute,1,"N",uu,uu_old,deltA,tnew,F1);
end proc);
|
> |
interface(prettyprint=3);
|
> |
Jp:=subs("N"=N,proc(n0,nf,uu::Vector,uu_old::Vector,deltA::float,tnew::float,Nt::integer,J::Matrix(storage=sparse,datatype=float[8]))
local h::float,left::float,right::float,top::float,bot::float,i::integer,j::integer,ind::integer;
h:=1.0/"N";
#J:=Matrix(1..Nt,1..Nt,storage=sparse,datatype=float[8]):
for i from n0 to nf do
for j from 1 to "N" do
#for j from 1 to "N" do
ind:=i+(j-1)*"N":
J[ind,ind]:=1.0+deltA*(0.5*uu[ind]+uu_old[ind]):
if i > 1 then J[ind,ind]:=J[ind,ind]+deltA*0.5/h^2:J[ind,ind-1]:=-deltA*0.5/h^2:end:
if i < "N" then J[ind,ind]:=J[ind,ind]+deltA*0.5/h^2:J[ind,ind+1]:=-deltA*0.5/h^2:end:
if j >1 then J[ind,ind]:=J[ind,ind]+deltA*0.5/h^2:J[ind,ind-"N"]:=-deltA*0.5/h^2:end:
if j < "N" then J[ind,ind]:= J[ind,ind]+deltA*0.5/h^2:J[ind,ind+"N"]:=-deltA*0.5/h^2:end:
od:od:
#J;
end proc);
|
> |
Jac:=subs("N"=N,proc(uu::Vector,uu_old::Vector,deltA::float,tnew::float,Nt::integer,J::Matrix(storage=sparse,datatype=float[8]))
local h::float,left::float,right::float,top::float,bot::float,i::integer,j::integer,ind::integer;
Jp(1,"N",uu,uu_old,deltA,tnew,Nt,J);
#J;
end proc);
|
> |
JpDistribute := proc(n0,nf,uu::Vector, uu_old::Vector, deltA::float, tnew::float, Nt::integer,J::Matrix(storage=sparse,datatype=float[8]))
local nmid;
if 100 < nf - n0 then
#nmid := floor(1/2*nf - 1/2*n0) + i_low;
nmid:=iquo(n0+nf,2);
Continue(null,
Task = [JpDistribute, n0,nmid,uu,uu_old,deltA,tnew,Nt,J],
Task = [JpDistribute,nmid,nf,uu,uu_old,deltA,tnew,Nt,J]);
else
Jp(n0,nf,uu,uu_old,deltA,tnew,Nt,J); end if;
end proc;
|
> |
Jacparallel:=subs("N"=N,
proc(uu::Vector, uu_old::Vector, deltA::float, tnew::float, Nt::integer,J::Matrix(storage=sparse,datatype=float[8]))
local h::float,left::float,right::float,top::float,bot::float,i::integer,j::integer,ind::integer;
Start(JpDistribute,1,"N",uu,uu_old,deltA,tnew,Nt,J);
end proc);
|
|