Skip to content

Instantly share code, notes, and snippets.

@dwatanabee
Last active August 24, 2020 07:59
Show Gist options
  • Save dwatanabee/0b09e3f393a1b5af1aba7e67c004c0a7 to your computer and use it in GitHub Desktop.
Save dwatanabee/0b09e3f393a1b5af1aba7e67c004c0a7 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#ifdef _OPENMP
#include <omp.h>
#endif
#include "../headers/function_header.h"
extern struct _PROBLEM *problem;
extern struct _FLAGS *flags;
void density_filter(FEM *actfem)
{
int i, j, ID;
double H, r, dis;
PROBLEM *prob;
ELEMENT *actele1, *actele2;
NODE *actnode;
prob = problem;
/*--------------------------------------------------------- cal df / ds */
for (i = 0; i < actfem->nelx; i++)
{
actele1 = &(actfem->element[i]);
r = actele1->filter->r;
/*-----------initialization------------------*/
actele1->filobj = 0.0;
/*summation of density filter*/
for (j = 0; j < actele1->filter->numele; j++)
{
ID = actele1->filter->ID[j];
dis = actele1->filter->dis[j];
actele2 = &(actfem->element[ID]);
H = r - dis;
actele1->filobj += actele2->obj * H * actele2->filsensi;
}
}
}
@dwatanabee
Copy link
Author

obj...raw sensitivity of objective (or constraint) function
filobj...filtered sensitivity

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