Add simple type for describing boundary conditions for the flow
equation.
This commit is contained in:
parent
0a69e72f3c
commit
ad508cf6e0
45
flow_bc.c
Normal file
45
flow_bc.c
Normal 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
20
flow_bc.h
Normal 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 */
|
Loading…
Reference in New Issue
Block a user