示例#1
0
/**
 * Writes the unknwons to a netCDF-file (-> constructor) with respect to the boundary sizes.
 *
 * boundarySize[0] == left
 * boundarySize[1] == right
 * boundarySize[2] == bottom
 * boundarySize[3] == top
 *
 * @param i_h water heights at a given time step.
 * @param i_hu momentums in x-direction at a given time step.
 * @param i_hv momentums in y-direction at a given time step.
 * @param i_boundarySize size of the boundaries.
 * @param i_time simulation time of the time step.
 */
void io::NetCdfWriter::writeTimeStep( const Float2D &i_h,
                                      const Float2D &i_hu,
                                      const Float2D &i_hv, 
                                      float i_time) {
	if (timeStep == 0)
		// Write bathymetry
		writeVarTimeIndependent(b, bVar);
		
	//write i_time
	nc_put_var1_float(dataFile, timeVar, &timeStep, &i_time);

	//write water height
	writeVarTimeDependent(i_h, hVar);

	//write momentum in x-direction
	writeVarTimeDependent(i_hu, huVar);

	//write momentum in y-direction
	writeVarTimeDependent(i_hv, hvVar);

	//Write everything to the file
	nc_sync(dataFile);

	// Increment timeStep for next call
	timeStep++;
}
示例#2
0
/**
 * Writes the unknwons to a netCDF-file (-> constructor) with respect to the boundary sizes.
 *
 * boundarySize[0] == left
 * boundarySize[1] == right
 * boundarySize[2] == bottom
 * boundarySize[3] == top
 *
 * @param i_h water heights at a given time step.
 * @param i_hu momentums in x-direction at a given time step.
 * @param i_hv momentums in y-direction at a given time step.
 * @param i_boundarySize size of the boundaries.
 * @param i_time simulation time of the time step.
 */
void io::NetCdfWriter::writeTimeStep( const Float2D &i_h,
                                      const Float2D &i_hu,
                                      const Float2D &i_hv,
                                      float i_time, bool i_writeBathymetry) {
	/*
	 * Prints the arrays
	for(int row = 0; row < i_h.getRows(); row++)
		for(int col = 0; col < i_h.getCols(); col++)
			{
				std::cout << "Row " << row << ", Column " << col << std::endl;
				std::cout << i_h[row][col] << " " << i_hu[row][col] << " " << i_hv[row][col] << std::endl;
			}
	*/

	if (timeStep == 0 && i_writeBathymetry)
		// Write bathymetry
		writeVarTimeIndependent(b, bVar);

	//write i_time
	nc_put_var1_float(dataFile, timeVar, &timeStep, &i_time);

	//write water height
	writeVarTimeDependent(i_h, hVar);

	//write momentum in x-direction
	writeVarTimeDependent(i_hu, huVar);

	//write momentum in y-direction
	writeVarTimeDependent(i_hv, hvVar);

	// Increment timeStep for next call
	timeStep++;

	if (flush > 0 && timeStep % flush == 0)
		nc_sync(dataFile);

	nc_sync(dataFile);
#ifndef NDEBUG
	std:string text = "Wrote to file ";
	
	std::ostringstream buff;
   		buff << dataFile;
	tools::Logger::logger.printString(text + buff.str());
#endif
}
示例#3
0
void io::NetCdfWriter::writeTimeStep( const Float2D &i_h,
                                      const Float2D &i_hu,
                                      const Float2D &i_hv,
                                      const Float2D &i_b,
                                      float i_time) {
	//write i_time
	nc_put_var1_float(dataFile, timeVar, &timeStep, &i_time);

	//write water height
	writeVarTimeDependent(i_h, hVar);

	//write momentum in x-direction
	writeVarTimeDependent(i_hu, huVar);

	//write momentum in y-direction
	writeVarTimeDependent(i_hv, hvVar);

	//write bathymetry
	writeVarTimeDependent(i_b, bVar);

	// Increment timeStep for next call
	timeStep++;

	if (flush > 0 && timeStep % flush == 0)
		nc_sync(dataFile);

	nc_sync(dataFile);
#ifndef NDEBUG
	std:string text = "Wrote to file ";
	
	std::ostringstream buff;
   		buff << dataFile;
	tools::Logger::logger.printString(text + buff.str());
#endif

}