DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_PointCloudOperatorFactory.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_PointCloudOperatorFactory.hpp"
42 #include "DTK_BuhmannBasis.hpp"
43 #include "DTK_DBC.hpp"
47 #include "DTK_WendlandBasis.hpp"
48 #include "DTK_WuBasis.hpp"
49 
50 namespace DataTransferKit
51 {
52 //--------------------------------------------------------------------------//
53 // Constructor
55 {
56  d_name_map["Spline Interpolation"] = SPLINE_INTERPOLATION;
57  d_name_map["Moving Least Square Reconstruction"] = MOVING_LEAST_SQUARE;
58  d_name_map["Node To Node"] = NODE_TO_NODE;
59 
60  d_basis_map["Wendland"] = WENDLAND;
61  d_basis_map["Wu"] = WU;
62  d_basis_map["Buhmann"] = BUHMANN;
63 }
64 
65 //---------------------------------------------------------------------------//
66 // Creation method.
67 Teuchos::RCP<MapOperator> PointCloudOperatorFactory::create(
68  const Teuchos::RCP<const TpetraMap> &domain_map,
69  const Teuchos::RCP<const TpetraMap> &range_map,
70  const Teuchos::ParameterList &parameters )
71 {
72  // Get the name of the map to build.
73  std::string map_name = parameters.get<std::string>( "Map Type" );
74  DTK_REQUIRE( d_name_map.count( map_name ) );
75  int map_id = d_name_map.find( map_name )->second;
76 
77  // Get the spatial dimension.
78  int space_dim = parameters.get<int>( "Spatial Dimension" );
79 
80  // Get the basis type.
81  std::string basis_name = "invalid";
82  int basis_id = -1;
83  if ( parameters.isParameter( "Basis Type" ) )
84  {
85  basis_name = parameters.get<std::string>( "Basis Type" );
86  DTK_REQUIRE( d_basis_map.count( basis_name ) );
87  basis_id = d_basis_map.find( basis_name )->second;
88  }
89 
90  // Get the basis order.
91  int basis_order = -1;
92  if ( parameters.isParameter( "Basis Order" ) )
93  {
94  basis_order = parameters.get<int>( "Basis Order" );
95  }
96 
97  // Build the map.
98  Teuchos::RCP<MapOperator> map;
99  switch ( map_id )
100  {
101  // Spline Interpolation.
102  case NODE_TO_NODE:
103  switch ( space_dim )
104  {
105  case 1:
106  map = Teuchos::rcp( new NodeToNodeOperator<1>(
107  domain_map, range_map, parameters ) );
108  break;
109  case 2:
110  map = Teuchos::rcp( new NodeToNodeOperator<2>(
111  domain_map, range_map, parameters ) );
112  break;
113  case 3:
114  map = Teuchos::rcp( new NodeToNodeOperator<3>(
115  domain_map, range_map, parameters ) );
116  break;
117  }
118  break;
119 
120  // Spline Interpolation.
121  case SPLINE_INTERPOLATION:
122  switch ( space_dim )
123  {
124  case 1:
125  switch ( basis_id )
126  {
127  case WENDLAND:
128  switch ( basis_order )
129  {
130  case 0:
131  map = Teuchos::rcp(
133  domain_map, range_map, parameters ) );
134  break;
135  case 2:
136  map = Teuchos::rcp(
138  domain_map, range_map, parameters ) );
139  break;
140  case 4:
141  map = Teuchos::rcp(
143  domain_map, range_map, parameters ) );
144  break;
145  case 6:
146  map = Teuchos::rcp(
148  domain_map, range_map, parameters ) );
149  break;
150  }
151  break;
152  case WU:
153  switch ( basis_order )
154  {
155  case 2:
156  map = Teuchos::rcp(
158  domain_map, range_map, parameters ) );
159  break;
160  case 4:
161  map = Teuchos::rcp(
163  domain_map, range_map, parameters ) );
164  break;
165  }
166  break;
167  case BUHMANN:
168  switch ( basis_order )
169  {
170  case 3:
171  map = Teuchos::rcp(
173  domain_map, range_map, parameters ) );
174  break;
175  }
176  break;
177  }
178  break;
179 
180  case 2:
181  switch ( basis_id )
182  {
183  case WENDLAND:
184  switch ( basis_order )
185  {
186  case 0:
187  map = Teuchos::rcp(
189  domain_map, range_map, parameters ) );
190  break;
191  case 2:
192  map = Teuchos::rcp(
194  domain_map, range_map, parameters ) );
195  break;
196  case 4:
197  map = Teuchos::rcp(
199  domain_map, range_map, parameters ) );
200  break;
201  case 6:
202  map = Teuchos::rcp(
204  domain_map, range_map, parameters ) );
205  break;
206  }
207  break;
208  case WU:
209  switch ( basis_order )
210  {
211  case 2:
212  map = Teuchos::rcp(
214  domain_map, range_map, parameters ) );
215  break;
216  case 4:
217  map = Teuchos::rcp(
219  domain_map, range_map, parameters ) );
220  break;
221  }
222  break;
223  case BUHMANN:
224  switch ( basis_order )
225  {
226  case 3:
227  map = Teuchos::rcp(
229  domain_map, range_map, parameters ) );
230  break;
231  }
232  break;
233  }
234  break;
235 
236  case 3:
237  switch ( basis_id )
238  {
239  case WENDLAND:
240  switch ( basis_order )
241  {
242  case 0:
243  map = Teuchos::rcp(
245  domain_map, range_map, parameters ) );
246  break;
247  case 2:
248  map = Teuchos::rcp(
250  domain_map, range_map, parameters ) );
251  break;
252  case 4:
253  map = Teuchos::rcp(
255  domain_map, range_map, parameters ) );
256  break;
257  case 6:
258  map = Teuchos::rcp(
260  domain_map, range_map, parameters ) );
261  break;
262  }
263  break;
264  case WU:
265  switch ( basis_order )
266  {
267  case 2:
268  map = Teuchos::rcp(
270  domain_map, range_map, parameters ) );
271  break;
272  case 4:
273  map = Teuchos::rcp(
275  domain_map, range_map, parameters ) );
276  break;
277  }
278  break;
279  case BUHMANN:
280  switch ( basis_order )
281  {
282  case 3:
283  map = Teuchos::rcp(
285  domain_map, range_map, parameters ) );
286  break;
287  }
288  break;
289  }
290  break;
291  }
292  break;
293 
294  // Moving least square reconstruction.
295  case MOVING_LEAST_SQUARE:
296  switch ( space_dim )
297  {
298  case 1:
299  switch ( basis_id )
300  {
301  case WENDLAND:
302  switch ( basis_order )
303  {
304  case 0:
305  map = Teuchos::rcp(
307  WendlandBasis<0>, 1>( domain_map, range_map,
308  parameters ) );
309  break;
310  case 2:
311  map = Teuchos::rcp(
313  WendlandBasis<2>, 1>( domain_map, range_map,
314  parameters ) );
315  break;
316  case 4:
317  map = Teuchos::rcp(
319  WendlandBasis<4>, 1>( domain_map, range_map,
320  parameters ) );
321  break;
322  case 6:
323  map = Teuchos::rcp(
325  WendlandBasis<6>, 1>( domain_map, range_map,
326  parameters ) );
327  break;
328  }
329  break;
330  case WU:
331  switch ( basis_order )
332  {
333  case 2:
334  map = Teuchos::rcp(
336  1>(
337  domain_map, range_map, parameters ) );
338  break;
339  case 4:
340  map = Teuchos::rcp(
342  1>(
343  domain_map, range_map, parameters ) );
344  break;
345  }
346  break;
347  case BUHMANN:
348  switch ( basis_order )
349  {
350  case 3:
351  map = Teuchos::rcp(
353  BuhmannBasis<3>, 1>( domain_map, range_map,
354  parameters ) );
355  break;
356  }
357  break;
358  }
359  break;
360 
361  case 2:
362  switch ( basis_id )
363  {
364  case WENDLAND:
365  switch ( basis_order )
366  {
367  case 0:
368  map = Teuchos::rcp(
370  WendlandBasis<0>, 2>( domain_map, range_map,
371  parameters ) );
372  break;
373  case 2:
374  map = Teuchos::rcp(
376  WendlandBasis<2>, 2>( domain_map, range_map,
377  parameters ) );
378  break;
379  case 4:
380  map = Teuchos::rcp(
382  WendlandBasis<4>, 2>( domain_map, range_map,
383  parameters ) );
384  break;
385  case 6:
386  map = Teuchos::rcp(
388  WendlandBasis<6>, 2>( domain_map, range_map,
389  parameters ) );
390  break;
391  }
392  break;
393  case WU:
394  switch ( basis_order )
395  {
396  case 2:
397  map = Teuchos::rcp(
399  2>(
400  domain_map, range_map, parameters ) );
401  break;
402  case 4:
403  map = Teuchos::rcp(
405  2>(
406  domain_map, range_map, parameters ) );
407  break;
408  }
409  break;
410  case BUHMANN:
411  switch ( basis_order )
412  {
413  case 3:
414  map = Teuchos::rcp(
416  BuhmannBasis<3>, 2>( domain_map, range_map,
417  parameters ) );
418  break;
419  }
420  break;
421  }
422  break;
423 
424  case 3:
425  switch ( basis_id )
426  {
427  case WENDLAND:
428  switch ( basis_order )
429  {
430  case 0:
431  map = Teuchos::rcp(
433  WendlandBasis<0>, 3>( domain_map, range_map,
434  parameters ) );
435  break;
436  case 2:
437  map = Teuchos::rcp(
439  WendlandBasis<2>, 3>( domain_map, range_map,
440  parameters ) );
441  break;
442  case 4:
443  map = Teuchos::rcp(
445  WendlandBasis<4>, 3>( domain_map, range_map,
446  parameters ) );
447  break;
448  case 6:
449  map = Teuchos::rcp(
451  WendlandBasis<6>, 3>( domain_map, range_map,
452  parameters ) );
453  break;
454  }
455  break;
456  case WU:
457  switch ( basis_order )
458  {
459  case 2:
460  map = Teuchos::rcp(
462  3>(
463  domain_map, range_map, parameters ) );
464  break;
465  case 4:
466  map = Teuchos::rcp(
468  3>(
469  domain_map, range_map, parameters ) );
470  break;
471  }
472  break;
473  case BUHMANN:
474  switch ( basis_order )
475  {
476  case 3:
477  map = Teuchos::rcp(
479  BuhmannBasis<3>, 3>( domain_map, range_map,
480  parameters ) );
481  break;
482  }
483  break;
484  }
485  break;
486  }
487  break;
488 
489  default:
490  bool map_type_is_valid = false;
491  DTK_INSIST( map_type_is_valid );
492  break;
493  }
494 
495  DTK_ENSURE( Teuchos::nonnull( map ) );
496  return map;
497 }
498 
499 //---------------------------------------------------------------------------//
500 
501 } // end namespace DataTransferKit
502 
503 //---------------------------------------------------------------------------//
504 // end DTK_MapOperator.cpp
505 //---------------------------------------------------------------------------//
Wendland compactly supported radial basis function.
Parallel moving least square interpolator.
Parallel moving least square interpolator MapOperator implementation.
Buhmann compactly supported radial basis function.
Parallel node-to-node transfer.
Assertions and Design-by-Contract for error handling.
Wendland compactly supported radial basis function.
Parallel spline interpolator.
Wu compactly supported radial basis function.
Teuchos::RCP< MapOperator > create(const Teuchos::RCP< const TpetraMap > &domain_map, const Teuchos::RCP< const TpetraMap > &range_map, const Teuchos::ParameterList &parameters)
Creation method.
Buhmann compactly supported radial basis function.
DTK_BasicEntitySet.cpp.
Wu compactly supported radial basis function.
Definition: DTK_WuBasis.hpp:58
Parallel moving least square interpolator MapOperator implementation.