Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ namespace geode
module, "FractureSimulationRunner" )
.def( pybind11::init< const SpatialDomain< 2 >& >(),
pybind11::arg( "box" ) )
.def( "add_x_node_monitoring",
&FractureSimulationRunner::add_x_node_monitoring,
pybind11::arg( "double" ),
"Add a monitoring value for x node, value should be "
"in[0.,1.]." )
.def( "add_fracture_set_descriptor",
&FractureSimulationRunner::add_fracture_set_descriptor,
pybind11::arg( "descriptor" ),
Expand All @@ -71,6 +76,9 @@ namespace geode
&FractureSimulationRunner::check_statistics,
pybind11::arg( "statistic_monitoring" ),
"Check computed statistics after simulation." )
.def( "string", &FractureSimulationRunner::string,
"Return a detailed description of the simulation "
"configurator." )
// Explicit overload bindings
// .def( "run",
// static_cast< const ObjectSets< OwnerSegment2D >& (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace geode
.def_readwrite( "printer", &SimulationConfigurator::printer,
"Optional SimulationPrinter for output" )
.def( "string", &SimulationConfigurator::string,
"Return a detailed description of the simulation configurator" )
"Return a detailed description of the object set simulation "
"configurator" )
.def( "__repr__", []( const SimulationConfigurator& self ) {
return "<SimulationConfigurator realizations="
+ std::to_string( self.realizations ) + ">";
Expand Down
1 change: 1 addition & 0 deletions bindings/python/tests/stochastic/test-py-mh-fractures.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def test_two_fracture_sets_simulator():
runner = stochastic.FractureSimulationRunner(domain)
runner.add_fracture_set_descriptor(setA)
runner.add_fracture_set_descriptor(setB)
runner.add_x_node_monitoring(0.3)
runner.initialize()

printer_config = stochastic.SimulationPrinterConfigurator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ namespace geode
std::string string() const
{
auto message = absl::StrCat( "FractureSetDescription: ", name );
for( const auto& fixed_object : observed_fractures )
{
absl::StrAppend( &message,
"\n\t --> observation (x,y,z)start: ",
fixed_object[0].string(),
" (x,y,z)end: ", fixed_object[1].string() );
}
absl::StrAppend(
&message, "\n\t --> length distribution: ", length.string() );
absl::StrAppend(
Expand All @@ -81,6 +88,13 @@ namespace geode
{
}

void add_x_node_monitoring( double beta_x_node )
{
OPENGEODE_EXCEPTION( beta_x_node <= 1.0 && beta_x_node >= 0.,
"[FractureSimulationRunner] x node should be inhibitated, "
"please provise a value in [0., 1.]." );
beta_x_node_ = beta_x_node;
}
void add_fracture_set_descriptor(
const FractureSetDescription& descriptor )
{
Expand Down Expand Up @@ -134,23 +148,43 @@ namespace geode
set_desc.p20, std::vector< uuid >{ set_id },
this->domain_ ) ) );
// spacing
if( set_desc.minimal_spacing < GLOBAL_EPSILON )
if( set_desc.minimal_spacing > GLOBAL_EPSILON )
{
continue;
auto interaction = std::make_unique<
EuclideanCutoffInteraction< OwnerSegment2D > >(
set_desc.minimal_spacing,
PairwiseInteraction<
OwnerSegment2D >::SCOPE::same_set );

this->ordered_energy_terms_.push_back(
this->energy_terms_collection_.add_energy_term(
std::make_unique< PairwiseTerm< OwnerSegment2D > >(
absl::StrCat( set_desc.name, "_min_spacing" ),
0., std::vector< uuid >{ set_id },
std::move( interaction ), this->domain_ ) ) );
}
}
// x node monitoring
if( std::fabs( beta_x_node_ - 1. ) > GLOBAL_EPSILON )
{
std::vector< uuid > set_uuids;
set_uuids.reserve( name_to_uuid.size() );
for( const auto& [name, id] : name_to_uuid )
{
set_uuids.push_back( id );
}
auto interaction = std::make_unique<
EuclideanCutoffInteraction< OwnerSegment2D > >(
set_desc.minimal_spacing,
PairwiseInteraction< OwnerSegment2D >::SCOPE::same_set );
0., PairwiseInteraction<
OwnerSegment2D >::SCOPE::different_set );

this->ordered_energy_terms_.push_back(
this->energy_terms_collection_.add_energy_term(
std::make_unique< PairwiseTerm< OwnerSegment2D > >(
absl::StrCat( set_desc.name, "_min_spacing" ), 0.,
std::vector< uuid >{ set_id },
std::move( interaction ), this->domain_ ) ) );
absl::StrCat( "inter_set_x_nodes" ), beta_x_node_,
set_uuids, std::move( interaction ),
this->domain_ ) ) );
}

this->mh_sampler_ =
std::make_unique< MetropolisHastings< OwnerSegment2D > >(
this->energy_terms_collection_,
Expand All @@ -173,8 +207,32 @@ namespace geode
}
}

std::string string() const
{
auto message =
absl::StrCat( "Fracture Simulation Runner description" );
for( const auto& desc : set_descriptors_ )
{
absl::StrAppend( &message, "\n\t ", desc.string() );
}
if( std::fabs( beta_x_node_ - 1. ) > GLOBAL_EPSILON )
{
absl::StrAppend( &message,
"\n\t --> x node monitioring (beta inhibition value): ",
beta_x_node_ );
}
else
{
absl::StrAppend(
&message, "\n\t --> x node monitioring : no inhibition." );
}
return message;
}

private:
std::vector< FractureSetDescription > set_descriptors_;
// x node monitoring
double beta_x_node_{ 1. };
};

} // namespace geode
1 change: 1 addition & 0 deletions tests/stochastic/sampling/mcmc/test-mh-fractures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ namespace
geode::FractureSimulationRunner runner( domain );
runner.add_fracture_set_descriptor( setA );
runner.add_fracture_set_descriptor( setB );
runner.add_x_node_monitoring( 0.3 );

runner.initialize();

Expand Down