File: reconstructProc0Mpi.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 (49 lines) | stat: -rw-r--r-- 1,754 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
47
48
49
// 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/FullGrid.h"
#include "StOpt/core/parallelism/ParallelComputeGridSplitting.h"

using namespace Eigen;
using namespace std;

namespace StOpt
{
ArrayXd reconstructProc0Mpi(const ArrayXd &p_point, const shared_ptr< FullGrid> &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);
    // define the grid for reconstruction
    ArrayXi pMin = p_grid->lowerPositionCoord(p_point);
    ArrayXi pMax = p_grid->upperPositionCoord(p_point);
    for (int id = 0; id <  nDim; ++id)
    {
        retGrid(id)[0] = pMin(id);
        retGrid(id)[1] = pMax(id) + 1;
    }
    // new grid
    shared_ptr<FullGrid> grid = p_grid->getSubGrid(retGrid);
    // values on grid
    ArrayXXd valuesExtended;
    if (p_values)
    {
        // values on grid
        valuesExtended = parall.reconstruct<double>(*p_values, retGrid);
    }
    // now interpolated
    if (p_world.rank() == 0)
        return (grid->createInterpolator(p_point)->applyVec(valuesExtended));
    return ArrayXd::Zero(1);
}
}
#endif