Cantera  3.1.0a1
PreconditionerFactory.cpp
Go to the documentation of this file.
1 //! @file PreconditionerFactory.cpp
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at https://cantera.org/license.txt for license and copyright information.
5 
8 
9 namespace Cantera
10 {
11 
12 PreconditionerFactory* PreconditionerFactory::factory() {
13  std::unique_lock<std::mutex> lock(precon_mutex);
14  if (!s_factory) {
15  s_factory = new PreconditionerFactory;
16  }
17  return s_factory;
18 };
19 
20 //! Delete preconditioner factory
22  std::unique_lock<std::mutex> lock(precon_mutex);
23  delete s_factory;
24  s_factory = 0;
25 };
26 
27 PreconditionerFactory* PreconditionerFactory::s_factory = 0;
28 std::mutex PreconditionerFactory::precon_mutex;
29 
30 PreconditionerFactory::PreconditionerFactory()
31 {
32  reg("Adaptive", []() { return new AdaptivePreconditioner(); });
33 }
34 
35 shared_ptr<PreconditionerBase> newPreconditioner(const string& precon)
36 {
37  return shared_ptr<PreconditionerBase>(PreconditionerFactory::factory()->create(precon));
38 };
39 
40 }
Declarations for the class AdaptivePreconditioner which is a child class of PreconditionerBase for pr...
AdaptivePreconditioner a preconditioner designed for use with large mechanisms that leverages sparse ...
void reg(const string &name, function< PreconditionerBase *(Args...)> f)
Register a new object construction function.
Definition: FactoryBase.h:80
Factory class to create preconditioner objects.
void deleteFactory() override
Delete preconditioner factory.
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564
shared_ptr< PreconditionerBase > newPreconditioner(const string &precon)
Create a Preconditioner object of the specified type.