testFunction3d.C 1.27 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2018 The Regents of the University of California
//
// This file is part of Qbox
//
// Qbox is distributed under the terms of the GNU General Public License
// as published by the Free Software Foundation, either version 2 of
// the License, or (at your option) any later version.
// See the file COPYING in the root directory of this distribution
// or <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////
//
// testFunction3d.C
//
////////////////////////////////////////////////////////////////////////////////
18 19 20 21
#include<iostream>
#include "Function3d.h"
using namespace std;

22 23 24
// usage: ./testFunction3d file.xml

int main(int argc, char** argv)
25 26
{
  Function3d f;
27 28 29 30 31 32
  if ( argc != 2 )
  {
    cerr << "usage: " << argv[0] << " file.xml" << endl;
    return 1;
  }
  f.read(argv[1]);
33

34 35 36
  cout << "function name: " << f.name << endl;
  cout << "function grid size: " << f.nx << " " << f.ny << " " << f.nz  << endl;
  cout << "function array size: " << f.val.size() << endl;
37 38

  double sum = 0.0;
39
  for ( int i = 0; i < f.val.size(); i++ )
40
  {
41
    sum += f.val[i]*f.val[i];
42
  }
43
  cout << "function norm2: " << sum / f.val.size() << endl;
44
}