Skip to content

Commit b101c7d

Browse files
committed
improve documenation and cleanup code.
1 parent 6479d55 commit b101c7d

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

include/world_builder/world.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,24 @@ namespace WorldBuilder
9292
*
9393
* Composition is identified by 2. This produces one
9494
* value in the output. The second entry identifies the composition number and the third
95-
* number is not used. So a commposition query asking about composition 1 looks like this:
95+
* number is not used. So a composition query asking about composition 1 looks like this:
9696
* {2,1,0}. A composition query prodoces one entry in the output vector.
9797
*
98-
* Grains are identified by 2. The second entry is the grain composition number and the third
98+
* Grains are identified by 3. The second entry is the grain composition number and the third
9999
* entry is the number of grains. A query about the grains, where it asks about composition 1
100-
* (for example enstatite) and 500 grains, looks like this: {2,1,500}.
100+
* (for example enstatite) and 500 grains, looks like this: {3,1,500}.
101101
* A composition query prodoces n_grains*10 entries in the output vector. The first n_grains
102102
* entries are the sizes of all the grains, and the other 9 entries are sets of rotation
103103
* matrices. The rotation matrix entries are ordered [0][0],[0][1],[0][2],[1][0],[1][1],etc.
104+
*
105+
* The tag is identified by 4 and no extra information is needed. So the tag
106+
* input usually looks like {4,0,0}. A tag query produces one entry in the output
107+
* vector, representing the index of the tag of the last/dominant feature.
108+
*
109+
* The velocity is identified by 5 and no extra information is needed. So the tag
110+
* input usually looks like {5,0,0}. A tag query produces three entry in the output
111+
* vector, representing the x, y and z velocity, even in 2D. In 2D the velocies are
112+
* projected on the 2D plane, and the 3rd velocity element will be zero.
104113
*/
105114
std::vector<double> properties(const std::array<double, 2> &point,
106115
const double depth,
@@ -131,8 +140,13 @@ namespace WorldBuilder
131140
* matrices. The rotation matrix entries are ordered [0][0],[0][1],[0][2],[1][0],[1][1],etc.
132141
*
133142
* The tag is identified by 4 and no extra information is needed. So the tag
134-
* input usually looks like {4,0,0}. A tag query prodoces one entry in the output
143+
* input usually looks like {4,0,0}. A tag query produces one entry in the output
135144
* vector, representing the index of the tag of the last/dominant feature.
145+
*
146+
* The velocity is identified by 5 and no extra information is needed. So the tag
147+
* input usually looks like {5,0,0}. A tag query produces three entry in the output
148+
* vector, representing the x, y and z velocity, even in 2D. In 2D the velocies are
149+
* projected on the 2D plane, and the 3rd velocity element will be zero.
136150
*/
137151
std::vector<double> properties(const std::array<double, 3> &point,
138152
const double depth,

source/world_builder/world.cc

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,11 @@ namespace WorldBuilder
306306

307307
const std::array<double, 3> point_3d_cartesian = this->parameters.coordinate_system->natural_to_cartesian_coordinates(coord_3d.get_array());
308308

309-
// Todo: convert 3d velocity to 2d velocity
310309
std::vector<double> results = this->properties(point_3d_cartesian, depth, properties);
311310
unsigned int counter = 0;
312-
for (unsigned int i = 0; i < properties.size(); ++i)
311+
for (auto property : properties)
313312
{
314-
switch (properties[i][0])
313+
switch (property[0])
315314
{
316315
case 1: // temperature
317316
{
@@ -337,13 +336,8 @@ namespace WorldBuilder
337336
{
338337
// convert 3d velocity vector to a 2d one
339338
Point<2> vector = Point<2>(cartesian);
340-
//vector[0] = (results[counter]-cross_section[0][0])/surface_coord_conversions[0];
341-
//vector[1] = results[counter+2];
342339
vector[0] = surface_coord_conversions[0]*results[counter]+surface_coord_conversions[1]*results[counter+1];
343340
vector[1] = results[counter+2];
344-
//vector[2] = 0;
345-
//if(vector.norm_square() > delaunator::EPSILON)
346-
// std::cout << counter << ": case 5: vec = " << vector << ", ("<< results[counter] << ":" << results[counter+1] << ":" << results[counter+2] << ")" << ", results[counter] = " << results[counter] << ", cross_section[0][0] = " << cross_section[0][0] << ", surface_coord_conversions[0] = " << surface_coord_conversions[0] << ", 2nd: " << ", cross_section[0][1] = " << cross_section[0][1] << ", surface_coord_conversions[1] = " << surface_coord_conversions[1]<< std::endl;
347341
results[counter] = surface_coord_conversions[0]*results[counter]+surface_coord_conversions[1]*results[counter+1];
348342
results[counter+1] = results[counter+2];
349343
results[counter+2] = 0;
@@ -352,15 +346,15 @@ namespace WorldBuilder
352346
}
353347
default:
354348
{
355-
WBAssertThrow(false,
356-
"Internal error: Unimplemented property provided. " <<
357-
"Only temperature (1), composition (2), grains (3), tag (4) or velocity (5) are allowed. "
358-
"Provided property number was: " << properties[i][0]);
349+
WBAssert(false,
350+
"Internal error: Unimplemented property provided by internal process. " <<
351+
"Only temperature (1), composition (2), grains (3), tag (4) or velocity (5) are allowed. "
352+
"Provided property number was: " << property[0]);
359353
}
360354
}
361355

362356
}
363-
return results;//this->properties(point_3d_cartesian, depth, properties);
357+
return results;
364358
}
365359

366360

0 commit comments

Comments
 (0)