7 #ifndef PORTAGE_INTERPOLATE_INTERPOLATE_1ST_ORDER_H_ 8 #define PORTAGE_INTERPOLATE_INTERPOLATE_1ST_ORDER_H_ 24 #include "wonton/support/CoordinateSystem.h" 27 #include "tangram/driver/driver.h" 28 #include "tangram/driver/CellMatPoly.h" 29 #include "tangram/support/MatPoly.h" 90 typename SourceMeshType,
91 typename TargetMeshType,
92 typename SourceStateType,
93 typename TargetStateType,
95 template<
class,
int,
class,
class>
96 class InterfaceReconstructorType = DummyInterfaceReconstructor,
97 class Matpoly_Splitter = void,
98 class Matpoly_Clipper = void,
99 class CoordSys = Wonton::DefaultCoordSys
104 using InterfaceReconstructor =
105 Tangram::Driver<InterfaceReconstructorType, D, SourceMeshType,
106 Matpoly_Splitter, Matpoly_Clipper>;
114 TargetMeshType
const & target_mesh,
115 SourceStateType
const & source_state,
117 std::shared_ptr<InterfaceReconstructor> ir) :
118 source_mesh_(source_mesh),
119 target_mesh_(target_mesh),
120 source_state_(source_state),
121 interp_var_name_(
"VariableNameNotSet"),
122 source_vals_(
nullptr),
124 interface_reconstructor_(ir) {}
138 TargetMeshType
const & target_mesh,
139 SourceStateType
const & source_state,
141 source_mesh_(source_mesh),
142 target_mesh_(target_mesh),
143 source_state_(source_state),
144 interp_var_name_(
"VariableNameNotSet"),
145 source_vals_(nullptr),
146 num_tols_(num_tols) {}
175 interp_var_name_ = interp_var_name;
176 field_type_ = source_state_.field_type(Entity_kind::CELL, interp_var_name);
177 if (field_type_ == Field_type::MESH_FIELD)
178 source_state_.mesh_get_data(Entity_kind::CELL, interp_var_name,
181 source_state_.mat_get_celldata(interp_var_name, matid_, &source_vals_);
201 std::vector<Weights_t>
const & sources_and_weights)
const {
202 std::cerr <<
"Interpolation operator not implemented for this entity type" 210 SourceMeshType
const & source_mesh_;
211 TargetMeshType
const & target_mesh_;
212 SourceStateType
const & source_state_;
213 std::string interp_var_name_;
214 T
const * source_vals_;
216 Field_type field_type_ = Field_type::UNKNOWN_TYPE_FIELD;
219 std::shared_ptr<InterfaceReconstructor> interface_reconstructor_;
231 typename SourceMeshType,
232 typename TargetMeshType,
233 typename SourceStateType,
234 typename TargetStateType,
236 template<
class,
int,
class,
class>
class InterfaceReconstructorType,
237 class Matpoly_Splitter,
238 class Matpoly_Clipper,
241 D, Entity_kind::CELL,
242 SourceMeshType, TargetMeshType,
243 SourceStateType, TargetStateType,
245 InterfaceReconstructorType,
246 Matpoly_Splitter, Matpoly_Clipper, CoordSys> {
250 SourceMeshType, SourceStateType,
251 TargetMeshType, TargetStateType
255 using InterfaceReconstructor =
256 Tangram::Driver<InterfaceReconstructorType, D, SourceMeshType,
257 Matpoly_Splitter, Matpoly_Clipper>;
264 TargetMeshType
const & target_mesh,
265 SourceStateType
const & source_state,
267 std::shared_ptr<InterfaceReconstructor> ir,
268 const Parts*
const parts =
nullptr) :
269 source_mesh_(source_mesh),
270 target_mesh_(target_mesh),
271 source_state_(source_state),
272 interp_var_name_(
"VariableNameNotSet"),
273 source_vals_(
nullptr),
275 interface_reconstructor_(ir),
287 TargetMeshType
const & target_mesh,
288 SourceStateType
const & source_state,
290 const Parts*
const parts =
nullptr) :
291 source_mesh_(source_mesh),
292 target_mesh_(target_mesh),
293 source_state_(source_state),
294 interp_var_name_(
"VariableNameNotSet"),
295 source_vals_(nullptr),
328 interp_var_name_ = interp_var_name;
329 field_type_ = source_state_.field_type(Entity_kind::CELL, interp_var_name);
330 if (field_type_ == Field_type::MESH_FIELD)
331 source_state_.mesh_get_data(Entity_kind::CELL, interp_var_name,
334 source_state_.mat_get_celldata(interp_var_name, matid_, &source_vals_);
355 std::vector<Weights_t>
const & sources_and_weights)
const 357 int nsrccells = sources_and_weights.size();
358 if (!nsrccells)
return T(0.0);
367 if (field_type_ == Field_type::MESH_FIELD) {
368 for (
auto const& wt : sources_and_weights) {
369 int srccell = wt.entityID;
370 std::vector<double> pair_weights = wt.weights;
371 if (fabs(pair_weights[0]) < num_tols_.min_absolute_volume)
373 val += source_vals_[srccell] * pair_weights[0];
374 wtsum0 += pair_weights[0];
377 }
else if (field_type_ == Field_type::MULTIMATERIAL_FIELD) {
378 for (
auto const& wt : sources_and_weights) {
379 int srccell = wt.entityID;
380 std::vector<double> pair_weights = wt.weights;
381 if (fabs(pair_weights[0]) < num_tols_.min_absolute_volume)
383 int matcell = source_state_.cell_index_in_material(srccell, matid_);
384 val += source_vals_[matcell] * pair_weights[0];
385 wtsum0 += pair_weights[0];
410 SourceMeshType
const & source_mesh_;
411 TargetMeshType
const & target_mesh_;
412 SourceStateType
const & source_state_;
413 std::string interp_var_name_;
414 T
const * source_vals_;
416 Field_type field_type_ = Field_type::UNKNOWN_TYPE_FIELD;
419 std::shared_ptr<InterfaceReconstructor> interface_reconstructor_;
434 typename SourceMeshType,
435 typename TargetMeshType,
436 typename SourceStateType,
437 typename TargetStateType,
439 template<
class,
int,
class,
class>
class InterfaceReconstructorType,
440 class Matpoly_Splitter,
441 class Matpoly_Clipper,
444 D, Entity_kind::NODE,
445 SourceMeshType, TargetMeshType,
446 SourceStateType, TargetStateType,
448 InterfaceReconstructorType,
449 Matpoly_Splitter, Matpoly_Clipper, CoordSys> {
453 using InterfaceReconstructor =
454 Tangram::Driver<InterfaceReconstructorType, D, SourceMeshType,
455 Matpoly_Splitter, Matpoly_Clipper>;
463 TargetMeshType
const & target_mesh,
464 SourceStateType
const & source_state,
466 std::shared_ptr<InterfaceReconstructor> ir) :
467 source_mesh_(source_mesh),
468 target_mesh_(target_mesh),
469 source_state_(source_state),
470 interp_var_name_(
"VariableNameNotSet"),
471 source_vals_(
nullptr),
473 interface_reconstructor_(ir) {}
485 TargetMeshType
const & target_mesh,
486 SourceStateType
const & source_state,
488 source_mesh_(source_mesh),
489 target_mesh_(target_mesh),
490 source_state_(source_state),
491 interp_var_name_(
"VariableNameNotSet"),
492 source_vals_(nullptr),
493 num_tols_(num_tols) {}
522 interp_var_name_ = interp_var_name;
523 field_type_ = source_state_.field_type(Entity_kind::NODE, interp_var_name);
524 if (field_type_ == Field_type::MESH_FIELD)
525 source_state_.mesh_get_data(Entity_kind::NODE, interp_var_name,
528 source_state_.mat_get_celldata(interp_var_name, matid_, &source_vals_);
529 std::cerr <<
"Cannot remap NODE-centered multi-material data" <<
"\n";
551 std::vector<Weights_t>
const & sources_and_weights)
const 553 if (field_type_ != Field_type::MESH_FIELD)
return T(0.0);
555 int nsrcdualcells = sources_and_weights.size();
556 if (!nsrcdualcells)
return T(0.0);
565 for (
auto const& wt : sources_and_weights) {
566 int srcnode = wt.entityID;
567 std::vector<double> pair_weights = wt.weights;
568 if (fabs(pair_weights[0]) < num_tols_.min_absolute_volume)
570 val += source_vals_[srcnode] * pair_weights[0];
571 wtsum0 += pair_weights[0];
595 SourceMeshType
const & source_mesh_;
596 TargetMeshType
const & target_mesh_;
597 SourceStateType
const & source_state_;
598 std::string interp_var_name_;
599 T
const * source_vals_;
601 Field_type field_type_ = Field_type::UNKNOWN_TYPE_FIELD;
604 std::shared_ptr<InterfaceReconstructor> interface_reconstructor_;
613 #endif // PORTAGE_INTERPOLATE_INTERPOLATE_1ST_ORDER_H_ void set_material(int m)
Set the material we are operating on.
Definition: interpolate_1st_order.h:160
T operator()(int const targetEntityId, std::vector< Weights_t > const &sources_and_weights) const
Functor to do the actual interpolation.
Definition: interpolate_1st_order.h:200
std::vector< T > vector
Definition: portage.h:238
Intersection and other tolerances to handle tiny values.
Definition: portage.h:152
~Interpolate_1stOrder()=default
Copy constructor (disabled)
Portage::Interpolate_1stOrder< D, Entity_kind::CELL, SourceMeshType, TargetMeshType, SourceStateType, TargetStateType, T, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys >::set_material void set_material(int m)
Set the material we are operating on.
Definition: interpolate_1st_order.h:312
Manages source and target sub-meshes for part-by-part remap.
Interpolate_1stOrder(SourceMeshType const &source_mesh, TargetMeshType const &target_mesh, SourceStateType const &source_state, NumericTolerances_t num_tols)
Constructor without interface reconstructor.
Definition: interpolate_1st_order.h:137
Portage::Interpolate_1stOrder< D, Entity_kind::NODE, SourceMeshType, TargetMeshType, SourceStateType, TargetStateType, T, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys >::set_material void set_material(int m)
Set the material we are operating on.
Definition: interpolate_1st_order.h:507
Manages source and target sub-meshes for part-by-part remap. It detects boundaries mismatch and provi...
Definition: parts.h:234
void set_interpolation_variable(std::string const &interp_var_name, Portage::vector< Wonton::Vector< D >> *gradients=nullptr)
Set the variable name to be interpolated.
Definition: interpolate_1st_order.h:173
static constexpr int order
Definition: interpolate_1st_order.h:207
Definition: coredriver.h:42
Portage::Interpolate_1stOrder< D, Entity_kind::CELL, SourceMeshType, TargetMeshType, SourceStateType, TargetStateType, T, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys >::Interpolate_1stOrder Interpolate_1stOrder(SourceMeshType const &source_mesh, TargetMeshType const &target_mesh, SourceStateType const &source_state, NumericTolerances_t num_tols, const Parts *const parts=nullptr)
Constructor.
Definition: interpolate_1st_order.h:286
Interpolate_1stOrder does a 1st order interpolation of scalars.
Definition: interpolate_1st_order.h:101
Portage::Interpolate_1stOrder< D, Entity_kind::NODE, SourceMeshType, TargetMeshType, SourceStateType, TargetStateType, T, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys >::Interpolate_1stOrder Interpolate_1stOrder(SourceMeshType const &source_mesh, TargetMeshType const &target_mesh, SourceStateType const &source_state, NumericTolerances_t num_tols)
Constructor without interface reconstructor.
Definition: interpolate_1st_order.h:484
Portage::Interpolate_1stOrder< D, Entity_kind::NODE, SourceMeshType, TargetMeshType, SourceStateType, TargetStateType, T, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys >::set_interpolation_variable void set_interpolation_variable(std::string const &interp_var_name, Portage::vector< Wonton::Vector< D >> *gradients=nullptr)
Set the variable name to be interpolated.
Definition: interpolate_1st_order.h:520
Portage::Interpolate_1stOrder< D, Entity_kind::CELL, SourceMeshType, TargetMeshType, SourceStateType, TargetStateType, T, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys >::set_interpolation_variable void set_interpolation_variable(std::string const &interp_var_name, Portage::vector< Wonton::Vector< D >> *gradients=nullptr)
Set the variable name to be interpolated.
Definition: interpolate_1st_order.h:326