Skip to content
Snippets Groups Projects
Commit 48629ea6 authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

DNS code is written, compiles, but doesn't link

I need to figure out how to define the read_parameters method properly
parent 343cffba
No related branches found
No related tags found
1 merge request!21Bugfix/nansampling
......@@ -74,11 +74,16 @@ class _base(object):
self,
parameters = None,
function_suffix = '',
template_class = '',
template_prefix = '',
file_group = 'parameters'):
if type(parameters) == type(None):
parameters = self.parameters
key = sorted(list(parameters.keys()))
src_txt = ('int read_parameters' + function_suffix + '()\n{\n' +
src_txt = (template_prefix +
'int ' +
template_class +
'read_parameters' + function_suffix + '()\n{\n' +
'hid_t parameter_file;\n' +
'hid_t dset, memtype, space;\n' +
'char fname[256];\n' +
......
......@@ -2,6 +2,36 @@
#include <cmath>
#include "NSVE.hpp"
int grow_single_dataset(hid_t dset, int tincrement)
{
int ndims;
hsize_t space;
space = H5Dget_space(dset);
ndims = H5Sget_simple_extent_ndims(space);
hsize_t *dims = new hsize_t[ndims];
H5Sget_simple_extent_dims(space, dims, NULL);
dims[0] += tincrement;
H5Dset_extent(dset, dims);
H5Sclose(space);
delete[] dims;
return EXIT_SUCCESS;
}
herr_t grow_dataset_visitor(
hid_t o_id,
const char *name,
const H5O_info_t *info,
void *op_data)
{
if (info->type == H5O_TYPE_DATASET)
{
hsize_t dset = H5Dopen(o_id, name, H5P_DEFAULT);
grow_single_dataset(dset, *((int*)(op_data)));
H5Dclose(dset);
}
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVE<rnumber>::read_iteration(void)
{
......
......@@ -34,35 +34,13 @@
#include "vorticity_equation.hpp"
#include "full_code/direct_numerical_simulation.hpp"
int grow_single_dataset(hid_t dset, int tincrement)
{
int ndims;
hsize_t space;
space = H5Dget_space(dset);
ndims = H5Sget_simple_extent_ndims(space);
hsize_t *dims = new hsize_t[ndims];
H5Sget_simple_extent_dims(space, dims, NULL);
dims[0] += tincrement;
H5Dset_extent(dset, dims);
H5Sclose(space);
delete[] dims;
return EXIT_SUCCESS;
}
int grow_single_dataset(hid_t dset, int tincrement);
herr_t grow_dataset_visitor(
hid_t o_id,
const char *name,
const H5O_info_t *info,
void *op_data)
{
if (info->type == H5O_TYPE_DATASET)
{
hsize_t dset = H5Dopen(o_id, name, H5P_DEFAULT);
grow_single_dataset(dset, *((int*)(op_data)));
H5Dclose(dset);
}
return EXIT_SUCCESS;
}
void *op_data);
template <typename rnumber>
class NSVE: public direct_numerical_simulation
......
......@@ -28,26 +28,41 @@
#define MAIN_CODE_HPP
#include <cfenv>
#include <string>
#include <iostream>
#include "base.hpp"
#include "field.hpp"
#include "scope_timer.hpp"
int myrank, nprocs;
template <class DNS>
main_code(
const std::string &simname,
int main_code(
int argc,
char *argv[],
const bool floating_point_exceptions)
{
/* floating point exception switch */
if (this->floating_point_exceptions)
if (floating_point_exceptions)
feenableexcept(FE_INVALID | FE_OVERFLOW);
else
// using std::cerr because DEBUG_MSG requires myrank to be defined
std::cerr << ("FPE have been turned OFF" << std::endl;
std::cerr << "FPE have been turned OFF" << std::endl;
if (argc != 2)
{
std::cerr <<
"Wrong number of command line arguments. Stopping." <<
std::endl;
MPI_Finalize();
return EXIT_SUCCESS;
}
std::string simname = std::string(argv[1]);
/* initialize MPI environment */
int myrank, nprocs;
#ifdef NO_FFTWOMP
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
......@@ -83,11 +98,8 @@ main_code(
/* import fftw wisdom */
if (myrank == 0)
{
char fname[256];
sprintf(fname, "%s_fftw_wisdom.txt", simname.c_str());
fftwf_import_wisdom_from_filename(fname);
}
fftwf_import_wisdom_from_filename(
(simname + std::string("_fftw_wisdom.txt")).c_str());
fftwf_mpi_broadcast_wisdom(MPI_COMM_WORLD);
......@@ -105,7 +117,7 @@ main_code(
* recover from should not be important enough to not clean up fftw and MPI
* things.
*/
DNS *dns(
DNS *dns = new DNS(
MPI_COMM_WORLD,
simname);
int return_value;
......@@ -124,17 +136,16 @@ main_code(
DEBUG_MSG("problem calling dns->finalize(), return value is %d",
return_value);
delete dns;
/* export fftw wisdom */
fftwf_mpi_gather_wisdom(MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if (myrank == 0)
{
char fname[256];
sprintf(fname, "%s_fftw_wisdom.txt", simname);
fftwf_export_wisdom_to_filename(fname);
}
fftwf_export_wisdom_to_filename(
(simname + std::string("_fftw_wisdom.txt")).c_str());
......@@ -142,7 +153,7 @@ main_code(
fftwf_mpi_cleanup();
fftw_mpi_cleanup();
#ifndef NO_FFTWOMP
if (nbThreads > 1){
if (nThreads > 1){
fftw_cleanup_threads();
fftwf_cleanup_threads();
}
......
from bfps.DNS import DNS
def main():
c = DNS()
c.write_src()
c.compile_code()
return None
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment