C++ified reordering transport solver facade.

This commit is contained in:
Atgeirr Flø Rasmussen committed 2012-01-24 13:47:00 +01:00
1 parent 9e0a018103
commit 3424e0211b
10 files changed
+56 -27

No files matched your search

+2 -2
View File
@@ -85,7 +85,7 @@ opm/core/transport/reorder/reordersequence.c \
opm/core/transport/reorder/twophase.c \
opm/core/transport/reorder/nlsolvers.c \
opm/core/transport/reorder/tarjan.c \
opm/core/transport/reorder/twophasetransport.c
opm/core/transport/reorder/twophasetransport.cpp
nobase_include_HEADERS = \
@@ -201,7 +201,7 @@ opm/core/transport/reorder/nlsolvers.h \
opm/core/transport/reorder/reordersequence.h \
opm/core/transport/reorder/twophase.h \
opm/core/transport/reorder/tarjan.h \
opm/core/transport/reorder/twophasetransport.h
opm/core/transport/reorder/twophasetransport.hpp
if UMFPACK
libopmcore_la_SOURCES += opm/core/linalg/call_umfpack.c
+2
View File
@@ -11,5 +11,7 @@ scaneclipsedeck
if UMFPACK
noinst_PROGRAMS += spu_2p reorder-qfs
spu_2p_SOURCES = spu_2p.cpp
reorder_qfs_SOURCES = reorder-qfs.cpp
endif
@@ -16,7 +16,7 @@
#include <opm/core/linalg/call_umfpack.h>
#include <opm/core/utility/cart_grid.h>
#include <opm/core/transport/reorder/twophasetransport.h>
#include <opm/core/transport/reorder/twophasetransport.hpp>
struct Rock {
@@ -39,12 +39,12 @@ static struct Rock*
init_rock(int nc, int d)
{
int i,j;
struct Rock *rock = malloc(sizeof *rock);
struct Rock *rock = (struct Rock*) malloc(sizeof *rock);
if (rock!=NULL)
{
rock->perm = malloc(nc*d*d*sizeof *rock->perm);
rock->poro = malloc(nc * sizeof *rock->poro);
rock->perm = (double*) malloc(nc*d*d*sizeof *rock->perm);
rock->poro = (double*) malloc(nc * sizeof *rock->poro);
if ((rock->perm==NULL) || (rock->poro==NULL))
{
@@ -84,7 +84,7 @@ qfs(grid_t *g, struct Rock *rock, double *src,
alloc_sz += g->number_of_faces; /* trans */
alloc_sz += totconn; /* gpress */
htrans = malloc(alloc_sz * sizeof *htrans);
htrans = (double*) malloc(alloc_sz * sizeof *htrans);
trans = htrans + totconn;
gpress = trans + g->number_of_faces;
@@ -129,11 +129,11 @@ int main(void)
{
struct UnstructuredGrid *g = create_cart_grid_2d(10,10);
struct Rock *rock = init_rock(g->number_of_cells, g->dimensions);
double *sat = malloc(g->number_of_cells *sizeof *sat);
double *press = malloc(g->number_of_cells *sizeof *press);
double *flux = malloc(g->number_of_faces *sizeof *flux);
double *pv = malloc(g->number_of_cells *sizeof *pv);
double *src = malloc(g->number_of_cells *sizeof *src);
double *sat = (double*) malloc(g->number_of_cells *sizeof *sat);
double *press = (double*) malloc(g->number_of_cells *sizeof *press);
double *flux = (double*) malloc(g->number_of_faces *sizeof *flux);
double *pv = (double*) malloc(g->number_of_cells *sizeof *pv);
double *src = (double*) malloc(g->number_of_cells *sizeof *src);
vector_zero(g->number_of_cells, sat);
vector_zero(g->number_of_cells, src);
+1 -1
View File
@@ -68,7 +68,7 @@
#include <opm/core/transport/CSRMatrixBlockAssembler.hpp>
#include <opm/core/transport/SinglePointUpwindTwoPhase.hpp>
#include <opm/core/transport/reorder/twophasetransport.h>
#include <opm/core/transport/reorder/twophasetransport.hpp>
+8
View File
@@ -16,6 +16,10 @@
#ifndef FLUID_H
#define FLUID_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef MATLAB_MEX_FILE
void init_fluid(const mxArray *);
#else
@@ -26,4 +30,8 @@ double fluxfun (double sw, const int);
double dfluxfun (double sw, const int);
int getNumSatRegions(void);
#ifdef __cplusplus
}
#endif
#endif /* FLUID_H */
+8
View File
@@ -3,6 +3,10 @@
#ifndef NLSOLVERS_H
#define NLSOLVERS_H
#ifdef __cplusplus
extern "C" {
#endif
struct NonlinearSolverCtrl
{
enum Method {RIDDERS, REGULAFALSI, BISECTION} method;
@@ -18,6 +22,10 @@ double bisection (double (*)(double, void*), void*, struct NonlinearSolverCtrl
double ridders (double (*)(double, void*), void*, struct NonlinearSolverCtrl *ctrl);
double regulafalsi (double (*)(double, void*), void*, struct NonlinearSolverCtrl *ctrl);
#ifdef __cplusplus
}
#endif
#endif /* NLSOLVERS_H */
/* Local Variables: */
@@ -2,12 +2,22 @@
#ifndef REORDERSEQUENCE_H_INCLUDED
#define REORDERSEQUENCE_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
struct UnstructuredGrid;
void compute_sequence(struct UnstructuredGrid *grid, const double *flux,
int *sequence, int *components, int *ncomponents);
#ifdef __cplusplus
}
#endif
#endif /* REORDERSEQUENCE_H_INCLUDED */
/* Local Variables: */
/* c-basic-offset:4 */
/* End: */
+7
View File
@@ -3,6 +3,9 @@
#ifndef TWOPHASE_H_INCLUDED
#define TWOPHASE_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
struct UnstructuredGrid;
@@ -31,6 +34,10 @@ init_solverdata(struct UnstructuredGrid *grid, const double *darcyflux,
const double *porevolume, const double *source,
const int *satnum, double dt, double *saturation);
#ifdef __cplusplus
}
#endif
#endif /* TWOPHASE_H_INCLUDED */
/* Local Variables: */
@@ -10,7 +10,7 @@
#include "tarjan.h"
#include "nlsolvers.h"
#include "twophase.h"
#include "twophasetransport.h"
#include "twophasetransport.hpp"
#include <mex.h>
extern int interrupt_signal;
@@ -26,7 +26,7 @@ extern int interrupt_signal;
#include <opm/core/transport/reorder/tarjan.h>
#include <opm/core/transport/reorder/nlsolvers.h>
#include <opm/core/transport/reorder/twophase.h>
#include <opm/core/transport/reorder/twophasetransport.h>
#include <opm/core/transport/reorder/twophasetransport.hpp>
#define print printf
@@ -58,8 +58,8 @@ void twophasetransport(
/* Compute sequence of single-cell problems */
sequence = malloc( grid->number_of_cells * sizeof *sequence);
components = malloc(( grid->number_of_cells+1) * sizeof *components);
sequence = (int*) malloc( grid->number_of_cells * sizeof *sequence);
components = (int*) malloc(( grid->number_of_cells+1) * sizeof *components);
compute_sequence(grid, darcyflux, sequence, components, &ncomponents);
assert(ncomponents == grid->number_of_cells);
@@ -68,7 +68,7 @@ void twophasetransport(
ctrl.maxiterations = 20;
ctrl.nltolerance = 1e-9;
ctrl.method = REGULAFALSI;
ctrl.method = NonlinearSolverCtrl::REGULAFALSI;
ctrl.initialguess = 0.5;
/* Assume all strong components are single-cell domains. */
@@ -1,11 +1,8 @@
/* Copyright 2011 (c) Jostein R. Natvig <Jostein.R.Natvig at sintef.no> */
#ifndef TWOPHASETRANSPORT_H_INCLUDED
#define TWOPHASETRANSPORT_H_INCLUDED
#ifndef TWOPHASETRANSPORT_HPP_INCLUDED
#define TWOPHASETRANSPORT_HPP_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
struct UnstructuredGrid;
void twophasetransport(
@@ -17,8 +14,5 @@ void twophasetransport(
const int *satnum,
double *saturation);
#ifdef __cplusplus
}
#endif
#endif /* TWOPHASETRANSPORT_H_INCLUDED */
#endif /* TWOPHASETRANSPORT_HPP_INCLUDED */