Merge pull request #1200 from andlaus/some_fixes

Some fixes
This commit is contained in:
dr-robertk 2017-12-20 13:04:12 +01:00 committed by GitHub
commit 761788100d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 31 additions and 191 deletions

View File

@ -81,19 +81,7 @@ macro (sources_hook)
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverIstl.cpp
)
endif (NOT dune-istl_FOUND)
if (NOT SuiteSparse_FOUND)
list (REMOVE_ITEM opm-core_SOURCES
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_umfpack.c
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverUmfpack.cpp
)
endif (NOT SuiteSparse_FOUND)
if (NOT PETSC_FOUND)
list (REMOVE_ITEM opm-core_SOURCES
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_petsc.c
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverPetsc.cpp
)
endif (NOT PETSC_FOUND)
if ((NOT MPI_FOUND) OR (NOT DUNE_ISTL_FOUND))
list (REMOVE_ITEM tests_SOURCES
${PROJECT_SOURCE_DIR}/tests/test_parallel_linearsolver.cpp

View File

@ -19,7 +19,7 @@
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

View File

@ -19,7 +19,7 @@
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

View File

@ -19,7 +19,7 @@
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

View File

@ -18,7 +18,7 @@
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

View File

@ -19,7 +19,7 @@
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

View File

@ -17,7 +17,7 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -18,7 +18,7 @@
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

View File

@ -19,6 +19,9 @@
*/
#include "config.h"
#if HAVE_PETSC
#include <cstring>
#include <opm/core/linalg/LinearSolverPetsc.hpp>
#include <unordered_map>
@ -287,3 +290,4 @@ namespace{
} // namespace Opm
#endif // HAVE_PETSC

View File

@ -20,6 +20,11 @@
#ifndef OPM_LINEARSOLVERPETSC_HEADER_INCLUDED
#define OPM_LINEARSOLVERPETSC_HEADER_INCLUDED
#if !HAVE_PETSC
#error "LinearSolverPetsc.hpp included, but the PETSc libraries are not available!"
#endif
#include <opm/core/linalg/LinearSolverInterface.hpp>
#include <opm/core/utility/parameters/ParameterGroup.hpp>
#include <string>

View File

@ -34,6 +34,8 @@
*/
#include "config.h"
#if HAVE_UMFPACK
#include <assert.h>
#include <stdlib.h>
@ -183,3 +185,15 @@ call_UMFPACK(struct CSRMatrix *A, const double *b, double *x)
csc_deallocate(csc);
}
#else
#include <stdlib.h>
#include <opm/core/linalg/call_umfpack.h>
void
call_UMFPACK(struct CSRMatrix *A, const double *b, double *x)
{
/* UMFPACK is not available */
abort();
}
#endif

View File

@ -1,130 +0,0 @@
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/util/numeric/cmp.hpp>
#include <opm/core/simulator/SimulatorState.hpp>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace Opm;
bool
SimulatorState::equals (const SimulatorState& other,
double epsilon) const {
bool equal = (num_phases_ == other.num_phases_);
// if we use &=, then all the tests will be run regardless
equal = equal && cmp::vector_equal( pressure() , other.pressure() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( temperature() , other.temperature() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( facepressure() , other.facepressure() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( faceflux() , other.faceflux() , cmp::default_abs_epsilon , epsilon);
equal = equal && cmp::vector_equal( saturation() , other.saturation() , cmp::default_abs_epsilon , epsilon);
return equal;
}
void
SimulatorState::init(int number_of_cells, int number_of_faces, int num_phases)
{
num_cells_ = number_of_cells;
num_faces_ = number_of_faces;
num_phases_ = num_phases;
// clear memory
cellData_ = std::vector< std::vector<double> > ();
faceData_ = std::vector< std::vector<double> > ();
int id;
id = registerCellData("PRESSURE", 1, 0.0 );
if( id != pressureId_ )
OPM_THROW(std::logic_error,"ids in SimulatorState do not match");
assert( pressureId_ == id );
id = registerCellData("TEMPERATURE", 1, 273.15 + 20 );
assert( temperatureId_ == id );
id = registerCellData("SATURATION", num_phases_, 0.0 );
assert( saturationId_ == id );
for (int cell = 0; cell < number_of_cells; ++cell) {
// Defaulting the second saturation to 1.0.
// This will usually be oil in a water-oil case,
// gas in an oil-gas case.
// For proper initialization, one should not rely on this,
// but use available phase information instead.
saturation()[num_phases_*cell + 1] = 1.0;
}
id = registerFaceData("FACEPRESSURE", 1, 0.0 );
assert( facePressureId_ == id );
id = registerFaceData("FACEFLUX", 1, 0.0 );
assert( faceFluxId_ == id );
}
size_t
SimulatorState::registerCellData( const std::string& name, const int components, const double initialValue )
{
// check if init has been called
const size_t pos = cellData_.size();
cellDataNames_.emplace_back( name );
cellData_.emplace_back( num_cells_ * components, initialValue );
return pos;
}
size_t
SimulatorState::registerFaceData( const std::string& name, const int components, const double initialValue )
{
// check if init has been called
const size_t pos = faceData_.size();
faceDataNames_.emplace_back( name );
faceData_.emplace_back( num_faces_ * components, initialValue );
return pos ;
}
void SimulatorState::setCellDataComponent( const std::string& name , size_t component , const std::vector<int>& cells , const std::vector<double>& values) {
const auto iter = std::find( cellDataNames_.begin() , cellDataNames_.end() , name);
int id = iter - cellDataNames_.begin();
auto& data = cellData_[id];
if (component >= size_t(num_phases_))
throw std::invalid_argument("Invalid component");
if (cells.size() != values.size())
throw std::invalid_argument("size mismatch between cells and values");
/* This is currently quite broken; the setCellDataComponent
method assumes that the number of components in the field
we are currently focusing on has num_phases components in
total. This restriction should be lifted by allowing a per
field number of components.
*/
if (data.size() != size_t(num_phases_ * num_cells_))
throw std::invalid_argument("Can currently only be used on fields with num_components == num_phases (i.e. saturation...) ");
for (size_t i = 0; i < cells.size(); i++) {
if (cells[i] < num_cells_) {
auto field_index = cells[i] * num_phases_ + component;
auto value = values[i];
data[field_index] = value;
} else {
throw std::invalid_argument("Invalid cell number");
}
}
}
std::vector<double>& SimulatorState::getCellData( const std::string& name ) {
const auto iter = std::find( cellDataNames_.begin() , cellDataNames_.end() , name);
int id = iter - cellDataNames_.begin();
auto& data = cellData_[id];
return data;
}
const std::vector<double>& SimulatorState::getCellData( const std::string& name ) const {
const auto iter = std::find( cellDataNames_.begin() , cellDataNames_.end() , name);
int id = iter - cellDataNames_.begin();
const auto& data = cellData_[id];
return data;
}

View File

@ -26,7 +26,7 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
opm-core/travis/build-opm-core.sh
cd opm-core/build
ctest --output-on-failure
popd > /dev/null

View File

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
cd opm-core
mkdir build
cd build
cmake -D SUPERLU_ROOT=../../SuperLU ../
make
popd > /dev/null

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
git clone https://github.com/dune-project/dune-istl.git
cd dune-istl
git checkout tags/v2.3.1
mkdir build
cd build
cmake ../
make
popd > /dev/null

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -e
pushd . > /dev/null
git clone https://github.com/starseeker/SuperLU.git
cd SuperLU
mkdir build
cd build
cmake -D CMAKE_INSTALL_PREFIX=.. -D SUPERLU_BUILD_EXAMPLES=OFF -D SUPERLU_ENABLE_TESTING=OFF ../
make install
popd > /dev/null