Programmierpraktikum NPDGL I
|
Dies ist ein Beispiel zur Verwendung der Klasse InitialProjection.
TestFunc1 f;
Grid g(1, 5, 10); // initialize Dof vector DofVectorType U0(g);
std::vector
ist Teil der sogenannten Standard Template Library (STL).Projection projection(g); projection.apply(f, U0);
U0
mit den Auswertungen der Anfangsdatenfunktion in den Mittelpunkten der Gitterzellen gefüllt sein.gnuplot
Datei aus: * @skipline write_gnuplot
#include "projection.hh" #include "mygrid.hh" #include "function_library.hh" #include "dataoutput.hh" #include "dofvector.hh" int main(int argc, const char *argv[]) { typedef DefaultDofVectorTraits< double > DofVectorTraits; typedef DefaultDofVector< DofVectorTraits > DofVectorType; // initialize function that needs to be projected TestFunc1 f; // initialize grid Grid g(1, 5, 10); // initialize Dof vector DofVectorType U0(g); // initialize Projection Projection projection(g); projection.apply(f, U0); // write U0 as gnuplot file DataOutput :: GnuplotOneD dataOut(g, "initial_data.plot"); dataOut.write(U0); return 0; }