1+ /*
2+ * Copyright (c) 2019 - 2026 Geode-solutions
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5+ * of this software and associated documentation files (the "Software"), to deal
6+ * in the Software without restriction, including without limitation the rights
7+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+ * copies of the Software, and to permit persons to whom the Software is
9+ * furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+ * SOFTWARE.
21+ *
22+ */
23+ #pragma once
24+
25+ #include " ../../common.hpp"
26+ #include < geode/stochastic/applications/fractures.hpp>
27+
28+ namespace geode
29+ {
30+ void define_fracture_network_description ( pybind11::module & module )
31+ {
32+ pybind11::class_< FractureSamplerConfig >( module ,
33+ " FractureSamplerConfig" ,
34+ " Configuration of the stochastic fracture sampler." )
35+ .def ( pybind11::init<>() )
36+ .def_readwrite ( " move_ratio" , &FractureSamplerConfig::move_ratio,
37+ " Relative probability of proposing a change move." )
38+ .def_readwrite ( " length" , &FractureSamplerConfig::length,
39+ " Distribution used to sample fracture lengths." )
40+ .def_readwrite ( " azimuth" , &FractureSamplerConfig::azimuth,
41+ " Distribution used to sample fracture orientations." );
42+
43+ pybind11::class_< FractureSetDescription >( module ,
44+ " FractureSetDescription" , " Description of a fracture family." )
45+ .def ( pybind11::init<>() )
46+
47+ .def_readwrite ( " name" , &FractureSetDescription::fset_name,
48+ " Name of the fracture set." )
49+
50+ .def_readwrite ( " sampler" , &FractureSetDescription::sampler,
51+ " Sampling configuration used to generate fractures." )
52+
53+ .def_readwrite ( " birth_ratio" , &FractureSetDescription::birth_ratio,
54+ " Relative probability of birth moves." )
55+
56+ .def_readwrite ( " death_ratio" , &FractureSetDescription::death_ratio,
57+ " Relative probability of death moves." )
58+
59+ .def_readwrite ( " change_ratio" ,
60+ &FractureSetDescription::change_ratio,
61+ " Relative probability of change moves." )
62+
63+ .def_readwrite ( " p20" , &FractureSetDescription::p20,
64+ " Target fracture density (number of fractures per unit area)." )
65+
66+ .def_readwrite ( " expected_number" ,
67+ &FractureSetDescription::expected_number,
68+ " Expected number of fractures, if monitored." )
69+
70+ .def_readwrite ( " p21" , &FractureSetDescription::p21,
71+ " Target fracture intensity (total fracture length per unit "
72+ " area)." )
73+
74+ .def_readwrite ( " expected_total_length" ,
75+ &FractureSetDescription::expected_total_length,
76+ " Expected cumulative fracture length, if monitored." )
77+
78+ .def (
79+ " add_observed_fracture" ,
80+ []( FractureSetDescription& self, const geode::Point2D& start,
81+ const geode::Point2D& end ) {
82+ self.observed_fractures .push_back ( { start, end } );
83+ },
84+ " Add a fixed observed fracture defined by two endpoints." )
85+
86+ .def_readwrite ( " minimal_spacing" ,
87+ &FractureSetDescription::minimal_spacing,
88+ " Minimum allowed spacing between fractures." )
89+
90+ .def ( " string" , &FractureSetDescription::string,
91+ " Return a detailed textual description of the fracture set." )
92+
93+ .def ( " __repr__" , []( const FractureSetDescription& self ) {
94+ return " <FractureSetDescription name='" + self.fset_name + " '>" ;
95+ } );
96+
97+ pybind11::class_< FractureNetworkDescription >( module ,
98+ " FractureNetworkDescription" ,
99+ " Description of a complete fracture network simulation." )
100+
101+ .def ( pybind11::init<>() )
102+
103+ .def_readwrite ( " name" , &FractureNetworkDescription::fnet_name,
104+ " Name of the fracture network." )
105+
106+ .def_readwrite ( " domain" , &FractureNetworkDescription::domain,
107+ " Spatial simulation domain." )
108+
109+ .def_readwrite ( " fracture_sets" ,
110+ &FractureNetworkDescription::fracture_sets,
111+ " List of fracture sets composing the network." )
112+
113+ .def ( " add_fracture_set" ,
114+ &FractureNetworkDescription::add_fracture_set,
115+ pybind11::return_value_policy::reference_internal,
116+ " Create and return a new fracture set." )
117+
118+ .def ( " add_x_node_monitoring" ,
119+ &FractureNetworkDescription::add_x_node_monitoring,
120+ pybind11::arg ( " beta" ),
121+ " Enable monitoring of X-node interactions with the given "
122+ " weight." )
123+
124+ .def_readwrite ( " expected_x_node" ,
125+ &FractureNetworkDescription::expected_x_node,
126+ " Expected number of X-nodes, if monitored." )
127+
128+ .def ( " string" , &FractureNetworkDescription::string,
129+ " Return a detailed textual description of the network." )
130+
131+ .def ( " __repr__" , []( const FractureNetworkDescription& self ) {
132+ return " <FractureNetworkDescription name='" + self.fnet_name
133+ + " '>" ;
134+ } );
135+
136+ // module.def( "build_fractures_simulation_context",
137+ // &build_fractures_simulation_context, pybind11::arg(
138+ // "description" ), "Build a simulation context from a
139+ // fracture network description." );
140+ //
141+ // module.def( "build_fractures_targeted_stat",
142+ // &build_fractures_targeted_stat, pybind11::arg(
143+ // "description" ), "Create the target statistics associated
144+ // with a fracture network " "description." );
145+
146+ module .def ( " build_fractures_simulation_runner" ,
147+ &build_fractures_simulation_runner, pybind11::arg ( " description" ),
148+ " Create a ready-to-use simulation runner from a fracture network "
149+ " description." );
150+ }
151+
152+ } // namespace geode
0 commit comments