Skip to content

Commit 06df9f3

Browse files
Merge pull request #149 from Geode-solutions/fix/added_queries_for_horizon_conformity
fix(HorizonsStack): Added queries to know if a stratigraphic componen…
2 parents 30ba082 + ff6ecff commit 06df9f3

6 files changed

Lines changed: 127 additions & 0 deletions

File tree

include/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ namespace geode
6363

6464
[[nodiscard]] std::optional< uuid > under( const uuid& element ) const;
6565

66+
[[nodiscard]] bool is_conformal_above( const uuid& element ) const;
67+
68+
[[nodiscard]] bool is_conformal_under( const uuid& element ) const;
69+
6670
void save_stratigraphic_relationships(
6771
std::string_view directory ) const;
6872

include/geode/geosciences/implicit/representation/core/detail/helpers.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ namespace geode
105105
const HorizonsStack< dimension >& horizon_stack,
106106
std::string_view horizon_name );
107107

108+
template < index_t dimension >
109+
[[nodiscard]] std::optional< uuid > stratigraphic_unit_id_from_name(
110+
const HorizonsStack< dimension >& horizon_stack,
111+
std::string_view unit_name );
112+
108113
[[nodiscard]] std::vector< MeshElement >
109114
opengeode_geosciences_implicit_api invalid_stratigraphic_tetrahedra(
110115
const StratigraphicModel& model );

include/geode/geosciences/implicit/representation/core/horizons_stack.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ namespace geode
169169
[[nodiscard]] bool is_baselap_of( const Horizon< dimension >& baselap,
170170
const StratigraphicUnit< dimension >& baselap_top ) const;
171171

172+
[[nodiscard]] std::string string() const;
173+
172174
public:
173175
void compute_top_and_bottom_horizons( HorizonsStackBuilderKey key );
174176

src/geode/geosciences/implicit/mixin/core/stratigraphic_relationships.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,56 @@ namespace geode
160160
return std::nullopt;
161161
}
162162

163+
bool is_conformal_above( const uuid& element ) const
164+
{
165+
const auto index_from = vertex_id( element );
166+
OPENGEODE_EXCEPTION( index_from,
167+
"[StratigraphicRelationships::Impl::is_conformal_"
168+
"above] Did not find element id in relations graph. Element "
169+
"with id ",
170+
element.string(), "probably doesn't exist." );
171+
for( const auto& edge_vertex :
172+
this->graph().edges_around_vertex( index_from.value() ) )
173+
{
174+
if( !above_relations_->value( edge_vertex.edge_id ) )
175+
{
176+
continue;
177+
}
178+
if( edge_vertex.vertex_id == UNDER_EDGE_VERTEX )
179+
{
180+
return unconformity_relations_->value( edge_vertex.edge_id )
181+
== NO_UNCONFORMITY;
182+
}
183+
}
184+
geode::Logger::debug( "Didn't find any relation leading to above" );
185+
return true;
186+
}
187+
188+
bool is_conformal_under( const uuid& element ) const
189+
{
190+
const auto index_from = vertex_id( element );
191+
OPENGEODE_EXCEPTION( index_from,
192+
"[StratigraphicRelationships::Impl::is_conformal_"
193+
"under] Did not find element id in relations graph. Element "
194+
"with id ",
195+
element.string(), "probably doesn't exist." );
196+
for( const auto& edge_vertex :
197+
this->graph().edges_around_vertex( index_from.value() ) )
198+
{
199+
if( !above_relations_->value( edge_vertex.edge_id ) )
200+
{
201+
continue;
202+
}
203+
if( edge_vertex.vertex_id == ABOVE_EDGE_VERTEX )
204+
{
205+
return unconformity_relations_->value( edge_vertex.edge_id )
206+
== NO_UNCONFORMITY;
207+
}
208+
}
209+
geode::Logger::debug( "Didn't find any relation leading to under" );
210+
return true;
211+
}
212+
163213
index_t add_above_relation(
164214
const ComponentID& above, const ComponentID& under )
165215
{
@@ -182,6 +232,9 @@ namespace geode
182232
id.value(), EROSION_RELATION );
183233
return id.value();
184234
}
235+
geode::Logger::trace( "Found no edge between erosion ",
236+
erosion.string(), " and eroded ", eroded.string(),
237+
", creating a new one" );
185238
const auto index = add_relation_edge( erosion, eroded );
186239
unconformity_relations_->set_value( index, EROSION_RELATION );
187240
return index;
@@ -197,6 +250,9 @@ namespace geode
197250
id.value(), BASELAP_RELATION );
198251
return id.value();
199252
}
253+
geode::Logger::trace( "Found no edge between baselap_top ",
254+
baselap_top.string(), " and baselap ", baselap.string(),
255+
", creating a new one" );
200256
const auto index = add_relation_edge( baselap_top, baselap );
201257
unconformity_relations_->set_value( index, BASELAP_RELATION );
202258
return index;
@@ -389,6 +445,18 @@ namespace geode
389445
return impl_->under( element );
390446
}
391447

448+
bool StratigraphicRelationships::is_conformal_above(
449+
const uuid& element ) const
450+
{
451+
return impl_->is_conformal_above( element );
452+
}
453+
454+
bool StratigraphicRelationships::is_conformal_under(
455+
const uuid& element ) const
456+
{
457+
return impl_->is_conformal_under( element );
458+
}
459+
392460
index_t StratigraphicRelationships::add_above_relation(
393461
const ComponentID& above,
394462
const ComponentID& under,

src/geode/geosciences/implicit/representation/core/detail/helpers.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,21 @@ namespace geode
386386
return std::nullopt;
387387
}
388388

389+
template < index_t dimension >
390+
std::optional< uuid > stratigraphic_unit_id_from_name(
391+
const HorizonsStack< dimension >& horizon_stack,
392+
absl::string_view unit_name )
393+
{
394+
for( const auto& unit : horizon_stack.stratigraphic_units() )
395+
{
396+
if( unit.name() == unit_name )
397+
{
398+
return unit.id();
399+
}
400+
}
401+
return std::nullopt;
402+
}
403+
389404
std::vector< MeshElement > invalid_stratigraphic_tetrahedra(
390405
const StratigraphicModel& implicit_model )
391406
{
@@ -449,5 +464,9 @@ namespace geode
449464
template std::optional< uuid >
450465
opengeode_geosciences_implicit_api horizon_id_from_name< 3 >(
451466
const HorizonsStack< 3 >&, absl::string_view );
467+
template std::optional< uuid > stratigraphic_unit_id_from_name< 2 >(
468+
const HorizonsStack< 2 >&, absl::string_view );
469+
template std::optional< uuid > stratigraphic_unit_id_from_name< 3 >(
470+
const HorizonsStack< 3 >&, absl::string_view );
452471
} // namespace detail
453472
} // namespace geode

src/geode/geosciences/implicit/representation/core/horizons_stack.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,35 @@ namespace geode
181181
baselap.id(), baselap_top.id() );
182182
}
183183

184+
template < index_t dimension >
185+
std::string HorizonsStack< dimension >::string() const
186+
{
187+
auto result = absl::StrCat(
188+
"HorizonsStack ", this->name(), " from top to bottom:" );
189+
const auto& top_unit = this->stratigraphic_unit(
190+
this->above( this->top_horizon().value() ).value() );
191+
absl::StrAppend( &result, "\n", top_unit.component_id().string(),
192+
", named ", top_unit.name() );
193+
for( const auto& horizon : this->top_to_bottom_horizons() )
194+
{
195+
if( !this->is_conformal_above( horizon.id() ) )
196+
{
197+
absl::StrAppend( &result, "\n Unconformal above" );
198+
}
199+
absl::StrAppend( &result, "\n---", horizon.component_id().string(),
200+
", named ", horizon.name() );
201+
if( !this->is_conformal_under( horizon.id() ) )
202+
{
203+
absl::StrAppend( &result, "\n Unconformal under" );
204+
}
205+
const auto& under_unit =
206+
this->stratigraphic_unit( this->under( horizon.id() ).value() );
207+
absl::StrAppend( &result, "\n", under_unit.component_id().string(),
208+
", named ", under_unit.name() );
209+
}
210+
return result;
211+
}
212+
184213
template < index_t dimension >
185214
void HorizonsStack< dimension >::compute_top_and_bottom_horizons(
186215
HorizonsStackBuilderKey /*unused*/ )

0 commit comments

Comments
 (0)