xref: /libCEED/examples/fluids/conv_test.sh (revision 45f1e31534dab57749ac564f1e0d76b3f0f0e0d7)
1#!/bin/bash
2
3# Copyright (c) 2017, Lawrence Livermore National Security, LLC.
4# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
5# All Rights reserved. See files LICENSE and NOTICE for details.
6#
7# This file is part of CEED, a collection of benchmarks, miniapps, software
8# libraries and APIs for efficient high-order finite element and spectral
9# element discretizations for exascale applications. For more information and
10# source code availability see http://github.com/ceed.
11#
12# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
13# a collaborative effort of two U.S. Department of Energy organizations (Office
14# of Science and the National Nuclear Security Administration) responsible for
15# the planning and preparation of a capable exascale ecosystem, including
16# software, applications, hardware, advanced system engineering and early
17# testbed platforms, in support of the nation's exascale computing imperative.
18
19declare -A run_flags
20    run_flags[problem]=euler_vortex
21    run_flags[degree]=2
22    run_flags[dm_plex_box_faces]=20,20,1
23    run_flags[euler_test]=none
24    run_flags[lx]=1e3
25    run_flags[ly]=1e3
26    run_flags[lz]=1
27    run_flags[ts_max_time]=.02
28    run_flags[ts_rk_type]=5bs
29    run_flags[ts_rtol]=1e-10
30    run_flags[ts_atol]=1e-10
31
32declare -A test_flags
33    test_flags[degree_start]=1
34    test_flags[degree_stride]=1
35    test_flags[degree_end]=3
36    test_flags[res_start]=6
37    test_flags[res_stride]=2
38    test_flags[res_end]=10
39
40file_name=conv_test_result.csv
41
42echo ",mesh_res,degree,rel_error" > $file_name
43
44i=0
45for ((d=${test_flags[degree_start]}; d<=${test_flags[degree_end]}; d+=${test_flags[degree_stride]})); do
46    run_flags[degree]=$d
47    for ((res=${test_flags[res_start]}; res<=${test_flags[res_end]}; res+=${test_flags[res_stride]})); do
48        run_flags[dm_plex_box_faces]=$res,$res,1
49        args=''
50        for arg in "${!run_flags[@]}"; do
51            if ! [[ -z ${run_flags[$arg]} ]]; then
52                args="$args -$arg ${run_flags[$arg]}"
53            fi
54        done
55        ./navierstokes $args | grep "Relative Error:" | awk -v i="$i" -v res="$res" -v d="$d" '{ printf "%d,%d,%d,%.5f\n", i, res, d, $3}' >> $file_name
56        i=$((i+1))
57    done
58done
59
60# Compare the output CSV file with the reference file
61count=$(diff conv_test_result.csv tests-output/fluids-navierstokes-conv-euler.csv | grep "^>" | wc -l)
62if [ ${count} != 0 ]; then
63    printf "\n# TEST FAILED!\n\n"
64    diff -q conv_test_result.csv tests-output/fluids-navierstokes-conv-euler.csv
65    printf "\n"
66fi
67