Multiscale Universal Interface  2.0
A Concurrent Framework for Coupling Heterogeneous Solvers
sampler_pseudo_n2_linear.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Multiscale Universal Interface Code Coupling Library *
3 * *
4 * Copyright (C) 2019 Y. H. Tang, S. Kudo, X. Bian, Z. Li, G. E. Karniadakis *
5 * *
6 * This software is jointly licensed under the Apache License, Version 2.0 *
7 * and the GNU General Public License version 3, you may use it according *
8 * to either. *
9 * *
10 * ** Apache License, version 2.0 ** *
11 * *
12 * Licensed under the Apache License, Version 2.0 (the "License"); *
13 * you may not use this file except in compliance with the License. *
14 * You may obtain a copy of the License at *
15 * *
16 * http://www.apache.org/licenses/LICENSE-2.0 *
17 * *
18 * Unless required by applicable law or agreed to in writing, software *
19 * distributed under the License is distributed on an "AS IS" BASIS, *
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
21 * See the License for the specific language governing permissions and *
22 * limitations under the License. *
23 * *
24 * ** GNU General Public License, version 3 ** *
25 * *
26 * This program is free software: you can redistribute it and/or modify *
27 * it under the terms of the GNU General Public License as published by *
28 * the Free Software Foundation, either version 3 of the License, or *
29 * (at your option) any later version. *
30 * *
31 * This program is distributed in the hope that it will be useful, *
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
34 * GNU General Public License for more details. *
35 * *
36 * You should have received a copy of the GNU General Public License *
37 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
38 *****************************************************************************/
39 
48 #ifndef MUI_SAMPLER_PSEUDO_N2_LINEAR_H_
49 #define MUI_SAMPLER_PSEUDO_N2_LINEAR_H_
50 
51 #include "../../config.h"
52 #include "../sampler.h"
53 
54 namespace mui {
55 
56 template<typename CONFIG=default_config, typename O_TP=typename CONFIG::REAL, typename I_TP=O_TP>
58 public:
59  using OTYPE = O_TP;
60  using ITYPE = I_TP;
61  using REAL = typename CONFIG::REAL;
62  using INT = typename CONFIG::INT;
63  using point_type = typename CONFIG::point_type;
64 
66 
67  template<template<typename,typename> class CONTAINER>
68  inline OTYPE filter( point_type focus, const CONTAINER<ITYPE,CONFIG> &data_points ) const {
71  OTYPE value_1st = 0, value_2nd = 0;
72  for( size_t i = 0 ; i < data_points.size() ; i++ ) {
73  REAL dr2 = normsq( focus - data_points[i].first );
74  if ( dr2 < r2min_1st ) {
75  r2min_2nd = r2min_1st;
76  value_2nd = value_1st;
77  r2min_1st = dr2;
78  value_1st = data_points[i].second ;
79  } else if ( dr2 < r2min_2nd ) {
80  r2min_2nd = dr2;
81  value_2nd = data_points[i].second ;
82  }
83  }
84  REAL r1 = std::sqrt( r2min_1st );
85  REAL r2 = std::sqrt( r2min_2nd );
86  return ( value_1st * r2 + value_2nd * r1 ) / ( r1 + r2 );
87  }
88 
89  inline geometry::any_shape<CONFIG> support( point_type focus, REAL domain_mag ) const {
90  return geometry::sphere<CONFIG>( focus, h );
91  }
92 protected:
94 };
95 
96 }
97 
98 #endif /* MUI_SAMPLER_NN_H_ */
Definition: geometry.h:92
Definition: geometry.h:158
Definition: sampler_pseudo_n2_linear.h:57
typename CONFIG::REAL REAL
Definition: sampler_pseudo_n2_linear.h:61
typename CONFIG::INT INT
Definition: sampler_pseudo_n2_linear.h:62
geometry::any_shape< CONFIG > support(point_type focus, REAL domain_mag) const
Definition: sampler_pseudo_n2_linear.h:89
OTYPE filter(point_type focus, const CONTAINER< ITYPE, CONFIG > &data_points) const
Definition: sampler_pseudo_n2_linear.h:68
REAL h
Definition: sampler_pseudo_n2_linear.h:93
I_TP ITYPE
Definition: sampler_pseudo_n2_linear.h:60
O_TP OTYPE
Definition: sampler_pseudo_n2_linear.h:59
typename CONFIG::point_type point_type
Definition: sampler_pseudo_n2_linear.h:63
sampler_pseudo_n2_linear(REAL h_)
Definition: sampler_pseudo_n2_linear.h:65
Definition: comm.h:54
SCALAR max(vexpr< E, SCALAR, D > const &u)
Definition: point.h:350
SCALAR normsq(vexpr< E, SCALAR, D > const &u)
Definition: point.h:380