33 using namespace Utilities;
43 min_depth(NaN::
DSNAN),
48 this->
name =
"random uniform distribution deflected";
60 "Random uniform distribution grains model. The size of the grains can be independently set " 61 "to a single value or to a random distribution.");
65 "The distance from the fault center in meters from which the composition of this feature is present.");
67 "The distance from the fault in meters to which the composition of this feature is present.");
70 "A list with the integer labels of the composition which are present there.");
73 "Whether the value should replace any value previously defined at this location (replace) or " 74 "add the value to the previously define value (add, not implemented). Replacing implies that all values not " 75 "explicitly defined are set to zero.");
79 "A list of the size of all of the grains in each composition. If set to <0, the size will be randomized between 0 and 1.");
83 "A list of whether the sizes of the grains should be normalized or not. If normalized, the total of the grains of a composition will be equal to 1.");
87 "A list of the deflections of all of the grains in each composition between 0 and 1.");
90 "A list with the rotation matrices of the grains which are present there for each compositions.");
93 "A list with the z-x-z Euler angles of the grains which are present there for each compositions.");
102 min_depth = prm.
get<
double>(
"min distance fault center");
103 max_depth = prm.
get<
double>(
"max distance fault center");
106 const bool set_euler_angles = prm.
check_entry(
"basis Euler angles z-x-z");
107 const bool set_rotation_matrices = prm.
check_entry(
"basis rotation matrices");
109 WBAssertThrow(!(set_euler_angles ==
true && set_rotation_matrices ==
true),
110 "Only Euler angles or Rotation matrices may be set, but both are set for " << prm.
get_full_json_path());
113 WBAssertThrow(!(set_euler_angles ==
false && set_rotation_matrices ==
false),
114 "Euler angles or Rotation matrices have to be set, but neither are set for " << prm.
get_full_json_path());
116 if (set_euler_angles)
118 std::vector<std::array<double,3> > basis_euler_angles_vector = prm.
get_vector<std::array<double,3> >(
"basis Euler angles z-x-z");
120 for (
size_t i = 0; i<basis_euler_angles_vector.size(); ++i)
131 operation = prm.
get<std::string>(
"orientation operation");
137 "There are not the same amount of compositions (" << compositions.size()
138 <<
") and grain_sizes (" << grain_sizes.size() <<
").");
139 WBAssertThrow(compositions.size() == normalize_grain_sizes.size(),
140 "There are not the same amount of compositions (" << compositions.size()
141 <<
") and normalize_grain_sizes (" << normalize_grain_sizes.size() <<
").");
143 "There are not the same amount of compositions (" << compositions.size()
144 <<
") and deflections (" << deflections.size() <<
").");
146 "There are not the same amount of compositions (" << compositions.size()
153 const unsigned int composition_number,
167 std::uniform_real_distribution<> dist(0.0,1.0);
191 const double z = 2.0* three * deflections[i];
199 const double r = std::sqrt( z );
200 const double Vx =
std::sin( phi ) * r;
201 const double Vy =
std::cos( phi ) * r;
202 const double Vz = std::sqrt( 2.F - z );
208 const double st =
std::sin( theta );
209 const double ct =
std::cos( theta );
210 const double Sx = Vx * ct - Vy * st;
211 const double Sy = Vx * st + Vy * ct;
216 std::array<std::array<double,3>,3> rotation_matrices;
217 rotation_matrices[0][0] = (Vx * Sx - ct);
218 rotation_matrices[0][1] = (Vx * Sy - st);
219 rotation_matrices[0][2] = Vx * Vz;
221 rotation_matrices[1][0] = (Vy * Sx + st);
222 rotation_matrices[1][1] = (Vy * Sy - ct);
223 rotation_matrices[1][2] = Vy * Vz;
225 rotation_matrices[2][0] = Vz * Sx;
226 rotation_matrices[2][1] = Vz * Sy;
227 rotation_matrices[2][2] = 1.0 - z;
231 std::array<std::array<double, 3>, 3> rot_T= rotation_matrices;
232 rot_T[0][1] = rotation_matrices[1][0];
233 rot_T[1][0] = rotation_matrices[0][1];
234 rot_T[1][2] = rotation_matrices[2][1];
235 rot_T[2][1] = rotation_matrices[1][2];
236 rot_T[0][2] = rotation_matrices[2][0];
237 rot_T[2][0] = rotation_matrices[0][2];
242 it_rotation_matrices = result1;
245 double total_size = 0;
246 for (
auto &&it_sizes : grains_local.
sizes)
249 total_size += it_sizes;
254 const double one_over_total_size = 1/total_size;
260 for (
auto &&size : grains_local.
sizes)
262 size = size*one_over_total_size;
bool check_entry(const std::string &name) const
std::array< std::array< double, 3 >, 3 > multiply_3x3_matrices(const std::array< std::array< double, 3 >, 3 > mat1, const std::array< std::array< double, 3 >, 3 > mat2)
std::mt19937 & get_random_number_engine()
std::vector< double > sizes
WorldBuilder::World * world
std::string get_full_json_path(size_t max_size=std::numeric_limits< size_t >::max()) const
#define WB_REGISTER_FEATURE_FAULT_GRAINS_MODEL(classname, name)
double cos(const double angle)
double distance_from_plane
#define WBAssertThrow(condition, message)
std::array< std::array< double, 3 >, 3 > euler_angles_to_rotation_matrix(double phi1_d, double theta_d, double phi2_d)
double sin(const double raw_angle)
std::vector< std::array< std::array< double, 3 >, 3 > > rotation_matrices
void declare_entry(const std::string &name, const Types::Interface &type, const std::string &documentation)
std::vector< T > get_vector(const std::string &name)
T get(const std::string &name)