Skip to content

Commit ad5130e

Browse files
committed
cleaned up tidymess interface.cc
1 parent aad8ee7 commit ad5130e

1 file changed

Lines changed: 49 additions & 16 deletions

File tree

src/amuse_tidymess/interface.cc

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
#include <unordered_map>
88
#include <vector>
99

10-
#include "tidymess_worker.h"
1110
#include "Tidy.h"
1211
#include "Breakup.h"
1312
#include "Collision.h"
1413
#include "Initializer.h"
1514

16-
// AMUSE STOPPING CONDITIONS SUPPORT
15+
#include "tidymess_worker.h"
1716
#include <stopcond.h>
1817

1918

@@ -23,7 +22,6 @@ std::unique_ptr<Collision> collision;
2322
std::unique_ptr<Breakup> breakup;
2423

2524
int particle_id_counter = 0;
26-
// std::unordered_map<int, size_t> bodies_map;
2725
double begin_time = 0;
2826
int init_shape = 0;
2927
int dt_sign = 1;
@@ -116,19 +114,41 @@ int commit_particles() {
116114
return 0;
117115
}
118116

117+
/**
118+
* Recommit parameters after commit_parameters has been called
119+
*/
119120
int recommit_parameters() {
120121
commit_parameters();
121122
return 0;
122123
}
123124

125+
/**
126+
* Recommit particles after commit_particles has been called
127+
*/
124128
int recommit_particles() {
129+
if (tidymess->get_tidal_model() > 0) {
130+
switch(init_shape) {
131+
case 0:
132+
tidymess->set_to_spherical_shape();
133+
break;
134+
case 1:
135+
tidymess->set_to_equilibrium_shape();
136+
break;
137+
default:
138+
return -1;
139+
}
140+
tidymess->update_angular_momentum();
141+
142+
}
143+
tidymess->commit_parameters();
144+
tidymess->initialize();
145+
125146
return 0;
126147
}
127148

128149
/**
129-
* Define a new particle in the stellar dynamics code. The particle is
130-
* initialized with the provided mass, radius, position and velocity.
131-
* This function returns an index that can be used to refer to this particle.
150+
* Define a new particle in Tidymess. This function returns an
151+
* index that can be used to refer to this particle.
132152
*/
133153
int new_particle(
134154
int* index_of_the_particle,
@@ -735,14 +755,19 @@ int set_initial_shape(int initial_shape) {
735755
return 0;
736756
}
737757

738-
// FIX
758+
/**
759+
* Get Tidymess collision mode
760+
*/
739761
int get_collision_mode(int* collision_mode) {
740762
if (!collision_mode) return -1;
741763

742764
*collision_mode = tidymess->get_collision_mode();
743765
return 0;
744766
}
745767

768+
/**
769+
* Set Tidymess collision mode
770+
*/
746771
int set_collision_mode(int collision_mode) {
747772
tidymess->set_collision_mode(collision_mode);
748773
return 0;
@@ -751,7 +776,7 @@ int set_collision_mode(int collision_mode) {
751776
int get_roche_mode(int* roche_mode) {
752777
if (!roche_mode) return -1;
753778

754-
*roche_mode = tidymess->roche_mode; // doesn't appear in Tidy
779+
*roche_mode = tidymess->roche_mode;
755780
return 0;
756781
}
757782
int set_roche_mode(int roche_mode) {
@@ -779,11 +804,19 @@ int get_num_integration_step(int* num_integration_step) {
779804
return 0;
780805
}
781806

807+
/**
808+
* Needed to compile the interface;
809+
* not implemented yet
810+
*/
782811
int get_eps2(double* epsilon_squared) {
783812
if (!epsilon_squared) return -1;
784813
return 0;
785814
}
786815

816+
/**
817+
* Needed to compile the interface;
818+
* not implemented yet
819+
*/
787820
int set_eps2(double epsilon_squared) {
788821
return 0;
789822
}
@@ -797,6 +830,10 @@ int get_total_energy(double* total_energy) {
797830
return 0;
798831
}
799832

833+
/**
834+
* Needed to compile the interface;
835+
* not implemented yet
836+
*/
800837
int get_kinetic_energy(double* kinetic_energy) {
801838
if (!kinetic_energy) return -1;
802839
return 0;
@@ -1046,9 +1083,6 @@ int get_potential_at_point(
10461083
double* phi,
10471084
int npoints
10481085
) {
1049-
// for (int i = 0; i < npoints; i++) {
1050-
// phi[i] = 0.0;
1051-
// }
10521086
return 0;
10531087
}
10541088

@@ -1066,14 +1100,13 @@ int get_gravity_at_point(
10661100
double* az,
10671101
int npoints
10681102
) {
1069-
// for (int i = 0; i < npoints; i++) {
1070-
// ax[i] = 0.0;
1071-
// ay[i] = 0.0;
1072-
// az[i] = 0.0;
1073-
// }
10741103
return 0;
10751104
}
10761105

1106+
/**
1107+
* Needed to compile the interface;
1108+
* not implemented yet
1109+
*/
10771110
int synchronize_model() {
10781111
return 0;
10791112
}

0 commit comments

Comments
 (0)