コード例 #1
0
    static void checkFetch( Teuchos::RCP<Teuchos::Comm<int> const> const &comm,
                            View1 const &ranks, View1 const &indices,
                            View2 const &v_exp, View2 const &v_ref,
                            bool &success, Teuchos::FancyOStream &out )
    {
        auto v_imp = DataTransferKit::Details::NearestNeighborOperatorImpl<
            DeviceType>::fetch( comm, ranks, indices, v_exp );

        TEST_COMPARE_ARRAYS( toArray( v_imp ), toArray( v_ref ) );
    }
コード例 #2
0
TEUCHOS_UNIT_TEST(Teuchos_Validator, stringValidatorConverter)
{
  std::string defaultParameterName = "default";
  std::string nonDefaultParameterName = "non default";

  RCP<StringValidator> nonDefaultValidator = rcp(
    new StringValidator(tuple<std::string>("value1", "cheese", "kurtis", "is", "awesome")));
  ParameterList myList("String Validator List");
  myList.set("non default", "kurtis", "parameter for non default validator",
    nonDefaultValidator);

  RCP<ParameterList> readInPL = writeThenReadPL(myList);

  RCP<const StringValidator> readinNonDefault =
    rcp_dynamic_cast<const StringValidator>(
      readInPL->getEntry(nonDefaultParameterName).validator(), true);
  TEST_COMPARE_ARRAYS(*(readinNonDefault->validStringValues()),
    *(nonDefaultValidator->validStringValues()));
}
コード例 #3
0
    static void
    checkSendAcrossNetwork( Teuchos::RCP<Teuchos::Comm<int> const> const &comm,
                            View1 const &ranks, View2 const &v_exp,
                            View2 const &v_ref, bool &success,
                            Teuchos::FancyOStream &out )
    {
        Tpetra::Distributor distributor( comm );
        distributor.createFromSends( toArray( ranks ) );

        // NOTE here we assume that the reference solution is sized properly
        auto v_imp =
            Kokkos::create_mirror( typename View2::memory_space(), v_ref );

        DataTransferKit::Details::DistributedSearchTreeImpl<
            DeviceType>::sendAcrossNetwork( distributor, v_exp, v_imp );

        // FIXME not sure why I need that guy but I do get a bus error when it
        // is not here...
        Kokkos::fence();

        TEST_COMPARE_ARRAYS( toArray( v_imp ), toArray( v_ref ) );
    }
コード例 #4
0
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL(Teuchos_Validator, StringToIntegralConverterTest, T)
{
  std::string defaultStringToIntegralParameterName = "defaultsti";
  std::string stringToIntegralParameterName = "sti";
  ParameterList myList;
  RCP<StringToIntegralParameterEntryValidator< T > > defaultStiValidator = rcp(
    new StringToIntegralParameterEntryValidator< T >(
      tuple<std::string>("value1", "value2", "value3"), stringToIntegralParameterName));
  RCP<StringToIntegralParameterEntryValidator< T > > stiValidator = rcp(
    new StringToIntegralParameterEntryValidator< T >(
      tuple<std::string>("value3", "value4", "value5"), 
      tuple<std::string>("the third value", "the fourth value", "the fifth value"),
      tuple< T >(3,4,5),
      stringToIntegralParameterName));
  myList.set(defaultStringToIntegralParameterName,
    "value1", "parameter with default sti validator", defaultStiValidator);
  myList.set(stringToIntegralParameterName, "value3", "parameter with sti validator",
    stiValidator);

  RCP<ParameterList> readInPL = writeThenReadPL(myList);


  RCP<const StringToIntegralParameterEntryValidator< T > > 
  readInDefaultStiValidator =
    rcp_dynamic_cast<const StringToIntegralParameterEntryValidator< T > >(
      readInPL->getEntry(
        defaultStringToIntegralParameterName).validator(), true);
  RCP<const StringToIntegralParameterEntryValidator< T > > 
  readInStiValidator =
    rcp_dynamic_cast<const StringToIntegralParameterEntryValidator< T > >(
      readInPL->getEntry(
        stringToIntegralParameterName).validator(), true);

  Array<std::string> readInDefaultValidStrings =
    *(readInDefaultStiValidator->validStringValues());
  Array<std::string> defaultValidStrings =
    *(defaultStiValidator->validStringValues());
  TEST_COMPARE_ARRAYS(readInDefaultValidStrings, defaultValidStrings);

  TEST_ASSERT(readInDefaultStiValidator->getStringDocs().is_null());
  TEST_EQUALITY( readInDefaultStiValidator->getDefaultParameterName(),
    defaultStiValidator->getDefaultParameterName());
  for(int i=0; i<defaultValidStrings.size(); ++i){
    TEST_EQUALITY(defaultStiValidator->getIntegralValue(defaultValidStrings[i]),
      readInDefaultStiValidator->getIntegralValue(defaultValidStrings[i]));
  }

  Array<std::string> readInValidStrings = *(readInStiValidator->validStringValues());
  Array<std::string> validStrings = *(stiValidator->validStringValues());
  TEST_COMPARE_ARRAYS(readInValidStrings, validStrings);

  TEST_COMPARE_ARRAYS(*(readInStiValidator->getStringDocs()),
    *(stiValidator->getStringDocs()));
  TEST_EQUALITY( readInStiValidator->getDefaultParameterName(),
    stiValidator->getDefaultParameterName());
  for(int i=0; i<validStrings.size(); ++i){
    TEST_EQUALITY(stiValidator->getIntegralValue(validStrings[i]),
      readInStiValidator->getIntegralValue(validStrings[i]));
  }

}
コード例 #5
0
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( MeshGenerator, structured, DeviceType )
{
    MPI_Comm comm = MPI_COMM_WORLD;
    Kokkos::View<DTK_CellTopology *, DeviceType> cell_topologies_view;
    Kokkos::View<unsigned int *, DeviceType> cells;
    Kokkos::View<double **, DeviceType> coordinates;

    // 2D test
    std::string filename = "structured_2d.txt";
    std::vector<std::vector<DataTransferKit::Coordinate>> coordinates_ref;
    std::vector<unsigned int> cells_ref;
    std::tie( coordinates_ref, cells_ref ) = readInputFile( filename );
    // Move mesh according to the rank
    int comm_rank;
    MPI_Comm_rank( comm, &comm_rank );
    std::vector<unsigned int> n_subdivisions = {{4, 3}};
    double offset = n_subdivisions[1] * comm_rank;
    for ( auto &coord : coordinates_ref )
        coord[1] += offset;

    std::tie( cell_topologies_view, cells, coordinates ) =
        buildStructuredMesh<DeviceType>( comm, n_subdivisions );

    // Check view size
    unsigned int n_vertices = coordinates_ref.size();
    unsigned int n_cells = 1;
    for ( auto n_sub : n_subdivisions )
        n_cells *= n_sub;
    TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells );
    TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() );
    TEST_EQUALITY( coordinates.extent( 0 ), n_vertices );

    // Check topology
    auto cell_topologies_view_host =
        Kokkos::create_mirror_view( cell_topologies_view );
    Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view );
    for ( unsigned int i = 0; i < n_cells; ++i )
        TEST_EQUALITY( cell_topologies_view_host( i ), DTK_QUAD_4 );

    // Check cells
    auto cells_host = Kokkos::create_mirror_view( cells );
    Kokkos::deep_copy( cells_host, cells );
    TEST_COMPARE_ARRAYS( cells_host, cells_ref );

    // Check coordinates
    unsigned int dim = 2;
    auto coordinates_host = Kokkos::create_mirror_view( coordinates );
    Kokkos::deep_copy( coordinates_host, coordinates );
    for ( unsigned int i = 0; i < n_vertices; ++i )
        for ( unsigned int j = 0; j < dim; ++j )
            TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] );

    // 3D test
    filename = "structured_3d.txt";
    std::tie( coordinates_ref, cells_ref ) = readInputFile( filename );
    // Move mesh according to the rank
    n_subdivisions = {{2, 3, 4}};
    offset = n_subdivisions[2] * comm_rank;
    for ( auto &coord : coordinates_ref )
        coord[2] += offset;

    std::tie( cell_topologies_view, cells, coordinates ) =
        buildStructuredMesh<DeviceType>( comm, n_subdivisions );

    n_vertices = coordinates_ref.size();
    n_cells = 1;
    for ( auto n_sub : n_subdivisions )
        n_cells *= n_sub;

    TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells );
    TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() );
    TEST_EQUALITY( coordinates.extent( 0 ), n_vertices );

    // Check topology
    cell_topologies_view_host =
        Kokkos::create_mirror_view( cell_topologies_view );
    Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view );
    for ( unsigned int i = 0; i < n_cells; ++i )
        TEST_EQUALITY( cell_topologies_view_host( i ), DTK_HEX_8 );

    // Check cells
    cells_host = Kokkos::create_mirror_view( cells );
    Kokkos::deep_copy( cells_host, cells );
    TEST_COMPARE_ARRAYS( cells_host, cells_ref );

    // Check coordinates
    dim = 3;
    coordinates_host = Kokkos::create_mirror_view( coordinates );
    Kokkos::deep_copy( coordinates_host, coordinates );
    for ( unsigned int i = 0; i < n_vertices; ++i )
        for ( unsigned int j = 0; j < dim; ++j )
            TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] );
}
コード例 #6
0
TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( MeshGenerator, mixed, DeviceType )
{
    MPI_Comm comm = MPI_COMM_WORLD;

    Kokkos::View<DTK_CellTopology *, DeviceType> cell_topologies_view;
    Kokkos::View<unsigned int *, DeviceType> cells;
    Kokkos::View<double **, DeviceType> coordinates;

    // 2D test
    std::string filename = "mixed_2d.txt";
    std::vector<std::vector<DataTransferKit::Coordinate>> coordinates_ref;
    std::vector<unsigned int> cells_ref;
    std::tie( coordinates_ref, cells_ref ) = readInputFile( filename );
    unsigned int dim = 2;
    // Move mesh according to the rank
    int comm_rank;
    MPI_Comm_rank( comm, &comm_rank );
    double offset = 3. * comm_rank;
    for ( auto &coord : coordinates_ref )
        coord[0] += offset;

    std::tie( cell_topologies_view, cells, coordinates ) =
        buildMixedMesh<DeviceType>( comm, dim );

    // Check view size
    unsigned int n_vertices = coordinates_ref.size();
    unsigned int n_cells = 6;
    TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells );
    TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() );
    TEST_EQUALITY( coordinates.extent( 0 ), n_vertices );

    // Check topology
    auto cell_topologies_view_host =
        Kokkos::create_mirror_view( cell_topologies_view );
    Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view );
    std::vector<DTK_CellTopology> cell_topology_ref = {
        {DTK_QUAD_4, DTK_TRI_3, DTK_QUAD_4, DTK_QUAD_4, DTK_TRI_3, DTK_QUAD_4}};
    for ( unsigned int i = 0; i < n_cells; ++i )
        TEST_EQUALITY( cell_topologies_view_host( i ), cell_topology_ref[i] );

    // Check cells
    auto cells_host = Kokkos::create_mirror_view( cells );
    Kokkos::deep_copy( cells_host, cells );
    TEST_COMPARE_ARRAYS( cells_host, cells_ref );

    // Check coordinates
    auto coordinates_host = Kokkos::create_mirror_view( coordinates );
    Kokkos::deep_copy( coordinates_host, coordinates );
    for ( unsigned int i = 0; i < n_vertices; ++i )
        for ( unsigned int j = 0; j < dim; ++j )
            TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] );

    // 3D test
    filename = "mixed_3d.txt";
    std::tie( coordinates_ref, cells_ref ) = readInputFile( filename );
    dim = 3;
    // Move mesh according to the rank
    for ( auto &coord : coordinates_ref )
        coord[0] += offset;

    std::tie( cell_topologies_view, cells, coordinates ) =
        buildMixedMesh<DeviceType>( comm, dim );

    // Check view size
    n_vertices = coordinates_ref.size();
    TEST_EQUALITY( cell_topologies_view.extent( 0 ), n_cells );
    TEST_EQUALITY( cells.extent( 0 ), cells_ref.size() );
    TEST_EQUALITY( coordinates.extent( 0 ), n_vertices );

    // Check topology
    Kokkos::deep_copy( cell_topologies_view_host, cell_topologies_view );
    cell_topology_ref = {
        {DTK_HEX_8, DTK_TET_4, DTK_HEX_8, DTK_HEX_8, DTK_TET_4, DTK_HEX_8}};
    for ( unsigned int i = 0; i < n_cells; ++i )
        TEST_EQUALITY( cell_topologies_view_host( i ), cell_topology_ref[i] );

    // Check cells
    cells_host = Kokkos::create_mirror_view( cells );
    Kokkos::deep_copy( cells_host, cells );
    TEST_COMPARE_ARRAYS( cells_host, cells_ref );

    // Check coordinates
    coordinates_host = Kokkos::create_mirror_view( coordinates );
    Kokkos::deep_copy( coordinates_host, coordinates );
    for ( unsigned int i = 0; i < n_vertices; ++i )
        for ( unsigned int j = 0; j < dim; ++j )
            TEST_EQUALITY( coordinates_host( i, j ), coordinates_ref[i][j] );
}