NOX
Development
|
.H
and source files end in
.C
NOX::Abstract::Group
is in
the file NOX_Abstract_Group.H
.
//@HEADER // ************************************************************************ // // NOX: An Object-Oriented Nonlinear Solver Package // Copyright (2002) Sandia Corporation // // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive // license for use of this work by or on behalf of the U.S. Government. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or // Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. // ************************************************************************ // CVS Information // $Source$ // $Author$ // $Date$ // $Revision$ // ************************************************************************ //@HEADEROnce the file is committed to the CVS repository, the CVS Information lines will look something like the following:
// $Source$ // $Author$ // $Date$ // $Revision$The header information is automatically filled in between the two
//@HEADER
keys when we run the nox/maintenance/update_nox_headers.sh
command.
NOX_Abstract_Vector.H
header
file.
#ifndef NOX_ABSTRACT_VECTOR_H #define NOX_ABSTRACT_VECTOR_H ...body of include file goes here... #endif
iostream
) directly
in your files. Instead, include NOX_Common.H
. The goal is
to better enable system portability since some machines have
math.h
and others have cmath
and so
on. Currently, we have the following system headers:
cstdlib
cstdio
cassert
iostream
iomanip
string
cmath
vector
map
deque
algorithm
sstream
fstream
#include "../test/utils/NOX_TestCompare.H"
#include "NOX_TestCompare.H"
*
) or references (&
) should be declared
using forward declarations, and not by including the header files.
NOX
namespace. No exceptions!
Abstract
Parameter
Solver
StatusTest
LineSearch
Direction
Epetra
NOX::Linesearch::MoreThuente
).
_
' or `__
').
{}
function. The reason for this is that if the function does not inline
correctly, it can actually lead to slower code rather than faster
code.
void foo (); // No!! void foo(); // Better
int i,j; // No!! int i; // Yes int j;
*
' and `&
' should
be written together with the types of variables instead of with the
names of variables in order to emphasize that they are part of the type
definition. Instead of saying that *i
is an int
,
say that i
is an int*
.
int *i; // No!! int* i; // Yes
if
, for
,
while
, etc.if (a == b && c < d || e == f) // No! { /* Stuff */ } if (((a == b) && (c < d)) || (e == f)) // Yes { /* Stuff */ }
if
statement should always follow on
a separate line.
if ( /*Something*/ ) i++; // No!! if ( /*Something*/ ) // Yes! i++;
if ( /*Something*/ ) // Yes! { i++; j++; } if ( /*Something*/ ) { // Okay i++; j++; } if ( /*Something*/ ) // No! { i++; j++; }Adding the following line to your \c .emacs file will help:
(c-set-offset 'substatement-open 0)
=
signs and all logical
operators.
.
' or `->
', nor between unary operators
and operands.
const
or
enum
; never using #define
.
NOX::Utils
class has utility functions related
to printing. To use it, include NOX_Utils.H
.
NOX::Utils::out
or NOX::Utils::pout
functions with the appropriate
MsgType flag. The flags are:
NOX::Utils::Error
NOX::Utils::Warning
NOX::Utils::OuterIteration
NOX::Utils::InnerIteration
NOX::Utils::Parameters
NOX::Utils::Details
NOX::Utils::OuterIterationStatusTest
NOX::Utils::LinearSolverDetails
NOX::Utils::TestDetails
NOX::Utils::StepperIteration
NOX::Utils::StepperDetails
NOX::Utils::StepperParameters
NOX::Utils::Debug
NOX::Utils::err
or NOX::Utils::perr
and then throw an exception with the std::string
"NOX Error"
. For example if utils is a NOX::Utils object,
if (/* Error Condition */) { utils.err() << "ERROR: NOX::Epetra::Group::getNewton() - invalid Newton vector" << std::endl; throw "NOX Error"; }
/*
) is followed by an exclamation mark to indicate that
it's a Doxygen comment. The open and close comment markers are on
lines by themselves, and the text of the comment is indented two
spaces. Always include a \brief
description. The long
description follows. Observe the use of the formatting tags
\c
and \e
. The \note
tag is
used for any special notes. The \author
tag is
recommended.
/*! \brief Arbitrary combination of status tests. In the \c AND (see NOX::Status::Combo::ComboType) combination, the result is \c Unconverged (see NOX::Status::StatusType) if \e any of the tests is \c Unconverged. Otherwise, the result is equal to the result of the \e first test in the list that is either \c Converged or \c Failed. It is not recommended to mix \c Converged and \c Failed tests in an \c AND combination. In the \c OR combination, the result is \c Unconverged if \e all of the tests are \c Unconverged. Otherwise, it is the result of the \e first test in the list that is either \c Converged or \c Failed. Therefore, it will generally make sense to put the \c Failed -type tests at the end of the \c OR list. \note We always runs through all tests, even if we don't need to. This is useful so that the user knows which tests have and have not be satisfied. \author Tammy Kolda (SNL 8950) */ class Combo : public Test { ... }; // class Combo
/*! \brief %Newton-like solver with a line search. The following parameters are valid for this solver: - "Line Search" - Sublist of the line search parameters, passed to the NOX::Linesearch::Factory. Defaults to an empty list. - "Linear Solver" - Sublist of the linear solver parameters, passed to Abstract::Group::computeNewton(). Furthermore, the "Tolerance" within this list may be modified by the resetForcingTerm(). Defaults to an empty list. - "Forcing Term Method" - Method to compute the forcing term, i.e., the tolerance for the linear solver. Defaults to "" (nothing). Choices are "Type 1" and "Type 2". - "Forcing Term Minimum Tolerance" - Minimum acceptable linear solver tolerance. Defaults to 1.0e-6. - "Forcing Term Maximum Tolerance" = Maximum acceptable linear solver tolerance. Default to 0.01. - "Forcing Term Alpha" - Used for the "Type 2" forcing term calculation. Defaults to 1.5. - "Forcing Term Gamma" - Used for the "Type 2" forcing term calculation. Defaults to 0.9. \author Tammy Kolda (SNL 8950), Roger Pawlowski (SNL 9233) */Here's a more complicated example to produce a two-tiered list.
/*! The parameters must specify the type of line search as well as all the corresponding parameters for that line search. <ul> <li> "Method" - Name of the line search. Valid choices are <ul> <li> "Full Step" (NOX::Linesearch::FullStep) <li> "Interval %Halving" (NOX::Linesearch::Halving) <li> "Polynomial" (NOX::Linesearch::Polynomial) <li> "More'-Thuente" (NOX::Linesearch::MoreThuente) </ul> </ul> */
\brief
comments. Those can be formatted in either of two
ways, as follows.
/*! \brief The test can be either the AND of all the component tests, or the OR of all the component tests. */ enum ComboType {AND, OR}; //! Constructor Combo(ComboType t = OR);
Newton
to the
NOX::Solver::Newton class.
//! Newton-like solver with a line search.To prevent that automatic link, insert a percent sign (
%
)
immediately before the word that is causing the link. For example,
//! %Newton-like solver with a line search.