Skip to content
Snippets Groups Projects
Commit 5fcaf72a authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

better averaging
parent a3d94702
Branches
Tags
No related merge requests found
// $Id: ViewsIO.cpp,v 1.2 2006-01-28 00:58:25 geuzaine Exp $ // $Id: ViewsIO.cpp,v 1.3 2006-01-28 03:23:15 geuzaine Exp $
// //
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// //
...@@ -645,12 +645,26 @@ static void get_nod(int nbelm, List_T *list, int nbnod, int nbcomp, ...@@ -645,12 +645,26 @@ static void get_nod(int nbelm, List_T *list, int nbnod, int nbcomp,
static void print_elm(FILE *file, int num, int nbnod, Nod nod[8], static void print_elm(FILE *file, int num, int nbnod, Nod nod[8],
int nbcomp, double *vals, int dim) int nbcomp, double *vals, int dim)
{ {
// FIXME: implement a nice algo to assign regions based on the values! // compute average value in elm
double avg = 0.; double d = 0.;
for(int i = 0; i < nbcomp*nbnod; i++) for(int k = 0; k < nbnod; k++) {
avg += vals[i]; double *v = &vals[nbcomp * k];
avg /= (double)(nbcomp*nbnod); switch(nbcomp) {
int ele = (int)fabs(avg) + 1, phys = 1; case 1: // scalar
d += v[0];
break;
case 3 : // vector
d += sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2]));
break;
case 9 : // tensor
d += ComputeVonMises(v);
break;
}
}
d /= (double)nbnod;
// assign val as elementary region number
int ele = (int)fabs(d) + 1, phys = 1;
switch(dim){ switch(dim){
case 0: case 0:
......
// $Id: ExtractElements.cpp,v 1.2 2006-01-28 01:44:11 geuzaine Exp $ // $Id: ExtractElements.cpp,v 1.3 2006-01-28 03:23:15 geuzaine Exp $
// //
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// //
...@@ -90,13 +90,27 @@ static void extract(List_T *inList, int inNb, ...@@ -90,13 +90,27 @@ static void extract(List_T *inList, int inNb,
int nb = List_Nbr(inList) / inNb; int nb = List_Nbr(inList) / inNb;
for(int i = 0; i < List_Nbr(inList); i += nb) { for(int i = 0; i < List_Nbr(inList); i += nb) {
double *val = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + double *vals = (double *)List_Pointer_Fast(inList, i + 3 * nbNod +
timeStep * nbNod * nbComp); timeStep * nbNod * nbComp);
double v = 0.; double d = 0.;
for(int j = 0; j < nbNod*nbComp; j++) for(int k = 0; k < nbNod; k++) {
v += val[j]; double *v = &vals[nbComp * k];
v /= (double)(nbNod*nbComp); switch(nbComp) {
if(v >= MinVal && v < MaxVal){ case 1: // scalar
d += v[0];
break;
case 3 : // vector
d += sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2]));
break;
case 9 : // tensor
d += ComputeVonMises(v);
break;
}
}
d /= (double)nbNod;
// '<=' and '<' so that we can do segmentation without playing
// without worrying about roudoff errors
if(d >= MinVal && d < MaxVal){
for(int j = 0; j < nb; j++) for(int j = 0; j < nb; j++)
List_Add(outList, List_Pointer_Fast(inList, i + j)); List_Add(outList, List_Pointer_Fast(inList, i + j));
(*outNb)++; (*outNb)++;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment