diff --git a/include/world_builder/world.h b/include/world_builder/world.h index 0627eb60d..85f0a6155 100644 --- a/include/world_builder/world.h +++ b/include/world_builder/world.h @@ -92,15 +92,24 @@ namespace WorldBuilder * * Composition is identified by 2. This produces one * value in the output. The second entry identifies the composition number and the third - * number is not used. So a commposition query asking about composition 1 looks like this: + * number is not used. So a composition query asking about composition 1 looks like this: * {2,1,0}. A composition query prodoces one entry in the output vector. * - * Grains are identified by 2. The second entry is the grain composition number and the third + * Grains are identified by 3. The second entry is the grain composition number and the third * entry is the number of grains. A query about the grains, where it asks about composition 1 - * (for example enstatite) and 500 grains, looks like this: {2,1,500}. + * (for example enstatite) and 500 grains, looks like this: {3,1,500}. * A composition query prodoces n_grains*10 entries in the output vector. The first n_grains * entries are the sizes of all the grains, and the other 9 entries are sets of rotation * matrices. The rotation matrix entries are ordered [0][0],[0][1],[0][2],[1][0],[1][1],etc. + * + * The tag is identified by 4 and no extra information is needed. So the tag + * input usually looks like {4,0,0}. A tag query produces one entry in the output + * vector, representing the index of the tag of the last/dominant feature. + * + * The velocity is identified by 5 and no extra information is needed. So the tag + * input usually looks like {5,0,0}. A tag query produces three entry in the output + * vector, representing the x, y and z velocity, even in 2D. In 2D the velocies are + * projected on the 2D plane, and the 3rd velocity element will be zero. */ std::vector properties(const std::array &point, const double depth, @@ -131,8 +140,13 @@ namespace WorldBuilder * matrices. The rotation matrix entries are ordered [0][0],[0][1],[0][2],[1][0],[1][1],etc. * * The tag is identified by 4 and no extra information is needed. So the tag - * input usually looks like {4,0,0}. A tag query prodoces one entry in the output + * input usually looks like {4,0,0}. A tag query produces one entry in the output * vector, representing the index of the tag of the last/dominant feature. + * + * The velocity is identified by 5 and no extra information is needed. So the tag + * input usually looks like {5,0,0}. A tag query produces three entry in the output + * vector, representing the x, y and z velocity, even in 2D. In 2D the velocies are + * projected on the 2D plane, and the 3rd velocity element will be zero. */ std::vector properties(const std::array &point, const double depth, diff --git a/source/world_builder/world.cc b/source/world_builder/world.cc index 3fa7b6d30..910b8973e 100644 --- a/source/world_builder/world.cc +++ b/source/world_builder/world.cc @@ -306,12 +306,11 @@ namespace WorldBuilder const std::array point_3d_cartesian = this->parameters.coordinate_system->natural_to_cartesian_coordinates(coord_3d.get_array()); - // Todo: convert 3d velocity to 2d velocity std::vector results = this->properties(point_3d_cartesian, depth, properties); unsigned int counter = 0; - for (unsigned int i = 0; i < properties.size(); ++i) + for (auto property : properties) { - switch (properties[i][0]) + switch (property[0]) { case 1: // temperature { @@ -337,13 +336,8 @@ namespace WorldBuilder { // convert 3d velocity vector to a 2d one Point<2> vector = Point<2>(cartesian); - //vector[0] = (results[counter]-cross_section[0][0])/surface_coord_conversions[0]; - //vector[1] = results[counter+2]; vector[0] = surface_coord_conversions[0]*results[counter]+surface_coord_conversions[1]*results[counter+1]; vector[1] = results[counter+2]; - //vector[2] = 0; - //if(vector.norm_square() > delaunator::EPSILON) - // 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; results[counter] = surface_coord_conversions[0]*results[counter]+surface_coord_conversions[1]*results[counter+1]; results[counter+1] = results[counter+2]; results[counter+2] = 0; @@ -352,15 +346,15 @@ namespace WorldBuilder } default: { - WBAssertThrow(false, - "Internal error: Unimplemented property provided. " << - "Only temperature (1), composition (2), grains (3), tag (4) or velocity (5) are allowed. " - "Provided property number was: " << properties[i][0]); + WBAssert(false, + "Internal error: Unimplemented property provided by internal process. " << + "Only temperature (1), composition (2), grains (3), tag (4) or velocity (5) are allowed. " + "Provided property number was: " << property[0]); } } } - return results;//this->properties(point_3d_cartesian, depth, properties); + return results; }