File: reconstructProc0ForIntMpi.cpp

package info (click to toggle)
stopt 5.12%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,860 kB
  • sloc: cpp: 70,456; python: 5,950; makefile: 72; sh: 57
file content (46 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2016 EDF
// All Rights Reserved
// This code is published under the GNU Lesser General Public License (GNU LGPL)
#ifdef USE_MPI
#include <memory>
#include <Eigen/Dense>
#include "StOpt/core/utils/types.h"
#include "StOpt/core/grids/RegularSpaceIntGrid.h"
#include "StOpt/core/parallelism/ParallelComputeGridSplitting.h"

using namespace Eigen;
using namespace std;

namespace StOpt
{
ArrayXd reconstructProc0ForIntMpi(const ArrayXi &p_point, const shared_ptr< RegularSpaceIntGrid> &p_grid,  const shared_ptr< ArrayXXd >    &p_values, const Eigen::Array< bool, Eigen::Dynamic, 1>   &p_bdimToSplit, const boost::mpi::communicator &p_world)
{
    int nDim = p_grid->getDimension();
    ArrayXi initialDimension   = p_grid->getDimensions();
    // organize the hypercube splitting for parallel
    ArrayXi splittingRatio = paraOptimalSplitting(initialDimension, p_bdimToSplit, p_world);
    // for parallelization
    ParallelComputeGridSplitting parall(initialDimension, splittingRatio, p_world);
    // create the subgrid
    SubMeshIntCoord retGrid(nDim);
    for (int id = 0; id <  nDim; ++id)
    {
        retGrid(id)[0] = p_point(id) - p_grid->getLowValueDim(id);
        retGrid(id)[1] = p_point(id) - p_grid->getLowValueDim(id) + 1;
    }
    // new grid
    shared_ptr<RegularSpaceIntGrid> grid = p_grid->getSubGrid(retGrid);
    // values on grid
    ArrayXXd valuesExtended;
    if (p_values)
    {
        // values on grid
        valuesExtended = parall.reconstruct<double>(*p_values, retGrid);
    }
    // now the extendend value has only one point
    if (p_world.rank() == 0)
        return valuesExtended.col(0);
    return ArrayXd::Zero(1);
}
}
#endif