// laplace_periodic.edp // // Discussion: // // Solve the Laplace equation in the square with periodic boundary // conditions, and writes the resulting data to files, using the // ffmatlib() interface, for subsequent graphics processing by MATLAB or Octave. // // Licensing: // // Copyright (C) 2018 Chloros2 // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see // . // // Modified: // // 2018-05-19 // // Author: // // Chloros2 // include "ffmatlib.idp" cout << endl; cout << "laplace_periodic():" << endl; cout << " FreeFem++ version." << endl; cout << " Solve the Laplace equation on a periodic domain." << endl; cout << " Using the ffmatlib interface, export the data for graphic" << endl; cout << " processing by MATLAB/Octave." << endl; // // The region is 2*pi x 2*pi square. // mesh Th = square ( 30, 30, [ 2 * x * pi, 2 * y * pi ] ); // // Define a finite element space of periodic elements. // fespace Vh ( Th, P1, periodic = [ [ 2, y ], [ 4, y ], [ 1, x ], [ 3, x ] ] ); Vh u, v; func f = sin ( x + pi / 4.0 ) * cos ( y + pi / 2.0 ); problem laplace ( u, v ) = int2d(Th)(dx(u)*dx(v)+dy(u)*dy(v)) +int2d(Th)(-f*v); laplace; plot ( u, value = true, fill = true, ps = "laplace_periodic.ps" ); // // Write out data for later processing by MATLAB/Octave. // savemesh ( Th, "laplace_periodic.msh" ); ffSaveVh ( Th, Vh, "laplace_periodic_vh.txt" ); ffSaveData ( u, "laplace_periodic_data.txt" ); // // Terminate. // cout << "\n"; cout << "laplace_periodic():\n"; cout << " Normal end of execution.\n"; exit ( 0 );