Skip to content
Snippets Groups Projects
Commit c342db71 authored by cmaffeo2's avatar cmaffeo2
Browse files

--amend

parent 4b132126
No related branches found
No related tags found
No related merge requests found
......@@ -408,6 +408,9 @@ void Configuration::copyToCUDA() {
// TODO: The above line fails when there is not enough memory. If it fails, stop.
// TODO: what's going on here?
// pmf_h is made as a copy of *part[i].pmf, which is then asynchronously copied to Device, and
// is not deleted
// seems like bad code, but not 100% sure
for (int i = 0; i < numParts; i++) {
BaseGrid *pmf = NULL, *diffusionGrid = NULL;
BrownianParticleType *b = new BrownianParticleType(part[i]);
......
......@@ -52,8 +52,30 @@ KeyGrid RigidBodyType::createKeyGrid(String s) {
return g;
}
void RigidBodyType::addPotentialGrid(String s) {
potentialGrids.push_back( createKeyGrid(s) );
// tokenize and return
int numTokens = s.tokenCount();
if (numTokens != 2) {
printf("ERROR: could not add Grid.\n"); // TODO improve this message
exit(1);
}
String* token = new String[numTokens];
s.tokenize(token);
String key = token[0];
BaseGrid g(token[1]);
potentialGrids.push_back( g );
}
void RigidBodyType::addDensityGrid(String s) {
densityGrids.push_back( createKeyGrid(s) );
// tokenize and return
int numTokens = s.tokenCount();
if (numTokens != 2) {
printf("ERROR: could not add Grid.\n"); // TODO improve this message
exit(1);
}
String* token = new String[numTokens];
s.tokenize(token);
String key = token[0];
BaseGrid g(token[1]);
densityGrids.push_back( g );
}
......@@ -9,41 +9,47 @@
#include "useful.h"
#include "BaseGrid.h"
// Stores particle type's potential grid and other information
struct KeyGrid {
String key;
BaseGrid grid;
KeyGrid() :
key(NULL), grid() { }
};
class RigidBodyType {
private:
// Deletes all members
void clear();
// void copy(const RigidBodyType& src);
KeyGrid createKeyGrid(String s);
public:
/* RigidBodyType(const String& name = "") : */
/* name(name), num(0), */
/* reservoir(NULL), mass(1.0f), inertia(), transDamping(), */
/* rotDamping(), potentialGrids(NULL), densityGrids(NULL), */
/* potentialGrids_D(NULL), densityGrids_D(NULL) { } */
RigidBodyType(const String& name = "") :
name(name), num(0),
reservoir(NULL), mass(1.0f), inertia(), transDamping(),
rotDamping(), potentialGrids(NULL), densityGrids(NULL),
potentialGrids_D(NULL), densityGrids_D(NULL) { }
rotDamping() {
/* potentialGrids = *(new thrust::host_vector<BaseGrid>()); */
/* densityGrids = *(new thrust::host_vector<BaseGrid>()); */
/* potentialGrids = *(new thrust::host_vector<BaseGrid>()); */
/* densityGrids = *(new thrust::host_vector<BaseGrid>()); */
/* thrust::host_vector<BaseGrid> potentialGrids; */
/* thrust::host_vector<BaseGrid> densityGrids; */
/* thrust::device_vector<BaseGrid> potentialGrids_D; */
/* thrust::device_vector<BaseGrid> densityGrids_D; */
potentialGrids = thrust::host_vector<BaseGrid>();
densityGrids = thrust::host_vector<BaseGrid>();
potentialGrids = thrust::host_vector<BaseGrid>();
densityGrids = thrust::host_vector<BaseGrid>();
}
/* RigidBodyType(const RigidBodyType& src) { copy(src); } */
~RigidBodyType() { clear(); }
/* RigidBodyType& operator=(const RigidBodyType& src); */
// crop
// Crops all BaseGrid members
// @param boundries to crop to (x0, y0, z0) -> (x1, y1, z1);
// whether to change the origin
// @return success of function (if false nothing was done)
/* bool crop(int x0, int y0, int z0, int x1, int y1, int z1, bool keep_origin); */
void addPotentialGrid(String s);
void addDensityGrid(String s);
......@@ -52,17 +58,14 @@ public:
int num; // number of particles of this type
Reservoir* reservoir;
/* BaseGrid* pmf; */
float mass;
Vector3 inertia;
Vector3 transDamping;
Vector3 rotDamping;
/* std::vector<KeyGrid> potentialGrids; */
/* std::vector<KeyGrid> densityGrids; */
thrust::host_vector<KeyGrid> potentialGrids;
thrust::device_vector<KeyGrid> potentialGrids_D;
thrust::host_vector<KeyGrid> densityGrids;
thrust::device_vector<KeyGrid> densityGrids_D;
thrust::host_vector<BaseGrid> potentialGrids;
thrust::host_vector<BaseGrid> densityGrids;
thrust::device_vector<BaseGrid> potentialGrids_D;
thrust::device_vector<BaseGrid> densityGrids_D;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment