14#include "arcane/aleph/IAlephFactory.h"
15#include "arcane/core/ServiceBuilder.h"
30 FactoryImpl(
const String& name)
32 , m_initialized(
false)
45 const String& name()
const {
return m_name; }
69 m_impl_map.insert(std::make_pair(1,
new FactoryImpl(
"Sloop")));
70 m_impl_map.insert(std::make_pair(2,
new FactoryImpl(
"Hypre")));
71 m_impl_map.insert(std::make_pair(3,
new FactoryImpl(
"Trilinos")));
72 m_impl_map.insert(std::make_pair(4,
new FactoryImpl(
"Cuda")));
73 m_impl_map.insert(std::make_pair(5,
new FactoryImpl(
"PETSc")));
77 for (
const auto& i : m_impl_map) {
79 const String& name = implementation->name();
80 debug() <<
"\33[1;34m\t[AlephFactory] Adding " << name <<
" library..."
82 auto factory = sb.createReference(name +
"AlephFactory",
SB_AllowNull);
83 implementation->setFactory(factory);
85 debug() <<
"\33[1;34m\t[AlephFactory] done"
95 for (
const auto& i : m_impl_map)
102IAlephFactoryImpl* AlephFactory::
103_getFactory(
Integer solver_index)
105 FactoryImplMap::const_iterator ci = m_impl_map.find(solver_index);
106 if (ci == m_impl_map.end())
107 ARCANE_FATAL(
"Invalid solver index '{0}' for aleph factory", solver_index);
109 IAlephFactoryImpl* factory = implementation->factory();
111 throw NotSupportedException(A_FUNCINFO,
112 String::format(
"Implementation for '{0}' not available",
113 implementation->name()));
115 if (!implementation->m_initialized) {
116 debug() <<
"\33[1;34m\t\t[_getFactory] initializing solver_index="
117 << solver_index <<
" ..."
119 implementation->m_initialized =
true;
120 factory->initialize();
129hasSolverImplementation(
Integer solver_index)
131 FactoryImplMap::const_iterator ci = m_impl_map.find(solver_index);
132 if (ci == m_impl_map.end())
135 IAlephFactoryImpl* factory = implementation->factory();
144IAlephTopology* AlephFactory::
145GetTopology(AlephKernel* kernel,
Integer index,
Integer nb_row_size)
147 debug() <<
"\33[1;34m\t\t[IAlephFactory::GetTopology] Switch=" << kernel->underlyingSolver() <<
"\33[0m";
148 auto f = _getFactory(kernel->underlyingSolver());
149 return f->createTopology(
traceMng(), kernel, index, nb_row_size);
155IAlephVector* AlephFactory::
156GetVector(AlephKernel* kernel,
Integer index)
158 debug() <<
"\33[1;34m\t\t[AlephFactory::GetVector] Switch=" << kernel->underlyingSolver() <<
"\33[0m";
159 auto f = _getFactory(kernel->underlyingSolver());
160 return f->createVector(
traceMng(), kernel, index);
166IAlephMatrix* AlephFactory::
167GetMatrix(AlephKernel* kernel,
Integer index)
169 debug() <<
"\33[1;34m\t\t[AlephFactory::GetMatrix] Switch=" << kernel->underlyingSolver() <<
"\33[0m";
170 auto f = _getFactory(kernel->underlyingSolver());
171 return f->createMatrix(
traceMng(), kernel, index);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Interface of an implementation factory for Aleph.
Reference to an instance.
Utility class for instantiating a service of a given interface.
Unicode character string.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
ITraceMng * traceMng() const
Trace manager.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ SB_AllowNull
Allows the service to be absent.
Int32 Integer
Type representing an integer.