OMCompiler/SimulationRuntime/cpp/SimCoreFactory/Policies/StaticLinSolverOMCFactory.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file belongs to the OpenModelica Run-Time System | ||
| 3 | * | ||
| 4 | * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings | ||
| 5 | * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights | ||
| 6 | * reserved. | ||
| 7 | * | ||
| 8 | * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
| 9 | * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY | ||
| 10 | * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S | ||
| 11 | * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL | ||
| 12 | * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. | ||
| 13 | * | ||
| 14 | * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License | ||
| 15 | * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs: | ||
| 16 | * http://www.openmodelica.org or https://github.com/OpenModelica/ or | ||
| 17 | * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU | ||
| 18 | * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW | ||
| 19 | * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause. | ||
| 20 | * | ||
| 21 | * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY | ||
| 23 | * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF | ||
| 24 | * OSMC-PL. | ||
| 25 | * | ||
| 26 | */ | ||
| 27 | |||
| 28 | #pragma once | ||
| 29 | /** @addtogroup simcorefactoriesPolicies | ||
| 30 | * | ||
| 31 | * @{ | ||
| 32 | */ | ||
| 33 | #include <SimCoreFactory/ObjectFactory.h> | ||
| 34 | shared_ptr<ILinSolverSettings> createLinearSolverSettings(); | ||
| 35 | shared_ptr<ILinearAlgLoopSolver> createLinearSolver(shared_ptr<ILinSolverSettings> solver_settings,shared_ptr<ILinearAlgLoop> algLoop = shared_ptr<ILinearAlgLoop>()); | ||
| 36 | shared_ptr<ILinSolverSettings> createDgesvSolverSettings(); | ||
| 37 | shared_ptr<ILinearAlgLoopSolver> createDgesvSolver(shared_ptr<ILinSolverSettings> solver_settings,shared_ptr<ILinearAlgLoop> algLoop = shared_ptr<ILinearAlgLoop>()); | ||
| 38 | template<class CreationPolicy> | ||
| 39 | struct StaticLinSolverOMCFactory : virtual public ObjectFactory<CreationPolicy>{ | ||
| 40 | |||
| 41 | public: | ||
| 42 | StaticLinSolverOMCFactory(PATH library_path, PATH modelicasystem_path,PATH config_path) | ||
| 43 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | : ObjectFactory<CreationPolicy>(library_path,modelicasystem_path,config_path) |
| 44 | { | ||
| 45 | } | ||
| 46 | |||
| 47 | 1 | virtual ~StaticLinSolverOMCFactory() {} | |
| 48 | |||
| 49 | 1 | virtual shared_ptr<ILinSolverSettings> createLinSolverSettings(string lin_solver) | |
| 50 | { | ||
| 51 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (lin_solver.compare("linearSolver") == 0) |
| 52 | { | ||
| 53 | ✗ | throw ModelicaSimulationError(MODEL_FACTORY, "Selected lin solver is not supported for static Linking. Use dgesvSolver instead."); | |
| 54 | } | ||
| 55 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | else if (lin_solver.compare("dgesvSolver") == 0) |
| 56 | { | ||
| 57 | 1 | shared_ptr<ILinSolverSettings> settings = createDgesvSolverSettings(); | |
| 58 | 1 | return settings; | |
| 59 | } | ||
| 60 | else | ||
| 61 | ✗ | throw ModelicaSimulationError(MODEL_FACTORY, "Selected lin solver is not available"); | |
| 62 | } | ||
| 63 | |||
| 64 | 1 | virtual shared_ptr<ILinearAlgLoopSolver> createLinSolver(string solver_name, shared_ptr<ILinSolverSettings> solver_settings,shared_ptr<ILinearAlgLoop> algLoop = shared_ptr<ILinearAlgLoop>()) | |
| 65 | { | ||
| 66 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (solver_name.compare("linearSolver") == 0) |
| 67 | { | ||
| 68 | ✗ | throw ModelicaSimulationError(MODEL_FACTORY, "Selected lin solver is not supported for static Linking. Use dgesvSolver instead."); | |
| 69 | } | ||
| 70 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | else if (solver_name.compare("dgesvSolver") == 0) |
| 71 | { | ||
| 72 |
2/5✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
|
3 | shared_ptr<ILinearAlgLoopSolver> solver = createDgesvSolver(solver_settings, algLoop); |
| 73 | 1 | return solver; | |
| 74 | } | ||
| 75 | else | ||
| 76 | ✗ | throw ModelicaSimulationError(MODEL_FACTORY, "Selected lin solver is not available"); | |
| 77 | } | ||
| 78 | }; | ||
| 79 | |||
| 80 | /** @} */ // end of simcorefactoriesPolicies | ||
| 81 |