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

add field_container class.

code compiles, but doesn't do anything yet...
parent f9d539d1
No related branches found
No related tags found
No related merge requests found
/**********************************************************************
* *
* Copyright 2015 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 *
* *
**********************************************************************/
#include "field.hpp"
template <class number,
field_backend be,
field_components fc>
field_container<number, be, fc>::field_container(
int nx, int ny, int nz,
MPI_Comm COMM_TO_USE)
{
this->comm = COMM_TO_USE;
MPI_Comm_rank(this->comm, &this->myrank);
MPI_Comm_size(this->comm, &this->nprocs);
if (be == FFTW)
{
ptrdiff_t nfftw[3];
nfftw[0] = nz;
nfftw[1] = ny;
nfftw[2] = nx;
this->local_size = fftw_mpi_local_size_many(
3,
nfftw,
ncomp(fc),
FFTW_MPI_DEFAULT_BLOCK,
this->comm,
this->subsizes,
this->starts);
}
this->sizes[0] = nz;
this->sizes[1] = ny;
this->sizes[2] = nx;
if (fc == THREE || fc == THREExTHREE)
this->sizes[3] = 3;
if (fc == THREExTHREE)
this->sizes[4] = 3;
if (be == FFTW)
{
for (int i=1; i<ndim(fc); i++)
{
this->subsizes[i] = this->sizes[i];
this->starts[i] = 0;
}
}
}
template <class number,
field_backend be,
field_components fc>
field_container<number, be, fc>::~field_container()
{}
template <class number,
field_backend be,
field_components fc>
int field_container<number, be, fc>::read(
const char *fname,
const char *dset_name,
int iteration)
{
return EXIT_SUCCESS;
}
template <class number,
field_backend be,
field_components fc>
int field_container<number, be, fc>::write(
const char *fname,
const char *dset_name,
int iteration)
{
return EXIT_SUCCESS;
}
//template <class rnum,
// field_representation repr,
// field_backend be,
// field_components fc>
//field::field(
// int *n,
// MPI_Comm COMM_TO_USE)
//{}
//
//field::~field()
//{}
/**********************************************************************
* *
* Copyright 2015 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 *
* *
**********************************************************************/
#include <mpi.h>
#include <hdf5.h>
#include <fftw3-mpi.h>
#include <vector>
#ifndef FIELD
#define FIELD
enum field_representation {REAL, COMPLEX, BOTH};
enum field_backend {FFTW};
enum field_components {ONE, THREE, THREExTHREE};
constexpr unsigned int ncomp(
field_components fc)
/* return actual number of field components for each enum value */
{
return ((fc == THREE) ? 3 : (
(fc == THREExTHREE) ? 9 : 1));
}
constexpr unsigned int ndim(
field_components fc)
/* return actual number of field dimensions for each enum value */
{
return ((fc == THREE) ? 4 : (
(fc == THREExTHREE) ? 5 : 3));
}
template <class number,
field_backend be,
field_components fc>
class field_container
{
public:
/* description */
hsize_t sizes[ndim(fc)];
hsize_t subsizes[ndim(fc)];
hsize_t starts[ndim(fc)];
ptrdiff_t slice_size, local_size, full_size;
int myrank, nprocs;
MPI_Comm comm;
std::vector<int> rank;
std::vector<std::vector<int>> all_start;
std::vector<std::vector<int>> all_size;
number *data;
/* methods */
field_container(
int nx, int ny, int nz,
MPI_Comm COMM_TO_USE);
~field_container();
int read(
const char *fname,
const char *dset_name,
int iteration);
int write(
const char *fname,
const char *dset_name,
int iteration);
};
//template <class rnum,
// field_representation repr,
// field_backend be,
// field_components fc>
//class field
//{
// public:
//
// field_container< *kdata, *rdata;
//
// /* methods */
// field(
// int *n,
// MPI_Comm COMM_TO_USE);
// ~field();
//};
#endif//FIELD
......@@ -88,7 +88,8 @@ print('This is bfps version ' + VERSION)
### lists of files and MANIFEST.in
src_file_list = ['field_descriptor',
src_file_list = ['field',
'field_descriptor',
'rFFTW_distributed_particles',
'distributed_particles',
'particles',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment