// Copyright (C) 2012, 2014 David Maxwell // // This file is part of PISM. // // PISM 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. // // PISM 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 PISM; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "IPMeanSquareFunctional.hh" //! Implicitly set the normalization constant for the functional. /*! The normalization constant is selected so that if an input IceModelVec2V has component vectors all of length \a scale, then the funtional value will be 1. I.e. \f[ c_N^{-1} = \sum_{i} w_i {\tt scale}^2. \f]*/ PetscErrorCode IPMeanSquareFunctional2V::normalize(double scale) { PetscErrorCode ierr; // The local value of the weights double value = 0; if(m_weights) { double **w_a; ierr = m_weights->get_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; iget_array(w_a); CHKERRQ(ierr); for( int i=m_grid.xs; iend_access(); CHKERRQ(ierr); } else { for( int i=m_grid.xs; i