7 #ifndef PORTAGE_CORE_DRIVER_H_ 8 #define PORTAGE_CORE_DRIVER_H_ 17 #include <type_traits> 23 #include "tangram/driver/driver.h" 29 #include "wonton/support/Point.h" 30 #include "wonton/support/CoordinateSystem.h" 44 using Wonton::Entity_kind;
47 using Wonton::UNKNOWN_KIND;
48 using Wonton::Entity_type;
49 using Wonton::PARALLEL_OWNED;
57 class SourceMesh,
class SourceState,
58 class TargetMesh,
class TargetState,
59 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
60 class Matpoly_Splitter,
61 class Matpoly_Clipper,
98 class SourceMesh,
class SourceState,
99 class TargetMesh,
class TargetState,
100 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
101 class Matpoly_Splitter,
102 class Matpoly_Clipper,
107 template<Entity_kind ONWHAT>
109 TargetMesh, TargetState,
110 InterfaceReconstructorType,
111 Matpoly_Splitter, Matpoly_Clipper,
119 virtual Entity_kind
onwhat() = 0;
131 template<Entity_kind ONWHAT,
132 template <
int, Entity_kind,
class,
class>
class Search>
135 assert(ONWHAT ==
onwhat());
137 return derived_class_ptr->template search<Search>();
154 template <Entity_kind,
class,
class,
class,
155 template <
class,
int,
class,
class>
class,
158 Portage::
vector<std::vector<Portage::Weights_t>>
160 assert(ONWHAT ==
onwhat());
162 return derived_class_ptr->template intersect_meshes<Intersect>(intersection_candidates);
180 template <Entity_kind,
class,
class,
class,
181 template <
class,
int,
class,
class>
class,
184 std::
vector<Portage::vector<std::vector<Portage::Weights_t>>>
188 return derived_class_ptr->template intersect_materials<Intersect>(intersection_candidates);
200 template<Entity_kind ONWHAT>
202 std::string
const field_name,
208 assert(ONWHAT ==
onwhat());
211 boundary_limiter_type,
212 material_id, source_part);
233 template<
typename T = double,
235 template<int, Entity_kind,
class,
class,
class,
class,
class,
236 template <
class,
int,
class,
class>
class,
237 class,
class,
class>
class Interpolate
242 assert(ONWHAT ==
onwhat());
245 template interpolate_mesh_var<T, Interpolate>(srcvarname, trgvarname,
272 template<
typename T = double,
274 template<int, Entity_kind,
class,
class,
class,
class,
class,
275 template <
class,
int,
class,
class>
class,
276 class,
class,
class>
class Interpolate>
277 typename std::enable_if<ONWHAT == CELL, void>
279 Portage::vector<std::vector<Weights_t>> const& sources_and_weights,
280 const PartPair<D, SourceMesh, SourceState,
281 TargetMesh, TargetState>* parts_pair,
282 Portage::vector<Vector<D>>* gradients = nullptr) {
283 assert(ONWHAT ==
onwhat());
286 template interpolate_mesh_var<T, Interpolate>(srcvarname, trgvarname,
303 template <
typename T = double,
304 template<int, Entity_kind,
class,
class,
class,
class,
class,
305 template <
class,
int,
class,
class>
class,
306 class,
class,
class>
class Interpolate>
308 std::vector<Portage::vector<std::vector<Weights_t>>> const& sources_and_weights_by_mat,
309 std::vector<Portage::vector<Vector<D>>>* gradients = nullptr) {
313 template interpolate_mat_var<T, Interpolate>(srcvarname,
315 sources_and_weights_by_mat,
330 template<Entity_kind ONWHAT>
333 assert(ONWHAT ==
onwhat());
346 template<Entity_kind ONWHAT>
349 assert(ONWHAT ==
onwhat());
362 template<Entity_kind ONWHAT>
365 std::string
const & trg_var_name,
366 double global_lower_bound = -std::numeric_limits<double>::max(),
367 double global_upper_bound = std::numeric_limits<double>::max(),
374 assert(ONWHAT ==
onwhat());
397 template<Entity_kind ONWHAT>
400 const double min_absolute_volume) {
401 assert(ONWHAT ==
onwhat());
403 derived_class_ptr->
set_num_tols(min_absolute_distance, min_absolute_volume);
414 template<Entity_kind ONWHAT>
417 assert(ONWHAT ==
onwhat());
436 void set_interface_reconstructor_options(
bool all_convex,
437 const std::vector<Tangram::IterativeMethodTolerances_t> &tols =
438 std::vector<Tangram::IterativeMethodTolerances_t>()) {
441 derived_class_ptr->set_interface_reconstructor_options(all_convex, tols);
486 class SourceMesh,
class SourceState,
487 class TargetMesh = SourceMesh,
class TargetState = SourceState,
489 class Matpoly_Splitter = void,
490 class Matpoly_Clipper = void,
491 class CoordSys = Wonton::DefaultCoordSys
494 SourceMesh, SourceState,
495 TargetMesh, TargetState,
496 InterfaceReconstructorType,
503 InterfaceReconstructorType,
504 Matpoly_Splitter, Matpoly_Clipper, CoordSys>;
522 SourceState
const& source_state,
523 TargetMesh
const& target_mesh,
524 TargetState& target_state,
525 Wonton::Executor_type
const *executor =
nullptr)
526 : source_mesh_(source_mesh),
527 target_mesh_(target_mesh),
528 source_state_(source_state),
529 target_state_(target_state),
532 #ifdef PORTAGE_ENABLE_MPI 533 mycomm_ = MPI_COMM_NULL;
534 auto mpiexecutor =
dynamic_cast<Wonton::MPIExecutor_type
const *
>(executor);
535 if (mpiexecutor && mpiexecutor->mpicomm != MPI_COMM_NULL) {
536 mycomm_ = mpiexecutor->mpicomm;
537 MPI_Comm_rank(mycomm_, &comm_rank_);
538 MPI_Comm_size(mycomm_, &nprocs_);
565 template<
template<
int, Entity_kind,
class,
class>
class Search>
569 const Search<D, ONWHAT, SourceMesh, TargetMesh>
570 search_functor(source_mesh_, target_mesh_);
572 int ntarget_ents = target_mesh_.num_entities(ONWHAT, PARALLEL_OWNED);
578 target_mesh_.end(ONWHAT, PARALLEL_OWNED),
579 candidates.begin(), search_functor);
595 template<
template <Entity_kind,
class,
class,
class,
596 template <
class,
int,
class,
class>
class,
598 Portage::
vector<std::vector<Portage::Weights_t>>
603 if (reconstructor_tols_.empty()) {
604 reconstructor_tols_ = { {1000, num_tols_.min_absolute_distance,
605 num_tols_.min_absolute_volume},
606 {100, num_tols_.min_absolute_distance,
607 num_tols_.min_absolute_distance} };
611 else if (!num_tols_.user_tolerances) {
612 num_tols_.min_absolute_distance = reconstructor_tols_[0].arg_eps;
613 num_tols_.min_absolute_volume = reconstructor_tols_[0].fun_eps;
617 int nents = target_mesh_.num_entities(ONWHAT, PARALLEL_OWNED);
620 Intersect<ONWHAT, SourceMesh, SourceState, TargetMesh,
621 InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper>
622 intersector(source_mesh_, source_state_, target_mesh_, num_tols_);
625 target_mesh_.end(ONWHAT, PARALLEL_OWNED),
627 sources_and_weights.begin(),
630 return sources_and_weights;
636 const double min_absolute_volume) {
637 num_tols_.min_absolute_distance = min_absolute_distance;
638 num_tols_.min_absolute_volume = min_absolute_volume;
639 num_tols_.user_tolerances =
true;
644 num_tols_ = num_tols;
660 void set_interface_reconstructor_options(
bool all_convex,
661 const std::vector<Tangram::IterativeMethodTolerances_t> &tols =
662 std::vector<Tangram::IterativeMethodTolerances_t>()) {
663 reconstructor_tols_ = tols;
664 reconstructor_all_convex_ = all_convex;
686 template <Entity_kind,
class,
class,
class,
687 template <
class,
int,
class,
class>
class,
690 std::
vector<Portage::vector<std::vector<Weights_t>>>
695 int nmats = source_state_.num_materials();
698 assert(
typeid(InterfaceReconstructorType<SourceMesh, D,
699 Matpoly_Splitter, Matpoly_Clipper >) !=
701 Matpoly_Splitter, Matpoly_Clipper>));
710 interface_reconstructor_ =
711 std::unique_ptr<Tangram::Driver<InterfaceReconstructorType, D,
715 >(
new Tangram::Driver<InterfaceReconstructorType, D,
718 Matpoly_Clipper>(source_mesh_, reconstructor_tols_,
719 reconstructor_all_convex_));
721 int ntargetcells = target_mesh_.num_entities(CELL, PARALLEL_OWNED);
724 std::vector<int> cell_num_mats, cell_mat_ids;
725 std::vector<double> cell_mat_volfracs;
726 std::vector<Wonton::Point<D>> cell_mat_centroids;
731 ccc_vfcen_data(cell_num_mats, cell_mat_ids, cell_mat_volfracs,
734 interface_reconstructor_->set_volume_fractions(cell_num_mats,
738 interface_reconstructor_->reconstruct(executor_);
745 Intersect<CELL, SourceMesh, SourceState, TargetMesh,
746 InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper>
747 intersector(source_mesh_, source_state_, target_mesh_, num_tols_,
748 interface_reconstructor_);
753 std::vector<Portage::vector<std::vector<Weights_t>>>
754 source_weights_by_mat(nmats);
756 for (
int m = 0; m < nmats; m++) {
757 std::vector<int> matcellstgt;
759 intersector.set_material(m);
786 std::vector<std::vector<Weights_t>> this_mat_sources_and_wts(ntargetcells);
788 target_mesh_.end(CELL, PARALLEL_OWNED),
790 this_mat_sources_and_wts.begin(),
796 ntargetcells = target_mesh_.num_entities(CELL, PARALLEL_OWNED);
798 for (
int c = 0; c < ntargetcells; c++) {
799 std::vector<Weights_t>
const& cell_mat_sources_and_weights =
800 this_mat_sources_and_wts[c];
801 int nwts = cell_mat_sources_and_weights.size();
802 for (
int s = 0; s < nwts; s++) {
803 std::vector<double>
const& wts = cell_mat_sources_and_weights[s].weights;
805 if (wts[0] > num_tols_.min_absolute_volume) {
806 matcellstgt.push_back(c);
815 int nmatcells = matcellstgt.size();
816 int nmatcells_global = nmatcells;
817 #ifdef PORTAGE_ENABLE_MPI 818 if (mycomm_!= MPI_COMM_NULL)
819 MPI_Allreduce(&nmatcells, &nmatcells_global, 1, MPI_INT, MPI_SUM,
823 if (nmatcells_global) {
824 int nmatstrg = target_state_.num_materials();
827 for (
int i = 0; i < nmatstrg; i++)
828 if (target_state_.material_name(i) == source_state_.material_name(m)) {
834 target_state_.mat_add_cells(m2, matcellstgt);
851 target_state_.add_material(source_state_.material_name(m),
863 std::vector<double> mat_volfracs(nmatcells);
864 std::vector<Point<D>> mat_centroids(nmatcells);
866 source_weights_by_mat[m].resize(nmatcells);
868 for (
int ic = 0; ic < nmatcells; ic++) {
869 int c = matcellstgt[ic];
872 std::vector<Weights_t>
const &
873 cell_mat_sources_and_weights = this_mat_sources_and_wts[c];
874 int nwts = cell_mat_sources_and_weights.size();
875 for (
int s = 0; s < nwts; s++) {
876 std::vector<double>
const& wts = cell_mat_sources_and_weights[s].weights;
878 for (
int d = 0; d < D; d++)
879 matcen[d] += wts[d+1];
882 mat_volfracs[ic] = matvol/target_mesh_.cell_volume(c);
883 mat_centroids[ic] = matcen;
885 source_weights_by_mat[m][ic] = cell_mat_sources_and_weights;
888 target_state_.mat_add_celldata(
"mat_volfracs", m, &(mat_volfracs[0]));
889 target_state_.mat_add_celldata(
"mat_centroids", m, &(mat_centroids[0]));
893 return source_weights_by_mat;
895 return std::vector<Portage::vector<std::vector<Weights_t>>>();
910 std::string
const field_name,
919 auto const field_type = source_state_.field_type(ONWHAT, field_name);
922 bool const multimat =
923 ONWHAT == Entity_kind::CELL and
924 field_type == Field_type::MULTIMATERIAL_FIELD;
926 std::vector<int> mat_cells;
929 if (interface_reconstructor_) {
930 std::vector<int> mat_cells_all;
931 source_state_.mat_get_cells(material_id, &mat_cells_all);
932 nallent = mat_cells_all.size();
936 mat_cells.reserve(nallent);
937 for (
auto const& c : mat_cells_all)
938 if (source_mesh_.cell_get_type(c) == PARALLEL_OWNED)
939 mat_cells.push_back(c);
942 throw std::runtime_error(
"interface reconstructor not set");
945 nallent = source_mesh_.num_entities(ONWHAT, ALL);
953 Gradient
kernel(source_mesh_, source_state_, field_name,
954 limiter_type, boundary_limiter_type,
955 interface_reconstructor_, source_part);
957 Gradient
kernel(source_mesh_, source_state_, field_name,
958 limiter_type, boundary_limiter_type, source_part);
972 std::vector<Vector<D>> owned_gradient_field(mat_cells.size());
974 kernel.set_material(material_id);
977 owned_gradient_field.begin(),
kernel);
979 for (
auto const& c : mat_cells) {
980 int cm = source_state_.cell_index_in_material(c, material_id);
981 gradient_field[cm] = owned_gradient_field[i++];
986 source_mesh_.end(ONWHAT, PARALLEL_OWNED),
987 gradient_field.begin(),
kernel);
991 return gradient_field;
1002 template<
typename T = double,
1003 template<int, Entity_kind,
class,
class,
class,
class,
class,
1004 template<
class,
int,
class,
class>
class,
1005 class,
class,
class>
class Interpolate
1011 if (source_state_.get_entity(srcvarname) != ONWHAT) {
1012 std::cerr <<
"Variable " << srcvarname <<
" not defined on Entity_kind " 1013 << ONWHAT <<
". Skipping!" << std::endl;
1018 using Interpolator = Interpolate<D, ONWHAT,
1019 SourceMesh, TargetMesh,
1020 SourceState, TargetState,
1022 InterfaceReconstructorType,
1023 Matpoly_Splitter, Matpoly_Clipper, CoordSys>;
1025 Interpolator interpolator(source_mesh_, target_mesh_, source_state_,
1027 interpolator.set_interpolation_variable(srcvarname, gradients);
1031 T* target_mesh_field =
nullptr;
1032 target_state_.mesh_get_data(ONWHAT, trgvarname, &target_mesh_field);
1036 target_mesh_.end(ONWHAT, PARALLEL_OWNED),
1037 sources_and_weights.begin(),
1038 target_field, interpolator);
1068 template<
typename T = double,
1069 template<int, Entity_kind,
class,
class,
class,
class,
class,
1070 template<
class,
int,
class,
class>
class,
1071 class,
class,
class>
class Interpolate,
1072 Entity_kind ONWHAT1 = ONWHAT,
1073 typename =
typename std::enable_if<ONWHAT1 == CELL>::type>
1077 const PartPair<D, SourceMesh, SourceState,
1078 TargetMesh, TargetState>* partition,
1081 if (source_state_.get_entity(srcvarname) != ONWHAT) {
1082 std::cerr <<
"Variable " << srcvarname <<
" not defined on Entity_kind " 1083 << ONWHAT <<
". Skipping!" << std::endl;
1088 using Interpolator = Interpolate<D, ONWHAT,
1089 SourceMesh, TargetMesh,
1090 SourceState, TargetState,
1092 InterfaceReconstructorType,
1093 Matpoly_Splitter, Matpoly_Clipper, CoordSys>;
1095 Interpolator interpolator(source_mesh_, target_mesh_, source_state_, num_tols_, partition);
1096 interpolator.set_interpolation_variable(srcvarname, gradients);
1100 T* target_mesh_field =
nullptr;
1101 target_state_.mesh_get_data(ONWHAT, trgvarname, &target_mesh_field);
1104 assert(ONWHAT == Entity_kind::CELL && partition !=
nullptr);
1110 auto const& source_part = partition->source();
1111 auto const& target_part = partition->target();
1114 int const& max_source_id = source_mesh_.num_entities(ONWHAT, ALL);
1115 int const& max_target_id = target_mesh_.num_entities(ONWHAT, ALL);
1118 source_part.cells().end(),
1119 [&](
int current){ assert(current <= max_source_id); });
1122 target_part.cells().end(),
1123 [&](
int current){ assert(current <= max_target_id); });
1126 int const target_part_size = target_part.size();
1134 auto filter_weights = [&](
int entity) {
1145 for (
auto&& weight : entity_weights) {
1147 if(source_part.contains(weight.entityID)) {
1148 heap.emplace_back(weight);
1151 heap.shrink_to_fit();
1157 target_part.cells().end(),
1158 parts_weights.begin(), filter_weights);
1166 T temporary_storage[target_part_size];
1170 target_part.cells().end(),
1171 parts_weights.begin(), target_part_field, interpolator);
1173 for (
int i=0; i < target_part_size; ++i) {
1174 auto const& j = target_part.cells()[i];
1175 target_mesh_field[j] = target_part_field[i];
1211 template<
typename T = double,
1212 template<int, Entity_kind,
class,
class,
class,
class,
class,
1213 template<
class,
int,
class,
class>
class,
1214 class,
class,
class>
class Interpolate,
1215 Entity_kind ONWHAT1 = ONWHAT,
1216 typename =
typename std::enable_if<ONWHAT1 == CELL>::type>
1222 using Interpolator = Interpolate<D, ONWHAT,
1223 SourceMesh, TargetMesh,
1224 SourceState, TargetState,
1226 InterfaceReconstructorType,
1227 Matpoly_Splitter, Matpoly_Clipper, CoordSys>;
1229 Interpolator interpolator(source_mesh_, target_mesh_,
1230 source_state_, num_tols_,
1231 interface_reconstructor_);
1233 int const nmats = source_state_.num_materials();
1235 for (
int m = 0; m < nmats; m++) {
1237 interpolator.set_material(m);
1241 auto mat_grad = (gradients !=
nullptr ? &((*gradients)[m]) :
nullptr);
1244 interpolator.set_interpolation_variable(srcvarname, mat_grad);
1248 if (target_state_.mat_get_num_cells(m) == 0)
continue;
1250 std::vector<int> matcellstgt;
1251 target_state_.mat_get_cells(m, &matcellstgt);
1257 T *target_field_raw;
1258 target_state_.mat_get_celldata(trgvarname, m, &target_field_raw);
1259 assert (target_field_raw !=
nullptr);
1264 sources_and_weights_by_mat[m].begin(),
1265 target_field, interpolator);
1273 target_state_.mat_add_celldata(trgvarname, m, target_field_raw);
1278 #endif // HAVE_TANGRAM 1293 if (not mismatch_fixer_) {
1303 SourceMesh, SourceState,
1304 TargetMesh, TargetState>
1306 SourceMesh, SourceState,
1307 TargetMesh, TargetState>
1308 (source_mesh_, source_state_, target_mesh_, target_state_,
1312 return mismatch_fixer_->check_mismatch(source_weights);
1323 assert(mismatch_fixer_ &&
"check_mismatch must be called first!");
1324 return mismatch_fixer_->has_mismatch();
1357 std::string
const & trg_var_name,
1358 double global_lower_bound = -std::numeric_limits<double>::max(),
1359 double global_upper_bound = std::numeric_limits<double>::max(),
1367 assert(mismatch_fixer_ &&
"check_mismatch must be called first!");
1369 if (source_state_.field_type(ONWHAT, src_var_name) ==
1370 Field_type::MESH_FIELD)
1371 return mismatch_fixer_->fix_mismatch(src_var_name, trg_var_name,
1372 global_lower_bound, global_upper_bound,
1373 conservation_tol, maxiter,
1374 partial_fixup_type, empty_fixup_type);
1379 SourceMesh
const & source_mesh_;
1380 TargetMesh
const & target_mesh_;
1381 SourceState
const & source_state_;
1382 TargetState & target_state_;
1389 Wonton::Executor_type
const *executor_;
1391 #ifdef PORTAGE_ENABLE_MPI 1392 MPI_Comm mycomm_ = MPI_COMM_NULL;
1412 std::vector<Tangram::IterativeMethodTolerances_t> reconstructor_tols_;
1413 bool reconstructor_all_convex_ =
true;
1417 std::shared_ptr<Tangram::Driver<InterfaceReconstructorType, D,
1419 Matpoly_Splitter, Matpoly_Clipper>
1420 > interface_reconstructor_;
1426 void ccc_vfcen_data(std::vector<int>& cell_num_mats,
1427 std::vector<int>& cell_mat_ids,
1428 std::vector<double>& cell_mat_volfracs,
1429 std::vector<Wonton::Point<D>>& cell_mat_centroids) {
1431 int nsourcecells = source_mesh_.num_entities(CELL,
1434 int nmats = source_state_.num_materials();
1435 cell_num_mats.assign(nsourcecells, 0);
1439 std::vector<int> cell_mat_ids_full(nsourcecells*nmats, -1);
1440 std::vector<double> cell_mat_volfracs_full(nsourcecells*nmats, 0.0);
1441 std::vector<Wonton::Point<D>> cell_mat_centroids_full(nsourcecells*nmats);
1443 bool have_centroids =
true;
1445 for (
int m = 0; m < nmats; m++) {
1446 std::vector<int> cellids;
1447 source_state_.mat_get_cells(m, &cellids);
1448 for (
int c : cellids) {
1449 int nmatc = cell_num_mats[c];
1450 cell_mat_ids_full[c*nmats+nmatc] = m;
1453 nvals += cellids.size();
1455 double const * matfracptr;
1456 source_state_.mat_get_celldata(
"mat_volfracs", m, &matfracptr);
1457 int const num_cell_ids = cellids.size();
1458 for (
int ic = 0; ic < num_cell_ids; ic++)
1459 cell_mat_volfracs_full[cellids[ic]*nmats+m] = matfracptr[ic];
1461 Wonton::Point<D>
const *matcenvec;
1464 if (source_state_.get_entity(
"mat_centroids")==Entity_kind::UNKNOWN_KIND) {
1465 have_centroids =
false;
1469 source_state_.mat_get_celldata(
"mat_centroids", m, &matcenvec);
1470 if (cellids.size() && !matcenvec) {
1471 have_centroids =
false;
1473 for (
int ic = 0; ic < num_cell_ids; ic++)
1474 cell_mat_centroids_full[cellids[ic]*nmats+m] = matcenvec[ic];
1483 cell_mat_ids.resize(nvals);
1484 cell_mat_volfracs.resize(nvals);
1485 cell_mat_centroids.resize(nvals);
1488 for (
int c = 0; c < nsourcecells; c++) {
1489 for (
int m = 0; m < cell_num_mats[c]; m++) {
1490 int matid = cell_mat_ids_full[c*nmats+m];
1491 cell_mat_ids[idx] = matid;
1492 cell_mat_volfracs[idx] = cell_mat_volfracs_full[c*nmats+matid];
1494 cell_mat_centroids[idx] = cell_mat_centroids_full[c*nmats+matid];
1503 SourceMesh, SourceState,
1504 TargetMesh, TargetState>> mismatch_fixer_;
1512 class SourceMesh,
class SourceState,
1513 class TargetMesh,
class TargetState,
1514 template <
class,
int,
class,
class>
class InterfaceReconstructorType,
1515 class Matpoly_Splitter,
1516 class Matpoly_Clipper,
1519 TargetMesh, TargetState,
1520 InterfaceReconstructorType,
1521 Matpoly_Splitter, Matpoly_Clipper,
1525 SourceMesh
const & source_mesh,
1526 SourceState
const & source_state,
1527 TargetMesh
const & target_mesh,
1528 TargetState & target_state,
1529 Wonton::Executor_type
const *executor) {
1542 SourceMesh, SourceState,
1543 TargetMesh, TargetState,
1544 InterfaceReconstructorType,
1545 Matpoly_Splitter, Matpoly_Clipper,
1548 SourceMesh, SourceState,
1549 TargetMesh, TargetState,
1550 InterfaceReconstructorType,
1551 Matpoly_Splitter, Matpoly_Clipper,
1553 (source_mesh, source_state,
1554 target_mesh, target_state,
1567 SourceMesh, SourceState,
1568 TargetMesh, TargetState,
1569 InterfaceReconstructorType,
1570 Matpoly_Splitter, Matpoly_Clipper,
1573 SourceMesh, SourceState,
1574 TargetMesh, TargetState,
1575 InterfaceReconstructorType,
1576 Matpoly_Splitter, Matpoly_Clipper,
1578 (source_mesh, source_state,
1579 target_mesh, target_state,
1583 throw std::runtime_error(
"Remapping on "+
Wonton::to_string(onwhat)+
" not implemented");
1590 #endif // PORTAGE_CORE_DRIVER_H_ Boundary_Limiter_type
Boundary limiter type.
Definition: portage.h:91
Definition: dummy_interface_reconstructor.h:30
void set_num_tols(const double min_absolute_distance, const double min_absolute_volume)
Set core numerical tolerances.
Definition: coredriver.h:635
Definition: fix_mismatch.h:122
std::vector< T > vector
Definition: portage.h:238
OutputIterator transform(InputIterator first, InputIterator last, OutputIterator result, UnaryFunction op)
Definition: portage.h:250
void interpolate_mat_var(std::string srcvarname, std::string trgvarname, std::vector< Portage::vector< std::vector< Weights_t >>> const &sources_and_weights_by_mat, std::vector< Portage::vector< Vector< D >>> *gradients=nullptr)
Definition: coredriver.h:307
bool check_mismatch(Portage::vector< std::vector< Weights_t >> const &source_weights)
Definition: coredriver.h:1290
Intersection and other tolerances to handle tiny values.
Definition: portage.h:152
T * pointer
Definition: portage.h:241
void set_num_tols(const double min_absolute_distance, const double min_absolute_volume)
Set numerical tolerances for small distances and volumes.
Definition: coredriver.h:399
void set_num_tols(const NumericTolerances_t &num_tols)
Set numerical tolerances for small volumes, distances, etc.
Definition: coredriver.h:416
void for_each(InputIterator first, InputIterator last, UnaryFunction f)
Definition: portage.h:264
bool fix_mismatch(std::string const &src_var_name, std::string const &trg_var_name, double global_lower_bound=-std::numeric_limits< double >::max(), double global_upper_bound=std::numeric_limits< double >::max(), double conservation_tol=1e2 *std::numeric_limits< double >::epsilon(), int maxiter=5, Partial_fixup_type partial_fixup_type=Partial_fixup_type::SHIFTED_CONSERVATIVE, Empty_fixup_type empty_fixup_type=Empty_fixup_type::EXTRAPOLATE)
Return if meshes are mismatched (check_mismatch must already have been called)
Definition: coredriver.h:364
Partial_fixup_type
Fixup options for partially filled cells.
Definition: portage.h:114
Compute limited gradient of a field or components of a field.
Definition: gradient.h:52
bool has_mismatch()
Definition: coredriver.h:1322
bool check_mismatch(Portage::vector< std::vector< Weights_t >> const &source_weights)
Check if meshes are mismatched (don't cover identical portions of space)
Definition: coredriver.h:332
Manages source and target sub-meshes for part-by-part remap.
double const epsilon
Numerical tolerance.
Definition: weight.h:34
virtual Entity_kind onwhat()=0
Portage::vector< std::vector< int > > search()
search for candidate source entities whose control volumes (cells, dual cells) overlap the control vo...
Definition: coredriver.h:134
virtual ~CoreDriverBase()=default
Manages source and target sub-meshes for part-by-part remap. It detects boundaries mismatch and provi...
Definition: parts.h:234
void interpolate_mesh_var(std::string srcvarname, std::string trgvarname, Portage::vector< std::vector< Weights_t >> const &sources_and_weights, const PartPair< D, SourceMesh, SourceState, TargetMesh, TargetState > *partition, Portage::vector< Vector< D >> *gradients=nullptr)
Interpolate mesh variable from source part to target part.
Definition: coredriver.h:1075
Limiter_type
Limiter type.
Definition: portage.h:85
bool has_mismatch()
Return if meshes are mismatched (check_mismatch must already have been called)
Definition: coredriver.h:348
void interpolate_mesh_var(std::string srcvarname, std::string trgvarname, Portage::vector< std::vector< Weights_t >> const &sources_and_weights, Portage::vector< Vector< D >> *gradients=nullptr)
Definition: coredriver.h:239
CoreDriver(SourceMesh const &source_mesh, SourceState const &source_state, TargetMesh const &target_mesh, TargetState &target_state, Wonton::Executor_type const *executor=nullptr)
Constructor for the CORE remap driver.
Definition: coredriver.h:521
std::vector< Wonton::Weights_t > entity_weights_t
Definition: parts.h:36
Definition: portage.h:134
Portage::vector< std::vector< int > > search()
Definition: coredriver.h:567
CoreDriverBase - Base class for core driver that is agnostic to the Entity_kind.
Definition: coredriver.h:105
bool fix_mismatch(std::string const &src_var_name, std::string const &trg_var_name, double global_lower_bound=-std::numeric_limits< double >::max(), double global_upper_bound=std::numeric_limits< double >::max(), double conservation_tol=1e2 *std::numeric_limits< double >::epsilon(), int maxiter=5, Partial_fixup_type partial_fixup_type=Partial_fixup_type::SHIFTED_CONSERVATIVE, Empty_fixup_type empty_fixup_type=Empty_fixup_type::EXTRAPOLATE)
Repair the remapped field to account for boundary mismatch.
Definition: coredriver.h:1356
Definition: portage.h:114
Entity_kind onwhat()
What entity kind is this defined on?
Definition: coredriver.h:553
Definition: coredriver.h:42
void set_num_tols(const NumericTolerances_t &num_tols)
Set all numerical tolerances.
Definition: coredriver.h:643
double kernel(const Kernel kern, double x)
General kernel function.
Definition: weight.h:313
std::unique_ptr< CoreDriverBase< D, SourceMesh, SourceState, TargetMesh, TargetState, InterfaceReconstructorType, Matpoly_Splitter, Matpoly_Clipper, CoordSys > > make_core_driver(Entity_kind onwhat, SourceMesh const &source_mesh, SourceState const &source_state, TargetMesh const &target_mesh, TargetState &target_state, Wonton::Executor_type const *executor)
Definition: coredriver.h:1524
std::vector< Portage::vector< std::vector< Portage::Weights_t > > > intersect_materials(Portage::vector< std::vector< int >> const &intersection_candidates)
Definition: coredriver.h:185
Portage::vector< std::vector< Portage::Weights_t > > intersect_meshes(Portage::vector< std::vector< int >> const &intersection_candidates)
intersect target entities with candidate source entities
Definition: coredriver.h:159
Portage::vector< Vector< D > > compute_source_gradient(std::string const field_name, Limiter_type limiter_type=NOLIMITER, Boundary_Limiter_type boundary_limiter_type=BND_NOLIMITER, int material_id=0, const Part< SourceMesh, SourceState > *source_part=nullptr) const
Compute the gradient field of the given variable on source mesh.
Definition: coredriver.h:909
void Intersect(const IsotheticBBox< D > &box, const KDTree< D > *kdtree, std::vector< int > &pfound)
Definition: kdtree.h:439
CoreDriver - Core driver that remaps fields on a particular Entity_kind (ONWHAT) like CELL or NODE...
Definition: coredriver.h:64
std::string to_string(Limiter_type limiter_type)
Definition: portage.h:96
Portage::vector< Vector< D > > compute_source_gradient(std::string const field_name, Limiter_type limiter_type=NOLIMITER, Boundary_Limiter_type boundary_limiter_type=BND_NOLIMITER, int material_id=0, const Part< SourceMesh, SourceState > *source_part=nullptr)
Compute the gradient field of the given variable on source mesh.
Definition: coredriver.h:201
Empty_fixup_type
Fixup options for empty cells.
Definition: portage.h:134