1
// Copyright (C) 2012 Nuno David Lopes.-----------------------------------
2
// e-mail: ndl@ptmat.fc.ul.pt
3
// http://ptmat.fc.ul.pt/~ndl/
4
// Licensed under the GNU LGPL Version 3.0 or later.
5
// This program provides a demo of the DOLFWAVE library.
6
// Solitary wave evolution by adimensional generic
7
// KdV-BBM with CDG method
10
using namespace dolfin;
11
using namespace dolfin::dolfwave;
14
const double A=-20.; //
15
const double B=200.; // $x\in[A.B]$
17
const double mu=0.31623;
19
class ElevationInitKdV: public Expression
22
ElevationInitKdV(const double& delta0,const double& epsilon,
23
const double& delta1,const double& delta2):
24
delta0(delta0), epsilon(epsilon), delta1(delta1), delta2(delta2) {}
25
void eval(Array<double> & values,const Array<double> & x) const
28
Definition of the solitary wave solution
29
for the adimensional generic KdV-BBM equations
32
double c=delta0+delta0/80.; //Free parameter for speed/wave height
33
double b=3./2.*epsilon; //Nonlinear coeff.
34
double Psi=3.*(c-delta0)/b;
35
double Theta=1./2.*sqrt((c-delta0)/(delta2-c*delta1));
36
values[0]=Psi/sqr(cosh(Theta*x[0]));
40
const double ε
44
// --------------------------------------------------------------------
46
int main(int argc, char* argv[])
51
info("Wrong number of arguments");
52
info("argv[1]='2' for KdV-BBM or argv[1]='1' for KdV");
53
info("argv[2]=penalty_tau");
54
info("argv[3]=output_dir");
57
std::stringstream output_dir;
59
// Options, Initialization, Mesh and User functions
60
Dolfwave dw(120000 /*MaxSteps*/,
63
"aKdVcdgP1P2_1D" /*FormName*/,
64
"LU_P" /* uBLAS AlgBackEND*/,
65
"gnuplot" /*Plotter*/,
66
output_dir.str() /*OutDir*/,
70
dw.SetParameter("KdVPade",kdv_21_pade);
71
else if (atoi(argv[1])==2)
72
dw.SetParameter("KdVPade",kdv_22_pade);
74
double kdvp=parameters("dolfwave_parameters")["KdVPade"];
75
double delta1=(kdvp-1.)*mu*mu/6.; //Sec.-ord. disp. coeff.
76
double delta2=kdvp*mu*mu/6.; //Third-ord. disp. coeff.
78
dw.SetParameter("aKdVDelta0",1.0);
79
dw.SetParameter("aKdVEpsilon",eps);
80
dw.SetParameter("aKdVDelta1",delta1);
81
dw.SetParameter("aKdVDelta2",delta2);
82
dw.SetParameter("PenaltyTau",atof(argv[2]));
83
info(parameters,true);// Some info on the used parameters
84
Interval mesh(1001,A,B);
85
ElevationInitKdV eta_init(parameters("dolfwave_parameters")["aKdVDelta0"],
86
parameters("dolfwave_parameters")["aKdVEpsilon"],
87
parameters("dolfwave_parameters")["aKdVDelta1"],
88
parameters("dolfwave_parameters")["aKdVDelta2"]);
89
//initial condition for elevation
90
dw.SpacesFunctionsVectorsInit(mesh); // Init. Spaces Functions & Vectors
91
dw.BilinearFormInit(mesh);//BilinearForm a initialization
92
dw.MatricesAssemble( ); //Matrices M and Mf initialization
93
dw.LinearFormsInit( );
94
dw.InitialCondition(eta_init); //Initial Conditions L2 projection
97
dw.LUFactorization(true ); //Re-use factorization
100
dw.RKInit("exp4"); // Explicit 4th-order Runge-Kutta
101
dw.RKSolve();//Runge-Kutta for 3 initial steps
102
dw.PCInit(mesh,true);
104
for(int i=4; i<dw.MaxSteps+1;i++)
107
if (!(i%dw.WriteGap))
111
dw.Volume(mesh,zero);
112
dw.Info(i,true);// Output some extra information on memory usage
116
return (EXIT_SUCCESS);