Loading...
Searching...
No Matches
PETScOptions.h
// Copyright (C) 2013 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
#ifndef __DOLFIN_PETSC_OPTIONS_H
#define __DOLFIN_PETSC_OPTIONS_H
#ifdef HAS_PETSC
#include <string>
#include <boost/lexical_cast.hpp>
#include <petscsys.h>
#include <dolfin/common/SubSystemsManager.h>
#include <dolfin/log/log.h>
#include "PETScObject.h"
namespace dolfin
{
class PETScOptions
{
public:
static void set(std::string option);
static void set(std::string option, bool value);
static void set(std::string option, int value);
static void set(std::string option, double value);
static void set(std::string option, std::string value);
template<typename T>
static void set(std::string option, const T value)
{
SubSystemsManager::init_petsc();
if (option[0] != '-')
option = '-' + option;
PetscErrorCode ierr;
ierr = PetscOptionsSetValue(NULL, option.c_str(),
boost::lexical_cast<std::string>(value).c_str());
if (ierr != 0)
PETScObject::petsc_error(ierr, __FILE__, "PetscOptionsSetValue");
}
static void clear(std::string option);
static void clear();
};
}
#endif
#endif
dolfin::PETScObject::petsc_error
static void petsc_error(int error_code, std::string filename, std::string petsc_function)
Print error message for PETSc calls that return an error.
Definition PETScObject.cpp:29
dolfin::PETScOptions
Definition PETScOptions.h:42
dolfin::PETScOptions::clear
static void clear()
Clear PETSc global options database.
Definition PETScOptions.cpp:63
dolfin::PETScOptions::set
static void set(std::string option, const T value)
Genetic function for setting PETSc option.
Definition PETScOptions.h:62
dolfin::PETScOptions::set
static void set(std::string option)
Set PETSc option that takes no value.
Definition PETScOptions.cpp:25
dolfin::SubSystemsManager::init_petsc
static void init_petsc()
Initialize PETSc without command-line arguments.
Definition SubSystemsManager.cpp:125
dolfin
Definition adapt.h:30