Basic functions for producing output files

When Montjoie is included, there are some standalone functions that can be used either to read or write output files, with the following format :

A basic example for using these functions is proposed below

// definition of the display grid
GridInterpolationFull<Dimension2>l; grid;
// for instance : 2-D regular grid
Real_wp xmin = -2, xmax = 2, ymin = -2, ymax = 2;
int nbx = 100, nby = 100;
grid.SetPlaneOutput(xmin, xmax, ymin, ymax, nbx, nby);

// if you are unsure about node orderings
// you can compute position of the points of the grid
VectReal_wp teta; VectR2 points2d;
grid.GenerateGridPoints(points2d, teta);

// and use these position to express a function
VectReal_wp val(points2d.GetM()), val2;
for (int i = 0; i < points2d.GetM(); i++)
  {
    Real_wp x =  points2d(i)(0), y = points2d(i)(1);
    val(i) = sin(x)*cos(y);
  }

// then you can produce a Matlab file with these datas
WriteMatlab(val, grid, "output.dat");

// you can also read datas
// val should be equal to val2 after calling this function
ReadMatlab(val2, grid, "output.dat", false);

// same stuff for vtk format :
val2.Clear();
WriteVtk(val, grid, "output.vtk");
ReadVtk(val2, grid, "output.vtk");

// For vtk outputs, it is also possible to produce outputs on unstructed grid, for example with a mesh :
Mesh<Dimension2> mesh;
mesh.Read("test.mesh");

val.Reallocate(mesh.GetNbVertices());
for (int i = 0; i < val.GetM(); i++)
  {
    Real_wp x = mesh.Vertex(i)(0), y = mesh.Vertex(i)(1);
    val(i) = sin(x)*cos(y);
  }

mesh.Write("output.vtk", false, false);
// then you append to the file the datas
ofstream file_out("output.vtk", ios::app);
WriteVtk(val, "u", file_out, false, false);
file_out.close();

An implementation of classes for writing seismogramms with buffering (to prevent from writing on the disk at each iteration) is also proposed by the classes WriteOnTheGoWithBuffer and WriteOnTheGoWithTinyBuffer.

WriteOnTheGoWithBuffer<Real_wp> buffer;
// the second argument is the number of vectors stored in the buffer
buffer.Init("sismo.dat". 100);

VectReal_wp x(N);
for (int nt = 0; nt < nb_iterations; nt++)
  {
    // evolution of x
    // ...

    // each time you want to print something on the file, you call AddVect
    buffer.AddVect(x);
  }

// at the end, buffer is released
buffer.CloseBuffer();

Functions for basic inputs/outputs

ReadMedit reads an output file .bb
WriteMedit writes a solution in an output file .bb
ReadMeshData reads an output file .elb
WriteMeshData writes values of a physical index in an output file .elb
ReadInputFile reads a data file
getElement_Equation returns the finite element and equation given in a data file
swapEndian swaps octets of a float, double or integer
WriteVtk writes a vtk output file
ReadVtk reads data from a vtk output file
WriteBinaryDoubleOrFloat writes a vector in double or single precision and in binary format
ReadBinaryDoubleOrFloat reads a vector in double or single precision from a binary file
WriteOnTheGo appends values to an output file

Methods of class WriteOnTheGoWithTinyBuffer/WriteOnTheGoWithBuffer

Init initialisation of the buffer
AddTinyVect adds a vector to the list of vectors to write in the file
AddVect adds a vector to the list of vectors to write in the file
CloseBuffer writes remaining vectors stored in the buffer, and closes the file.