PolyFEM
Loading...
Searching...
No Matches
ProblemFactory.cpp
Go to the documentation of this file.
1#include "ProblemFactory.hpp"
2
4#include "MiscProblem.hpp"
5#include "FrankeProblem.hpp"
6#include "ElasticProblem.hpp"
8#include "KernelProblem.hpp"
9#include "StokesProblem.hpp"
10#include "TestProblem.hpp"
11#include "NodeProblem.hpp"
12
14
15namespace polyfem
16{
17 using namespace assembler;
18
19 namespace problem
20 {
21
23 {
24 static ProblemFactory instance;
25
26 return instance;
27 }
28
30 {
31 problems_.emplace("Linear", []() { return std::make_shared<LinearProblem>("Linear"); });
32 problems_.emplace("Quadratic", []() { return std::make_shared<QuadraticProblem>("Quadratic"); });
33 problems_.emplace("Cubic", []() { return std::make_shared<CubicProblem>("Cubic"); });
34 problems_.emplace("Sine", []() { return std::make_shared<SineProblem>("Sine"); });
35 problems_.emplace("Franke", []() { return std::make_shared<FrankeProblem>("Franke"); });
36 problems_.emplace("FrankeOld", []() { return std::make_shared<FrankeProblemOld>("FrankeOld"); });
37 problems_.emplace("GenericScalarExact", []() { return std::make_shared<GenericScalarProblemExact>("GenericScalarExact"); });
38 problems_.emplace("Zero_BC", []() { return std::make_shared<ZeroBCProblem>("Zero_BC"); });
39
40 problems_.emplace("Elastic", []() { return std::make_shared<ElasticProblem>("Elastic"); });
41 problems_.emplace("Walk", []() { return std::make_shared<WalkProblem>("Walk"); });
42 problems_.emplace("TorsionElastic", []() { return std::make_shared<TorsionElasticProblem>("TorsionElastic"); });
43 problems_.emplace("DoubleTorsionElastic", []() { return std::make_shared<DoubleTorsionElasticProblem>("DoubleTorsionElastic"); });
44 problems_.emplace("ElasticZeroBC", []() { return std::make_shared<ElasticProblemZeroBC>("ElasticZeroBC"); });
45 problems_.emplace("ElasticExact", []() { return std::make_shared<ElasticProblemExact>("ElasticExact"); });
46 problems_.emplace("ElasticCantileverExact", []() { return std::make_shared<ElasticCantileverExact>("ElasticCantileverExact"); });
47 problems_.emplace("CompressionElasticExact", []() { return std::make_shared<CompressionElasticProblemExact>("CompressionElasticExact"); });
48 problems_.emplace("QuadraticElasticExact", []() { return std::make_shared<QuadraticElasticProblemExact>("QuadraticElasticExact"); });
49 problems_.emplace("LinearElasticExact", []() { return std::make_shared<LinearElasticProblemExact>("LinearElasticExact"); });
50 problems_.emplace("PointBasedTensor", []() { return std::make_shared<PointBasedTensorProblem>("PointBasedTensor"); });
51 // problems_.emplace("Kernel", []() { return std::make_shared<KernelProblem>("Kernel"); });
52 problems_.emplace("Node", []() { return std::make_shared<NodeProblem>("Node"); });
53
54 problems_.emplace("TimeDependentScalar", []() { return std::make_shared<TimeDependentProblem>("TimeDependentScalar"); });
55 problems_.emplace("MinSurf", []() { return std::make_shared<MinSurfProblem>("MinSurf"); });
56 problems_.emplace("Gravity", []() { return std::make_shared<GravityProblem>("Gravity"); });
57
58 problems_.emplace("ConstantVelocity", []() { return std::make_shared<ConstantVelocity>("ConstantVelocity"); });
59 problems_.emplace("TwoSpheres", []() { return std::make_shared<TwoSpheres>("TwoSpheres"); });
60 problems_.emplace("DrivenCavity", []() { return std::make_shared<DrivenCavity>("DrivenCavity"); });
61 problems_.emplace("DrivenCavityC0", []() { return std::make_shared<DrivenCavityC0>("DrivenCavityC0"); });
62 problems_.emplace("DrivenCavitySmooth", []() { return std::make_shared<DrivenCavitySmooth>("DrivenCavitySmooth"); });
63 problems_.emplace("Flow", []() { return std::make_shared<Flow>("Flow"); });
64 problems_.emplace("FlowWithObstacle", []() { return std::make_shared<FlowWithObstacle>("FlowWithObstacle"); });
65 problems_.emplace("CornerFlow", []() { return std::make_shared<CornerFlow>("CornerFlow"); });
66 problems_.emplace("UnitFlowWithObstacle", []() { return std::make_shared<UnitFlowWithObstacle>("UnitFlowWithObstacle"); });
67 problems_.emplace("StokesLaw", []() { return std::make_shared<StokesLawProblem>("StokesLaw"); });
68 problems_.emplace("TaylorGreenVortex", []() { return std::make_shared<TaylorGreenVortexProblem>("TaylorGreenVortex"); });
69 problems_.emplace("SimpleStokeProblemExact", []() { return std::make_shared<SimpleStokeProblemExact>("SimpleStokeProblemExact"); });
70 problems_.emplace("SineStokeProblemExact", []() { return std::make_shared<SineStokeProblemExact>("SineStokeProblemExact"); });
71 problems_.emplace("TransientStokeProblemExact", []() { return std::make_shared<TransientStokeProblemExact>("TransientStokeProblemExact"); });
72 problems_.emplace("Kovnaszy", []() { return std::make_shared<Kovnaszy>("Kovnaszy"); });
73 problems_.emplace("Airfoil", []() { return std::make_shared<Airfoil>("Airfoil"); });
74 problems_.emplace("Lshape", []() { return std::make_shared<Lshape>("Lshape"); });
75
76 problems_.emplace("TestProblem", []() { return std::make_shared<TestProblem>("TestProblem"); });
77
78 problems_.emplace("BilaplacianProblemWithSolution", []() { return std::make_shared<BilaplacianProblemWithSolution>("BilaplacianProblemWithSolution"); });
79
80 for (auto it = problems_.begin(); it != problems_.end(); ++it)
81 problem_names_.push_back(it->first);
82 }
83
84 std::shared_ptr<Problem> ProblemFactory::get_problem(const std::string &problem) const
85 {
86 auto it = problems_.find(problem);
87
88 if (it == problems_.end())
89 {
90 logger().error("Problem {} does not exist", problem);
91 return problems_.at("Linear")();
92 }
93
94 return it->second();
95 }
96 } // namespace problem
97} // namespace polyfem
std::vector< std::string > problem_names_
std::map< std::string, std::function< std::shared_ptr< assembler::Problem >()> > problems_
static const ProblemFactory & factory()
std::shared_ptr< assembler::Problem > get_problem(const std::string &problem) const
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:42