Commit 4386f59a authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

remove a few camelCase functions

parent 735f43a0
Pipeline #9334 failed with stages
in 2 minutes and 21 seconds
......@@ -341,7 +341,7 @@ class ParticleProblem :
"""
n_nodes = len(nodes[:,0])
s = np.ndarray((n_nodes,self._dim**2))
self._lib.particleProblemComputeStressTensor(self._p,_np2c(nodes[:,:self._dim]),c_double(radius),c_int(n_nodes),_np2c(s))
self._lib.particle_problem_compute_stress_tensor(self._p,_np2c(nodes[:,:self._dim]),c_double(radius),c_int(n_nodes),_np2c(s))
return s
def write_vtk(self, odir, i, t) :
......@@ -629,7 +629,7 @@ class ParticleProblem :
def set_use_queue(self, use_queue=1):
"""Enables the use of the queue if 1 and disables it if 0."""
self._lib.particleProblemSetUseQueue(self._p, c_int(use_queue))
self._lib.particle_problem_set_use_queue(self._p, c_int(use_queue))
def _save_contacts(self):
"""Saves the contacts from the current time step."""
......@@ -645,7 +645,7 @@ class ParticleProblem :
"""Removes particles based on given flag."""
if flag.shape != (self.n_particles(),) :
raise NameError("size of flag array should be the number of particles")
self._lib.particleProblemRemoveBodies(self._p, _np2c(flag,np.int32))
self._lib.particle_roblem_remove_bodies(self._p, _np2c(flag,np.int32))
def load_msh_boundaries(self, filename, tags=None, shift=None,material="default") :
......
......@@ -150,13 +150,13 @@ static double dot(const double *x, const double *y) {
}
/* Particle */
static void particleBoundingBox(const Particle *p, const double x[DIMENSION], double pmin[DIMENSION], double pmax[DIMENSION]){
static void particle_bounding_box(const Particle *p, const double x[DIMENSION], double pmin[DIMENSION], double pmax[DIMENSION]){
for (int i = 0; i < DIMENSION; ++i) {
pmin[i] = x[i] - p->r;
pmax[i] = x[i] + p->r;
}
}
static double particleProblemGetMu(const ParticleProblem *p, int mat0, int mat1) {
static double particle_problem_get_mu(const ParticleProblem *p, int mat0, int mat1) {
return p->mu[mat0*p->n_material+mat1];
}
static void _cross (const double *a, const double *b, double *c) {
......@@ -278,7 +278,7 @@ static int contact_init_particle_particle(Contact *c, const ParticleProblem *p,
return D < alert;
}
static void diskBoundingBox(const Disk *d, double *pmin, double *pmax) {
static void disk_bounding_box(const Disk *d, double *pmin, double *pmax) {
const double r = fabs(d->r);
for (int i = 0; i < DIMENSION; ++i) {
pmin[i] = d->x[i] - r;
......@@ -339,7 +339,7 @@ static int contact_init_disk_particle(Contact *c, ParticleProblem *p, size_t dis
return D < alert;
}
static void periodicSegmentBoundingBox(const PeriodicSegment *s, double *pmin, double *pmax) {
static void periodic_segment_bounding_box(const PeriodicSegment *s, double *pmin, double *pmax) {
for (int i = 0; i < DIMENSION; ++i) {
pmin[i] = fmin(s->p[0][i], s->p[1][i]);
pmax[i] = fmax(s->p[0][i], s->p[1][i]);
......@@ -354,7 +354,7 @@ static void coordAdd(double *x, double a, const double *y) {
#endif
}
static void segmentBoundingBox(const Segment *s, double *pmin, double *pmax) {
static void segment_bounding_box(const Segment *s, double *pmin, double *pmax) {
for (int i = 0; i < DIMENSION; ++i) {
pmin[i] = fmin(s->p[0][i], s->p[1][i]);
pmax[i] = fmax(s->p[0][i], s->p[1][i]);
......@@ -426,7 +426,7 @@ void particle_problem_add_boundary_triangle(ParticleProblem *p, const double x0[
}
}
size_t particleProblemAddBoundaryPeriodicTriangle(ParticleProblem *p, const double x0[DIMENSION], const double x1[DIMENSION], const double x2[DIMENSION], const int etag){
size_t particle_problem_add_boundary_periodic_triangle(ParticleProblem *p, const double x0[DIMENSION], const double x1[DIMENSION], const double x2[DIMENSION], const int etag){
PeriodicTriangle *t = vectorPush(&p->periodicTriangles);
t->entity_id = -1;
for(size_t ie = 0; ie < vectorSize(p->periodicEntities); ++ie){
......@@ -445,7 +445,7 @@ size_t particleProblemAddBoundaryPeriodicTriangle(ParticleProblem *p, const dou
return vectorSize(p->periodicTriangles) - 1;
}
static void periodicTriangleBoundingBox(const PeriodicTriangle *t, double *pmin, double *pmax) {
static void periodic_triangle_bounding_box(const PeriodicTriangle *t, double *pmin, double *pmax) {
for (int i = 0; i < 3; ++i) {
pmin[i] = fmin(fmin(t->p[0][i], t->p[1][i]), t->p[2][i]);
pmax[i] = fmax(fmax(t->p[0][i], t->p[1][i]), t->p[2][i]);
......@@ -453,7 +453,7 @@ static void periodicTriangleBoundingBox(const PeriodicTriangle *t, double *pmin,
}
static void triangleBoundingBox(const Triangle *t, double *pmin, double *pmax) {
static void triangle_bounding_box(const Triangle *t, double *pmin, double *pmax) {
for (int i = 0; i < 3; ++i) {
pmin[i] = fmin(fmin(t->p[0][i], t->p[1][i]), t->p[2][i]);
pmax[i] = fmax(fmax(t->p[0][i], t->p[1][i]), t->p[2][i]);
......@@ -622,7 +622,7 @@ static void bbadd(double *amin, double *amax, const double *bmin, const double *
}
}
static void _particleProblemBoundingBox(ParticleProblem *p, double *bbmin, double *bbmax) {
static void particle_problem_bounding_box(ParticleProblem *p, double *bbmin, double *bbmax) {
double amin[DIMENSION], amax[DIMENSION];
for (int i = 0; i < DIMENSION; ++i) {
bbmin[i] = DBL_MAX;
......@@ -631,28 +631,28 @@ static void _particleProblemBoundingBox(ParticleProblem *p, double *bbmin, doubl
for (size_t i = 0; i < vectorSize(p->particles); ++i) {
double position[DIMENSION];
particle_get_position(p, &p->particles[i], position);
particleBoundingBox(&p->particles[i], position, amin, amax);
particle_bounding_box(&p->particles[i], position, amin, amax);
bbadd(bbmin, bbmax, amin, amax);
}
for (size_t i = 0; i < vectorSize(p->disks); ++i) {
diskBoundingBox(&p->disks[i], amin, amax);
disk_bounding_box(&p->disks[i], amin, amax);
bbadd(bbmin, bbmax, amin, amax);
}
for (size_t i = 0; i < vectorSize(p->segments); ++i) {
segmentBoundingBox(&p->segments[i], amin, amax);
segment_bounding_box(&p->segments[i], amin, amax);
bbadd(bbmin, bbmax, amin, amax);
}
for(size_t i = 0; i < vectorSize(p->periodicSegments); ++i){
periodicSegmentBoundingBox(&p->periodicSegments[i], amin, amax);
periodic_segment_bounding_box(&p->periodicSegments[i], amin, amax);
bbadd(bbmin, bbmax, amin, amax);
}
#if DIMENSION == 3
for (size_t i = 0; i < vectorSize(p->triangles); ++i) {
triangleBoundingBox(&p->triangles[i], amin, amax);
triangle_bounding_box(&p->triangles[i], amin, amax);
bbadd(bbmin, bbmax, amin, amax);
}
for(size_t i = 0; i < vectorSize(p->periodicTriangles); ++i){
periodicTriangleBoundingBox(&p->periodicTriangles[i], amin, amax);
periodic_triangle_bounding_box(&p->periodicTriangles[i], amin, amax);
bbadd(bbmin, bbmax, amin, amax);
}
#endif
......@@ -674,7 +674,7 @@ typedef struct {
ContactTree *contact_tree_create(ParticleProblem *p, double alert) {
double bbmin[DIMENSION], bbmax[DIMENSION];
_particleProblemBoundingBox(p, bbmin, bbmax);
particle_problem_bounding_box(p, bbmin, bbmax);
ContactTree *tree = malloc(sizeof(ContactTree));
tree->tree = cellNew(bbmin, bbmax);
tree->tmp0 = NULL;
......@@ -710,7 +710,7 @@ void contact_tree_add_periodic_segment(ContactTree *tree, PeriodicSegment *segme
}
*vectorPush(&tree->periodic_tag) = segment->entity_id;
double amin[DIMENSION], amax[DIMENSION];
periodicSegmentBoundingBox(segment, amin, amax);
periodic_segment_bounding_box(segment, amin, amax);
addAlert(tree->alert/2, amin, amax);
cellAdd(tree->tree, amin, amax, i, NULL);
}
......@@ -724,7 +724,7 @@ void contact_tree_add_periodic_triangle(ContactTree *tree, PeriodicTriangle *tri
}
*vectorPush(&tree->periodic_tag) = triangle->entity_id;
double amin[DIMENSION], amax[DIMENSION];
periodicTriangleBoundingBox(triangle, amin, amax);
periodic_triangle_bounding_box(triangle, amin, amax);
addAlert(tree->alert/2, amin, amax);
cellAdd(tree->tree, amin, amax, i, NULL);
}
......@@ -739,7 +739,7 @@ void contact_tree_add_ghost_particle(ContactTree *tree, int id, const double *tr
*vectorPush(&tree->ghost_position) = tree->problem->particles[id].x[d]+translation[d];
}
double amin[DIMENSION], amax[DIMENSION];
particleBoundingBox(&tree->problem->particles[id], tree->ghost_position+vectorSize(tree->ghost_position)-DIMENSION, amin, amax);
particle_bounding_box(&tree->problem->particles[id], tree->ghost_position+vectorSize(tree->ghost_position)-DIMENSION, amin, amax);
addAlert(tree->alert/2, amin, amax);
cellAdd(tree->tree, amin, amax, i, NULL);
}
......@@ -770,7 +770,7 @@ void contact_tree_add_particle(ContactTree *tree, int id, const Contact *old_con
double amin[DIMENSION], amax[DIMENSION];
double position[DIMENSION];
particle_get_position(p, &p->particles[id], position);
particleBoundingBox(&p->particles[id], position, amin, amax);
particle_bounding_box(&p->particles[id], position, amin, amax);
addAlert(tree->alert/2, amin, amax);
vectorClear(tree->tmp0);
cellAdd(tree->tree, amin, amax, i, &tree->tmp0);
......@@ -810,12 +810,12 @@ static void contact_tree_gen_boundary_contact(ContactTree *tree, ContactType typ
double amin[DIMENSION], amax[DIMENSION];
ParticleProblem *p = tree->problem;
if (type == PARTICLE_DISK)
diskBoundingBox(&p->disks[id], amin, amax);
disk_bounding_box(&p->disks[id], amin, amax);
else if (type == PARTICLE_SEGMENT)
segmentBoundingBox(&p->segments[id], amin, amax);
segment_bounding_box(&p->segments[id], amin, amax);
#if DIMENSION == 3
else if (type == PARTICLE_TRIANGLE)
triangleBoundingBox(&p->triangles[id], amin, amax);
triangle_bounding_box(&p->triangles[id], amin, amax);
#endif
else printf("invalid type !!!!\n");
addAlert(tree->alert/2, amin, amax);
......@@ -903,28 +903,28 @@ typedef struct {
size_t size;
}Fifo;
static Fifo *fifoNew(size_t maxSize) {
static Fifo *fifo_new(size_t maxSize) {
Fifo *f = malloc(sizeof(Fifo));
f->b = f->e = f->data = malloc(sizeof(size_t)*(maxSize+1));
f->size = maxSize+1;
return f;
}
static void fifoPush(Fifo *f, size_t v) {
static void fifo_push(Fifo *f, size_t v) {
*(f->e++) = v;
if (f->e == f->data + f->size) f->e = f->data;
}
#define FIFO_EMPTY ((size_t)-1)
static size_t fifoPop(Fifo *f) {
static size_t fifo_pop(Fifo *f) {
if (f->b == f->e) return FIFO_EMPTY;
size_t v = *(f->b++);
if (f->b == f->data + f->size) f->b = f->data;
return v;
}
static void fifoFree(Fifo *f) {
static void fifo_free(Fifo *f) {
free(f->data);
free(f);
}
......@@ -969,7 +969,7 @@ static int contact_solve(ParticleProblem *p, Contact *c, double dt, double tol)
imass1 = p->bodies[p1->body].invertM;
iinertmom0 = p->bodies[p0->body].invertI;
iinertmom1 = p->bodies[p1->body].invertI;
mu = particleProblemGetMu(p,p0->material,p1->material);
mu = particle_problem_get_mu(p,p0->material,p1->material);
double x0[DIMENSION];
Body *body0 = &p->bodies[p0->body];
#if DIMENSION == 2
......@@ -998,11 +998,11 @@ static int contact_solve(ParticleProblem *p, Contact *c, double dt, double tol)
iinertmom1 = p->bodies[p1->body].invertI;
}
if (c->type == PARTICLE_DISK) {
mu = particleProblemGetMu(p,p->disks[c->o0].b.material,p1->material);
mu = particle_problem_get_mu(p,p->disks[c->o0].b.material,p1->material);
D = contact_update_disk_particle(c, p, x1, basis, r0, r1);
}
if (c->type == PARTICLE_SEGMENT) {
mu = particleProblemGetMu(p,p->segments[c->o0].b.material,p1->material);
mu = particle_problem_get_mu(p,p->segments[c->o0].b.material,p1->material);
D = contact_update_segment_particle(c, p, x1, basis, r0, r1);
if (!projection_is_on_segment(&p->segments[c->o0], x1)) contact_avoided = 1;
}
......@@ -1097,7 +1097,7 @@ void randomize(int arr[], int n) {
}
}
static int _particleProblemSolveContacts(ParticleProblem *p, double dt, double tol) {
static int particle_problem_solve_contacts(ParticleProblem *p, double dt, double tol) {
int converged = 0;
int iter = 0;
int *order = malloc(vectorSize(p->contacts)*sizeof(int));
......@@ -1120,7 +1120,7 @@ static int _particleProblemSolveContacts(ParticleProblem *p, double dt, double t
return 1;
}
static void _genContactByBody(ParticleProblem *p, size_t **contactByBodyPPtr, size_t **contactByBodyPtr) {
static void gen_contact_by_body(ParticleProblem *p, size_t **contactByBodyPPtr, size_t **contactByBodyPtr) {
size_t *nContactByBody = malloc(sizeof(size_t)*(vectorSize(p->bodies)));
for (size_t i = 0; i < vectorSize(p->bodies); ++i) {
nContactByBody[i] = 0;
......@@ -1149,7 +1149,7 @@ static void _genContactByBody(ParticleProblem *p, size_t **contactByBodyPPtr, si
*contactByBodyPPtr = contactByBodyP;
}
void particleProblemComputeStressTensor(ParticleProblem *p, const double *nodes, const double radius, const int n_nodes, double *stressTensor)
void particle_problem_compute_stress_tensor(ParticleProblem *p, const double *nodes, const double radius, const int n_nodes, double *stressTensor)
{
for (int i = 0; i < n_nodes*DIMENSION*DIMENSION; ++i) {
stressTensor[i] = 0;
......@@ -1160,7 +1160,7 @@ void particleProblemComputeStressTensor(ParticleProblem *p, const double *nodes,
double V = 4./3.*M_PI*radius*radius*radius;
#endif
double bbmin[DIMENSION], bbmax[DIMENSION];
_particleProblemBoundingBox(p, bbmin, bbmax);
particle_problem_bounding_box(p, bbmin, bbmax);
Cell *tree = cellNew(bbmin, bbmax);
double amin[DIMENSION], amax[DIMENSION];
int *found = NULL;
......@@ -1176,13 +1176,13 @@ void particleProblemComputeStressTensor(ParticleProblem *p, const double *nodes,
Cell *stree = cellNew(bbmin, bbmax);
// filter
for (size_t is = 0; is < vectorSize(p->segments); ++is) {
segmentBoundingBox(&p->segments[is], amin, amax);
segment_bounding_box(&p->segments[is], amin, amax);
cellAdd(stree,amin,amax,is,NULL);
}
#if DIMENSION == 3
Cell *ttree = cellNew(bbmin, bbmax);
for (size_t it = 0; it < vectorSize(p->triangles); ++it) {
triangleBoundingBox(&p->triangles[it], amin, amax);
triangle_bounding_box(&p->triangles[it], amin, amax);
cellAdd(ttree,amin,amax,it,NULL);
}
#endif
......@@ -1266,21 +1266,21 @@ void particleProblemComputeStressTensor(ParticleProblem *p, const double *nodes,
#endif
}
static int _particleProblemSolveContactsQueue(ParticleProblem *p, double dt, double tol) {
Fifo *queue = fifoNew(vectorSize(p->contacts));
static int particle_problem_solve_contact_queue(ParticleProblem *p, double dt, double tol) {
Fifo *queue = fifo_new(vectorSize(p->contacts));
size_t *contactByBody, *contactByBodyP;
_genContactByBody(p, &contactByBodyP, &contactByBody);
gen_contact_by_body(p, &contactByBodyP, &contactByBody);
int *activeContact = malloc(sizeof(int)*vectorSize(p->contacts));
for (size_t i = 0; i < vectorSize(p->contacts); ++i) {
fifoPush(queue, i);
fifo_push(queue, i);
activeContact[i] = 1;
}
int iter =0;
for (size_t ic = fifoPop(queue); ic != FIFO_EMPTY; ic=fifoPop(queue)){
for (size_t ic = fifo_pop(queue); ic != FIFO_EMPTY; ic=fifo_pop(queue)){
Contact *c = &p->contacts[ic];
if(iter>4000*vectorSize(p->contacts)*(DIMENSION)){
printf("Warning : Convergence not reached\n");
fifoFree(queue);
fifo_free(queue);
free(activeContact);
free(contactByBodyP);
free(contactByBody);
......@@ -1292,37 +1292,37 @@ static int _particleProblemSolveContactsQueue(ParticleProblem *p, double dt, dou
for (size_t j = contactByBodyP[p->particles[c->o0].body]; j < contactByBodyP[p->particles[c->o0].body+1]; ++j) {
if (!activeContact[contactByBody[j]]){
activeContact[contactByBody[j]] = 1;
fifoPush(queue, contactByBody[j]);
fifo_push(queue, contactByBody[j]);
}
}
}
for (size_t j = contactByBodyP[p->particles[c->o1].body]; j < contactByBodyP[p->particles[c->o1].body+1]; ++j) {
if (!activeContact[contactByBody[j]]){
activeContact[contactByBody[j]] = 1;
fifoPush(queue, contactByBody[j]);
fifo_push(queue, contactByBody[j]);
}
}
fifoPush(queue,ic);
fifo_push(queue,ic);
}
else {
activeContact[ic] = 0;
}
iter++;
}
fifoFree(queue);
fifo_free(queue);
free(activeContact);
free(contactByBodyP);
free(contactByBody);
return 1;
}
int particleProblemSolve(ParticleProblem *p, double alert, double dt, double tol, int maxit)
static int particle_problem_solve(ParticleProblem *p, double alert, double dt, double tol, int maxit)
{
particle_problem_gen_contacts(p, alert);
if (p->use_queue)
return _particleProblemSolveContactsQueue(p,dt,tol);
return particle_problem_solve_contact_queue(p,dt,tol);
else
return _particleProblemSolveContacts(p,dt,tol);
return particle_problem_solve_contacts(p,dt,tol);
}
int particle_problem_iterate(ParticleProblem *p, double alert, double dt, double tol, int maxit,int force_motion, double *externalForces)
......@@ -1368,7 +1368,7 @@ int particle_problem_iterate(ParticleProblem *p, double alert, double dt, double
//Ajouter torques
}
}
if(!particleProblemSolve(p, alert, dt, tol, maxit) && !force_motion){
if(!particle_problem_solve(p, alert, dt, tol, maxit) && !force_motion){
for (size_t j = 0; j < vectorSize(p->bodies); ++j){
Body *body = &p->bodies[p->particles[j].body];
for (size_t i = 0; i < DIMENSION; ++i){
......@@ -1418,7 +1418,7 @@ size_t particle_problem_add_boundary_segment(ParticleProblem *p, const double x0
}
return vectorSize(p->segments) - 1;
}
size_t particleProblem_add_boundary_periodic_entity(ParticleProblem *p, const int etag, const int edim, const double transform[DIMENSION]){
size_t particle_problem_add_boundary_periodic_entity(ParticleProblem *p, const int etag, const int edim, const double transform[DIMENSION]){
PeriodicEntity *pe = vectorPush(&p->periodicEntities);
pe->etag = etag;
pe->edim = edim;
......@@ -1426,6 +1426,7 @@ size_t particleProblem_add_boundary_periodic_entity(ParticleProblem *p, const in
pe->transform[i] = transform[i];
return vectorSize(p->periodicEntities) - 1;
}
size_t particle_problem_add_boundary_periodic_segment(ParticleProblem *p, const double x0[DIMENSION], const double x1[DIMENSION], const int etag){
PeriodicSegment *ps = vectorPush(&p->periodicSegments);
ps->entity_id = -1;
......@@ -1444,7 +1445,7 @@ size_t particle_problem_add_boundary_periodic_segment(ParticleProblem *p, const
return vectorSize(p->periodicSegments) - 1;
}
void particleProblemRemoveBodies(ParticleProblem *p, const int *keep_flag) {
void particle_problem_remove_bodies(ParticleProblem *p, const int *keep_flag) {
int *keepParticles = malloc(sizeof(size_t)*vectorSize(p->particles));
for (int i = 0;i<vectorSize(p->particles);i++){
if (keep_flag[p->particles[i].body])
......@@ -1620,7 +1621,7 @@ ParticleProblem *particle_problem_new() {
return p;
}
void particleProblemSetUseQueue(ParticleProblem *p, int use_queue) {
void particle_problem_set_use_queue(ParticleProblem *p, int use_queue) {
p->use_queue = use_queue;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment