Merge pull request #1115 from atgeirr/remove-more-grid-stuff
Remove more files moved to opm-grid.
This commit is contained in:
commit
87650a3819
|
@ -130,8 +130,6 @@ list (APPEND MAIN_SOURCE_FILES
|
|||
list (APPEND TEST_SOURCE_FILES
|
||||
tests/test_compressedpropertyaccess.cpp
|
||||
tests/test_dgbasis.cpp
|
||||
tests/test_cartgrid.cpp
|
||||
tests/test_ug.cpp
|
||||
tests/test_cubic.cpp
|
||||
tests/test_event.cpp
|
||||
tests/test_flowdiagnostics.cpp
|
||||
|
@ -139,12 +137,9 @@ list (APPEND TEST_SOURCE_FILES
|
|||
tests/test_parallelistlinformation.cpp
|
||||
tests/test_sparsevector.cpp
|
||||
tests/test_velocityinterpolation.cpp
|
||||
tests/test_quadratures.cpp
|
||||
tests/test_uniformtablelinear.cpp
|
||||
tests/test_wells.cpp
|
||||
tests/test_wachspresscoord.cpp
|
||||
tests/test_column_extract.cpp
|
||||
tests/test_geom2d.cpp
|
||||
tests/test_linearsolver.cpp
|
||||
tests/test_parallel_linearsolver.cpp
|
||||
tests/test_param.cpp
|
||||
|
@ -160,9 +155,7 @@ list (APPEND TEST_SOURCE_FILES
|
|||
tests/test_wellsgroup.cpp
|
||||
tests/test_wellcollection.cpp
|
||||
tests/test_timer.cpp
|
||||
tests/test_minpvprocessor.cpp
|
||||
tests/test_pinchprocessor.cpp
|
||||
tests/test_gridutilities.cpp
|
||||
tests/test_anisotropiceikonal.cpp
|
||||
tests/test_stoppedwells.cpp
|
||||
tests/test_relpermdiagnostics.cpp
|
||||
|
@ -197,7 +190,6 @@ list (APPEND TEST_DATA_FILES
|
|||
tests/wells_manager_data_wellSTOP.data
|
||||
tests/wells_group.data
|
||||
tests/TESTTIMER.DATA
|
||||
tests/CORNERPOINT_ACTNUM.DATA
|
||||
tests/wells_stopped.data
|
||||
tests/relpermDiagnostics.DATA
|
||||
tests/norne_pvt.data
|
||||
|
@ -210,7 +202,6 @@ list (APPEND EXAMPLE_SOURCE_FILES
|
|||
examples/compute_initial_state.cpp
|
||||
examples/compute_tof.cpp
|
||||
examples/compute_tof_from_files.cpp
|
||||
examples/mirror_grid.cpp
|
||||
examples/wells_example.cpp
|
||||
examples/diagnose_relperm.cpp
|
||||
tutorials/tutorial1.cpp
|
||||
|
@ -233,7 +224,6 @@ list (APPEND ATTIC_FILES
|
|||
# programs listed here will not only be compiled, but also marked for
|
||||
# installation
|
||||
list (APPEND PROGRAM_SOURCE_FILES
|
||||
examples/mirror_grid.cpp
|
||||
)
|
||||
|
||||
# originally generated with the command:
|
||||
|
|
|
@ -1,406 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 Statoil ASA.
|
||||
Copyright 2014 Andreas Lauser.
|
||||
|
||||
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 "config.h"
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
/**
|
||||
* @file mirror_grid.cpp
|
||||
* @brief Mirror grid taken from grdecl file
|
||||
*
|
||||
* The input grid is mirrored in either the x- or y-direction, resulting in a periodic grid.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/// Print init message in new grid filename
|
||||
void printInitMessage(std::ofstream& out, const char* origfilename, std::string direction) {
|
||||
std::ifstream infile;
|
||||
infile.open(origfilename, std::ios::in);
|
||||
if (!infile) {
|
||||
std::cerr << "Can't open input file " << origfilename << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
// Print init message and copy comments from original grid file
|
||||
out << "-- This grdecl file is generated from OPM application 'mirror_grid.cpp'." << std::endl
|
||||
<< "-- The grid '" << origfilename << "' is mirrored around itself in the " << direction << " direction." << std::endl
|
||||
<< "-- Thus, the resulting grid should be periodic in the " << direction << "-direction." << std::endl
|
||||
<< "-- Original comments taken from '" << origfilename << "':" << std::endl;
|
||||
std::string nextInLine;
|
||||
while (getline(infile, nextInLine)) {
|
||||
if (nextInLine.substr(0,2) == "--") {
|
||||
out << nextInLine << std::endl;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
/// Write keyword values to file
|
||||
template <class T>
|
||||
void printKeywordValues(std::ofstream& out, std::string keyword, std::vector<T> values, int nCols) {
|
||||
out << keyword << std::endl;
|
||||
int col = 0;
|
||||
typename std::vector<T>::iterator iter;
|
||||
for (iter = values.begin(); iter != values.end(); ++iter) {
|
||||
out << *iter << " ";
|
||||
++col;
|
||||
// Break line for every nCols entry.
|
||||
if (col == nCols) {
|
||||
out << std::endl;
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
if (col != 0)
|
||||
out << std::endl;
|
||||
out << "/" << std::endl << std::endl;
|
||||
}
|
||||
|
||||
// forward declaration
|
||||
std::vector<double> getMapaxesValues(const Opm::Deck& deck);
|
||||
|
||||
/// Mirror keyword MAPAXES in deck
|
||||
void mirror_mapaxes( const Opm::Deck& deck, std::string direction, std::ofstream& out) {
|
||||
// Assumes axis aligned with x/y-direction
|
||||
std::cout << "Warning: Keyword MAPAXES not fully understood. Result should be verified manually." << std::endl;
|
||||
if (deck.hasKeyword("MAPAXES")) {
|
||||
std::vector<double> mapaxes = getMapaxesValues(deck);
|
||||
std::vector<double> mapaxes_mirrored = mapaxes;
|
||||
// Double the length of the coordinate axis
|
||||
if (direction == "x") {
|
||||
mapaxes_mirrored[4] = (mapaxes[4]-mapaxes[2])*2 + mapaxes[2];
|
||||
}
|
||||
else if (direction == "y") {
|
||||
mapaxes_mirrored[1] = (mapaxes[1]-mapaxes[3])*2 + mapaxes[3];
|
||||
}
|
||||
printKeywordValues(out, "MAPAXES", mapaxes_mirrored, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/// Mirror keyword SPECGRID in deck
|
||||
void mirror_specgrid( const Opm::Deck& deck, std::string direction, std::ofstream& out) {
|
||||
// We only need to multiply the dimension by 2 in the correct direction.
|
||||
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
|
||||
std::vector<int> dimensions(3);
|
||||
dimensions[0] = specgridRecord.getItem("NX").get< int >(0);
|
||||
dimensions[1] = specgridRecord.getItem("NY").get< int >(0);
|
||||
dimensions[2] = specgridRecord.getItem("NZ").get< int >(0);
|
||||
if (direction == "x") {dimensions[0] *= 2;}
|
||||
else if (direction == "y") {dimensions[1] *= 2;}
|
||||
else {std::cerr << "Direction should be either x or y" << std::endl; exit(1);}
|
||||
out << "SPECGRID" << std::endl << dimensions[0] << " " << dimensions[1] << " " << dimensions[2] << " "
|
||||
<< specgridRecord.getItem("NUMRES").get< int >(0) << " "
|
||||
<< specgridRecord.getItem("COORD_TYPE").get< std::string >(0) << " "
|
||||
<< std::endl << "/" << std::endl << std::endl;
|
||||
}
|
||||
|
||||
/// Mirror keyword COORD in deck
|
||||
void mirror_coord(const Opm::Deck& deck, std::string direction, std::ofstream& out) {
|
||||
// We assume uniform spacing in x and y directions and parallel top and bottom faces
|
||||
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
|
||||
std::vector<int> dimensions(3);
|
||||
dimensions[0] = specgridRecord.getItem("NX").get< int >(0);
|
||||
dimensions[1] = specgridRecord.getItem("NY").get< int >(0);
|
||||
dimensions[2] = specgridRecord.getItem("NZ").get< int >(0);
|
||||
std::vector<double> coord = deck.getKeyword("COORD").getRawDoubleData();
|
||||
const int entries_per_pillar = 6;
|
||||
std::vector<double> coord_mirrored;
|
||||
// Handle the two directions differently due to ordering of the pillars.
|
||||
if (direction == "x") {
|
||||
// Total entries in mirrored ZCORN. Number of pillars times 6
|
||||
const int entries = (2*dimensions[0] + 1) * (dimensions[1] + 1) * entries_per_pillar;
|
||||
// Entries per line in x-direction. Number of pillars in x-direction times 6
|
||||
const int entries_per_line = entries_per_pillar*(dimensions[0] + 1);
|
||||
coord_mirrored.assign(entries, 0.0);
|
||||
// Distance between pillars in x-directiion
|
||||
const double spacing = coord[entries_per_pillar]-coord[0];
|
||||
std::vector<double>::iterator it_new = coord_mirrored.begin();
|
||||
std::vector<double>::iterator it_orig;
|
||||
// Loop through each pillar line in the x-direction
|
||||
for (it_orig = coord.begin(); it_orig != coord.end(); it_orig += entries_per_line) {
|
||||
// Copy old pillars
|
||||
copy(it_orig, it_orig + entries_per_line, it_new);
|
||||
// Add new pillars in between
|
||||
it_new += entries_per_line;
|
||||
std::vector<double> next_vec(it_orig + entries_per_line - entries_per_pillar, it_orig + entries_per_line);
|
||||
for (int r=0; r < dimensions[0]; ++r) {
|
||||
next_vec[0] += spacing;
|
||||
next_vec[3] += spacing;
|
||||
copy(next_vec.begin(), next_vec.end(), it_new);
|
||||
it_new += entries_per_pillar;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (direction == "y") {
|
||||
// Total entries in mirrored ZCORN. Number of pillars times 6
|
||||
const int entries = (dimensions[0] + 1) * (2*dimensions[1] + 1) * entries_per_pillar;
|
||||
// Entries per line in y-direction. Number of pillars in y-direction times 6
|
||||
const int entries_per_line = entries_per_pillar*(dimensions[0] + 1);
|
||||
coord_mirrored.assign(entries, 0.0);
|
||||
// Distance between pillars in y-directiion
|
||||
const double spacing = coord[entries_per_line + 1]-coord[1];
|
||||
std::vector<double>::iterator it_new = coord_mirrored.begin();
|
||||
// Copy old pillars
|
||||
copy(coord.begin(), coord.end(), it_new);
|
||||
// Add new pillars at the end
|
||||
it_new += coord.size();
|
||||
std::vector<double> next_vec(coord.end() - entries_per_line, coord.end());
|
||||
for ( ; it_new != coord_mirrored.end(); it_new += entries_per_line) {
|
||||
for (int i = 1; i < entries_per_line; i += 3) {
|
||||
next_vec[i] += spacing;
|
||||
}
|
||||
copy(next_vec.begin(), next_vec.end(), it_new);
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Direction should be either x or y" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
// Write new COORD values to output file
|
||||
printKeywordValues(out, "COORD", coord_mirrored, 6);
|
||||
}
|
||||
|
||||
/// Mirror keyword ZCORN in deck
|
||||
void mirror_zcorn(const Opm::Deck& deck, std::string direction, std::ofstream& out) {
|
||||
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
|
||||
std::vector<int> dimensions(3);
|
||||
dimensions[0] = specgridRecord.getItem("NX").get< int >(0);
|
||||
dimensions[1] = specgridRecord.getItem("NY").get< int >(0);
|
||||
dimensions[2] = specgridRecord.getItem("NZ").get< int >(0);
|
||||
std::vector<double> zcorn = deck.getKeyword("ZCORN").getRawDoubleData();
|
||||
std::vector<double> zcorn_mirrored;
|
||||
// Handle the two directions differently due to ordering of the pillars.
|
||||
if (direction == "x") {
|
||||
// Total entries in mirrored ZCORN. Eight corners per cell.
|
||||
const int entries = dimensions[0]*2*dimensions[1]*dimensions[2]*8;
|
||||
zcorn_mirrored.assign(entries, 0.0);
|
||||
// Entries per line in x-direction. Two for each cell.
|
||||
const int entries_per_line = dimensions[0]*2;
|
||||
std::vector<double>::iterator it_new = zcorn_mirrored.begin();
|
||||
std::vector<double>::iterator it_orig = zcorn.begin();
|
||||
// Loop through each line and copy old corner-points and add new (which are the old reversed)
|
||||
for ( ; it_orig != zcorn.end(); it_orig += entries_per_line) {
|
||||
std::vector<double> next_vec(it_orig, it_orig + entries_per_line);
|
||||
std::vector<double> next_reversed = next_vec;
|
||||
reverse(next_reversed.begin(), next_reversed.end());
|
||||
// Copy old corner-points
|
||||
copy(it_orig, it_orig + entries_per_line, it_new);
|
||||
it_new += entries_per_line;
|
||||
// Add new corner-points
|
||||
copy(next_reversed.begin(), next_reversed.end(), it_new);
|
||||
it_new += entries_per_line;
|
||||
}
|
||||
}
|
||||
else if (direction == "y") {
|
||||
// Total entries in mirrored ZCORN. Eight corners per cell.
|
||||
const int entries = dimensions[0]*dimensions[1]*2*dimensions[2]*8;
|
||||
zcorn_mirrored.assign(entries, 0.0);
|
||||
// Entries per line in x-direction. Two for each cell.
|
||||
const int entries_per_line_x = dimensions[0]*2;
|
||||
// Entries per layer of corner-points. Four for each cell
|
||||
const int entries_per_layer = dimensions[0]*dimensions[1]*4;
|
||||
std::vector<double>::iterator it_new = zcorn_mirrored.begin();
|
||||
std::vector<double>::iterator it_orig = zcorn.begin();
|
||||
// Loop through each layer and copy old corner-points and add new (which are the old reordered)
|
||||
for ( ; it_orig != zcorn.end(); it_orig += entries_per_layer) {
|
||||
// Copy old corner-points
|
||||
copy(it_orig, it_orig + entries_per_layer, it_new);
|
||||
it_new += entries_per_layer;
|
||||
// Add new corner-points
|
||||
std::vector<double> next_vec(it_orig, it_orig + entries_per_layer);
|
||||
std::vector<double> next_reordered(entries_per_layer, 0.0);
|
||||
std::vector<double>::iterator it_next = next_vec.end();
|
||||
std::vector<double>::iterator it_reordered = next_reordered.begin();
|
||||
// Reorder next entries
|
||||
for ( ; it_reordered != next_reordered.end(); it_reordered += entries_per_line_x) {
|
||||
copy(it_next - entries_per_line_x, it_next, it_reordered);
|
||||
it_next -= entries_per_line_x;
|
||||
}
|
||||
copy(next_reordered.begin(), next_reordered.end(), it_new);
|
||||
it_new += entries_per_layer;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Direction should be either x or y" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
// Write new ZCORN values to output file
|
||||
printKeywordValues(out, "ZCORN", zcorn_mirrored, 8);
|
||||
}
|
||||
|
||||
std::vector<int> getKeywordValues(std::string keyword, const Opm::Deck& deck, int /*dummy*/) {
|
||||
return deck.getKeyword(keyword).getIntData();
|
||||
}
|
||||
|
||||
std::vector<double> getKeywordValues(std::string keyword, const Opm::Deck& deck, double /*dummy*/) {
|
||||
return deck.getKeyword(keyword).getRawDoubleData();
|
||||
}
|
||||
|
||||
std::vector<double> getMapaxesValues(const Opm::Deck& deck)
|
||||
{
|
||||
const auto& mapaxesRecord = deck.getKeyword("MAPAXES").getRecord(0);
|
||||
std::vector<double> result;
|
||||
for (size_t itemIdx = 0; itemIdx < mapaxesRecord.size(); ++itemIdx) {
|
||||
const auto& curItem = mapaxesRecord.getItem(itemIdx);
|
||||
|
||||
for (size_t dataItemIdx = 0; dataItemIdx < curItem.size(); ++dataItemIdx) {
|
||||
result.push_back(curItem.get< double >(dataItemIdx));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Mirror keywords that have one value for each cell
|
||||
template <class T>
|
||||
void mirror_celldata(std::string keyword, const Opm::Deck& deck, std::string direction, std::ofstream& out) {
|
||||
if ( ! deck.hasKeyword(keyword)) {
|
||||
std::cout << "Ignoring keyword " << keyword << " as it was not found." << std::endl;
|
||||
return;
|
||||
}
|
||||
// Get data from eclipse deck
|
||||
const auto& specgridRecord = deck.getKeyword("SPECGRID").getRecord(0);
|
||||
std::vector<int> dimensions(3);
|
||||
dimensions[0] = specgridRecord.getItem("NX").get< int >(0);
|
||||
dimensions[1] = specgridRecord.getItem("NY").get< int >(0);
|
||||
dimensions[2] = specgridRecord.getItem("NZ").get< int >(0);
|
||||
std::vector<T> values = getKeywordValues(keyword, deck, T(0.0));
|
||||
std::vector<T> values_mirrored(2*dimensions[0]*dimensions[1]*dimensions[2], 0.0);
|
||||
// Handle the two directions differently due to ordering of the pillars.
|
||||
if (direction == "x") {
|
||||
typename std::vector<T>::iterator it_orig = values.begin();
|
||||
typename std::vector<T>::iterator it_new = values_mirrored.begin();
|
||||
// Loop through each line and copy old cell data and add new (which are the old reversed)
|
||||
for ( ; it_orig != values.end(); it_orig += dimensions[0]) {
|
||||
// Copy old cell data
|
||||
copy(it_orig, it_orig + dimensions[0], it_new);
|
||||
it_new += dimensions[0];
|
||||
// Add new cell data
|
||||
std::vector<double> next_vec(it_orig, it_orig + dimensions[0]);
|
||||
std::vector<double> next_reversed = next_vec;
|
||||
reverse(next_reversed.begin(), next_reversed.end());
|
||||
copy(next_reversed.begin(), next_reversed.end(), it_new);
|
||||
it_new += dimensions[0];
|
||||
}
|
||||
}
|
||||
else if (direction =="y") {
|
||||
typename std::vector<T>::iterator it_orig = values.begin();
|
||||
typename std::vector<T>::iterator it_new = values_mirrored.begin();
|
||||
// Entries per layer
|
||||
const int entries_per_layer = dimensions[0]*dimensions[1];
|
||||
// Loop through each layer and copy old cell data and add new (which are the old reordered)
|
||||
for ( ; it_orig != values.end(); it_orig += entries_per_layer) {
|
||||
// Copy old cell data
|
||||
copy(it_orig, it_orig + entries_per_layer, it_new);
|
||||
it_new += entries_per_layer;
|
||||
// Add new cell data
|
||||
std::vector<T> next_vec(it_orig, it_orig + entries_per_layer);
|
||||
std::vector<T> next_reordered(entries_per_layer, 0.0);
|
||||
typename std::vector<T>::iterator it_next = next_vec.end();
|
||||
typename std::vector<T>::iterator it_reordered = next_reordered.begin();
|
||||
// Reorder next entries
|
||||
for ( ; it_reordered != next_reordered.end(); it_reordered += dimensions[0]) {
|
||||
copy(it_next - dimensions[0], it_next, it_reordered);
|
||||
it_next -= dimensions[0];
|
||||
}
|
||||
copy(next_reordered.begin(), next_reordered.end(), it_new);
|
||||
it_new += entries_per_layer;
|
||||
}
|
||||
}
|
||||
else {
|
||||
std::cerr << "Direction should be either x or y" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
// Write new keyword values to output file
|
||||
printKeywordValues(out, keyword, values_mirrored, 8);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Set output precision
|
||||
int decimals = 16;
|
||||
|
||||
// Process input parameters
|
||||
if (argc != 3) {
|
||||
std::cout << "Usage: mirror_grid filename.grdecl direction" << std::endl;
|
||||
std::cout << "(replace direction with either x or y)" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
const char* eclipsefilename = argv[1];
|
||||
std::string direction(argv[2]);
|
||||
if ( ! ((direction == "x") || (direction == "y")) ) {
|
||||
std::cerr << "Unrecognized input parameter for direction: '" << direction
|
||||
<< "'. Should be either x or y (maybe also z later)." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Parse grdecl file
|
||||
std::cout << "Parsing grid file '" << eclipsefilename << "' ..." << std::endl;
|
||||
Opm::Parser parser;
|
||||
Opm::ParseContext parseContext;
|
||||
const Opm::Deck deck(parser.parseFile(eclipsefilename , parseContext));
|
||||
if ( ! (deck.hasKeyword("SPECGRID") && deck.hasKeyword("COORD") && deck.hasKeyword("ZCORN")) ) {
|
||||
std::cerr << "Grid file " << eclipsefilename << "are missing keywords SPECGRID, COORD or ZCORN!" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Create new grid file
|
||||
std::string mirrored_eclipsefilename = std::string(eclipsefilename);
|
||||
std::string::size_type last_dot = mirrored_eclipsefilename.find_last_of('.');
|
||||
mirrored_eclipsefilename = mirrored_eclipsefilename.substr(0, last_dot) + "_mirrored-" + direction + ".grdecl";
|
||||
std::ofstream outfile;
|
||||
outfile.open(mirrored_eclipsefilename.c_str(), std::ios::out | std::ios::trunc);
|
||||
if (!outfile) {
|
||||
std::cerr << "Can't open output file " << mirrored_eclipsefilename << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
outfile.precision(decimals);
|
||||
outfile.setf(std::ios::fixed);
|
||||
|
||||
// Print init message
|
||||
printInitMessage(outfile, eclipsefilename, direction);
|
||||
|
||||
// Mirror keywords
|
||||
mirror_mapaxes(deck, direction, outfile);
|
||||
mirror_specgrid(deck, direction, outfile);
|
||||
mirror_coord(deck, direction, outfile);
|
||||
mirror_zcorn(deck, direction, outfile);
|
||||
mirror_celldata<int>("ACTNUM", deck, direction, outfile);
|
||||
mirror_celldata<double>("PERMX", deck, direction, outfile);
|
||||
mirror_celldata<double>("PERMY", deck, direction, outfile);
|
||||
mirror_celldata<double>("PERMZ", deck, direction, outfile);
|
||||
mirror_celldata<double>("PORO", deck, direction, outfile);
|
||||
mirror_celldata<int>("SATNUM", deck, direction, outfile);
|
||||
mirror_celldata<double>("NTG", deck, direction, outfile);
|
||||
mirror_celldata<double>("SWCR", deck, direction, outfile);
|
||||
mirror_celldata<double>("SOWCR", deck, direction, outfile);
|
||||
}
|
|
@ -1,206 +0,0 @@
|
|||
RUNSPEC
|
||||
|
||||
DIMENS
|
||||
10 10 5 /
|
||||
|
||||
GRID
|
||||
|
||||
COORD
|
||||
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
|
||||
0.00000000E+00 0.20000000E+02 0.10000000E+02 0.00000000E+00
|
||||
0.00000000E+00 0.10000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.20000000E+02 0.00000000E+00 0.00000000E+00 0.20000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.30000000E+02 0.00000000E+00
|
||||
0.00000000E+00 0.30000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.40000000E+02 0.00000000E+00 0.00000000E+00 0.40000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.50000000E+02 0.00000000E+00
|
||||
0.00000000E+00 0.50000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.60000000E+02 0.00000000E+00 0.00000000E+00 0.60000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.70000000E+02 0.00000000E+00
|
||||
0.00000000E+00 0.70000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.80000000E+02 0.00000000E+00 0.00000000E+00 0.80000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.90000000E+02 0.00000000E+00
|
||||
0.00000000E+00 0.90000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.10000000E+03 0.00000000E+00 0.00000000E+00 0.10000000E+03
|
||||
0.00000000E+00 0.20000000E+02 0.00000000E+00 0.12000000E+02
|
||||
0.00000000E+00 0.00000000E+00 0.12000000E+02 0.20000000E+02
|
||||
0.10000000E+02 0.12000000E+02 0.00000000E+00 0.10000000E+02
|
||||
0.12000000E+02 0.20000000E+02 0.20000000E+02 0.12000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.12000000E+02 0.20000000E+02
|
||||
0.30000000E+02 0.12000000E+02 0.00000000E+00 0.30000000E+02
|
||||
0.12000000E+02 0.20000000E+02 0.40000000E+02 0.12000000E+02
|
||||
0.00000000E+00 0.40000000E+02 0.12000000E+02 0.20000000E+02
|
||||
0.50000000E+02 0.12000000E+02 0.00000000E+00 0.50000000E+02
|
||||
0.12000000E+02 0.20000000E+02 0.60000000E+02 0.12000000E+02
|
||||
0.00000000E+00 0.60000000E+02 0.12000000E+02 0.20000000E+02
|
||||
0.70000000E+02 0.12000000E+02 0.00000000E+00 0.70000000E+02
|
||||
0.12000000E+02 0.20000000E+02 0.80000000E+02 0.12000000E+02
|
||||
0.00000000E+00 0.80000000E+02 0.12000000E+02 0.20000000E+02
|
||||
0.90000000E+02 0.12000000E+02 0.00000000E+00 0.90000000E+02
|
||||
0.12000000E+02 0.20000000E+02 0.10000000E+03 0.12000000E+02
|
||||
0.00000000E+00 0.10000000E+03 0.12000000E+02 0.20000000E+02
|
||||
0.00000000E+00 0.24000000E+02 0.00000000E+00 0.00000000E+00
|
||||
0.24000000E+02 0.20000000E+02 0.10000000E+02 0.24000000E+02
|
||||
0.00000000E+00 0.10000000E+02 0.24000000E+02 0.20000000E+02
|
||||
0.20000000E+02 0.24000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.24000000E+02 0.20000000E+02 0.30000000E+02 0.24000000E+02
|
||||
0.00000000E+00 0.30000000E+02 0.24000000E+02 0.20000000E+02
|
||||
0.40000000E+02 0.24000000E+02 0.00000000E+00 0.40000000E+02
|
||||
0.24000000E+02 0.20000000E+02 0.50000000E+02 0.24000000E+02
|
||||
0.00000000E+00 0.50000000E+02 0.24000000E+02 0.20000000E+02
|
||||
0.60000000E+02 0.24000000E+02 0.00000000E+00 0.60000000E+02
|
||||
0.24000000E+02 0.20000000E+02 0.70000000E+02 0.24000000E+02
|
||||
0.00000000E+00 0.70000000E+02 0.24000000E+02 0.20000000E+02
|
||||
0.80000000E+02 0.24000000E+02 0.00000000E+00 0.80000000E+02
|
||||
0.24000000E+02 0.20000000E+02 0.90000000E+02 0.24000000E+02
|
||||
0.00000000E+00 0.90000000E+02 0.24000000E+02 0.20000000E+02
|
||||
0.10000000E+03 0.24000000E+02 0.00000000E+00 0.10000000E+03
|
||||
0.24000000E+02 0.20000000E+02 0.00000000E+00 0.36000000E+02
|
||||
0.00000000E+00 0.00000000E+00 0.36000000E+02 0.20000000E+02
|
||||
0.10000000E+02 0.36000000E+02 0.00000000E+00 0.10000000E+02
|
||||
0.36000000E+02 0.20000000E+02 0.20000000E+02 0.36000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.36000000E+02 0.20000000E+02
|
||||
0.30000000E+02 0.36000000E+02 0.00000000E+00 0.30000000E+02
|
||||
0.36000000E+02 0.20000000E+02 0.40000000E+02 0.36000000E+02
|
||||
0.00000000E+00 0.40000000E+02 0.36000000E+02 0.20000000E+02
|
||||
0.50000000E+02 0.36000000E+02 0.00000000E+00 0.50000000E+02
|
||||
0.36000000E+02 0.20000000E+02 0.60000000E+02 0.36000000E+02
|
||||
0.00000000E+00 0.60000000E+02 0.36000000E+02 0.20000000E+02
|
||||
0.70000000E+02 0.36000000E+02 0.00000000E+00 0.70000000E+02
|
||||
0.36000000E+02 0.20000000E+02 0.80000000E+02 0.36000000E+02
|
||||
0.00000000E+00 0.80000000E+02 0.36000000E+02 0.20000000E+02
|
||||
0.90000000E+02 0.36000000E+02 0.00000000E+00 0.90000000E+02
|
||||
0.36000000E+02 0.20000000E+02 0.10000000E+03 0.36000000E+02
|
||||
0.00000000E+00 0.10000000E+03 0.36000000E+02 0.20000000E+02
|
||||
0.00000000E+00 0.48000000E+02 0.00000000E+00 0.00000000E+00
|
||||
0.48000000E+02 0.20000000E+02 0.10000000E+02 0.48000000E+02
|
||||
0.00000000E+00 0.10000000E+02 0.48000000E+02 0.20000000E+02
|
||||
0.20000000E+02 0.48000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.48000000E+02 0.20000000E+02 0.30000000E+02 0.48000000E+02
|
||||
0.00000000E+00 0.30000000E+02 0.48000000E+02 0.20000000E+02
|
||||
0.40000000E+02 0.48000000E+02 0.00000000E+00 0.40000000E+02
|
||||
0.48000000E+02 0.20000000E+02 0.50000000E+02 0.48000000E+02
|
||||
0.00000000E+00 0.50000000E+02 0.48000000E+02 0.20000000E+02
|
||||
0.60000000E+02 0.48000000E+02 0.00000000E+00 0.60000000E+02
|
||||
0.48000000E+02 0.20000000E+02 0.70000000E+02 0.48000000E+02
|
||||
0.00000000E+00 0.70000000E+02 0.48000000E+02 0.20000000E+02
|
||||
0.80000000E+02 0.48000000E+02 0.00000000E+00 0.80000000E+02
|
||||
0.48000000E+02 0.20000000E+02 0.90000000E+02 0.48000000E+02
|
||||
0.00000000E+00 0.90000000E+02 0.48000000E+02 0.20000000E+02
|
||||
0.10000000E+03 0.48000000E+02 0.00000000E+00 0.10000000E+03
|
||||
0.48000000E+02 0.20000000E+02 0.00000000E+00 0.60000000E+02
|
||||
0.00000000E+00 0.00000000E+00 0.60000000E+02 0.20000000E+02
|
||||
0.10000000E+02 0.60000000E+02 0.00000000E+00 0.10000000E+02
|
||||
0.60000000E+02 0.20000000E+02 0.20000000E+02 0.60000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.60000000E+02 0.20000000E+02
|
||||
0.30000000E+02 0.60000000E+02 0.00000000E+00 0.30000000E+02
|
||||
0.60000000E+02 0.20000000E+02 0.40000000E+02 0.60000000E+02
|
||||
0.00000000E+00 0.40000000E+02 0.60000000E+02 0.20000000E+02
|
||||
0.50000000E+02 0.60000000E+02 0.00000000E+00 0.50000000E+02
|
||||
0.60000000E+02 0.20000000E+02 0.60000000E+02 0.60000000E+02
|
||||
0.00000000E+00 0.60000000E+02 0.60000000E+02 0.20000000E+02
|
||||
0.70000000E+02 0.60000000E+02 0.00000000E+00 0.70000000E+02
|
||||
0.60000000E+02 0.20000000E+02 0.80000000E+02 0.60000000E+02
|
||||
0.00000000E+00 0.80000000E+02 0.60000000E+02 0.20000000E+02
|
||||
0.90000000E+02 0.60000000E+02 0.00000000E+00 0.90000000E+02
|
||||
0.60000000E+02 0.20000000E+02 0.10000000E+03 0.60000000E+02
|
||||
0.00000000E+00 0.10000000E+03 0.60000000E+02 0.20000000E+02
|
||||
0.00000000E+00 0.72000000E+02 0.00000000E+00 0.00000000E+00
|
||||
0.72000000E+02 0.20000000E+02 0.10000000E+02 0.72000000E+02
|
||||
0.00000000E+00 0.10000000E+02 0.72000000E+02 0.20000000E+02
|
||||
0.20000000E+02 0.72000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.72000000E+02 0.20000000E+02 0.30000000E+02 0.72000000E+02
|
||||
0.00000000E+00 0.30000000E+02 0.72000000E+02 0.20000000E+02
|
||||
0.40000000E+02 0.72000000E+02 0.00000000E+00 0.40000000E+02
|
||||
0.72000000E+02 0.20000000E+02 0.50000000E+02 0.72000000E+02
|
||||
0.00000000E+00 0.50000000E+02 0.72000000E+02 0.20000000E+02
|
||||
0.60000000E+02 0.72000000E+02 0.00000000E+00 0.60000000E+02
|
||||
0.72000000E+02 0.20000000E+02 0.70000000E+02 0.72000000E+02
|
||||
0.00000000E+00 0.70000000E+02 0.72000000E+02 0.20000000E+02
|
||||
0.80000000E+02 0.72000000E+02 0.00000000E+00 0.80000000E+02
|
||||
0.72000000E+02 0.20000000E+02 0.90000000E+02 0.72000000E+02
|
||||
0.00000000E+00 0.90000000E+02 0.72000000E+02 0.20000000E+02
|
||||
0.10000000E+03 0.72000000E+02 0.00000000E+00 0.10000000E+03
|
||||
0.72000000E+02 0.20000000E+02 0.00000000E+00 0.84000000E+02
|
||||
0.00000000E+00 0.00000000E+00 0.84000000E+02 0.20000000E+02
|
||||
0.10000000E+02 0.84000000E+02 0.00000000E+00 0.10000000E+02
|
||||
0.84000000E+02 0.20000000E+02 0.20000000E+02 0.84000000E+02
|
||||
0.00000000E+00 0.20000000E+02 0.84000000E+02 0.20000000E+02
|
||||
0.30000000E+02 0.84000000E+02 0.00000000E+00 0.30000000E+02
|
||||
0.84000000E+02 0.20000000E+02 0.40000000E+02 0.84000000E+02
|
||||
0.00000000E+00 0.40000000E+02 0.84000000E+02 0.20000000E+02
|
||||
0.50000000E+02 0.84000000E+02 0.00000000E+00 0.50000000E+02
|
||||
0.84000000E+02 0.20000000E+02 0.60000000E+02 0.84000000E+02
|
||||
0.00000000E+00 0.60000000E+02 0.84000000E+02 0.20000000E+02
|
||||
0.70000000E+02 0.84000000E+02 0.00000000E+00 0.70000000E+02
|
||||
0.84000000E+02 0.20000000E+02 0.80000000E+02 0.84000000E+02
|
||||
0.00000000E+00 0.80000000E+02 0.84000000E+02 0.20000000E+02
|
||||
0.90000000E+02 0.84000000E+02 0.00000000E+00 0.90000000E+02
|
||||
0.84000000E+02 0.20000000E+02 0.10000000E+03 0.84000000E+02
|
||||
0.00000000E+00 0.10000000E+03 0.84000000E+02 0.20000000E+02
|
||||
0.00000000E+00 0.96000000E+02 0.00000000E+00 0.00000000E+00
|
||||
0.96000000E+02 0.20000000E+02 0.10000000E+02 0.96000000E+02
|
||||
0.00000000E+00 0.10000000E+02 0.96000000E+02 0.20000000E+02
|
||||
0.20000000E+02 0.96000000E+02 0.00000000E+00 0.20000000E+02
|
||||
0.96000000E+02 0.20000000E+02 0.30000000E+02 0.96000000E+02
|
||||
0.00000000E+00 0.30000000E+02 0.96000000E+02 0.20000000E+02
|
||||
0.40000000E+02 0.96000000E+02 0.00000000E+00 0.40000000E+02
|
||||
0.96000000E+02 0.20000000E+02 0.50000000E+02 0.96000000E+02
|
||||
0.00000000E+00 0.50000000E+02 0.96000000E+02 0.20000000E+02
|
||||
0.60000000E+02 0.96000000E+02 0.00000000E+00 0.60000000E+02
|
||||
0.96000000E+02 0.20000000E+02 0.70000000E+02 0.96000000E+02
|
||||
0.00000000E+00 0.70000000E+02 0.96000000E+02 0.20000000E+02
|
||||
0.80000000E+02 0.96000000E+02 0.00000000E+00 0.80000000E+02
|
||||
0.96000000E+02 0.20000000E+02 0.90000000E+02 0.96000000E+02
|
||||
0.00000000E+00 0.90000000E+02 0.96000000E+02 0.20000000E+02
|
||||
0.10000000E+03 0.96000000E+02 0.00000000E+00 0.10000000E+03
|
||||
0.96000000E+02 0.20000000E+02 0.00000000E+00 0.10800000E+03
|
||||
0.00000000E+00 0.00000000E+00 0.10800000E+03 0.20000000E+02
|
||||
0.10000000E+02 0.10800000E+03 0.00000000E+00 0.10000000E+02
|
||||
0.10800000E+03 0.20000000E+02 0.20000000E+02 0.10800000E+03
|
||||
0.00000000E+00 0.20000000E+02 0.10800000E+03 0.20000000E+02
|
||||
0.30000000E+02 0.10800000E+03 0.00000000E+00 0.30000000E+02
|
||||
0.10800000E+03 0.20000000E+02 0.40000000E+02 0.10800000E+03
|
||||
0.00000000E+00 0.40000000E+02 0.10800000E+03 0.20000000E+02
|
||||
0.50000000E+02 0.10800000E+03 0.00000000E+00 0.50000000E+02
|
||||
0.10800000E+03 0.20000000E+02 0.60000000E+02 0.10800000E+03
|
||||
0.00000000E+00 0.60000000E+02 0.10800000E+03 0.20000000E+02
|
||||
0.70000000E+02 0.10800000E+03 0.00000000E+00 0.70000000E+02
|
||||
0.10800000E+03 0.20000000E+02 0.80000000E+02 0.10800000E+03
|
||||
0.00000000E+00 0.80000000E+02 0.10800000E+03 0.20000000E+02
|
||||
0.90000000E+02 0.10800000E+03 0.00000000E+00 0.90000000E+02
|
||||
0.10800000E+03 0.20000000E+02 0.10000000E+03 0.10800000E+03
|
||||
0.00000000E+00 0.10000000E+03 0.10800000E+03 0.20000000E+02
|
||||
0.00000000E+00 0.12000000E+03 0.00000000E+00 0.00000000E+00
|
||||
0.12000000E+03 0.20000000E+02 0.10000000E+02 0.12000000E+03
|
||||
0.00000000E+00 0.10000000E+02 0.12000000E+03 0.20000000E+02
|
||||
0.20000000E+02 0.12000000E+03 0.00000000E+00 0.20000000E+02
|
||||
0.12000000E+03 0.20000000E+02 0.30000000E+02 0.12000000E+03
|
||||
0.00000000E+00 0.30000000E+02 0.12000000E+03 0.20000000E+02
|
||||
0.40000000E+02 0.12000000E+03 0.00000000E+00 0.40000000E+02
|
||||
0.12000000E+03 0.20000000E+02 0.50000000E+02 0.12000000E+03
|
||||
0.00000000E+00 0.50000000E+02 0.12000000E+03 0.20000000E+02
|
||||
0.60000000E+02 0.12000000E+03 0.00000000E+00 0.60000000E+02
|
||||
0.12000000E+03 0.20000000E+02 0.70000000E+02 0.12000000E+03
|
||||
0.00000000E+00 0.70000000E+02 0.12000000E+03 0.20000000E+02
|
||||
0.80000000E+02 0.12000000E+03 0.00000000E+00 0.80000000E+02
|
||||
0.12000000E+03 0.20000000E+02 0.90000000E+02 0.12000000E+03
|
||||
0.00000000E+00 0.90000000E+02 0.12000000E+03 0.20000000E+02
|
||||
0.10000000E+03 0.12000000E+03 0.00000000E+00 0.10000000E+03
|
||||
0.12000000E+03 0.20000000E+02
|
||||
/
|
||||
|
||||
ZCORN
|
||||
400*0.00
|
||||
800*0.40E+01
|
||||
800*0.80E+01
|
||||
800*1.20E+02
|
||||
800*1.60E+02
|
||||
400*2.00E+02
|
||||
/
|
||||
|
||||
ACTNUM
|
||||
200*0 100*1 200*0 /
|
||||
|
||||
|
||||
EDIT
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
Portions Copyright 2013 Uni Research AS.
|
||||
|
||||
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 "config.h"
|
||||
|
||||
/* --- Boost.Test boilerplate --- */
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
|
||||
#define NVERBOSE // Suppress own messages when throw()ing
|
||||
|
||||
#define BOOST_TEST_MODULE CartGridTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
/* --- our own headers --- */
|
||||
#include <opm/core/grid/cart_grid.h>
|
||||
#include <opm/core/grid.h>
|
||||
#include <stdio.h>
|
||||
|
||||
BOOST_AUTO_TEST_SUITE ()
|
||||
|
||||
BOOST_AUTO_TEST_CASE (facenumbers)
|
||||
{
|
||||
int faces[] = { 0, 6, 1, 8,
|
||||
1, 7, 2, 9,
|
||||
3, 8, 4, 10,
|
||||
4, 9, 5, 11 };
|
||||
struct UnstructuredGrid *g = create_grid_cart2d(2, 2, 1., 1.);
|
||||
int i;
|
||||
int k;
|
||||
for (i = 0; i < g->number_of_cells; ++i) {
|
||||
for (k = g->cell_facepos[i]; k < g->cell_facepos[i + 1]; ++k) {
|
||||
BOOST_REQUIRE_EQUAL (g->cell_faces[k], faces[k]);
|
||||
}
|
||||
}
|
||||
destroy_grid(g);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
|
@ -1,166 +0,0 @@
|
|||
|
||||
#include <config.h>
|
||||
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
#define NVERBOSE // to suppress our messages when throwing
|
||||
|
||||
#define BOOST_TEST_MODULE ColumnExtractTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <opm/core/grid/ColumnExtract.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(SingleColumnTest)
|
||||
{
|
||||
using namespace Opm;
|
||||
|
||||
const int size_x = 1, size_y = 1, size_z = 10;
|
||||
GridManager manager(size_x, size_y, size_z);
|
||||
|
||||
std::vector<std::vector<int> > columns;
|
||||
extractColumn(*manager.c_grid(), columns);
|
||||
|
||||
std::vector<int> correct_answer;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
correct_answer.push_back(i);
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(correct_answer.begin(), correct_answer.end(),
|
||||
columns[0].begin(), columns[0].end());
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(FourByFourColumnTest)
|
||||
{
|
||||
const int size_x = 4, size_y = 4, size_z = 10;
|
||||
using namespace Opm;
|
||||
GridManager manager(size_x, size_y, size_z);
|
||||
|
||||
std::vector<std::vector<int> > columns;
|
||||
extractColumn(*manager.c_grid(), columns);
|
||||
|
||||
std::vector<std::vector<int> > correct_answer;
|
||||
correct_answer.resize(size_x * size_y);
|
||||
for(int i = 0; i < size_x * size_y; i++) {
|
||||
for(int j = 0; j < 10; j++) {
|
||||
correct_answer[i].push_back( i + j*size_x*size_y);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < size_x * size_y; i++) {
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(correct_answer[i].begin(), correct_answer[i].end(),
|
||||
columns[i].begin(), columns[i].end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(DisjointColumn)
|
||||
{
|
||||
std::string grdecl =
|
||||
"SPECGRID \n"
|
||||
"3 3 3 1 F \n"
|
||||
"/ \n"
|
||||
" \n"
|
||||
"COORD \n"
|
||||
"0.0 0 0 0.0 0 3.0 \n"
|
||||
"1.0 0 0 1.0 0 3.0 \n"
|
||||
"2.0 0 0 2.0 0 3.0 \n"
|
||||
"3.0 0 0 3.0 0 3.0 \n"
|
||||
" \n"
|
||||
"0.0 1.0 0 0.0 1.0 3.0 \n"
|
||||
"1.0 1.0 0 1.0 1.0 3.0 \n"
|
||||
"2.0 1.0 0 2.0 1.0 3.0 \n"
|
||||
"3.0 1.0 0 3.0 1.0 3.0 \n"
|
||||
" \n"
|
||||
"0.0 2.0 0 0.0 2.0 3.0 \n"
|
||||
"1.0 2.0 0 1.0 2.0 3.0 \n"
|
||||
"2.0 2.0 0 2.0 2.0 3.0 \n"
|
||||
"3.0 2.0 0 3.0 2.0 3.0 \n"
|
||||
" \n"
|
||||
"0.0 3.0 0 0.0 3.0 3.0 \n"
|
||||
"1.0 3.0 0 1.0 3.0 3.0 \n"
|
||||
"2.0 3.0 0 2.0 3.0 3.0 \n"
|
||||
"3.0 3.0 0 3.0 3.0 3.0 \n"
|
||||
"/ \n"
|
||||
" \n"
|
||||
"ZCORN \n"
|
||||
"36*0.0 \n"
|
||||
"72*1.0 \n"
|
||||
"72*2.0 \n"
|
||||
"36*3.0 \n"
|
||||
"/ \n"
|
||||
" \n"
|
||||
"ACTNUM \n"
|
||||
"13*1 \n"
|
||||
"0 \n"
|
||||
"13*1 \n"
|
||||
"/ \n"
|
||||
"\n";
|
||||
|
||||
typedef std::vector< std::vector<int> > VVI;
|
||||
|
||||
const int correct[][3] = { { 0, 9, 17 } , // 0
|
||||
{ 1, 10, 18 } , // 1
|
||||
{ 2, 11, 19 } , // 2
|
||||
{ 3, 12, 20 } , // 3
|
||||
{ 21, - 1, - 1 } , // 4
|
||||
{ 5, 13, 22 } , // 5
|
||||
{ 6, 14, 23 } , // 6
|
||||
{ 7, 15, 24 } , // 7
|
||||
{ 8, 16, 25 } , // 8
|
||||
{ 4, - 1, - 1 } }; // 9
|
||||
|
||||
const std::size_t ncol = (sizeof correct) / (sizeof correct[0]);
|
||||
|
||||
VVI correct_answer(ncol);
|
||||
|
||||
for (std::size_t i = 0; i < ncol; ++i) {
|
||||
for (std::size_t j = 0; j < 3; ++j) {
|
||||
correct_answer[i].push_back(correct[i][j]);
|
||||
}
|
||||
}
|
||||
correct_answer[4].resize(1);
|
||||
correct_answer[9].resize(1);
|
||||
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::Parser parser;
|
||||
Opm::Deck deck = parser.parseString(grdecl , parseContext);
|
||||
Opm::EclipseGrid ep = Opm::EclipseGrid(deck);
|
||||
std::vector<int> actnum;
|
||||
for (size_t i = 1; i <= (3 * 3 * 3); i++)
|
||||
actnum.push_back(i != 14); // ACTNUM 13*1 0 13* 1
|
||||
ep.resetACTNUM(actnum.data());
|
||||
Opm::GridManager manager(ep);
|
||||
|
||||
VVI columns;
|
||||
Opm::extractColumn(*manager.c_grid(), columns);
|
||||
|
||||
#if 0
|
||||
for (size_t i = 0; i < columns.size(); ++i) {
|
||||
for (size_t j = 0; j < columns[i].size(); ++j) {
|
||||
std::cout << columns[i][j] << ' ';
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_EQUAL(columns.size(), correct_answer.size());
|
||||
|
||||
for (VVI::iterator
|
||||
xb = correct_answer.begin(), xe = correct_answer.end(),
|
||||
cb = columns .begin();
|
||||
xb != xe; ++xb, ++cb) {
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS((*xb).begin(), (*xb).end(),
|
||||
(*cb).begin(), (*cb).end());
|
||||
}
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
/* Copyright 2013 Uni Research AS
|
||||
* This file is licensed under GPL3, see http://www.opm-project.org/
|
||||
*/
|
||||
#include <config.h>
|
||||
|
||||
/* --- Boost.Test boilerplate --- */
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
|
||||
#define NVERBOSE // Suppress own messages when throw()ing
|
||||
|
||||
#define BOOST_TEST_MODULE CompGeo2DTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
/* --- our own headers --- */
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/grid/cornerpoint_grid.h> /* compute_geometry */
|
||||
|
||||
using namespace std;
|
||||
|
||||
/* Test properties on a grid that looks like this:
|
||||
*
|
||||
* /------
|
||||
* / | |
|
||||
* < | |
|
||||
* \ | |
|
||||
* \------
|
||||
*
|
||||
*/
|
||||
struct BackspaceGrid {
|
||||
UnstructuredGrid* g;
|
||||
|
||||
BackspaceGrid()
|
||||
{
|
||||
g = allocate_grid(
|
||||
2, /* ndims */
|
||||
2, /* number of cells */
|
||||
6, /* number of edges */
|
||||
6*2, /* six edges with two nodes each */
|
||||
3+4, /* one triangle and one quadrilateral */
|
||||
5); /* five nodes total */
|
||||
/* nodes */
|
||||
double nodes[] = {
|
||||
-1., 0., /* node 0 */
|
||||
0., 1., /* node 1 */
|
||||
1., 1., /* node 2 */
|
||||
1., -1., /* node 3 */
|
||||
0., -1., /* node 4 */
|
||||
};
|
||||
copy(nodes, nodes+sizeof(nodes)/sizeof(nodes[0]), g->node_coordinates);
|
||||
/* edges */
|
||||
int edges[] = {
|
||||
0, 1, /* edge 0 */
|
||||
1, 2, /* edge 1 */
|
||||
2, 3, /* edge 2 */
|
||||
3, 4, /* edge 3 */
|
||||
4, 0, /* edge 4 */
|
||||
4, 1, /* edge 5 */
|
||||
};
|
||||
copy(edges, edges+sizeof(edges)/sizeof(edges[0]), g->face_nodes);
|
||||
/* starting index in map for each edge */
|
||||
int edge_pos[] = {
|
||||
0, 2, 4, 6, 8, 10, 12,
|
||||
};
|
||||
copy(edge_pos, edge_pos+sizeof(edge_pos)/sizeof(edge_pos[0]), g->face_nodepos);
|
||||
/* topology, clock-wise ordering */
|
||||
int neighbours[] = {
|
||||
-1, 0, /* edge 0, between boundary and cell 0 */
|
||||
-1, 1, /* edge 1, between boundary and cell 1 */
|
||||
-1, 1, /* edge 2, between boundary and cell 1 */
|
||||
-1, 1, /* edge 3, between boundary and cell 1 */
|
||||
-1, 0, /* edge 4, between boundary and cell 0 */
|
||||
0, 1, /* edge 5, between cell 0 and cell 1 */
|
||||
};
|
||||
copy(neighbours, neighbours+sizeof(neighbours)/sizeof(neighbours[0]), g->face_cells);
|
||||
/* cells */
|
||||
int cells[] = {
|
||||
0, 5, 4, /* cell 0, clockwise */
|
||||
1, 2, 3, 5, /* cell 1, clockwise */
|
||||
};
|
||||
copy(cells, cells+sizeof(cells)/sizeof(cells[0]), g->cell_faces);
|
||||
/* starting index in map for each cell */
|
||||
int cell_pos[] = {
|
||||
0, 3, 7,
|
||||
};
|
||||
copy(cell_pos, cell_pos+sizeof(cell_pos)/sizeof(cell_pos[0]), g->cell_facepos);
|
||||
/* everything interesting actually happens here, for all tests */
|
||||
compute_geometry(g);
|
||||
}
|
||||
|
||||
~BackspaceGrid()
|
||||
{
|
||||
destroy_grid(g);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(CompGeo2D, BackspaceGrid)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(edgeMidpoints)
|
||||
{
|
||||
double midpoints[] = {
|
||||
-0.5, 0.5, /* edge 0 */
|
||||
0.5, 1., /* edge 1 */
|
||||
1., 0., /* edge 2 */
|
||||
0.5, -1., /* edge 3 */
|
||||
-0.5, -0.5, /* edge 4 */
|
||||
0., 0., /* edge 5 */
|
||||
};
|
||||
BOOST_REQUIRE (sizeof(midpoints)/sizeof(midpoints[0]) ==
|
||||
g->number_of_faces * g->dimensions);
|
||||
for (int edge = 0; edge < g->number_of_faces; ++edge)
|
||||
{
|
||||
for (int dim = 0; dim < g->dimensions; ++dim)
|
||||
{
|
||||
BOOST_REQUIRE_CLOSE (g->face_centroids[edge*g->dimensions+dim],
|
||||
midpoints[edge*g->dimensions+dim], 0.001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(edgeNormals)
|
||||
{
|
||||
/* inward normal when doing clockwise enumeration */
|
||||
double normals[] = {
|
||||
1., -1., /* edge 0 */
|
||||
0., -1., /* edge 1 */
|
||||
-2., 0., /* edge 2 */
|
||||
0., 1., /* edge 3 */
|
||||
1., 1., /* edge 4 */
|
||||
2., 0., /* edge 5 */
|
||||
};
|
||||
BOOST_REQUIRE (sizeof(normals)/sizeof(normals[0]) ==
|
||||
g->number_of_faces * g->dimensions);
|
||||
for (int edge = 0; edge < g->number_of_faces; ++edge)
|
||||
{
|
||||
for (int dim = 0; dim < g->dimensions; ++dim)
|
||||
{
|
||||
BOOST_REQUIRE_CLOSE (g->face_normals[edge*g->dimensions+dim],
|
||||
normals[edge*g->dimensions+dim], 0.001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(edgeLengths)
|
||||
{
|
||||
double lengths[] = {
|
||||
1.4142, /* edge 0 */
|
||||
1., /* edge 1 */
|
||||
2., /* edge 2 */
|
||||
1., /* edge 3 */
|
||||
1.4142, /* edge 4 */
|
||||
2., /* edge 5 */
|
||||
};
|
||||
BOOST_REQUIRE (sizeof(lengths)/sizeof(lengths[0]) == g->number_of_faces);
|
||||
for (int edge = 0; edge < g->number_of_faces; ++edge)
|
||||
{
|
||||
BOOST_REQUIRE_CLOSE (g->face_areas[edge], lengths[edge], 0.001);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cellAreas)
|
||||
{
|
||||
double areas[] = {
|
||||
1., 2.,
|
||||
};
|
||||
BOOST_REQUIRE (sizeof(areas)/sizeof(areas[0]) == g->number_of_cells);
|
||||
for (int cell = 0; cell < g->number_of_cells; ++cell)
|
||||
{
|
||||
BOOST_REQUIRE_CLOSE (g->cell_volumes[cell], areas[cell], 0.001);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cellCenters)
|
||||
{
|
||||
double cellCenters_var[] = {
|
||||
-1./3., 0.0, /* cell 0 */
|
||||
1./2., 0.0, /* cell 1 */
|
||||
};
|
||||
BOOST_REQUIRE (sizeof(cellCenters_var)/sizeof(cellCenters_var[0]) ==
|
||||
g->number_of_cells * g->dimensions);
|
||||
for (int cell = 0; cell < g->number_of_cells; ++cell)
|
||||
{
|
||||
for (int dim = 0; dim < g->dimensions; ++dim)
|
||||
{
|
||||
BOOST_REQUIRE_CLOSE (g->cell_centroids[cell*g->dimensions+dim],
|
||||
cellCenters_var[cell*g->dimensions+dim], 0.001);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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 <config.h>
|
||||
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
#define NVERBOSE // to suppress our messages when throwing
|
||||
|
||||
#define BOOST_TEST_MODULE GridUtilitiesTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/core/grid/GridUtilities.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cartesian_2d_cellNeighboursAcrossVertices)
|
||||
{
|
||||
const GridManager gm(2, 2);
|
||||
const UnstructuredGrid& grid = *gm.c_grid();
|
||||
const SparseTable<int> vnb = cellNeighboursAcrossVertices(grid);
|
||||
|
||||
const int num_elem = 12;
|
||||
const int elem[num_elem] = { 1, 2, 3, 0, 2, 3, 0, 1, 3, 0, 1, 2 };
|
||||
const int num_rows = 4;
|
||||
const int rowsizes[num_rows] = { 3, 3, 3, 3 };
|
||||
const SparseTable<int> truth(elem, elem + num_elem, rowsizes, rowsizes + num_rows);
|
||||
BOOST_CHECK(vnb == truth);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cartesian_3d_cellNeighboursAcrossVertices)
|
||||
{
|
||||
const GridManager gm(3, 2, 2);
|
||||
const UnstructuredGrid& grid = *gm.c_grid();
|
||||
const SparseTable<int> vnb = cellNeighboursAcrossVertices(grid);
|
||||
|
||||
BOOST_CHECK_EQUAL(int(vnb.size()), grid.number_of_cells);
|
||||
BOOST_REQUIRE(!vnb.empty());
|
||||
const int n = 7;
|
||||
BOOST_CHECK_EQUAL(int(vnb[0].size()), n);
|
||||
const int nb[n] = { 1, 3, 4, 6, 7, 9, 10 };
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(vnb[0].begin(), vnb[0].end(), nb, nb + n);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(cartesian_2d_orderCounterClockwise)
|
||||
{
|
||||
const GridManager gm(2, 2);
|
||||
const UnstructuredGrid& grid = *gm.c_grid();
|
||||
SparseTable<int> vnb = cellNeighboursAcrossVertices(grid);
|
||||
orderCounterClockwise(grid, vnb);
|
||||
|
||||
BOOST_REQUIRE(!vnb.empty());
|
||||
const int num_elem = 12;
|
||||
const int elem[num_elem] = { 1, 3, 2, 3, 2, 0, 3, 0, 1, 2, 0, 1 };
|
||||
const int num_rows = 4;
|
||||
const int rowsizes[num_rows] = { 3, 3, 3, 3 };
|
||||
const SparseTable<int> truth(elem, elem + num_elem, rowsizes, rowsizes + num_rows);
|
||||
BOOST_CHECK(vnb == truth);
|
||||
for (int c = 0; c < num_rows; ++c) {
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(vnb[c].begin(), vnb[c].end(), truth[c].begin(), truth[c].end());
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
Copyright 2014 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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 <config.h>
|
||||
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
#define NVERBOSE // to suppress our messages when throwing
|
||||
|
||||
#define BOOST_TEST_MODULE MinpvProcessorTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/core/grid/MinpvProcessor.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Processing)
|
||||
{
|
||||
std::vector<double> zcorn = { 0, 0, 0, 0,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
3, 3, 3, 3,
|
||||
3, 3, 3, 3,
|
||||
6, 6, 6, 6 };
|
||||
std::vector<double> zcorn2after = { 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
3, 3, 3, 3,
|
||||
3, 3, 3, 3,
|
||||
6, 6, 6, 6 };
|
||||
std::vector<double> zcorn3after = { 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
6, 6, 6, 6 };
|
||||
std::vector<double> zcorn4after = { 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
1, 1, 1, 1,
|
||||
3, 3, 3, 3,
|
||||
3, 3, 3, 3,
|
||||
6, 6, 6, 6 };
|
||||
std::vector<double> zcorn5after = { 0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
1, 1, 1, 1,
|
||||
1, 1, 1, 1,
|
||||
3, 3, 3, 3,
|
||||
6, 6, 6, 6 };
|
||||
|
||||
std::vector<double> pv = { 1, 2, 3 };
|
||||
std::vector<int> actnum = { 1, 1, 1 };
|
||||
|
||||
Opm::MinpvProcessor mp1(1, 1, 3);
|
||||
auto z1 = zcorn;
|
||||
bool fill_removed_cells = true;
|
||||
mp1.process(pv, 0.5, actnum, fill_removed_cells, z1.data());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(z1.begin(), z1.end(), zcorn.begin(), zcorn.end());
|
||||
|
||||
Opm::MinpvProcessor mp2(1, 1, 3);
|
||||
auto z2 = zcorn;
|
||||
mp2.process(pv, 1.5, actnum, fill_removed_cells, z2.data());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(z2.begin(), z2.end(), zcorn2after.begin(), zcorn2after.end());
|
||||
|
||||
Opm::MinpvProcessor mp3(1, 1, 3);
|
||||
auto z3 = zcorn;
|
||||
mp3.process(pv, 2.5, actnum, fill_removed_cells, z3.data());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(z3.begin(), z3.end(), zcorn3after.begin(), zcorn3after.end());
|
||||
|
||||
Opm::MinpvProcessor mp4(1, 1, 3);
|
||||
auto z4 = zcorn;
|
||||
mp4.process(pv, 1.5, actnum, !fill_removed_cells, z4.data());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(z4.begin(), z4.end(), zcorn4after.begin(), zcorn4after.end());
|
||||
|
||||
Opm::MinpvProcessor mp5(1, 1, 3);
|
||||
auto z5 = zcorn;
|
||||
mp5.process(pv, 2.5, actnum, !fill_removed_cells, z5.data());
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(z5.begin(), z5.end(), zcorn5after.begin(), zcorn5after.end());
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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 <config.h>
|
||||
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
#define NVERBOSE // to suppress our messages when throwing
|
||||
|
||||
#define BOOST_TEST_MODULE QuadratureTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <opm/core/grid/CellQuadrature.hpp>
|
||||
#include <opm/core/grid/FaceQuadrature.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
#include <cmath>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
template <class Quadrature>
|
||||
class Integrator
|
||||
{
|
||||
public:
|
||||
explicit Integrator(const UnstructuredGrid& grid, const int entity, const int degree)
|
||||
: quad_(grid, entity, degree),
|
||||
pt(grid.dimensions)
|
||||
{
|
||||
}
|
||||
template <class Func>
|
||||
double integrate(const Func& f) const
|
||||
{
|
||||
double res = 0;
|
||||
for (int quad_pt = 0; quad_pt < quad_.numQuadPts(); ++quad_pt) {
|
||||
quad_.quadPtCoord(quad_pt, &pt[0]);
|
||||
const double w = quad_.quadPtWeight(quad_pt);
|
||||
const double fval = f(&pt[0]);
|
||||
res += w*fval;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
private:
|
||||
const Quadrature quad_;
|
||||
mutable std::vector<double> pt;
|
||||
};
|
||||
|
||||
|
||||
template <class Quadrature, class Func>
|
||||
void testSingleCase(const UnstructuredGrid& grid,
|
||||
const int entity,
|
||||
const int degree,
|
||||
const double expected_answer)
|
||||
{
|
||||
Integrator<Quadrature> integrator(grid, entity, degree);
|
||||
Func f;
|
||||
const double val = integrator.integrate(f);
|
||||
BOOST_CHECK(std::fabs(val - expected_answer) < 1e-12);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
namespace cart2d
|
||||
{
|
||||
struct ConstantFunc
|
||||
{
|
||||
double operator()(const double*) const
|
||||
{
|
||||
return 1.234;
|
||||
}
|
||||
};
|
||||
|
||||
struct LinearFunc
|
||||
{
|
||||
double operator()(const double* x) const
|
||||
{
|
||||
return 1.0*x[0] + 2.0*x[1] + 3.0;
|
||||
}
|
||||
};
|
||||
|
||||
struct QuadraticFunc
|
||||
{
|
||||
double operator()(const double* x) const
|
||||
{
|
||||
return 3.0*x[0]*x[0] + 1.0*x[0]*x[1] + 2.0*x[1] + 3.0;
|
||||
}
|
||||
};
|
||||
|
||||
static void test()
|
||||
{
|
||||
// Set up 2d 1-cell cartesian case.
|
||||
GridManager g(1, 1);
|
||||
const UnstructuredGrid& grid = *g.c_grid();
|
||||
|
||||
// CellQuadrature tests.
|
||||
testSingleCase<CellQuadrature, ConstantFunc>(grid, 0, 1, 1.234);
|
||||
testSingleCase<CellQuadrature, LinearFunc>(grid, 0, 1, 4.5);
|
||||
testSingleCase<CellQuadrature, ConstantFunc>(grid, 0, 2, 1.234);
|
||||
testSingleCase<CellQuadrature, LinearFunc>(grid, 0, 2, 4.5);
|
||||
testSingleCase<CellQuadrature, QuadraticFunc>(grid, 0, 2, 5.25);
|
||||
|
||||
// FaceQuadrature tests, degree 1 precision.
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 0, 1, 4);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 1, 1, 5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 2, 1, 3.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 3, 1, 5.5);
|
||||
|
||||
// FaceQuadrature tests, degree 2 precision.
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 0, 2, 4);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 1, 2, 5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 2, 2, 3.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 3, 2, 5.5);
|
||||
|
||||
// FaceQuadrature tests, quadratic function, degree 2 precision.
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 0, 2, 4.0);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 1, 2, 7.5);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 2, 2, 4.0);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 3, 2, 6.5);
|
||||
}
|
||||
} // namespace cart2d
|
||||
|
||||
|
||||
namespace cart3d
|
||||
{
|
||||
struct LinearFunc
|
||||
{
|
||||
double operator()(const double* x) const
|
||||
{
|
||||
return 1.0*x[0] + 2.0*x[1] + 1.0*x[2] + 3.0;
|
||||
}
|
||||
};
|
||||
|
||||
struct QuadraticFunc
|
||||
{
|
||||
double operator()(const double* x) const
|
||||
{
|
||||
return 1.0*x[0]*x[1] + 2.0*x[1] + 4.0*x[2] + 3.0;
|
||||
}
|
||||
};
|
||||
|
||||
static void test()
|
||||
{
|
||||
// Set up 3d 1-cell cartesian case.
|
||||
GridManager g(1, 1, 1);
|
||||
const UnstructuredGrid& grid = *g.c_grid();
|
||||
|
||||
// CellQuadrature tests.
|
||||
testSingleCase<CellQuadrature, LinearFunc>(grid, 0, 1, 5.0);
|
||||
testSingleCase<CellQuadrature, LinearFunc>(grid, 0, 2, 5.0);
|
||||
testSingleCase<CellQuadrature, QuadraticFunc>(grid, 0, 2, 6.25);
|
||||
|
||||
// FaceQuadrature tests, degree 1 precision.
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 0, 1, 4.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 1, 1, 5.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 2, 1, 4.0);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 3, 1, 6.0);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 4, 1, 4.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 5, 1, 5.5);
|
||||
|
||||
// FaceQuadrature tests, degree 2 precision.
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 0, 2, 4.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 1, 2, 5.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 2, 2, 4.0);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 3, 2, 6.0);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 4, 2, 4.5);
|
||||
testSingleCase<FaceQuadrature, LinearFunc>(grid, 5, 2, 5.5);
|
||||
|
||||
// FaceQuadrature tests, quadratic function, degree 2 precision.
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 0, 2, 6.0);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 1, 2, 6.5);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 2, 2, 5.0);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 3, 2, 7.5);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 4, 2, 4.25);
|
||||
testSingleCase<FaceQuadrature, QuadraticFunc>(grid, 5, 2, 8.25);
|
||||
}
|
||||
|
||||
} // namespace cart3d
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_quadratures)
|
||||
{
|
||||
cart2d::test();
|
||||
cart3d::test();
|
||||
}
|
|
@ -1,177 +0,0 @@
|
|||
/* Copyright 2014 Statoil ASA
|
||||
* This file is licensed under GPL3, see http://www.opm-project.org/
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
/* --- Boost.Test boilerplate --- */
|
||||
#if HAVE_DYNAMIC_BOOST_TEST
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#endif
|
||||
|
||||
#define NVERBOSE // Suppress own messages when throw()ing
|
||||
|
||||
#define BOOST_TEST_MODULE TEST_UG
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/floating_point_comparison.hpp>
|
||||
|
||||
/* --- our own headers --- */
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/grid/cornerpoint_grid.h> /* compute_geometry */
|
||||
#include <opm/core/grid/GridManager.hpp> /* compute_geometry */
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
#include <opm/core/grid/cpgpreprocess/preprocess.h>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Equal) {
|
||||
Opm::ParseContext parseContext;
|
||||
const std::string filename1 = "CORNERPOINT_ACTNUM.DATA";
|
||||
const char *deck2Data =
|
||||
"RUNSPEC\n"
|
||||
"\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
"GRID\n"
|
||||
"DXV\n"
|
||||
"10*0.25 /\n"
|
||||
"DYV\n"
|
||||
"10*0.25 /\n"
|
||||
"DZV\n"
|
||||
"10*0.25 /\n"
|
||||
"TOPS\n"
|
||||
"100*0.25 /\n"
|
||||
"EDIT\n"
|
||||
"\n";
|
||||
|
||||
Opm::Parser parser;
|
||||
|
||||
Opm::Deck deck1 = parser.parseFile( filename1 , parseContext);
|
||||
Opm::EclipseState es1(deck1, parseContext);
|
||||
|
||||
Opm::Deck deck2 = parser.parseString( deck2Data , parseContext);
|
||||
Opm::EclipseState es2(deck2, parseContext);
|
||||
|
||||
BOOST_CHECK( deck1.hasKeyword("ZCORN") );
|
||||
BOOST_CHECK( deck1.hasKeyword("COORD") );
|
||||
|
||||
Opm::GridManager grid1(es1.getInputGrid());
|
||||
Opm::GridManager grid2(es2.getInputGrid());
|
||||
|
||||
const UnstructuredGrid* cgrid1 = grid1.c_grid();
|
||||
const UnstructuredGrid* cgrid2 = grid2.c_grid();
|
||||
|
||||
|
||||
|
||||
BOOST_CHECK( grid_equal( cgrid1 , cgrid1 ));
|
||||
BOOST_CHECK( grid_equal( cgrid2 , cgrid2 ));
|
||||
BOOST_CHECK( !grid_equal( cgrid1 , cgrid2 ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO This method might be obsolete after using EclipseState to generate grid
|
||||
BOOST_AUTO_TEST_CASE(EqualEclipseGrid) {
|
||||
const std::string filename = "CORNERPOINT_ACTNUM.DATA";
|
||||
Opm::Parser parser;
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::Deck deck = parser.parseFile( filename , parseContext);
|
||||
Opm::EclipseState es(deck, parseContext);
|
||||
auto grid = es.getInputGrid();
|
||||
|
||||
Opm::GridManager gridM(es.getInputGrid());
|
||||
const UnstructuredGrid* cgrid1 = gridM.c_grid();
|
||||
struct UnstructuredGrid * cgrid2;
|
||||
{
|
||||
struct grdecl g;
|
||||
const auto& dimens = deck.getKeyword("DIMENS");
|
||||
const auto& coord = deck.getKeyword("COORD");
|
||||
const auto& zcorn = deck.getKeyword("ZCORN");
|
||||
const auto& actnum = deck.getKeyword("ACTNUM");
|
||||
|
||||
g.dims[0] = dimens.getRecord(0).getItem("NX").get< int >(0);
|
||||
g.dims[1] = dimens.getRecord(0).getItem("NY").get< int >(0);
|
||||
g.dims[2] = dimens.getRecord(0).getItem("NZ").get< int >(0);
|
||||
|
||||
g.coord = coord.getSIDoubleData().data();
|
||||
g.zcorn = zcorn.getSIDoubleData().data();
|
||||
g.actnum = actnum.getIntData().data();
|
||||
g.mapaxes = NULL;
|
||||
|
||||
|
||||
cgrid2 = create_grid_cornerpoint(&g , 0.0);
|
||||
if (!cgrid2)
|
||||
throw std::runtime_error("Failed to construct grid.");
|
||||
}
|
||||
|
||||
|
||||
BOOST_CHECK( grid_equal( cgrid1 , cgrid2 ));
|
||||
destroy_grid( cgrid2 );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TOPS_Fully_Specified) {
|
||||
const char *deck1Data =
|
||||
"RUNSPEC\n"
|
||||
"\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 3 /\n"
|
||||
"GRID\n"
|
||||
"DX\n"
|
||||
"300*1000 /\n"
|
||||
"DY\n"
|
||||
"300*1000 /\n"
|
||||
"DZ\n"
|
||||
"100*20 100*30 100*50 /\n"
|
||||
"TOPS\n"
|
||||
"100*8325 /\n"
|
||||
"EDIT\n"
|
||||
"\n";
|
||||
|
||||
|
||||
const char *deck2Data =
|
||||
"RUNSPEC\n"
|
||||
"\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 3 /\n"
|
||||
"GRID\n"
|
||||
"DX\n"
|
||||
"300*1000 /\n"
|
||||
"DY\n"
|
||||
"300*1000 /\n"
|
||||
"DZ\n"
|
||||
"100*20 100*30 100*50 /\n"
|
||||
"TOPS\n"
|
||||
"100*8325 100*8345 100*8375/\n"
|
||||
"EDIT\n"
|
||||
"\n";
|
||||
|
||||
Opm::Parser parser;
|
||||
Opm::ParseContext parseContext;
|
||||
const Opm::Deck& deck1 = parser.parseString(deck1Data, parseContext);
|
||||
const Opm::Deck& deck2 = parser.parseString(deck2Data, parseContext);
|
||||
|
||||
Opm::EclipseState es1(deck1, parseContext);
|
||||
Opm::EclipseState es2(deck2, parseContext);
|
||||
|
||||
Opm::GridManager gridM1(es1.getInputGrid());
|
||||
Opm::GridManager gridM2(es2.getInputGrid());
|
||||
|
||||
const UnstructuredGrid* cgrid1 = gridM1.c_grid();
|
||||
const UnstructuredGrid* cgrid2 = gridM2.c_grid();
|
||||
|
||||
BOOST_CHECK(grid_equal(cgrid1, cgrid2));
|
||||
|
||||
Opm::EclipseGrid grid = Opm::UgGridHelpers::createEclipseGrid( *cgrid1 , es1.getInputGrid( ) );
|
||||
}
|
Loading…
Reference in New Issue
Block a user