<commit_before>/****************************************************************************
 * Copyright (c) 2012-2017 by the DataTransferKit authors                   *
 * All rights reserved.                                                     *
 *                                                                          *
 * This file is part of the DataTransferKit library. DataTransferKit is     *
 * distributed under a BSD 3-clause license. For the licensing terms see    *
 * the LICENSE file in the top-level directory.                             *
 ****************************************************************************/

#ifndef DTK_FINE_SEARCH_DEF_HPP
#define DTK_FINE_SEARCH_DEF_HPP

#include <DTK_DBC.hpp>
#include <DTK_FineSearchFunctor.hpp>
#include <Kokkos_Core.hpp>

namespace DataTransferKit
{
template <typename DeviceType>
void FineSearch<DeviceType>::search(
    Kokkos::View<Coordinate **, DeviceType> reference_points,
    Kokkos::View<bool *, DeviceType> point_in_cell,
    Kokkos::View<Coordinate **, DeviceType> physical_points,
    Kokkos::View<Coordinate ***, DeviceType> cells,
    Kokkos::View<unsigned int *, DeviceType> coarse_search_output_points,
    Kokkos::View<unsigned int *, DeviceType> coarse_search_output_cells,
    shards::CellTopology cell_topo )
{
    // Check the size of the Views
    DTK_REQUIRE( reference_points.extent( 0 ) == point_in_cell.extent( 0 ) );
    DTK_REQUIRE( reference_points.extent( 1 ) == physical_points.extent( 1 ) );
    DTK_REQUIRE( reference_points.extent( 1 ) == cells.extent( 2 ) );
    DTK_REQUIRE( coarse_search_output_cells.extent( 0 ) ==
                 coarse_search_output_points.extent( 0 ) );

    using ExecutionSpace = typename DeviceType::execution_space;
    int const n_ref_pts = reference_points.extent( 0 );

    // Perform the fine search. We hide the template parameters used by
    // Intrepid2, using the CellType template.
    // Note that if the Newton solver does not converge, Intrepid2 will just
    // return the last results and there is no way to know that the coordinates
    // in the reference frames where not found.
    unsigned int const cell_topo_key = cell_topo.getKey();
    if ( cell_topo_key ==
         shards::getCellTopologyData<shards::Hexahedron<8>>()->key )
    {
        Functor::FineSearch<CellType::Hexahedron_8, DeviceType> search_functor(
            reference_points, point_in_cell, physical_points, cells,
            coarse_search_output_points, coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_hex_8" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Hexahedron<27>>()->key )
    {
        Functor::FineSearch<CellType::Hexahedron_27, DeviceType> search_functor(
            reference_points, point_in_cell, physical_points, cells,
            coarse_search_output_points, coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_hex_27" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Pyramid<5>>()->key )
    {
        Functor::FineSearch<CellType::Pyramid_5, DeviceType> search_functor(
            reference_points, point_in_cell, physical_points, cells,
            coarse_search_output_points, coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_pyr_5" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Quadrilateral<4>>()->key )
    {
        Functor::FineSearch<CellType::Quadrilateral_4, DeviceType>
            search_functor( reference_points, point_in_cell, physical_points,
                            cells, coarse_search_output_points,
                            coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_quad_4" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Quadrilateral<8>>()->key )
    {
        Functor::FineSearch<CellType::Quadrilateral_9, DeviceType>
            search_functor( reference_points, point_in_cell, physical_points,
                            cells, coarse_search_output_points,
                            coarse_search_output_cells );
        Kokkos::parallel_for(<commit_msg>Fix a bug: replace Quadrilateral<8> by Quadrilateral<9><commit_after>/****************************************************************************
 * Copyright (c) 2012-2017 by the DataTransferKit authors                   *
 * All rights reserved.                                                     *
 *                                                                          *
 * This file is part of the DataTransferKit library. DataTransferKit is     *
 * distributed under a BSD 3-clause license. For the licensing terms see    *
 * the LICENSE file in the top-level directory.                             *
 ****************************************************************************/

#ifndef DTK_FINE_SEARCH_DEF_HPP
#define DTK_FINE_SEARCH_DEF_HPP

#include <DTK_DBC.hpp>
#include <DTK_FineSearchFunctor.hpp>
#include <Kokkos_Core.hpp>

namespace DataTransferKit
{
template <typename DeviceType>
void FineSearch<DeviceType>::search(
    Kokkos::View<Coordinate **, DeviceType> reference_points,
    Kokkos::View<bool *, DeviceType> point_in_cell,
    Kokkos::View<Coordinate **, DeviceType> physical_points,
    Kokkos::View<Coordinate ***, DeviceType> cells,
    Kokkos::View<unsigned int *, DeviceType> coarse_search_output_points,
    Kokkos::View<unsigned int *, DeviceType> coarse_search_output_cells,
    shards::CellTopology cell_topo )
{
    // Check the size of the Views
    DTK_REQUIRE( reference_points.extent( 0 ) == point_in_cell.extent( 0 ) );
    DTK_REQUIRE( reference_points.extent( 1 ) == physical_points.extent( 1 ) );
    DTK_REQUIRE( reference_points.extent( 1 ) == cells.extent( 2 ) );
    DTK_REQUIRE( coarse_search_output_cells.extent( 0 ) ==
                 coarse_search_output_points.extent( 0 ) );

    using ExecutionSpace = typename DeviceType::execution_space;
    int const n_ref_pts = reference_points.extent( 0 );

    // Perform the fine search. We hide the template parameters used by
    // Intrepid2, using the CellType template.
    // Note that if the Newton solver does not converge, Intrepid2 will just
    // return the last results and there is no way to know that the coordinates
    // in the reference frames where not found.
    unsigned int const cell_topo_key = cell_topo.getKey();
    if ( cell_topo_key ==
         shards::getCellTopologyData<shards::Hexahedron<8>>()->key )
    {
        Functor::FineSearch<CellType::Hexahedron_8, DeviceType> search_functor(
            reference_points, point_in_cell, physical_points, cells,
            coarse_search_output_points, coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_hex_8" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Hexahedron<27>>()->key )
    {
        Functor::FineSearch<CellType::Hexahedron_27, DeviceType> search_functor(
            reference_points, point_in_cell, physical_points, cells,
            coarse_search_output_points, coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_hex_27" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Pyramid<5>>()->key )
    {
        Functor::FineSearch<CellType::Pyramid_5, DeviceType> search_functor(
            reference_points, point_in_cell, physical_points, cells,
            coarse_search_output_points, coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_pyr_5" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Quadrilateral<4>>()->key )
    {
        Functor::FineSearch<CellType::Quadrilateral_4, DeviceType>
            search_functor( reference_points, point_in_cell, physical_points,
                            cells, coarse_search_output_points,
                            coarse_search_output_cells );
        Kokkos::parallel_for(
            REGION_NAME( "compute_pos_in_ref_space_quad_4" ),
            Kokkos::RangePolicy<ExecutionSpace>( 0, n_ref_pts ),
            search_functor );
    }
    else if ( cell_topo_key ==
              shards::getCellTopologyData<shards::Quadrilateral<9>>()->key )
    {
        Functor::FineSearch<CellType::Quadrilateral_9, DeviceType>
            search_functor( reference_points, point_in_cell, physical_points,
                            cells, coarse_search_output_points,
                            coarse_search_output_cells );
        Kokkos::parallel_for(
{'fraction_non_alphanumeric': 0.11891267842149454, 'fraction_numerical': 0.008816120906801008, 'mean_word_length': 2.8625861370085124, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927884', 'n_tokens_mistral': 2901, 'n_tokens_neox': 2763, 'n_words': 525}