| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// MueLu: A package for multigrid based preconditioning |
| 4 |
// |
| 5 |
// Copyright 2012 NTESS and the MueLu contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef ADR_PROBLEM_HPP |
| 11 |
#define ADR_PROBLEM_HPP |
| 12 |
|
| 13 |
#include <Teuchos_RCP.hpp> |
| 14 |
|
| 15 |
#include "Galeri_ConfigDefs.h" |
| 16 |
|
| 17 |
namespace ADR { |
| 18 |
|
| 19 |
namespace Xpetra { |
| 20 |
|
| 21 |
enum { |
| 22 |
DIR_LEFT = 0x01, |
| 23 |
DIR_RIGHT = 0x02, |
| 24 |
DIR_BOTTOM = 0x04, |
| 25 |
DIR_TOP = 0x08, |
| 26 |
DIR_FRONT = 0x10, |
| 27 |
DIR_BACK = 0x20, |
| 28 |
DIR_ALL = DIR_LEFT | DIR_RIGHT | DIR_BOTTOM | DIR_TOP | DIR_FRONT | DIR_BACK |
| 29 |
}; |
| 30 |
typedef size_t DirBC; |
| 31 |
|
| 32 |
template <typename Map, typename Matrix, typename MultiVector> |
| 33 |
class Problem : public Teuchos::Describable { |
| 34 |
public: |
| 35 |
Problem(Teuchos::ParameterList& list) |
| 36 |
: list_(list) { |
| 37 |
SetBoundary(); |
| 38 |
}; |
| 39 |
Problem(Teuchos::ParameterList& list, const Teuchos::RCP<const Map>& map) |
| 40 |
: list_(list) { |
| 41 |
Map_ = map; |
| 42 |
SetBoundary(); |
| 43 |
}; |
| 44 |
virtual ~Problem() {} |
| 45 |
|
| 46 |
virtual Teuchos::RCP<Matrix> BuildMatrix() = 0; |
| 47 |
virtual Teuchos::RCP<MultiVector> BuildCoords() { |
| 48 |
TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Coordinates construction is not implemented for this problem"); |
| 49 |
} |
| 50 |
virtual Teuchos::RCP<MultiVector> BuildNullspace() { |
| 51 |
TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Nullspace construction is not implemented for this problem"); |
| 52 |
} |
| 53 |
|
| 54 |
// Get methods |
| 55 |
Teuchos::RCP<const Map> getMap() const { return Map_; } |
| 56 |
Teuchos::RCP<const Matrix> getMatrix() const { return A_; } |
| 57 |
Teuchos::RCP<const MultiVector> getNullspace() const { return Nullspace_; } |
| 58 |
Teuchos::RCP<const MultiVector> getCoords() const { return Coords_; } |
| 59 |
|
| 60 |
// Set methods |
| 61 |
Teuchos::RCP<const Map> setMap(const Teuchos::RCP<const Map>& map) { Map_ = map; } |
| 62 |
|
| 63 |
protected: |
| 64 |
Teuchos::ParameterList& list_; |
| 65 |
Teuchos::RCP<const Map> Map_; |
| 66 |
Teuchos::RCP<Matrix> A_; |
| 67 |
Teuchos::RCP<MultiVector> Nullspace_; |
| 68 |
Teuchos::RCP<MultiVector> Coords_; |
| 69 |
|
| 70 |
DirBC DirichletBC_; |
| 71 |
|
| 72 |
private: |
| 73 |
void SetBoundary() { |
| 74 |
DirichletBC_ = DIR_ALL; |
| 75 |
if (this->list_.get("left boundary", "Dirichlet") == "Neumann") DirichletBC_ ^= DIR_LEFT; |
| 76 |
if (this->list_.get("right boundary", "Dirichlet") == "Neumann") DirichletBC_ ^= DIR_RIGHT; |
| 77 |
if (this->list_.get("bottom boundary", "Dirichlet") == "Neumann") DirichletBC_ ^= DIR_BOTTOM; |
| 78 |
if (this->list_.get("top boundary", "Dirichlet") == "Neumann") DirichletBC_ ^= DIR_TOP; |
| 79 |
if (this->list_.get("front boundary", "Dirichlet") == "Neumann") DirichletBC_ ^= DIR_FRONT; |
| 80 |
if (this->list_.get("back boundary", "Dirichlet") == "Neumann") DirichletBC_ ^= DIR_BACK; |
| 81 |
} |
| 82 |
}; |
| 83 |
|
| 84 |
} // namespace Xpetra |
| 85 |
|
| 86 |
} // namespace ADR |
| 87 |
|
| 88 |
#endif // ADR_PROBLEM_HPP |