Skip to content

Commit

Permalink
Merge branch 'amr' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jbakosi committed Sep 4, 2020
2 parents 9fc828c + 03c2f2f commit 9c264be
Show file tree
Hide file tree
Showing 72 changed files with 566 additions and 96 deletions.
7 changes: 3 additions & 4 deletions src/Base/Print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,16 +321,15 @@ class Print {
//! \note The number of labels and values must equal.
template< Style s = VERBOSE >
void diag( const std::vector< std::string >& labels,
const std::vector< std::size_t >& values,
const std::vector< std::string >& values,
bool precr = true ) const
{
Assert( labels.size() == values.size(), "Size mismatch" );
if (!labels.empty()) {
stream<s>() << (precr ? "\n" : "") <<
m_inprog_diag_fmt % labels[0] % std::to_string(values[0]);
m_inprog_diag_fmt % labels[0] % values[0];
for (std::size_t i=1; i<labels.size(); ++i)
stream<s>() <<
m_inprog_extra_diag_fmt % labels[i] % std::to_string(values[i]);
stream<s>() << m_inprog_extra_diag_fmt % labels[i] % values[i];
stream<s>() << (precr ? " " : "\n") << std::flush;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Control/Inciter/InputDeck/Grammar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,10 @@ namespace deck {
struct half_world :
tk::grm::control< use< keyword >, pegtl::digit, tag::amr, Tag > {};

//! coordref ... end block
struct coordref :
//! coords ... end block
struct coords :
pegtl::if_must<
tk::grm::readkw< use< kw::amr_coordref >::pegtl_string >,
tk::grm::readkw< use< kw::amr_coords >::pegtl_string >,
tk::grm::block< use< kw::end >,
half_world< kw::amr_xminus, tag::xminus >,
half_world< kw::amr_xplus, tag::xplus >,
Expand Down Expand Up @@ -1190,7 +1190,7 @@ namespace deck {
tk::grm::block< use< kw::end >,
refvars,
edgelist,
coordref,
coords,
tk::grm::process<
use< kw::amr_initial >,
tk::grm::store_back_option< use,
Expand Down
1 change: 0 additions & 1 deletion src/Control/Inciter/InputDeck/InputDeck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ class InputDeck : public tk::TaggedTuple< InputDeckMembers > {
kw::amr_tolref,
kw::amr_tolderef,
kw::amr_edgelist,
kw::amr_coordref,
kw::amr_xminus,
kw::amr_xplus,
kw::amr_yminus,
Expand Down
108 changes: 50 additions & 58 deletions src/Control/Keywords.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5630,7 +5630,7 @@ using partitioning = keyword< partitioning_info, TAOCPP_PEGTL_STRING("partitioni

struct amr_uniform_info {
using code = Code< u >;
static std::string name() { return "uniform"; }
static std::string name() { return "uniform refine"; }
static std::string shortDescription() { return
"Select uniform initial mesh refinement"; }
static std::string longDescription() { return
Expand All @@ -5640,7 +5640,7 @@ using amr_uniform = keyword< amr_uniform_info, TAOCPP_PEGTL_STRING("uniform") >;

struct amr_uniform_derefine_info {
using code = Code< d >;
static std::string name() { return "uniform_derefine"; }
static std::string name() { return "uniform derefine"; }
static std::string shortDescription() { return
"Select uniform initial mesh de-refinement"; }
static std::string longDescription() { return
Expand All @@ -5651,7 +5651,7 @@ using amr_uniform_derefine =

struct amr_initial_conditions_info {
using code = Code< i >;
static std::string name() { return "ic"; }
static std::string name() { return "initial conditions"; }
static std::string shortDescription() { return
"Select initial-conditions-based initial mesh refinement"; }
static std::string longDescription() { return
Expand All @@ -5661,15 +5661,46 @@ struct amr_initial_conditions_info {
using amr_initial_conditions =
keyword< amr_initial_conditions_info, TAOCPP_PEGTL_STRING("ic") >;

struct amr_edgelist_info {
using code = Code< e >;
static std::string name() { return "edge list"; }
static std::string shortDescription() { return
"Configure edge-node pairs for initial refinement"; }
static std::string longDescription() { return
R"(This keyword can be used to configure a list of edges that are explicitly
tagged for initial refinement during setup in inciter. The keyword
introduces an edgelist ... end block within an amr ... end block and must
contain a list of integer pairs, i.e., the number of ids must be even,
denoting the end-points of the nodes (=edge) which should be tagged for
refinement.)"; }
struct expect {
using type = std::size_t;
static constexpr type lower = 0;
static std::string description() { return "two ints"; }
};
};
using amr_edgelist =
keyword< amr_edgelist_info, TAOCPP_PEGTL_STRING("edgelist") >;

struct amr_coords_info {
using code = Code< c >;
static std::string name() { return "coords"; }
static std::string name() { return "coordinates"; }
static std::string shortDescription() { return
"Select coordinate-based initial mesh refinement"; }
static std::string longDescription() { return R"(This keyword is used to
select coordinate-based initial mesh refinement.)"; }
"Configure initial refinement using coordinate planes"; }
static std::string longDescription() { return
R"(This keyword can be used to configure entire volumes on a given side of a
plane in 3D space. The keyword introduces an coords ... end block within
an amr ... end block and must contain the either or multiple of the
following keywords: x- <real>, x+ <real>, y- <real>, y+ <real>, z- <real>,
z+ <real>. All edges of the input mesh will be tagged for refinement whose
end-points lie less than (-) or larger than (+) the real number given.
Example: 'x- 0.5' refines all edges whose end-point coordinates are less
than 0.5. Multiple specifications are understood by combining with a logical
AND. That is: 'x- 0.5 y+ 0.3' refines all edges whose end-point x
coordinates are less than 0.5 AND y coordinates are larger than 0.3.)"; }
};
using amr_coords = keyword< amr_coords_info, TAOCPP_PEGTL_STRING("coords") >;
using amr_coords =
keyword< amr_coords_info, TAOCPP_PEGTL_STRING("coords") >;

struct amr_initial_info {
static std::string name() { return "Initial refinement typelist"; }
Expand All @@ -5685,8 +5716,10 @@ struct amr_initial_info {
static std::string description() { return "string"; }
static std::string choices() {
return '\'' + amr_uniform::string() + "\' | \'"
+ amr_coords::string() + "\' | \'"
+ amr_initial_conditions::string() + '\'';
+ amr_uniform_derefine::string() + "\' | \'"
+ amr_initial_conditions::string() + "\' | \'"
+ amr_edgelist::string() + "\' | \'"
+ amr_coords::string() + '\'';
}
};
};
Expand Down Expand Up @@ -5716,55 +5749,14 @@ struct amr_refvar_info {
};
using amr_refvar = keyword< amr_refvar_info, TAOCPP_PEGTL_STRING("refvar") >;

struct amr_edgelist_info {
using code = Code< e >;
static std::string name() { return "initial refinement edge-nodes"; }
static std::string shortDescription() { return
"Configure edge-node pairs for initial refinement"; }
static std::string longDescription() { return
R"(This keyword can be used to configure a list of edges that are explicitly
tagged for initial refinement during setup in inciter. The keyword
introduces an edgelist ... end block within an amr ... end block and must
contain a list of integer pairs, i.e., the number of ids must be even,
denoting the end-points of the nodes (=edge) which should be tagged for
refinement.)"; }
struct expect {
using type = std::size_t;
static constexpr type lower = 0;
static std::string description() { return "two ints"; }
};
};
using amr_edgelist =
keyword< amr_edgelist_info, TAOCPP_PEGTL_STRING("edgelist") >;

struct amr_coordref_info {
static std::string name() {
return "initial refinement with coordinate planes"; }
static std::string shortDescription() { return
"Configure initial refinement using coordinate planes"; }
static std::string longDescription() { return
R"(This keyword can be used to configure entire volumes on a given side of a
plane in 3D space. The keyword introduces an coordref ... end block within
an amr ... end block and must contain the either or multiple of the
following keywords: x- <real>, x+ <real>, y- <real>, y+ <real>, z- <real>,
z+ <real>. All edges of the input mesh will be tagged for refinement whose
end-points lie less than (-) or larger than (+) the real number given.
Example: 'x- 0.5' refines all edges whose end-point coordinates are less
than 0.5. Multiple specifications are understood by combining with a logical
AND. That is: 'x- 0.5 y+ 0.3' refines all edges whose end-point x
coordinates are less than 0.5 AND y coordinates are larger than 0.3.)"; }
};
using amr_coordref =
keyword< amr_coordref_info, TAOCPP_PEGTL_STRING("coordref") >;

struct amr_xminus_info {
static std::string name() { return "initial refinement: x-"; }
static std::string shortDescription() { return "Configure initial refinement "
"for coordinates lower than an x-normal plane"; }
static std::string longDescription() { return
R"(This keyword can be used to configure a mesh refinement volume for edges
whose end-points are less than the x coordinate of a plane perpendicular to
coordinate x in 3D space. The keyword must be used in a coordref ... end
coordinate x in 3D space. The keyword must be used in a coords ... end
block within an amr ... end block with syntax 'x- <real>'. All edges of the
input mesh will be tagged for refinement whose end-points lie less than (-)
the real number given. Example: 'x- 0.5' refines all edges whose end-point
Expand All @@ -5784,7 +5776,7 @@ struct amr_xplus_info {
static std::string longDescription() { return
R"(This keyword can be used to configure a mesh refinement volume for edges
whose end-points are larger than the x coordinate of a plane perpendicular
to coordinate x in 3D space. The keyword must be used in a coordref ... end
to coordinate x in 3D space. The keyword must be used in a coords ... end
block within an amr ... end block with syntax 'x+ <real>'. All edges of the
input mesh will be tagged for refinement whose end-points lie larger than
(+) the real number given. Example: 'x+ 0.5' refines all edges whose
Expand All @@ -5804,7 +5796,7 @@ struct amr_yminus_info {
static std::string longDescription() { return
R"(This keyword can be used to configure a mesh refinement volume for edges
whose end-points are less than the y coordinate of a plane perpendicular to
coordinate y in 3D space. The keyword must be used in a coordref ... end
coordinate y in 3D space. The keyword must be used in a coords ... end
block within an amr ... end block with syntax 'y- <real>'. All edges of the
input mesh will be tagged for refinement whose end-points lie less than (-)
the real number given. Example: 'y- 0.5' refines all edges whose end-point
Expand All @@ -5824,7 +5816,7 @@ struct amr_yplus_info {
static std::string longDescription() { return
R"(This keyword can be used to configure a mesh refinement volume for edges
whose end-points are larger than the y coordinate of a plane perpendicular
to coordinate y in 3D space. The keyword must be used in a coordref ... end
to coordinate y in 3D space. The keyword must be used in a coords ... end
block within an amr ... end block with syntax 'y+ <real>'. All edges of the
input mesh will be tagged for refinement whose end-points lie larger than
(+) the real number given. Example: 'y+ 0.5' refines all edges whose
Expand All @@ -5844,7 +5836,7 @@ struct amr_zminus_info {
static std::string longDescription() { return
R"(This keyword can be used to configure a mesh refinement volume for edges
whose end-points are less than the z coordinate of a plane perpendicular to
coordinate z in 3D space. The keyword must be used in a coordref ... end
coordinate z in 3D space. The keyword must be used in a coords ... end
block within an amr ... end block with syntax 'z- <real>'. All edges of the
input mesh will be tagged for refinement whose end-points lie less than (-)
the real number given. Example: 'z- 0.5' refines all edges whose end-point
Expand All @@ -5864,7 +5856,7 @@ struct amr_zplus_info {
static std::string longDescription() { return
R"(This keyword can be used to configure a mesh refinement volume for edges
whose end-points are larger than the z coordinate of a plane perpendicular
to coordinate z in 3D space. The keyword must be used in a coordref ... end
to coordinate z in 3D space. The keyword must be used in a coords ... end
block within an amr ... end block with syntax 'z+ <real>'. All edges of the
input mesh will be tagged for refinement whose end-points lie larger than
(+) the real number given. Example: 'z+ 0.5' refines all edges whose
Expand Down Expand Up @@ -6049,7 +6041,7 @@ struct amr_info {
+ amr_tolref::string() + "\' | \'"
+ amr_tolderef::string() + "\' | \'"
+ amr_error::string() + "\' | \'"
+ amr_coordref::string() + "\' | \'"
+ amr_coords::string() + "\' | \'"
+ amr_edgelist::string() + "\'.";
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/Inciter/AMR/edge_store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace AMR {
}

/**
* @brief Function to add edge to ede store
* @brief Function to add edge to edge store
*
* @param key The key for the given edge
* @param e The edge data
Expand Down
33 changes: 22 additions & 11 deletions src/Inciter/AMR/mesh_adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,24 @@ namespace AMR {
*/
void mesh_adapter_t::mark_uniform_derefinement()
{
for (auto& kv : tet_store.edge_store.edges) {
auto& local = kv.second;
if (local.lock_case == Edge_Lock_Case::unlocked)
local.needs_derefining = 1;
const auto& inp = tet_store.get_active_inpoel();
auto& edge_store = tet_store.edge_store;
for (std::size_t t=0; t<inp.size()/4; ++t) {
const auto edges =
edge_store.generate_keys(
{inp[t*4+0], inp[t*4+1], inp[t*4+2], inp[t*4+3]});
for (const auto& tetedge : edges) {
auto e = edge_store.edges.find(tetedge);
if (e != end(edge_store.edges)) {
auto& local = e->second;
if (local.lock_case == Edge_Lock_Case::unlocked)
local.needs_derefining = 1;
}
}
mark_derefinement();
}
mark_derefinement();
}


/**
* @brief For a given set of edges, set their refinement criteria for
* refinement
Expand All @@ -137,13 +146,16 @@ namespace AMR {
local.needs_refining = 1;
}
} else if (r.second == edge_tag::DEREFINE) {
if (local.lock_case == Edge_Lock_Case::unlocked) {
if (local.lock_case > Edge_Lock_Case::unlocked) {
local.needs_derefining = 0;
} else {
local.needs_derefining = 1;
}
}
}

mark_refinement();
mark_derefinement();
}

void mesh_adapter_t::mark_error_refinement_corr( const EdgeData& edges )
Expand Down Expand Up @@ -391,7 +403,7 @@ namespace AMR {
} // if num_to_refine
else {
// If we got here, we don't want to refine this guy
tet_store.marked_refinements.add(tet_id, AMR::Refinement_Case::none);
//tet_store.marked_refinements.add(tet_id, AMR::Refinement_Case::none);
}
} // if active
else {
Expand Down Expand Up @@ -426,7 +438,7 @@ namespace AMR {
*/
void mesh_adapter_t::perform_refinement()
{
// Track tets which needs to be deleted this iteration
// Track tets which need to be deleted this iteration
std::set<size_t> round_two;

trace_out << "Perform ref" << std::endl;
Expand All @@ -451,7 +463,6 @@ namespace AMR {
refiner.refine_one_to_eight(tet_store,node_connectivity,tet_id);
break;
case AMR::Refinement_Case::two_to_eight:
tet_store.get_parent_id(tet_id);
round_two.insert( tet_store.get_parent_id(tet_id) );
//std::cout << "2->8\n";
break;
Expand Down Expand Up @@ -1364,7 +1375,7 @@ namespace AMR {
// What do we do with skip?
break;
}
// Mark tet as not needing refinement
// Mark tet as not needing derefinement
tet_store.marked_derefinements.erase(tet_id);
}
}
Expand Down
33 changes: 31 additions & 2 deletions src/Inciter/AMR/refinement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace AMR {

public:

size_t MAX_REFINEMENT_LEVEL = 4;
size_t MAX_REFINEMENT_LEVEL = 10;

// TODO: Document this
child_id_list_t generate_child_ids( tet_store_t& tet_store, size_t parent_id, size_t count = MAX_CHILDREN)
Expand Down Expand Up @@ -824,8 +824,37 @@ namespace AMR {
void derefine_eight_to_two(tet_store_t& tet_store, node_connectivity_t& node_connectivity, size_t parent_id)
{
//if (!check_allowed_derefinement(tet_store,parent_id)) return;

// Figure out which edge is the one that we want to have the
// split along
size_t edge_A = 0;
size_t edge_B = 0;

// will have 5 edges set to deref, find the one that's not
child_id_list_t children = tet_store.data(parent_id).children;
for (size_t i = 0; i < children.size(); i++)
{
// TODO: Is this in element or tet ids?
edge_list_t edge_list = tet_store.generate_edge_keys(children[i]);
for (size_t k = 0; k < NUM_TET_EDGES; k++)
{
edge_t edge = edge_list[k];
if (tet_store.edge_store.get(edge).needs_derefining)
{
continue;
}
else
{
// found the non-deref
edge_A = std::min( edge.first(), edge.second() );
edge_B = std::max( edge.first(), edge.second() );
//std::cout << "A " << edge_A << " B " << edge_B << std::endl;
}
}
}

derefine_eight_to_one(tet_store, node_connectivity, parent_id);
refine_one_to_two( tet_store, node_connectivity, parent_id);
refine_one_to_two( tet_store, node_connectivity, parent_id, edge_A, edge_B );
}

// TODO: Document This.
Expand Down
Loading

0 comments on commit 9c264be

Please sign in to comment.