Redesign cmake
Tune the makefile according to new principles, which adds a few bells
and whistles and for clarity.
Synopsis:
* The dependency on opm-common is completely gone. This is reflected in
travis and appveyor as well. No non-kitware cmake modules are used.
* Directories are flattened, quite a bit - source code is located in the
lib/ directory if it belongs to opm-parser, and external/ if third
party.
* The sibling build feature is implemented through cmake's
export(PACKAGE) rather than implicitly looking through source files.
* Targets explicitly set required public and private include
directories, compile options and definitions, which cmake will handle
and propagate
* opm-parser-config.cmake for downstream users is now provided.
* Dependencies are set up using targets. In the future, when cmake 3.x+
can be used, these should be either targets from newer Find modules,
or interface libraries.
* Fewer system specific assumptions are coded in, instead we assume
cmake or users set up system specific details.
* All module wide configuration and looking up libraries is handled in
the root makefile - all sub directories only set up libraries and
compile options for the module in question.
* Targets are defined and links handled transitively because cmake now
is told about them. ${module_LIBRARIES} variables are gone.
This is largely guided by the principles outlined in
https://rix0r.nl/blog/2015/08/13/cmake-guide/
Most source files are just moved - if they have some content change then
it's nothing more than include fixes or similar in order to make them
compile.
This commit is contained in:
154
tests/parser/SatfuncPropertyInitializersTests.cpp
Normal file
154
tests/parser/SatfuncPropertyInitializersTests.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Copyright 2015 IRIS
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE SatfuncPropertyInitializersTests
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
inline void check_property(const Eclipse3DProperties& props1,
|
||||
const Eclipse3DProperties& props2,
|
||||
const std::string& propertyName) {
|
||||
auto& data1 = props1.getDoubleGridProperty(propertyName).getData();
|
||||
auto& data2 = props2.getDoubleGridProperty(propertyName).getData();
|
||||
|
||||
BOOST_CHECK_CLOSE(data1[0], data2[0], 1e-12);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SaturationFunctionFamilyTests) {
|
||||
const char * deckdefault =
|
||||
"RUNSPEC\n"
|
||||
"OIL\n"
|
||||
"GAS\n"
|
||||
"WATER\n"
|
||||
"DIMENS\n"
|
||||
" 1 1 1 /\n"
|
||||
"TABDIMS\n"
|
||||
"1 /\n"
|
||||
"\n"
|
||||
"GRID\n"
|
||||
"DX\n"
|
||||
"1*0.25 /\n"
|
||||
"DYV\n"
|
||||
"1*0.25 /\n"
|
||||
"DZ\n"
|
||||
"1*0.25 /\n"
|
||||
"TOPS\n"
|
||||
"1*0.25 /\n"
|
||||
"PORO \n"
|
||||
"1*0.10 /\n"
|
||||
"PERMX \n"
|
||||
"10.25 /\n";
|
||||
|
||||
const char *family1 =
|
||||
"SWOF\n"
|
||||
" .2 .0 1.0 .0\n"
|
||||
" .3 .0 .8 .0\n"
|
||||
" .5 .5 .5 .0\n"
|
||||
" .8 .8 .0 .0\n"
|
||||
" 1.0 1.0 .0 .0 /\n"
|
||||
"SGOF\n"
|
||||
" .0 .0 1.0 .0\n"
|
||||
" .1 .0 .3 .0\n"
|
||||
" .5 .5 .1 .0\n"
|
||||
" .7 .8 .0 .0\n"
|
||||
" .8 1.0 .0 .0/\n";
|
||||
|
||||
const char *family2 =
|
||||
"SWFN\n"
|
||||
" .2 .0 .0\n"
|
||||
" .3 .0 .0\n"
|
||||
" .5 .5 .0\n"
|
||||
" .8 .8 .0\n"
|
||||
" 1.0 1.0 .0 /\n"
|
||||
"SGFN\n"
|
||||
" .0 .0 .0\n"
|
||||
" .1 .0 .0\n"
|
||||
" .5 .5 .0\n"
|
||||
" .7 .8 .0\n"
|
||||
" .8 1.0 .0/\n"
|
||||
"SOF3\n"
|
||||
" .0 .0 .0\n"
|
||||
" .2 .0 .0\n"
|
||||
" .3 1* .0\n"
|
||||
" .5 .5 .1\n"
|
||||
" .7 .8 .3\n"
|
||||
" .8 1.0 1.0/\n";
|
||||
|
||||
ParseContext parseContext;
|
||||
Parser parser;
|
||||
|
||||
char family1Deck[500] = " ";
|
||||
strcat(family1Deck , deckdefault);
|
||||
strcat(family1Deck , family1);
|
||||
Deck deck1 = parser.parseString(family1Deck, parseContext) ;
|
||||
Opm::TableManager tm1( deck1 );
|
||||
Opm::EclipseGrid grid1( deck1 );
|
||||
Opm::Eclipse3DProperties prop1( deck1, tm1, grid1 );
|
||||
|
||||
|
||||
char family2Deck[700] = " ";
|
||||
strcat(family2Deck , deckdefault);
|
||||
strcat(family2Deck , family2);
|
||||
Deck deck2 = parser.parseString(family2Deck, parseContext) ;
|
||||
Opm::TableManager tm2( deck2 );
|
||||
Opm::EclipseGrid grid2( deck2 );
|
||||
Opm::Eclipse3DProperties prop2( deck2, tm2, grid2 );
|
||||
|
||||
check_property(prop1, prop2, "SWL");
|
||||
check_property(prop1, prop2, "SWU");
|
||||
check_property(prop1, prop2, "SWCR");
|
||||
|
||||
check_property(prop1, prop2, "SGL");
|
||||
check_property(prop1, prop2, "SGU");
|
||||
check_property(prop1, prop2, "SGCR");
|
||||
|
||||
check_property(prop1, prop2, "SOWCR");
|
||||
check_property(prop1, prop2, "SOGCR");
|
||||
|
||||
check_property(prop1, prop2, "PCW");
|
||||
check_property(prop1, prop2, "PCG");
|
||||
|
||||
check_property(prop1, prop2, "KRW");
|
||||
check_property(prop1, prop2, "KRO");
|
||||
check_property(prop1, prop2, "KRG");
|
||||
|
||||
char familyMixDeck[1000] = " ";
|
||||
strcat(familyMixDeck , deckdefault);
|
||||
strcat(familyMixDeck , family1);
|
||||
strcat(familyMixDeck , family2);
|
||||
|
||||
Deck deckMix = parser.parseString(familyMixDeck, parseContext) ;
|
||||
Opm::TableManager tmMix( deckMix );
|
||||
Opm::EclipseGrid gridMix( deckMix );
|
||||
Opm::Eclipse3DProperties propMix( deckMix, tmMix, gridMix );
|
||||
BOOST_CHECK_THROW(propMix.getDoubleGridProperty("SGCR") , std::invalid_argument);
|
||||
}
|
||||
Reference in New Issue
Block a user