DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_MapOperatorFactory.cpp
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #include "DTK_MapOperatorFactory.hpp"
42 #include "DTK_ConsistentInterpolationOperator.hpp"
43 #include "DTK_DBC.hpp"
44 #include "DTK_L2ProjectionOperator.hpp"
45 #include "DTK_PointCloudOperatorFactory.hpp"
46 
47 namespace DataTransferKit
48 {
49 //--------------------------------------------------------------------------//
50 // Constructor
52 {
53  d_name_map["L2 Projection"] = L2_PROJECTION;
54  d_name_map["Consistent Interpolation"] = CONSISTENT_INTERPOLATION;
55  d_name_map["Point Cloud"] = POINT_CLOUD;
56 }
57 
58 //---------------------------------------------------------------------------//
59 // Creation method.
60 Teuchos::RCP<MapOperator>
61 MapOperatorFactory::create( const Teuchos::RCP<const TpetraMap> &domain_map,
62  const Teuchos::RCP<const TpetraMap> &range_map,
63  const Teuchos::ParameterList &parameters )
64 {
65  // Get the name of the map to build.
66  std::string map_name = parameters.get<std::string>( "Map Type" );
67  DTK_REQUIRE( d_name_map.count( map_name ) );
68  int map_id = d_name_map.find( map_name )->second;
69 
70  // Get the parameters for the map.
71  Teuchos::ParameterList map_list = parameters.sublist( map_name );
72 
73  // Initialize subclass factories.
74  PointCloudOperatorFactory pcloud_factory;
75 
76  // Build the map.
77  Teuchos::RCP<MapOperator> map;
78  switch ( map_id )
79  {
80  // L2 Projection.
81  case L2_PROJECTION:
82  map = Teuchos::rcp(
83  new L2ProjectionOperator( domain_map, range_map, parameters ) );
84  break;
85 
86  // Consistent Interpolation.
87  case CONSISTENT_INTERPOLATION:
88  map = Teuchos::rcp( new ConsistentInterpolationOperator(
89  domain_map, range_map, parameters ) );
90  break;
91 
92  // Spline Interpolation
93  case POINT_CLOUD:
94  map = pcloud_factory.create( domain_map, range_map, map_list );
95  break;
96 
97  // Throw on default.
98  default:
99  bool map_type_is_valid = false;
100  DTK_INSIST( map_type_is_valid );
101  break;
102  }
103 
104  DTK_ENSURE( Teuchos::nonnull( map ) );
105  return map;
106 }
107 
108 //---------------------------------------------------------------------------//
109 
110 } // end namespace DataTransferKit
111 
112 //---------------------------------------------------------------------------//
113 // end DTK_MapOperatorFactory.cpp
114 //---------------------------------------------------------------------------//
Assertions and Design-by-Contract for error handling.
Teuchos::RCP< MapOperator > create(const Teuchos::RCP< const TpetraMap > &domain_map, const Teuchos::RCP< const TpetraMap > &range_map, const Teuchos::ParameterList &parameters)
Creation method.
Teuchos::RCP< MapOperator > create(const Teuchos::RCP< const TpetraMap > &domain_map, const Teuchos::RCP< const TpetraMap > &range_map, const Teuchos::ParameterList &parameters)
Creation method.
DTK_BasicEntitySet.cpp.
Factory for DTK point cloud map operators.