42using Kernels = SchrodingerBaseKernels<
58static auto SetMesh = [](Mesh &mesh) {
return Mesh(mesh); };
59static auto SetOrthoSolver = []() {
return OrthoSolver(); };
60static auto SetCGSolver = []() {
return CGSolver(); };
61static auto SetGMRESSolver = []() {
return GMRESSolver(); };
64struct SchrodingerSolver :
public Kernels
69 CrankNicolsonSchrodingerTimeSolver(FiniteElementSpace &fes,
76 void Mult(ComplexGridFunction &psi)
override
82 } time_1_solver, time_2_solver;
85 SchrodingerSolver(
Options &config):
86 Kernels(config, SetMesh, SetOrthoSolver, SetCGSolver),
90 void Step() { time_1_solver.Mult(
psi1); time_2_solver.Mult(
psi2); }
94 const auto Grad_nd = [&](GridFunction &in_h1, GridFunction &out_nd)
100 const auto x_dot_Mm1 = [&](GridFunction &x, GridFunction &y)
104 const auto y_dot_Mm1 = [&](GridFunction &x, GridFunction &y)
108 const auto z_dot_Mm1 = [&](GridFunction &x, GridFunction &y)
115 void VelocityOneForm(GridFunction &ux, GridFunction &uy, GridFunction &uz)
141 void PressureProject() { ComputeDivU(); PoissonSolve();
GaugeTransform(); }
145 IncompressibleBaseFlow<SchrodingerSolver, GridFunction>;
148 VisualizerBase<Mesh, GridFunction, FiniteElementSpace, SchrodingerSolver, IncompressibleFlow>;
152int main(
int argc,
char *argv[])
154 Options opt(argc, argv);
155 Device device(opt.device);
158 SchrodingerSolver schrodinger(opt);
159 IncompressibleFlow flow(opt, schrodinger);
160 FlowVis vis(opt, schrodinger, flow, []() {
return ""; });
162 for (
int ti = 1; ti <= opt.max_steps; ti++)
164 const real_t t = ti * opt.dt;
165 const bool vis_steps = (ti % opt.vis_steps) == 0;
166 if (vis_steps) {
mfem::out <<
"#" << ti << std::endl; }
168 if (opt.visualization && vis_steps) { vis.GLVis(); vis.Save(ti, t); }
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the GMRES method.
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
IncompressibleBaseFlow< SchrodingerSolver, ParGridFunction > IncompressibleFlow
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
VisualizerBase< ParMesh, ParGridFunction, ParFiniteElementSpace, SchrodingerSolver, IncompressibleFlow > FlowVis
SchrodingerBaseKernels< ParMesh, ParFiniteElementSpace, ParComplexGridFunction, ParGridFunction, ParBilinearForm, ParMixedBilinearForm, ParLinearForm > Kernels
CrankNicolsonTimeBaseSolver< ParFiniteElementSpace, ParSesquilinearForm, ParComplexGridFunction > CrankNicolsonSolver
CrankNicolsonTimeBaseSolver(TFiniteElementSpace &fes, real_t hbar, real_t dt, std::function< GMRESSolver()> CreateGMRESSolver, real_t rtol, real_t atol, int maxiter, int print_level)
Options(int argc, char *argv[])
TComplexGridFunction psi1
OperatorHandle nd_dot_y_h1_op
void GradPsiVelocity(const real_t hbar, TGridFunction &ux, TGridFunction &uy, TGridFunction &uz)
TComplexGridFunction delta_psi2
TComplexGridFunction psi2
OperatorHandle diff_h1_op
OperatorHandle nd_dot_x_h1_op
void GradPsi(Gfn &Grad_nd, Xfn &x_dot_Mm1, Yfn &y_dot_Mm1, Zfn &z_dot_Mm1)
TFiniteElementSpace h1_fes
OperatorHandle nd_dot_z_h1_op
OperatorHandle grad_nd_op
TComplexGridFunction delta_psi1