| Cantera 3.0.0

Loading...
Searching...
No Matches
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
6#include "cantera/numerics/PreconditionerFactory.h"
7#include "cantera/numerics/AdaptivePreconditioner.h"
8
9 namespace Cantera
10{
11
12PreconditionerFactory* 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
21 void PreconditionerFactory::deleteFactory() {
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;
28std::mutex PreconditionerFactory::precon_mutex;
29
30PreconditionerFactory::PreconditionerFactory()
31{
32 reg("Adaptive", []() { return new AdaptivePreconditioner(); });
33}
34
35shared_ptr<PreconditionerBase> newPreconditioner(const string& precon)
36{
37 return shared_ptr<PreconditionerBase>(PreconditionerFactory::factory()->create(precon));
38};
39
40}
AdaptivePreconditioner.h
Declarations for the class AdaptivePreconditioner which is a child class of PreconditionerBase for pr...
PreconditionerFactory.h
Cantera::AdaptivePreconditioner
AdaptivePreconditioner a preconditioner designed for use with large mechanisms that leverages sparse ...
Definition AdaptivePreconditioner.h:27
Cantera::Factory< PreconditionerBase >::reg
void reg(const string &name, function< PreconditionerBase *(Args...)> f)
Register a new object construction function.
Definition FactoryBase.h:80
Cantera::PreconditionerFactory
Factory class to create preconditioner objects.
Definition PreconditionerFactory.h:18
Cantera::PreconditionerFactory::deleteFactory
void deleteFactory() override
Delete preconditioner factory.
Definition PreconditionerFactory.cpp:21
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::newPreconditioner
shared_ptr< PreconditionerBase > newPreconditioner(const string &precon)
Create a Preconditioner object of the specified type.
Definition PreconditionerFactory.cpp:35