Add simple type for describing boundary conditions for the flow

equation.
This commit is contained in:
Bård Skaflestad 2010-09-13 15:46:06 +00:00
parent 0a69e72f3c
commit ad508cf6e0
2 changed files with 65 additions and 0 deletions

45
flow_bc.c Normal file
View File

@ -0,0 +1,45 @@
#include <stdlib.h>
#include "flow_bc.h"
/* ---------------------------------------------------------------------- */
flowbc_t *
allocate_flowbc(size_t nf)
/* ---------------------------------------------------------------------- */
{
size_t i;
flowbc_t *new;
new = malloc(1 * sizeof *new);
if (new != NULL) {
new->type = malloc(nf * sizeof *new->type);
new->bcval = malloc(nf * sizeof *new->bcval);
if ((new->type == NULL) || (new->bcval == NULL)) {
deallocate_flowbc(new);
new = NULL;
} else {
for (i = 0; i < nf; i++) {
new->type [i] = UNSET;
new->bcval[i] = 0.0;
}
}
}
return new;
}
/* ---------------------------------------------------------------------- */
void
deallocate_flowbc(flowbc_t *fbc)
/* ---------------------------------------------------------------------- */
{
if (fbc != NULL) {
free(fbc->bcval);
free(fbc->type );
}
free(fbc);
}

20
flow_bc.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef FLOW_BC_H_INCLUDED
#define FLOW_BC_H_INCLUDED
#include <stddef.h>
enum flowbc_type { UNSET, PRESSURE, FLUX };
typedef struct {
enum flowbc_type *type;
double *bcval;
} flowbc_t;
flowbc_t *
allocate_flowbc(size_t nf);
void
deallocate_flowbc(flowbc_t *fbc);
#endif /* FLOW_BC_H_INCLUDED */