/**
	 * Writes a measurement for a given time
	 *
	 * @param i_time moment in time when the data were measured
	 * @param i_h simulated water height for given position and time
	 * @param i_b bathymetry for given position and time
	 */
	void writeData(const float i_time, const float i_h, const float i_b) {
		// append value to the output file
		ofstream l_outFile (outFileName.c_str(), ios::app);
		if (l_outFile.is_open())
			l_outFile << i_time << " " << i_h + i_b << endl;
		l_outFile.close();
	}
	/**
	 * The constructor
	 * Builds an object that collects data
	 * at a given time over a 2D domain
	 *
	 * @param i_time time of current data collection
	 */
	SpatialDataReceiver(const std::string i_baseName,
					    const float i_time):
					    time(i_time) {
		// create output file
		// name: i_baseName + "_profile_" + time
		std::ostringstream oss;
		oss << i_baseName << "_profile_" << time;
		outFileName = oss.str();
		// write header
		ofstream l_outFile(outFileName.c_str());
		l_outFile.close();
	};
	/**
	 * The constructor
	 * Builds an object that collects data over time in
	 * one single point in the 2D domain
	 *
	 * @param i_xPos position of point in x-direction
	 * @param i_yPos	position of point in y-direction
	 */
	TimeSeriesDataReceiver(const std::string i_baseName,
						   const float i_xPos,
				   	   	   const float i_yPos):
				   	   	   xPos(i_xPos),
				   	   	   yPos(i_yPos) {
		// create output file
		// name: i_baseName + "_dynamics_" + xPos + "_" + yPos
		std::ostringstream oss;
		oss << i_baseName << "_dynamics_" << xPos << "_" << yPos;
		outFileName = oss.str();

		// write header in the output file
		ofstream l_outFile(outFileName.c_str());
		l_outFile.close();
	};
Example #4
0
size_t File::bz2CompressFile(const wstring& p_file, const wstring& p_file_bz2)
{
	size_t l_outSize = 0;
	int64_t l_size = File::getSize(p_file);
	if (l_size > 0)
	{
		unique_ptr<byte[]> l_inData(new byte[l_size]);
		File l_f(p_file, File::READ, File::OPEN, false);
		size_t l_read_size = l_size;
		l_f.read(l_inData.get(), l_read_size);
		if (l_read_size == static_cast<uint64_t>(l_size))
		{
			unique_ptr<OutputStream> l_outFilePtr(new File(p_file_bz2, File::WRITE, File::TRUNCATE | File::CREATE, false));
			FilteredOutputStream<BZFilter, false> l_outFile(l_outFilePtr.get());
			l_outSize += l_outFile.write(l_inData.get(), l_size);
			l_outSize += l_outFile.flush();
		}
	}
	return l_outSize;
}
	/**
	 * Writes a measurement for a given time
	 */
	void writeData(const float i_offsetX,
				   const float i_offsetY,
				   const float i_dX,
				   const float i_dY,
				   const int i_nX,
				   const int i_nY,
				   const int i_nghosts,
				   const Float2D& i_h,
				   const Float2D& i_b) {
		ofstream l_outFile(outFileName.c_str(), ios::app);
		if (l_outFile.is_open()) {
			for (int i=0; i<i_nX; i++)
				for (int j=0; j<i_nY; j++)
					l_outFile << (i_offsetX + (i+0.5f)*i_dX) << " "
							  << (i_offsetY + (j+0.5f)*i_dY) << " "
							  << i_h[i+i_nghosts][j+i_nghosts]
							   + i_b[i+i_nghosts][j+i_nghosts] << endl;

		}
		l_outFile.close();
	}