19 template <
class T,
class solution_t >
20 gsAPALMBase<T,solution_t>::gsAPALMBase( gsALMBase<T> * ALM,
21 const gsAPALMData<T,solution_t> & Data)
26 this->_defaultOptions();
29 template <
class T,
class solution_t >
30 void gsAPALMBase<T,solution_t>::_defaultOptions()
32 m_options.addSwitch(
"Verbose",
"Verbosity",
false);
35 template <
class T,
class solution_t >
36 void gsAPALMBase<T,solution_t>::_getOptions()
38 m_verbose = m_options.getSwitch(
"verbose");
41 template <
class T,
class solution_t >
42 void gsAPALMBase<T,solution_t>::initialize()
47 template <
class T,
class solution_t >
48 void gsAPALMBase<T,solution_t>::serialSolve(
index_t Nsteps)
50 bool bisected =
false;
52 T dL = m_ALM->getLength();
58 Uold.setZero(m_ALM->numDofs(),1);
59 U0.setZero(m_ALM->numDofs(),1);
63 m_solutions.push_back({U0,L0});
65 m_ALM->setSolution(U0,L0);
67 for (
index_t k=0; k!=Nsteps; k++)
70 if (m_verbose)
gsInfo<<
"Load step "<< k<<
"\t"<<
"dL = "<<dL<<
"; curve time = "<<s<<
"\n";
75 if (!(m_ALM->converged()))
78 if (m_verbose)
gsInfo<<
"Error: Loop terminated, arc length method did not converge.\n";
81 m_ALM->setSolution(Uold,Lold);
87 Uold = m_ALM->solutionU();
88 Lold = m_ALM->solutionL();
90 T lambda = m_ALM->solutionL();
91 m_solutions.push_back({m_ALM->solutionU(),lambda});
94 this->serialStepOutput(m_ALM->solutionU(),lambda);
110 m_ALM->setLength(dL);
117 template <
class T,
class solution_t >
118 void gsAPALMBase<T,solution_t>::parallelSolve()
120 solution_t start, guess, reference;
131 std::vector<solution_t> stepSolutions;
132 std::vector<real_t> stepTimes;
133 std::vector<real_t> distances;
134 bool bisected =
false;
138 gsMatrix<T> Uguess,Uold, U0;
140 while (!m_data.empty() && it < itmax)
143 stepSolutions.resize(Nintervals);
144 stepTimes.resize(Nintervals);
145 distances.resize(Nintervals+1);
147 std::tie(ID,tstart,tend,dt0,start,guess) = m_data.pop();
148 std::tie(Uold,Lold) = start;
149 std::tie(Uguess,Lguess) = guess;
151 gsMatrix<> Uori = Uold;
154 dt0 = dt0 / Nintervals;
157 m_ALM->setLength(dt);
158 m_ALM->setSolution(Uold,Lold);
160 m_ALM->setPrevious(Uguess,Lguess);
161 gsDebug<<
"Start - ||u|| = "<<Uold.norm()<<
", L = "<<Lold<<
"\n";
162 gsDebug<<
"Guess - ||u|| = "<<Uguess.norm()<<
", L = "<<Lguess<<
"\n";
164 gsVector<> tmpU = Uold-Uguess;
165 real_t tmpL = Lold-Lguess;
170 gsInfo<<
"Starting with ID "<<ID<<
" from (|U|,L) = ("<<Uold.norm()<<
","<<Lold<<
"), curve time = "<<tstart<<
"\n";
171 for (
index_t k = 0; k!=Nintervals; k++)
173 gsDebug<<
"Interval "<<k+1<<
" of "<<Nintervals<<
"\n";
174 gsDebug<<
"Start - ||u|| = "<<Uold.norm()<<
", L = "<<Lold<<
"\n";
176 if (!(m_ALM->converged()))
178 gsInfo<<
"Error: Loop terminated, arc length method did not converge.\n";
181 m_ALM->setLength(dt);
182 m_ALM->setSolution(Uold,Lold);
187 GISMO_ENSURE(m_ALM->converged(),
"Loop terminated, arc length method did not converge.\n");
189 stepSolutions.at(k) = std::make_pair(m_ALM->solutionU(),m_ALM->solutionL());
190 stepTimes.at(k) = tstart + dt;
191 DeltaU = m_ALM->solutionU() - Uold;
192 DeltaL = m_ALM->solutionL() - Lold;
194 distances.at(k) = m_ALM->distance(DeltaU,DeltaL);
195 gsDebugVar(m_ALM->distance(DeltaU,DeltaL));
197 s += distances.at(k);
199 Uold = m_ALM->solutionU();
200 Lold = m_ALM->solutionL();
212 stepSolutions.resize(Nintervals);
213 stepTimes.resize(Nintervals);
214 distances.resize(Nintervals+1);
217 m_ALM->setLength(dt);
224 bool success = m_data.getReferenceByID(ID,reference);
227 DeltaU = reference.first - m_ALM->solutionU();
228 DeltaL = reference.second - m_ALM->solutionL();
229 distances.back() = m_ALM->distance(DeltaU,DeltaL);
236 s += distances.back();
244 m_data.submit(ID,distances,stepTimes,stepSolutions);
246 m_data.finishJob(ID);
252 std::tie(m_times,m_solutions) = m_data.getFlatSolution();
256 gsDebugVar(gsAsVector(m_times));
#define gsDebug
Definition: gsDebug.h:61
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
#define gsInfo
Definition: gsDebug.h:43