-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding an initial implementation of the "identity map" multimesh mapping
- Loading branch information
Showing
4 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
|
||
set(SRC_FILES | ||
same_simplex_dimension_surjection.hpp | ||
same_simplex_dimension_surjection.cpp | ||
) | ||
target_sources(wildmeshing_toolkit PRIVATE ${SRC_FILES}) | ||
|
||
add_subdirectory(utils) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "same_simplex_dimension_surjection.hpp" | ||
#include <numeric> | ||
#include <wmtk/Mesh.hpp> | ||
|
||
|
||
namespace wmtk::multimesh { | ||
std::vector<std::array<Tuple, 2>> same_simplex_dimension_surjection( | ||
const Mesh& parent, | ||
const Mesh& child) | ||
{ | ||
PrimitiveType primitive_type = parent.top_simplex_type(); | ||
assert(primitive_type == child.top_simplex_type()); | ||
long size = parent.capacity(primitive_type); | ||
assert(size == child.capacity(primitive_type)); | ||
std::vector<long> ps; | ||
ps.reserve(size); | ||
std::iota(ps.begin(), ps.end(), 0); | ||
return same_simplex_dimension_surjection(parent, child, ps); | ||
} | ||
|
||
std::vector<std::array<Tuple, 2>> same_simplex_dimension_surjection( | ||
const Mesh& parent, | ||
const Mesh& child, | ||
const std::vector<long>& parent_simplices) | ||
{ | ||
PrimitiveType primitive_type = parent.top_simplex_type(); | ||
assert(primitive_type == child.top_simplex_type()); | ||
|
||
long size = child.capacity(primitive_type); | ||
assert(size == long(parent_simplices.size())); | ||
std::vector<std::array<Tuple, 2>> ret; | ||
ret.reserve(size); | ||
|
||
auto parent_flag_accessor = parent.get_const_flag_accessor(primitive_type); | ||
auto child_flag_accessor = child.get_const_flag_accessor(primitive_type); | ||
|
||
for (long index = 0; index < size; ++index) { | ||
const Tuple ct = child.tuple_from_id(primitive_type, index); | ||
const Tuple pt = parent.tuple_from_id(primitive_type, parent_simplices.at(index)); | ||
if (parent_flag_accessor.const_scalar_attribute(pt) & 1 == 0) { | ||
continue; | ||
} | ||
if (child_flag_accessor.const_scalar_attribute(pt) & 1 == 0) { | ||
continue; | ||
} | ||
|
||
ret.emplace_back(std::array<Tuple, 2>{{pt, ct}}); | ||
} | ||
return ret; | ||
} | ||
} // namespace wmtk::multimesh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <array> | ||
#include <vector> | ||
#include <wmtk/Tuple.hpp> | ||
|
||
namespace wmtk { | ||
class Mesh; | ||
} | ||
|
||
namespace wmtk::multimesh { | ||
|
||
// Handles the "trivial " mapping case as we see in OBJ files | ||
// parent and child are assumed to be homogeneous meshes of the same dimension and the same number | ||
// of top level simplices It is assumed that for each index between [0,num_top_level_simplices) it | ||
// is assumed that the tuple parent.tuple_from_id(pt,index) should be mapped to | ||
// child.tuple_from_id(pt,index) | ||
std::vector<std::array<Tuple, 2>> same_simplex_dimension_surjection( | ||
const Mesh& parent, | ||
const Mesh& child); | ||
// same as above except the mapping selects a subset of parent_simplices | ||
// the tuple parent.tuple_from_id(pt,parent_simplices[index]) should be mapped to | ||
// child.tuple_from_id(pt,index) | ||
std::vector<std::array<Tuple, 2>> same_simplex_dimension_surjection( | ||
const Mesh& parent, | ||
const Mesh& child, | ||
const std::vector<long>& parent_simplices); | ||
} // namespace wmtk::multimesh |