Skip to content
Snippets Groups Projects
Commit 3291590d authored by Chichi Lalescu's avatar Chichi Lalescu
Browse files

add field output test

parent c4605fbf
Branches
Tags
1 merge request!23WIP: Feature/use cmake
Pipeline #
......@@ -263,6 +263,12 @@ class TEST(_code):
self.simulation_parser_arguments(parser_field_test)
self.job_parser_arguments(parser_field_test)
self.parameters_to_parser_arguments(parser_field_test)
parser_field_output_test = subparsers.add_parser(
'field_output_test',
help = 'plain field output test')
self.simulation_parser_arguments(parser_field_output_test)
self.job_parser_arguments(parser_field_output_test)
self.parameters_to_parser_arguments(parser_field_output_test)
return None
def prepare_launch(
self,
......
#include <string>
#include <cmath>
#include <random>
#include "field_output_test.hpp"
#include "scope_timer.hpp"
template <typename rnumber>
int field_output_test<rnumber>::initialize(void)
{
this->read_parameters();
return EXIT_SUCCESS;
}
template <typename rnumber>
int field_output_test<rnumber>::finalize(void)
{
return EXIT_SUCCESS;
}
template <typename rnumber>
int field_output_test<rnumber>::read_parameters()
{
this->test::read_parameters();
return EXIT_SUCCESS;
}
template <typename rnumber>
int field_output_test<rnumber>::do_work(void)
{
// allocate
field<rnumber, FFTW, ONE> *scal_field = new field<rnumber, FFTW, ONE>(
this->nx, this->ny, this->nz,
this->comm,
DEFAULT_FFTW_FLAG);
std::default_random_engine rgen;
std::normal_distribution<rnumber> rdist;
rgen.seed(1);
// fill up scal_field
scal_field->real_space_representation = true;
scal_field->RLOOP(
[&](ptrdiff_t rindex,
ptrdiff_t xindex,
ptrdiff_t yindex,
ptrdiff_t zindex){
scal_field->rval(rindex) = rdist(rgen);
});
scal_field->io(
this->simname + std::string("_fields.h5"),
"scal_field",
0,
false);
// deallocate
delete scal_field;
return EXIT_SUCCESS;
}
template class field_output_test<float>;
template class field_output_test<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 FILTER_OUTPUT_TEST_HPP
#define FILTER_OUTPUT_TEST_HPP
#include <cstdlib>
#include "base.hpp"
#include "kspace.hpp"
#include "field.hpp"
#include "full_code/test.hpp"
/** \brief A class for testing basic field class functionality.
*/
template <typename rnumber>
class field_output_test: public test
{
public:
field_output_test(
const MPI_Comm COMMUNICATOR,
const std::string &simulation_name):
test(
COMMUNICATOR,
simulation_name){}
~field_output_test(){}
int initialize(void);
int do_work(void);
int finalize(void);
int read_parameters(void);
};
#endif//FILTER_OUTPUT_TEST_HPP
......@@ -93,6 +93,7 @@ src_file_list = ['full_code/NSVEcomplex_particles',
'full_code/test',
'full_code/filter_test',
'full_code/field_test',
'full_code/field_output_test',
'hdf5_tools',
'full_code/get_rfields',
'full_code/resize',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment