spring_contact2.cc File Reference
#include "generic.h"
#include <fenv.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::plot_it (const std::string filename)
 Plot "landscape" of residuals (only for 2D problems!) More...
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

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

128 {
129  //feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW);
130 
131  // Store command line arguments
132  CommandLineArgs::setup(argc,argv);
133 
134  // CommandLineArgs::specify_command_line_flag("--bilinear");
135 
136  // CommandLineArgs::specify_command_line_flag("--completely_smooth");
137 
138  // CommandLineArgs::specify_command_line_flag("--single_kink");
139 
140  // CommandLineArgs::specify_command_line_flag("--old_version");
141 
142  // CommandLineArgs::specify_command_line_flag("--kuhn_tucker");
143 
144  // CommandLineArgs::specify_command_line_flag("--n_primary",
145  // &GlobalFct::N_primary);
146 
147  // Doc available command line flags
149 
150  // Parse command line
152 
153  // Doc what has actually been specified on the command line
155 
156  // Number of steps for load incrementation
157  unsigned nstep=10;
158  unsigned nstep_total=2*nstep;
159 
161 
162  ofstream outfile2;
163  outfile2.open("trace.dat");
164 
166  Vector<double> param;
167  Vector<double> unknowns;
168  GlobalFct::reset(unknowns);
169 
170  GlobalFct::Force=0.0;
171  for (unsigned j=0;j<nstep_total;j++)
172  {
173 
174  oomph_info << "\n\nSolving for force: " << GlobalFct::Force
175  << std::endl << std::endl;
176 
177  char name[100];
178  sprintf(name,"landscape%i.dat",j);
181  try
182  {
183  //BlackBoxFDNewtonSolver::Use_step_length_control=true;
184 
186  GlobalFct::get_residuals,param,unknowns);
187 
188  oomph_info << "Number of Newton iterations to convergence: "
189  << BlackBoxFDNewtonSolver::N_iter_taken++ << std::endl;
190 
191  char name[100];
192  sprintf(name,"soln%i.dat",j);
193  ofstream outfile;
194  outfile.open(name);
195  outfile << unknowns[0] << " "
196  << unknowns[1] << "\n";
197  outfile.close();
198 
199  oomph_info << "Displ: " << GlobalFct::U_max-unknowns[0]*unknowns[0]<< " "
200  << "Contact force: " << unknowns[1]*unknowns[1]<< " "
201  << std::endl;
202 
203 
204  unsigned n=unknowns.size();
205  outfile2 << GlobalFct::Force << " ";
206  for (unsigned k=0;k<n;k++)
207  {
208  outfile2 << unknowns[k] << " ";
209  }
210  outfile2 << std::endl;
211  }
212  catch(OomphLibError) {}
213 
214  // Sweep up and then down
215  if (j<nstep)
216  {
217  GlobalFct::Force+=2.1;
218  }
219  else
220  {
221  GlobalFct::Force-=2.1;
222  }
223  }
224 
225  outfile2.close();
226 
227 
228  // //----------------------------------------
229 
230  // oomph_info << "\n\n\n\nTRY POSSIBLY SPURIOUS SOLUTION\n"
231  // << "==============================\n\n";
232 
233  // // Try spurious solution
234  // GlobalFct::set_spurious_solution(unknowns);
235 
236  // BlackBoxFDNewtonSolver::black_box_fd_newton_solve(
237  // GlobalFct::get_residuals,param,unknowns);
238 
239  // oomph_info << "Number of Newton iterations to convergence: "
240  // << BlackBoxFDNewtonSolver::N_iter_taken++ << std::endl;
241 
242  // oomph_info << "\nPossibly spurious solution: "
243  // << unknowns[0] << " " << unknowns[1] << "\n\n";
244 
245 
246 
247 } // 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
double U_max
Max. displacement.
Definition: spring_contact.cc:45
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
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 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, plotDoE::name, oomph::oomph_info, oomph::CommandLineArgs::parse_and_assign(), GlobalFct::plot_it(), GlobalFct::reset(), Flag_definition::setup(), oomph::Global_string_for_annotation::string(), and GlobalFct::U_max.