Skip to content

Commit

Permalink
improve documenation and cleanup code.
Browse files Browse the repository at this point in the history
  • Loading branch information
MFraters committed Oct 20, 2024
1 parent 1e3c6c2 commit 753ee18
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
22 changes: 18 additions & 4 deletions include/world_builder/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> properties(const std::array<double, 2> &point,
const double depth,
Expand Down Expand Up @@ -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<double> properties(const std::array<double, 3> &point,
const double depth,
Expand Down
20 changes: 7 additions & 13 deletions source/world_builder/world.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,11 @@ namespace WorldBuilder

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

// Todo: convert 3d velocity to 2d velocity
std::vector<double> 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
{
Expand All @@ -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;
Expand All @@ -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;
}


Expand Down

0 comments on commit 753ee18

Please sign in to comment.