suanPan
Loading...
Searching...
No Matches
FactoryHelper.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * Copyright (C) 2017-2023 Theodore Chang
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 ******************************************************************************/
17
18#ifndef FACTORY_HELPER_HPP
19#define FACTORY_HELPER_HPP
20
21#include <suanPan.h>
22
23#include "Factory.hpp"
24#include "MetaMat/MetaMat"
25
26template<sp_d T> unique_ptr<MetaMat<T>> get_basic_container(const Factory<T>* const W) {
27 switch(W->storage_type) {
29#ifdef SUANPAN_CUDA
30 if(SolverType::CUDA == W->solver) return std::make_unique<FullMatCUDA<T>>(W->n_size, W->n_size);
31#endif
32 return std::make_unique<FullMat<T>>(W->n_size, W->n_size);
34 if(SolverType::SPIKE == W->solver) return std::make_unique<BandMatSpike<T>>(W->n_size, W->n_lobw, W->n_upbw);
35 return std::make_unique<BandMat<T>>(W->n_size, W->n_lobw, W->n_upbw);
37 return std::make_unique<BandSymmMat<T>>(W->n_size, W->n_lobw);
39 return std::make_unique<SymmPackMat<T>>(W->n_size);
41 if(SolverType::MUMPS == W->solver) return std::make_unique<SparseMatMUMPS<T>>(W->n_size, W->n_size, W->n_elem);
42 if(SolverType::SUPERLU == W->solver) return std::make_unique<SparseMatSuperLU<T>>(W->n_size, W->n_size, W->n_elem);
43#ifdef SUANPAN_MKL
44 if(SolverType::PARDISO == W->solver) return std::make_unique<SparseMatPARDISO<T>>(W->n_size, W->n_size, W->n_elem);
45 if(SolverType::FGMRES == W->solver) return std::make_unique<SparseMatFGMRES<T>>(W->n_size, W->n_size, W->n_elem);
46#endif
47#ifdef SUANPAN_CUDA
48 if(SolverType::CUDA == W->solver) return std::make_unique<SparseMatCUDA<T>>(W->n_size, W->n_size, W->n_elem);
49#endif
50 return std::make_unique<SparseMatSuperLU<T>>(W->n_size, W->n_size, W->n_elem);
52#ifdef SUANPAN_MKL
53 if(SolverType::FGMRES == W->solver) return std::make_unique<SparseSymmMatFGMRES<T>>(W->n_size, W->n_size, W->n_elem);
54#endif
55 return std::make_unique<SparseSymmMatMUMPS<T>>(W->n_size, W->n_size, W->n_elem);
56 default:
57 throw invalid_argument("need a proper storage scheme");
58 }
59}
60
61template<sp_d T> unique_ptr<MetaMat<T>> get_matrix_container(const Factory<T>* const W) {
62 auto global_mat = get_basic_container(W);
63
64 global_mat->set_solver_setting(W->setting);
65
66 return global_mat;
67}
68
69template<sp_d T1> shared_ptr<MetaMat<T1>>& get_mass(const shared_ptr<Factory<T1>>& W) { return W->global_mass; }
70
71template<sp_d T1> shared_ptr<MetaMat<T1>>& get_damping(const shared_ptr<Factory<T1>>& W) { return W->global_damping; }
72
73template<sp_d T1> shared_ptr<MetaMat<T1>>& get_stiffness(const shared_ptr<Factory<T1>>& W) { return W->global_stiffness; }
74
75template<sp_d T1> shared_ptr<MetaMat<T1>>& get_geometry(const shared_ptr<Factory<T1>>& W) { return W->global_geometry; }
76
77template<sp_d T> Col<T>& get_ninja(const shared_ptr<Factory<T>>& W) { return W->ninja; }
78
79template<sp_d T> Col<T>& get_sushi(const shared_ptr<Factory<T>>& W) { return W->sushi; }
80
81template<sp_d T> suanpan::set<uword>& get_reference_dof(const shared_ptr<Factory<T>>& W) { return W->reference_dof; }
82
83template<sp_d T> SpMat<T>& get_reference_load(const shared_ptr<Factory<T>>& W) { return W->reference_load; }
84
85template<sp_d T1> uvec& get_auxiliary_encoding(const shared_ptr<Factory<T1>>& W) { return W->auxiliary_encoding; }
86
87template<sp_d T1> Col<T1>& get_auxiliary_lambda(const shared_ptr<Factory<T1>>& W) { return W->auxiliary_lambda; }
88
89template<sp_d T> Col<T>& get_auxiliary_resistance(const shared_ptr<Factory<T>>& W) { return W->auxiliary_resistance; }
90
91template<sp_d T> Col<T>& get_auxiliary_load(const shared_ptr<Factory<T>>& W) { return W->auxiliary_load; }
92
93template<sp_d T> SpMat<T>& get_auxiliary_stiffness(const shared_ptr<Factory<T>>& W) { return W->auxiliary_stiffness; }
94
95template<sp_d T1> SpCol<T1>& get_trial_constraint_resistance(const shared_ptr<Factory<T1>>& W) { return W->trial_constraint_resistance; }
96
97template<sp_d T1> SpCol<T1>& get_current_constraint_resistance(const shared_ptr<Factory<T1>>& W) { return W->current_constraint_resistance; }
98
99template<sp_d T> T& get_trial_time(const shared_ptr<Factory<T>>& W) { return W->trial_time; }
100
101template<sp_d T1> Col<T1>& get_trial_load_factor(const shared_ptr<Factory<T1>>& W) { return W->trial_load_factor; }
102
103template<sp_d T> Col<T>& get_trial_load(const shared_ptr<Factory<T>>& W) { return W->trial_load; }
104
105template<sp_d T> Col<T>& get_trial_settlement(const shared_ptr<Factory<T>>& W) { return W->trial_settlement; }
106
107template<sp_d T> Col<T>& get_trial_resistance(const shared_ptr<Factory<T>>& W) { return W->trial_resistance; }
108
109template<sp_d T> Col<T>& get_trial_damping_force(const shared_ptr<Factory<T>>& W) { return W->trial_damping_force; }
110
111template<sp_d T> Col<T>& get_trial_inertial_force(const shared_ptr<Factory<T>>& W) { return W->trial_inertial_force; }
112
113template<sp_d T> Col<T>& get_trial_displacement(const shared_ptr<Factory<T>>& W) { return W->trial_displacement; }
114
115template<sp_d T> Col<T>& get_trial_velocity(const shared_ptr<Factory<T>>& W) { return W->trial_velocity; }
116
117template<sp_d T> Col<T>& get_trial_acceleration(const shared_ptr<Factory<T>>& W) { return W->trial_acceleration; }
118
119template<sp_d T> Col<T>& get_trial_temperature(const shared_ptr<Factory<T>>& W) { return W->trial_temperature; }
120
121template<sp_d T> T& get_incre_time(const shared_ptr<Factory<T>>& W) { return W->incre_time; }
122
123template<sp_d T1> Col<T1>& get_incre_load_factor(const shared_ptr<Factory<T1>>& W) { return W->incre_load_factor; }
124
125template<sp_d T> Col<T>& get_incre_load(const shared_ptr<Factory<T>>& W) { return W->incre_load; }
126
127template<sp_d T> Col<T>& get_incre_settlement(const shared_ptr<Factory<T>>& W) { return W->incre_settlement; }
128
129template<sp_d T> Col<T>& get_incre_resistance(const shared_ptr<Factory<T>>& W) { return W->incre_resistance; }
130
131template<sp_d T> Col<T>& get_incre_damping_force(const shared_ptr<Factory<T>>& W) { return W->incre_damping_force; }
132
133template<sp_d T> Col<T>& get_incre_inertial_force(const shared_ptr<Factory<T>>& W) { return W->incre_inertial_force; }
134
135template<sp_d T> Col<T>& get_incre_displacement(const shared_ptr<Factory<T>>& W) { return W->incre_displacement; }
136
137template<sp_d T> Col<T>& get_incre_velocity(const shared_ptr<Factory<T>>& W) { return W->incre_velocity; }
138
139template<sp_d T> Col<T>& get_incre_acceleration(const shared_ptr<Factory<T>>& W) { return W->incre_acceleration; }
140
141template<sp_d T> Col<T>& get_incre_temperature(const shared_ptr<Factory<T>>& W) { return W->incre_temperature; }
142
143template<sp_d T> T& get_current_time(const shared_ptr<Factory<T>>& W) { return W->current_time; }
144
145template<sp_d T1> Col<T1>& get_current_load_factor(const shared_ptr<Factory<T1>>& W) { return W->current_load_factor; }
146
147template<sp_d T> Col<T>& get_current_load(const shared_ptr<Factory<T>>& W) { return W->current_load; }
148
149template<sp_d T> Col<T>& get_current_settlement(const shared_ptr<Factory<T>>& W) { return W->current_settlement; }
150
151template<sp_d T> Col<T>& get_current_resistance(const shared_ptr<Factory<T>>& W) { return W->current_resistance; }
152
153template<sp_d T> Col<T>& get_current_damping_force(const shared_ptr<Factory<T>>& W) { return W->current_damping_force; }
154
155template<sp_d T> Col<T>& get_current_inertial_force(const shared_ptr<Factory<T>>& W) { return W->current_inertial_force; }
156
157template<sp_d T> Col<T>& get_current_displacement(const shared_ptr<Factory<T>>& W) { return W->current_displacement; }
158
159template<sp_d T> Col<T>& get_current_velocity(const shared_ptr<Factory<T>>& W) { return W->current_velocity; }
160
161template<sp_d T> Col<T>& get_current_acceleration(const shared_ptr<Factory<T>>& W) { return W->current_acceleration; }
162
163template<sp_d T> Col<T>& get_current_temperature(const shared_ptr<Factory<T>>& W) { return W->current_temperature; }
164
165template<sp_d T> T& get_pre_time(const shared_ptr<Factory<T>>& W) { return W->pre_time; }
166
167template<sp_d T1> Col<T1>& get_pre_load_factor(const shared_ptr<Factory<T1>>& W) { return W->pre_load_factor; }
168
169template<sp_d T> Col<T>& get_pre_load(const shared_ptr<Factory<T>>& W) { return W->pre_load; }
170
171template<sp_d T> Col<T>& get_pre_settlement(const shared_ptr<Factory<T>>& W) { return W->pre_settlement; }
172
173template<sp_d T> Col<T>& get_pre_resistance(const shared_ptr<Factory<T>>& W) { return W->pre_resistance; }
174
175template<sp_d T> Col<T>& get_pre_damping_force(const shared_ptr<Factory<T>>& W) { return W->pre_damping_force; }
176
177template<sp_d T> Col<T>& get_pre_inertial_force(const shared_ptr<Factory<T>>& W) { return W->pre_inertial_force; }
178
179template<sp_d T> Col<T>& get_pre_displacement(const shared_ptr<Factory<T>>& W) { return W->pre_displacement; }
180
181template<sp_d T> Col<T>& get_pre_velocity(const shared_ptr<Factory<T>>& W) { return W->pre_velocity; }
182
183template<sp_d T> Col<T>& get_pre_acceleration(const shared_ptr<Factory<T>>& W) { return W->pre_acceleration; }
184
185template<sp_d T> Col<T>& get_pre_temperature(const shared_ptr<Factory<T>>& W) { return W->pre_temperature; }
186
187template<sp_d T> Col<T>& get_eigenvalue(const shared_ptr<Factory<T>>& W) { return W->eigenvalue; }
188
189template<sp_d T> Mat<T>& get_eigenvector(const shared_ptr<Factory<T>>& W) { return W->eigenvector; }
190
191#endif // FACTORY_HELPER_HPP
192
Col< T > & get_trial_resistance(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:107
Col< T > & get_current_displacement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:157
Col< T > & get_pre_velocity(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:181
SpMat< T > & get_auxiliary_stiffness(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:93
Col< T > & get_incre_resistance(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:129
Col< T > & get_trial_settlement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:105
SpCol< T1 > & get_current_constraint_resistance(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:97
Col< T1 > & get_incre_load_factor(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:123
Col< T > & get_incre_inertial_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:133
shared_ptr< MetaMat< T1 > > & get_geometry(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:75
Col< T > & get_current_velocity(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:159
Col< T > & get_pre_acceleration(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:183
Col< T > & get_current_damping_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:153
Col< T > & get_trial_temperature(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:119
Col< T > & get_trial_velocity(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:115
Mat< T > & get_eigenvector(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:189
SpMat< T > & get_reference_load(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:83
unique_ptr< MetaMat< T > > get_basic_container(const Factory< T > *const W)
Definition: FactoryHelper.hpp:26
Col< T > & get_incre_temperature(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:141
Col< T > & get_trial_damping_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:109
Col< T > & get_incre_displacement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:135
Col< T > & get_trial_load(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:103
T & get_incre_time(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:121
Col< T > & get_pre_load(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:169
Col< T > & get_eigenvalue(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:187
Col< T > & get_current_load(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:147
Col< T > & get_trial_inertial_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:111
Col< T1 > & get_pre_load_factor(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:167
Col< T > & get_current_acceleration(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:161
SpCol< T1 > & get_trial_constraint_resistance(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:95
shared_ptr< MetaMat< T1 > > & get_mass(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:69
shared_ptr< MetaMat< T1 > > & get_stiffness(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:73
Col< T > & get_current_resistance(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:151
Col< T1 > & get_auxiliary_lambda(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:87
Col< T > & get_ninja(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:77
Col< T > & get_incre_acceleration(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:139
Col< T > & get_auxiliary_load(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:91
Col< T > & get_incre_velocity(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:137
Col< T > & get_current_inertial_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:155
suanpan::set< uword > & get_reference_dof(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:81
Col< T > & get_pre_inertial_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:177
Col< T > & get_pre_damping_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:175
Col< T1 > & get_current_load_factor(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:145
unique_ptr< MetaMat< T > > get_matrix_container(const Factory< T > *const W)
Definition: FactoryHelper.hpp:61
T & get_pre_time(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:165
Col< T > & get_incre_settlement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:127
Col< T > & get_incre_load(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:125
Col< T > & get_trial_displacement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:113
Col< T > & get_pre_settlement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:171
uvec & get_auxiliary_encoding(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:85
Col< T > & get_sushi(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:79
Col< T > & get_pre_temperature(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:185
Col< T > & get_trial_acceleration(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:117
Col< T > & get_current_temperature(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:163
Col< T1 > & get_trial_load_factor(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:101
Col< T > & get_current_settlement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:149
Col< T > & get_pre_displacement(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:179
Col< T > & get_incre_damping_force(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:131
Col< T > & get_auxiliary_resistance(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:89
Col< T > & get_pre_resistance(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:173
T & get_current_time(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:143
T & get_trial_time(const shared_ptr< Factory< T > > &W)
Definition: FactoryHelper.hpp:99
shared_ptr< MetaMat< T1 > > & get_damping(const shared_ptr< Factory< T1 > > &W)
Definition: FactoryHelper.hpp:71
A Factory class.
Definition: Factory.hpp:67
std::set< T > set
Definition: container.h:54