Skip to content
Snippets Groups Projects
Commit ebe9a19c authored by Tobias Baetge's avatar Tobias Baetge
Browse files

WIP implement static velocity field

parent 992e96b6
Branches
Tags
No related merge requests found
/******************************************************************************
* *
* Copyright 2019 Max Planck Institute for Dynamics and Self-Organization *
* *
* This file is part of bfps. *
* *
* bfps is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, either version 3 of the License, *
* or (at your option) any later version. *
* *
* bfps is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with bfps. If not, see <http://www.gnu.org/licenses/> *
* *
* Contact: Cristian.Lalescu@ds.mpg.de *
* *
******************************************************************************/
#define NDEBUG
#include <string>
#include <cmath>
#include "static_field.hpp"
#include "scope_timer.hpp"
#include "fftw_tools.hpp"
template <typename rnumber>
int static_field<rnumber>::initialize(void)
{
TIMEZONE("static_file::initialize");
this->read_iteration();
this->read_parameters();
if (this->myrank == 0)
{
// set caching parameters
hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
herr_t cache_err = H5Pset_cache(fapl, 0, 521, 134217728, 1.0);
variable_used_only_in_assert(cache_err);
DEBUG_MSG("when setting stat_file cache I got %d\n", cache_err);
this->stat_file = H5Fopen(
(this->simname + ".h5").c_str(),
H5F_ACC_RDWR,
fapl);
}
int data_file_problem;
if (this->myrank == 0)
data_file_problem = this->grow_file_datasets();
MPI_Bcast(&data_file_problem, 1, MPI_INT, 0, this->comm);
if (data_file_problem > 0)
{
std::cerr <<
data_file_problem <<
" problems growing file datasets.\ntrying to exit now." <<
std::endl;
return EXIT_FAILURE;
}
this->vorticity = new field<rnumber, FFTW, THREE>(
nx, ny, nz,
this->comm,
fftw_planner_string_to_flag[this->fftw_plan_rigor]);
this->stat_vel = new field<rnumber, FFTW, THREE>(
nx, ny, nz,
this->comm,
fftw_planner_string_to_flag[this->fftw_plan_rigor]);
//reading initial field which is either default or a specified source field
this->vorticity->io(
this->simname + std::string(".h5"),
"vorticity",
this->iteration,
true);
this->kk = new kspace<FFTW, SMOOTH>(
this->vorticity->clayout, this->dkx, this->dky, this->dkz);
// compute the velocity field and store
invert_curl(
this->kk,
this->vorticity,
stat_vel_field);
// transform velocity field to real space
this->stat_vel->ift();
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVE<rnumber>::step(void)
{
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVE<rnumber>::write_checkpoint(void)
{
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVE<rnumber>::finalize(void)
{
TIMEZONE("NSVE::finalize");
if (this->myrank == 0)
H5Fclose(this->stat_file);
delete this->vorticity;
delete this->stat_vel;
delete this->kk;
return EXIT_SUCCESS;
}
/** \brief Compute standard statistics for velocity and vorticity fields.
*
* IMPORTANT: at the end of this subroutine, `this->fs->cvelocity` contains
* the Fourier space representation of the velocity field, and
* `this->tmp_vec_field` contains the real space representation of the
* velocity field.
* This behavior is relied upon in the `NSVEparticles` class, so please
* don't break it.
*/
template <typename rnumber>
int NSVE<rnumber>::do_stats()
{
return EXIT_SUCCESS;
}
template <typename rnumber>
int NSVE<rnumber>::read_parameters(void)
{
TIMEZONE("NSVE::read_parameters");
this->direct_numerical_simulation::read_parameters();
hid_t parameter_file = H5Fopen((this->simname + ".h5").c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
this->fftw_plan_rigor = hdf5_tools::read_string(parameter_file, "parameters/fftw_plan_rigor");
H5Fclose(parameter_file);
return EXIT_SUCCESS;
}
template class NSVE<float>;
template class NSVE<double>;
/**********************************************************************
* *
* Copyright 2017 Max Planck Institute *
* for Dynamics and Self-Organization *
* *
* This file is part of bfps. *
* *
* bfps is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, either version 3 of the License, *
* or (at your option) any later version. *
* *
* bfps is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with bfps. If not, see <http://www.gnu.org/licenses/> *
* *
* Contact: Cristian.Lalescu@ds.mpg.de *
* *
**********************************************************************/
#ifndef STATIC_FIELD_HPP
#define STATIC_FIELD_HPP
#include <cstdlib>
#include "base.hpp"
#include "full_code/direct_numerical_simulation.hpp"
template <typename rnumber>
class static_field: public direct_numerical_simulation
{
public:
/* parameters that are read in read_parameters */
std::string fftw_plan_rigor;
/* other stuff */
kspace<FFTW, SMOOTH> *kk;
field<rnumber, FFTW, THREE> *velocity;
field<rnumber, FFTW, THREE> *stat_vel;
static_field(
const MPI_Comm COMMUNICATOR,
const std::string &simulation_name):
direct_numerical_simulation(
COMMUNICATOR,
simulation_name){}
~static_field(){}
int initialize(void);
int step(void);
int finalize(void);
virtual int read_parameters(void);
int write_checkpoint(void);
int do_stats(void);
};
#endif//STATIC_FIELD_HPP
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment