G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsBucklingSolver.h
Go to the documentation of this file.
1 
15 
16 #include <gsIO/gsFileData.h>
17 #include <gsIO/gsReadFile.h>
18 
19 #pragma once
20 
21 namespace gismo
22 {
23 
31 template <class T>
33 {
34 protected:
35 
37 
38  typedef std::function < bool ( gsVector<T> const &, gsSparseMatrix<T> & ) > Jacobian_t;
39  typedef std::function < bool ( gsVector<T> const &, gsVector<T> const &, gsSparseMatrix<T> & ) > dJacobian_t;
40 
41 public:
42 
52  gsVector<T> &rhs,
53  Jacobian_t &nonlinear,
54  T scaling = 1.0) :
55  m_rhs(rhs),
56  m_nonlinear(nonlinear),
57  m_scaling(scaling)
58  {
59  m_A = linear;
60  m_dnonlinear = [this](gsVector<T> const & x, gsVector<T> const & dx, gsSparseMatrix<T> & m) -> bool
61  {
62  return m_nonlinear(x,m);
63  };
64 
65  m_solver = gsSparseSolver<T>::get( "SimplicialLDLT" );
66 
67  m_status = this->initializeMatrix();
68  }
69 
79  gsVector<T> &rhs,
80  dJacobian_t &dnonlinear,
81  T scaling = 1.0) :
82  m_rhs(rhs),
83  m_dnonlinear(dnonlinear),
84  m_scaling(scaling)
85  {
86  m_A = linear;
87 
88  m_solver = gsSparseSolver<T>::get( "SimplicialLDLT" );
89 
90  m_status = this->initializeMatrix();
91  }
92 
93 
101  gsSparseMatrix<T> &nonlinear )
102  {
103  m_A = linear;
104  m_B = nonlinear-m_A;
105  }
106 
107  // todo: add solver option
108  // gsOptionList defaultOptions()
109  // {
110  // gsOptionList options;
111  // options = Base::defaultOptions()
112  // options.addString("Solver","Specify the sparse solver","SimplicialLDLT");
113  // return options;
114  // }
115 
116  gsStatus computeSparse(const index_t number = 10)
117  {
118  if (m_options.getInt("solver") != 3 )
119  gsWarn<<"It is highly recommended to use the Buckling solver (option 4)\n";
120 
121  return Base::computeSparse(number);
122  }
123 
124 
125 protected:
126 
127  gsStatus initializeMatrix()
128  {
129  bool verbose = m_options.getSwitch("verbose");
130  if (verbose) { gsInfo<<"Computing matrices" ; }
131  m_solver->compute(m_A);
132  if (verbose) { gsInfo<<"." ; }
133  m_solVec = m_solver->solve(m_scaling*m_rhs);
134  if (verbose) { gsInfo<<"." ; }
135  try
136  {
137  m_dnonlinear(m_solVec,gsVector<T>::Zero(m_solVec.rows()),m_B);
138  }
139  catch (...)
140  {
141  m_status = gsStatus::AssemblyError;
142  return m_status;
143  }
144  m_B -= m_A;
145  if (verbose) { gsInfo<<"." ; }
146  if (verbose) { gsInfo<<"Finished\n" ; }
147 
148  return m_status;
149  }
150 
151 protected:
152 
153  using Base::m_A;
154  const gsVector<T> m_rhs;
155  const Jacobian_t m_nonlinear;
156  dJacobian_t m_dnonlinear;
157  T m_scaling;
158  using Base::m_B;
159 
160 
162  mutable typename gsSparseSolver<T>::uPtr m_solver;
163  gsVector<> m_solVec;
164 
165  using Base::m_options;
166 
167  using Base::m_status;
168 };
169 
170 } // namespace gismo
Base class for buckling and modal analyses.
Base class for buckling and modal analyses.
Definition: gsEigenProblemBase.h:37
Performs linear buckling analysis given a matrix or functions of a matrix.
Definition: gsBucklingSolver.h:32
gsBucklingSolver(gsSparseMatrix< T > &linear, gsVector< T > &rhs, Jacobian_t &nonlinear, T scaling=1.0)
Constructor.
Definition: gsBucklingSolver.h:51
gsBucklingSolver(gsSparseMatrix< T > &linear, gsSparseMatrix< T > &nonlinear)
Constructor.
Definition: gsBucklingSolver.h:100
Assembly failed due to an error in the expression (e.g. overflow)
#define index_t
Definition: gsConfig.h:32
gsStatus
Definition: gsStructuralAnalysisTypes.h:20
const index_t & getInt(const std::string &label) const
Reads value for option label from options.
Definition: gsOptionList.cpp:37
gsSparseSolver< T >::uPtr m_solver
Linear solver employed.
Definition: gsBucklingSolver.h:162
#define gsWarn
Definition: gsDebug.h:50
gsBucklingSolver(gsSparseMatrix< T > &linear, gsVector< T > &rhs, dJacobian_t &dnonlinear, T scaling=1.0)
Constructor.
Definition: gsBucklingSolver.h:78
bool getSwitch(const std::string &label) const
Reads value for option label from options.
Definition: gsOptionList.cpp:51
Utility class which holds I/O XML data to read/write to/from files.
#define gsInfo
Definition: gsDebug.h:43
Abstract class for solvers. The solver interface is base on 3 methods: -compute set the system matrix...
Definition: gsSparseSolver.h:66
Utility class which holds I/O XML data to read/write to/from files.