Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
ISolverFabric.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 IFPEN-CEA
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 */
18
19/*!
20 * \file ISolverFabric.h
21 * \brief ISolverFabric.h
22 */
23
24#pragma once
25
26#include <alien/core/backend/BackEnd.h>
28#include <alien/utils/ObjectWithTrace.h>
29#include <cstdlib>
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34#include <boost/program_options/options_description.hpp>
35#include <boost/program_options/parsers.hpp>
36#include <boost/program_options/value_semantic.hpp>
37#include <boost/program_options/variables_map.hpp>
38
39#include <boost/property_tree/json_parser.hpp>
40#include <boost/property_tree/ptree.hpp>
41
42namespace Alien
43{
44
45/*---------------------------------------------------------------------------*/
46/*---------------------------------------------------------------------------*/
47
48template <typename tag>
50
51/*!
52 * \ingroup core
53 * \brief Solver Fabric
54 *
55 *
56 */
57class ISolverFabric : public ObjectWithTrace
58{
59 public:
60 typedef boost::program_options::options_description CmdLineOptionDescType;
61 typedef boost::program_options::variables_map CmdLineOptionType;
62
63 typedef boost::property_tree::ptree JsonOptionType;
64 //! Free resources
65 virtual ~ISolverFabric() {}
66
67 public:
68 /*!
69 * \brief Get the source backend id
70 * \returns The source backend id
71 */
72 virtual BackEndId backend() const = 0;
73
74 virtual void add_options(CmdLineOptionDescType& cmdline_options) const = 0;
75
76 /*!
77 * \brief Convert a vector from one format to another
78 * \param[in] sourceImpl Implementation of the source vector
79 * \param[in,out] targetImpl Implementation of the target vector
80 */
82 CmdLineOptionType const& options, Alien::IMessagePassingMng* pm) const = 0;
83
85 JsonOptionType const& options, Alien::IMessagePassingMng* pm) const = 0;
86
87 protected:
88 template <typename T>
89 static T get(
90 boost::program_options::variables_map const& options, std::string const& key)
91 {
92 return options[key].as<T>();
93 }
94
95 template <typename T>
96 static T get(boost::property_tree::ptree const& options, std::string const& key)
97 {
98 return options.get<T>(key);
99 }
100};
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105} // namespace Alien
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
ILinearSolver.h.
Linear solver interface.
virtual Alien::ILinearSolver * create(CmdLineOptionType const &options, Alien::IMessagePassingMng *pm) const =0
Convert a vector from one format to another.
virtual BackEndId backend() const =0
Get the source backend id.
virtual ~ISolverFabric()
Free resources.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17