Skip to content

Commit 0f09569

Browse files
committed
make decay_factor and lambda parameters
1 parent ce86584 commit 0f09569

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

src/pcms/interpolator/interpolation_base.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ Omega_h::Reals getCentroids(Omega_h::Mesh& mesh)
3131

3232
MLSMeshInterpolation::MLSMeshInterpolation(Omega_h::Mesh& source_mesh,
3333
double radius, uint min_req_support,
34-
uint degree, bool adapt_radius)
34+
uint degree, bool adapt_radius,
35+
double lambda, double decay_factor)
3536
: source_mesh_(source_mesh),
3637
target_mesh_(source_mesh),
3738
radius_(radius),
3839
min_req_supports_(min_req_support),
3940
degree_(degree),
40-
adapt_radius_(adapt_radius)
41+
adapt_radius_(adapt_radius),
42+
lambda_(lambda),
43+
decay_factor_(decay_factor)
4144
{
4245
single_mesh_ = true;
4346
target_coords_ = source_mesh_.coords();
@@ -60,13 +63,16 @@ MLSMeshInterpolation::MLSMeshInterpolation(Omega_h::Mesh& source_mesh,
6063
Omega_h::Mesh& target_mesh,
6164
const double radius,
6265
uint min_req_support, uint degree,
63-
const bool adapt_radius)
66+
const bool adapt_radius,
67+
double lambda, double decay_factor)
6468
: source_mesh_(source_mesh),
6569
target_mesh_(target_mesh),
6670
radius_(radius),
6771
min_req_supports_(min_req_support),
6872
degree_(degree),
69-
adapt_radius_(adapt_radius)
73+
adapt_radius_(adapt_radius),
74+
lambda_(lambda),
75+
decay_factor_(decay_factor)
7076
{
7177
OMEGA_H_CHECK_PRINTF(source_mesh_.dim() == 2 && target_mesh_.dim() == 2,
7278
"Only 2D meshes are supported but found %d, %d\n",
@@ -80,7 +86,7 @@ MLSMeshInterpolation::MLSMeshInterpolation(Omega_h::Mesh& source_mesh,
8086
target_field_ =
8187
Omega_h::HostWrite<Omega_h::Real>(target_mesh_.nverts(), "target field");
8288

83-
find_supports(min_req_supports_);
89+
find_supports(min_req_supports_, 3 * min_req_supports_);
8490
}
8591

8692
KOKKOS_INLINE_FUNCTION
@@ -391,8 +397,9 @@ void MLSMeshInterpolation::eval(
391397

392398
// TODO: make the basis function a template or pass it as a parameter
393399
auto target_field_write = mls_interpolation(
394-
Omega_h::Reals(source_field_), source_coords_, target_coords_, supports_, 2,
395-
degree_, pcms::RadialBasisFunction::RBF_GAUSSIAN, 0, 1e-6, 5);
400+
Omega_h::Reals(source_field_), source_coords_, target_coords_, supports_,
401+
source_mesh_.dim(), degree_, pcms::RadialBasisFunction::RBF_GAUSSIAN,
402+
lambda_, 1e-6, decay_factor_);
396403

397404
target_field_ = Omega_h::HostWrite<Omega_h::Real>(target_field_write);
398405
copyHostWrite2ScalarArrayView(target_field_, target_field);

src/pcms/interpolator/interpolation_base.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ class MLSMeshInterpolation final : public InterpolationBase
147147
*/
148148
MLSMeshInterpolation(Omega_h::Mesh& source_mesh, Omega_h::Mesh& target_mesh,
149149
double radius, uint min_req_supports = 10,
150-
uint degree = 3, bool adapt_radius = true);
150+
uint degree = 3, bool adapt_radius = true,
151+
double lambda = 0.0, double decay_factor = 5.0);
151152

152153
/**
153154
* @brief Centroids to Vertices interpolation for a single mesh
@@ -159,7 +160,8 @@ class MLSMeshInterpolation final : public InterpolationBase
159160
*/
160161
MLSMeshInterpolation(Omega_h::Mesh& source_mesh, double radius,
161162
uint min_req_supports = 10, uint degree = 3,
162-
bool adapt_radius = true);
163+
bool adapt_radius = true, double lambda = 0.0,
164+
double decay_factor = 5.0);
163165

164166
size_t getSourceSize() const override;
165167
size_t getTargetSize() const override;
@@ -168,6 +170,8 @@ class MLSMeshInterpolation final : public InterpolationBase
168170

169171
private:
170172
double radius_;
173+
double lambda_;
174+
double decay_factor_;
171175
bool adapt_radius_;
172176
bool single_mesh_ = false;
173177
uint degree_;

test/test_interpolation_class.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ TEST_CASE("Test MLSMeshInterpolation")
131131
pcms::printInfo("\n-------------------- Single Mesh Interpolation Test "
132132
"Started --------------------\n");
133133
pcms::printInfo("Mesh based search...\n");
134-
auto mls_single = MLSMeshInterpolation(source_mesh, 0.12, 15, 3, true);
134+
auto mls_single =
135+
MLSMeshInterpolation(source_mesh, 0.12, 15, 3, true, 0.0, 5.0);
135136

136137
auto source_points_reals = getCentroids(source_mesh);
137138
auto source_points_host =
@@ -157,7 +158,7 @@ TEST_CASE("Test MLSMeshInterpolation")
157158
REQUIRE(source_mesh.dim() == 2);
158159
pcms::printInfo("Point cloud based search...\n");
159160
auto point_mls = MLSPointCloudInterpolation(
160-
source_points_view, target_points_view, 2, 0.12, 15, 3, true);
161+
source_points_view, target_points_view, 2, 0.12, 15, 3, true, 0.0, 5.0);
161162

162163
Omega_h::Write<Omega_h::Real> sinxcosy_centroid(source_mesh.nfaces(),
163164
"sinxcosy_centroid");
@@ -279,8 +280,8 @@ TEST_CASE("Test MLSMeshInterpolation")
279280
// translate_mesh(&target_mesh, Omega_h::Vector<2>{(1.0 - 0.999) / 2.0,
280281
// (1.0 - 0.999) / 2.0});
281282

282-
auto mls_double =
283-
MLSMeshInterpolation(source_mesh, target_mesh, 0.12, 15, 3, true);
283+
auto mls_double = MLSMeshInterpolation(source_mesh, target_mesh, 0.12, 15,
284+
3, true, 0.0, 5.0);
284285

285286
Omega_h::HostWrite<double> source_data_host_write(source_sinxcosy_node);
286287
Omega_h::HostWrite<double> interpolated_data_hwrite(

0 commit comments

Comments
 (0)