spring_contact.cc File Reference
#include "generic.h"

Namespaces

 GlobalFct
 

Functions

void GlobalFct::reset (Vector< double > &unknowns)
 Reset unknowns to some nontrivial garbage. More...
 
void GlobalFct::get_residuals (const Vector< double > &param, const Vector< double > &unknowns, Vector< double > &residuals)
 Global residual fct. More...
 
void GlobalFct::set_spurious_solution (Vector< double > &unknowns)
 Set unknowns to spurious solution. More...
 
void GlobalFct::plot_it (const std::string filename)
 Plot "landscape" of residuals (only for 2D problems!) More...
 
int main (int argc, char **argv)
 

Variables

double GlobalFct::Force =0.0
 Force. More...
 
double GlobalFct::Stiffness =1.0
 Spring stiffness. More...
 
double GlobalFct::U_max =5.5
 Max. displacement. More...
 
unsigned GlobalFct::N_primary =1
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////

258 {
259 
260  // Store command line arguments
261  CommandLineArgs::setup(argc,argv);
262 
264 
265  CommandLineArgs::specify_command_line_flag("--completely_smooth");
266 
268 
270 
272 
275 
276  // Doc available command line flags
278 
279  // Parse command line
281 
282  // Doc what has actually been specified on the command line
284 
285  // Number of steps for load incrementation
286  unsigned nstep=10;
287  unsigned nstep_total=2*nstep;
288 
290 
291  ofstream outfile2;
292  outfile2.open("trace.dat");
293 
295  Vector<double> param;
296  Vector<double> unknowns;
297  GlobalFct::reset(unknowns);
298 
299  GlobalFct::Force=0.0;
300  for (unsigned j=0;j<nstep_total;j++)
301  {
302 
303  oomph_info << "\n\nSolving for force: " << GlobalFct::Force
304  << std::endl << std::endl;
305 
306  char name[100];
307  sprintf(name,"landscape%i.dat",j);
310  try
311  {
313  GlobalFct::get_residuals,param,unknowns);
314 
315  oomph_info << "Number of Newton iterations to convergence: "
316  << BlackBoxFDNewtonSolver::N_iter_taken++ << std::endl;
317 
318  char name[100];
319  sprintf(name,"soln%i.dat",j);
320  ofstream outfile;
321  outfile.open(name);
322  outfile << unknowns[0] << " "
323  << unknowns[1] << "\n";
324  outfile.close();
325 
326  unsigned n=unknowns.size();
327  outfile2 << GlobalFct::Force << " ";
328  for (unsigned k=0;k<n;k++)
329  {
330  outfile2 << unknowns[k] << " ";
331  }
332  outfile2 << std::endl;
333  }
334  catch(OomphLibError) {}
335 
336  // Sweep up and then down
337  if (j<nstep)
338  {
339  GlobalFct::Force+=1.0;
340  }
341  else
342  {
343  GlobalFct::Force-=1.0;
344  }
345  }
346 
347  outfile2.close();
348 
349 
350  //----------------------------------------
351 
352  oomph_info << "\n\n\n\nTRY POSSIBLY SPURIOUS SOLUTION\n"
353  << "==============================\n\n";
354 
355  // Try spurious solution
357 
359  GlobalFct::get_residuals,param,unknowns);
360 
361  oomph_info << "Number of Newton iterations to convergence: "
362  << BlackBoxFDNewtonSolver::N_iter_taken++ << std::endl;
363 
364  oomph_info << "\nPossibly spurious solution: "
365  << unknowns[0] << " " << unknowns[1] << "\n\n";
366 
367 
368 
369 } // end_of_main
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Definition: oomph_definitions.h:222
char char char int int * k
Definition: level2_impl.h:374
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
unsigned N_primary
Definition: spring_contact.cc:50
void get_residuals(const Vector< double > &param, const Vector< double > &unknowns, Vector< double > &residuals)
Global residual fct.
Definition: spring_contact.cc:65
void plot_it(const std::string filename)
Plot "landscape" of residuals (only for 2D problems!)
Definition: spring_contact.cc:211
void reset(Vector< double > &unknowns)
Reset unknowns to some nontrivial garbage.
Definition: spring_contact.cc:53
double Force
Force.
Definition: spring_contact.cc:39
void set_spurious_solution(Vector< double > &unknowns)
Set unknowns to spurious solution.
Definition: spring_contact.cc:187
string filename
Definition: MergeRestartFiles.py:39
unsigned Max_iter
Max. # of Newton iterations.
Definition: black_box_newton_solver.cc:44
unsigned N_iter_taken
Number of Newton iterations taken in most recent invocation.
Definition: black_box_newton_solver.cc:47
bool Doc_Progress
Definition: black_box_newton_solver.cc:51
void black_box_fd_newton_solve(ResidualFctPt residual_fct, const Vector< double > &params, Vector< double > &unknowns, JacobianFctPt jacobian_fct)
Definition: black_box_newton_solver.cc:67
void doc_available_flags()
Document available command line flags.
Definition: oomph_utilities.cc:676
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
Definition: oomph_utilities.cc:451
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Definition: oomph_utilities.cc:760
void doc_specified_flags()
Document specified command line flags.
Definition: oomph_utilities.cc:610
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
string name
Definition: plotDoE.py:33
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References oomph::BlackBoxFDNewtonSolver::black_box_fd_newton_solve(), oomph::CommandLineArgs::doc_available_flags(), oomph::BlackBoxFDNewtonSolver::Doc_Progress, oomph::CommandLineArgs::doc_specified_flags(), MergeRestartFiles::filename, GlobalFct::Force, GlobalFct::get_residuals(), j, k, oomph::BlackBoxFDNewtonSolver::Max_iter, n, oomph::BlackBoxFDNewtonSolver::N_iter_taken, GlobalFct::N_primary, plotDoE::name, oomph::oomph_info, oomph::CommandLineArgs::parse_and_assign(), GlobalFct::plot_it(), GlobalFct::reset(), GlobalFct::set_spurious_solution(), Flag_definition::setup(), oomph::CommandLineArgs::specify_command_line_flag(), and oomph::Global_string_for_annotation::string().