2013-05-10 10:25:46 +02:00
|
|
|
/*
|
2019-05-07 07:15:25 +02:00
|
|
|
Copyright (C) 2013 Equinor ASA, Norway.
|
2017-02-07 13:44:59 +01:00
|
|
|
|
|
|
|
|
The file 'geo_surface.c' is part of ERT - Ensemble based Reservoir Tool.
|
|
|
|
|
|
|
|
|
|
ERT 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.
|
|
|
|
|
|
|
|
|
|
ERT 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 at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
|
for more details.
|
2013-05-10 10:25:46 +02:00
|
|
|
*/
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2018-08-13 10:20:34 +02:00
|
|
|
#include <ert/util/test_util.hpp>
|
2013-05-10 10:25:46 +02:00
|
|
|
#include <ert/util/util.h>
|
2018-08-13 10:20:34 +02:00
|
|
|
#include <ert/util/test_work_area.hpp>
|
2013-05-10 10:25:46 +02:00
|
|
|
|
2018-08-13 10:20:34 +02:00
|
|
|
#include <ert/geometry/geo_surface.hpp>
|
2013-05-10 10:25:46 +02:00
|
|
|
|
|
|
|
|
|
2014-10-09 20:13:04 +02:00
|
|
|
void test_load(const char * input_file , const char * broken_file) {
|
2013-05-10 10:25:46 +02:00
|
|
|
geo_surface_type * surface = geo_surface_fload_alloc_irap( input_file , false );
|
2018-08-13 10:20:34 +02:00
|
|
|
double * data = (double *) util_calloc( geo_surface_get_size( surface ) , sizeof * data );
|
2017-02-07 13:44:59 +01:00
|
|
|
|
2013-05-10 10:25:46 +02:00
|
|
|
test_assert_true( geo_surface_fload_irap_zcoord( surface , input_file , data ));
|
|
|
|
|
test_assert_false( geo_surface_fload_irap_zcoord( surface , "/does/not/exist" , data ));
|
2014-10-09 20:13:04 +02:00
|
|
|
test_assert_false( geo_surface_fload_irap_zcoord( surface , broken_file , data ));
|
2013-05-10 10:25:46 +02:00
|
|
|
|
|
|
|
|
free( data );
|
|
|
|
|
geo_surface_free( surface );
|
2014-10-09 20:13:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void test_fprintf(const char * input_file ) {
|
|
|
|
|
geo_surface_type * surface1 = geo_surface_fload_alloc_irap( input_file , true );
|
|
|
|
|
test_work_area_type * work_area = test_work_area_alloc( "SURFACE-FPRINTF" );
|
2017-02-07 13:44:59 +01:00
|
|
|
|
2014-10-09 20:13:04 +02:00
|
|
|
geo_surface_fprintf_irap( surface1 , "surface/test/surface.irap");
|
|
|
|
|
{
|
|
|
|
|
geo_surface_type * surface2 = geo_surface_fload_alloc_irap( "surface/test/surface.irap" , true );
|
2017-02-07 13:44:59 +01:00
|
|
|
|
2014-10-09 20:13:04 +02:00
|
|
|
test_assert_true( geo_surface_equal( surface1 , surface2 ));
|
2017-02-07 13:44:59 +01:00
|
|
|
|
2014-10-09 20:13:04 +02:00
|
|
|
geo_surface_free( surface2 );
|
|
|
|
|
}
|
|
|
|
|
test_work_area_free( work_area );
|
|
|
|
|
geo_surface_free( surface1 );
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 13:44:59 +01:00
|
|
|
void test_create_new( const char * input_file) {
|
|
|
|
|
geo_surface_type * surface = geo_surface_alloc_new( 260, 511, 50.0, 50.0,
|
|
|
|
|
444230.0, 6809537.0,
|
|
|
|
|
-30.0);
|
|
|
|
|
test_assert_true(geo_surface_get_nx (surface) == 260);
|
|
|
|
|
test_assert_true(geo_surface_get_ny (surface) == 511);
|
|
|
|
|
test_assert_true(geo_surface_get_size(surface) == 511*260);
|
|
|
|
|
|
|
|
|
|
geo_surface_type * surirap = geo_surface_fload_alloc_irap( input_file , true );
|
|
|
|
|
test_assert_true( geo_surface_equal_header( surface, surirap ) );
|
|
|
|
|
|
|
|
|
|
geo_surface_free( surirap );
|
|
|
|
|
geo_surface_free( surface );
|
|
|
|
|
}
|
2014-10-09 20:13:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
int main( int argc , char ** argv) {
|
|
|
|
|
char * input_file = argv[1];
|
|
|
|
|
char * broken_file1 = argv[2];
|
|
|
|
|
|
|
|
|
|
test_load( input_file , broken_file1 );
|
|
|
|
|
test_fprintf( input_file );
|
2017-02-07 13:44:59 +01:00
|
|
|
test_create_new( input_file );
|
2013-05-10 10:25:46 +02:00
|
|
|
exit( 0 );
|
|
|
|
|
}
|