Skip to content

Commit

Permalink
fixed bug in SBGATPolyhedronGravityModel.cpp impacting km-based shapes
Browse files Browse the repository at this point in the history
  • Loading branch information
bbercovici committed Jan 11, 2019
1 parent 6133376 commit bb41d03
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ to apply the update (if any).
- The `Set Shape Mapper` option was renamed to `Set Results Overlay`
- Several GUI minors bug fixes

### Bug fixes:
- Fixed bug in `SbgatCore` that was due to an unecessary rescaling of the computed potentials and accelerations within `SbgatCore::ComputeSurfacePGM`. This bug was manifesting itself when calling `SbgatCore::ComputeSurfacePGM` with a shape model whose coordinates were expressed in kilometers. This bug was not affecting `SbgatGui` since it automatically rescales input shapes to meters upon loading.


### [SBGAT 1.12.2](https://github.com/bbercovici/SBGAT/releases/tag/1.12.2)

### New:
Expand Down
4 changes: 0 additions & 4 deletions SbgatCore/include/SbgatCore/SBGATPolyhedronGravityModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
void GetPotentialAcceleration(double const * point,double & potential,
arma::vec::fixed<3> & acc) const;


/**
Evaluates the Polyhedron Gravity Model potential and acceleration at the specified point assuming
a constant density
Expand All @@ -104,8 +103,6 @@ class VTKFILTERSCORE_EXPORT SBGATPolyhedronGravityModel : public vtkPolyDataAlgo
arma::vec::fixed<3> & acc) const;




/**
Evaluates the Polyhedron Gravity Model potential, acceleration and gravity gradient matrix at the specified point assuming
a constant density
Expand All @@ -119,7 +116,6 @@ the polydata used to construct the PGM
arma::vec::fixed<3> & acc,arma::mat::fixed<3,3> & gravity_gradient_mat) const ;



/**
Evaluates the Polyhedron Gravity Model potential, acceleration and gravity gradient matrix at the specified point assuming
a constant density
Expand Down
12 changes: 0 additions & 12 deletions SbgatCore/source/SBGATPolyhedronGravityModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@ void SBGATPolyhedronGravityModel::ComputeSurfacePGM(
vtkSmartPointer<SBGATPolyhedronGravityModel> pgm_filter = vtkSmartPointer<SBGATPolyhedronGravityModel>::New();
pgm_filter -> SetInputData(selected_shape);
pgm_filter -> SetDensity(density);
double scale_factor;

slopes.clear();
inertial_potentials.clear();
Expand All @@ -909,12 +908,9 @@ void SBGATPolyhedronGravityModel::ComputeSurfacePGM(

if (is_in_meters){
pgm_filter -> SetScaleMeters();
scale_factor = 1 ;
}
else{
pgm_filter -> SetScaleKiloMeters();
scale_factor = 1000;

}

pgm_filter -> Update();
Expand Down Expand Up @@ -952,11 +948,6 @@ void SBGATPolyhedronGravityModel::ComputeSurfacePGM(
pgm_filter -> GetPotentialAcceleration(facet_center,potential,acc);
acc_body_fixed = acc - arma::cross(omega,arma::cross(omega,facet_center));

// Scaling
acc_body_fixed /= scale_factor;
acc /= scale_factor;
potential /= std::pow(scale_factor,2);

slope = std::acos(arma::dot(-arma::normalise(acc_body_fixed),normal)) * 180./arma::datum::pi;

slopes[cellId] = slope;
Expand All @@ -969,8 +960,6 @@ void SBGATPolyhedronGravityModel::ComputeSurfacePGM(

}



void SBGATPolyhedronGravityModel::SaveSurfacePGM(vtkSmartPointer<vtkPolyData> selected_shape,
const std::vector<unsigned int> & queried_elements,
bool is_in_meters,
Expand Down Expand Up @@ -1166,7 +1155,6 @@ void SBGATPolyhedronGravityModel::LoadSurfacePGM(double & mass,

std::cout << "Done with slopes_json\n ";


nlohmann::json inertial_potentials_json;
try{
inertial_potentials_json = surface_pgm_json.at("inertial_potentials");
Expand Down
1 change: 0 additions & 1 deletion SbgatGui/source/Mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ void Mainwindow::createActions() {
connect(this -> open_select_mapper_window_action, &QAction::triggered, this, &Mainwindow::open_select_mapper_window);



}


Expand Down
4 changes: 2 additions & 2 deletions Tests/source/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ void TestsSBCore::test_sbgat_pgm_speed(){
std::cout << "-- Done computing pgm accelerations in " << elapsed_seconds.count() << " s\n";



// The surface acceleration are re-calculated, this time using the static method SBGATPolyhedronGravityModel::ComputeSurfacePGM
// that will also evaluate the inertial potential and geopotential in the process
std::vector<unsigned int> queried_elements;
for (int i = 0; i < polydata -> GetNumberOfCells(); ++i){
queried_elements.push_back(i);
Expand Down Expand Up @@ -403,7 +404,6 @@ void TestsSBCore::test_spherical_harmonics_coefs_consistency() {
spherical_harmonics -> Update();



// The spherical harmonics are saved to a file
spherical_harmonics -> SaveToJson("../gravity_output/harmo.json");

Expand Down

0 comments on commit bb41d03

Please sign in to comment.