Skip to content

Instantly share code, notes, and snippets.

@dwatanabee
Last active August 24, 2020 08:03
Show Gist options
  • Save dwatanabee/286b91f9e8ffef4fe7ee6fd0f35d1999 to your computer and use it in GitHub Desktop.
Save dwatanabee/286b91f9e8ffef4fe7ee6fd0f35d1999 to your computer and use it in GitHub Desktop.
/*----------------------------------------------density filter*/
void opt_filter_density(FEM *actfem, int iter)
{
int i,j,ID;
double r,dis;
double H;
double SUM[10];
ELEMENT *actele1,*actele2;
for(i=0;i<actfem->nelx;i++)
{
actele1 = &(actfem->element[i]);
r = actele1->filter->r;
for(j=0;j<10;j++) SUM[j] = 0.0;
for(j=0;j<actele1->filter->numele;j++)
{
ID = actele1->filter->ID[j];
dis = actele1->filter->dis[j];
actele2 = &(actfem->element[ID]);
if(dis <= r)
{
H = r - dis;
SUM[0] += H;
SUM[1] += H * actele2->xi;
}
}
actele1->filxi = SUM[1] / SUM[0];//filtered design variable
actele1->filsensi= 1.0 / SUM[0];//use to calculate sensitivity
}
}
@dwatanabee
Copy link
Author

dwatanabee commented Aug 24, 2020

xi...design variable
filxi...filtered design variable
filsensi...sum of weight coefficient
H...weight coefficient

about structure "filter"
r...radius of filter
dis...distance between the center each of the element
numele...The number of surrounding elements (actele2) involved in an element (actele1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment