GlobalFct Namespace Reference

Functions

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

Variables

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

Function Documentation

◆ get_residuals()

void GlobalFct::get_residuals ( const Vector< double > &  param,
const Vector< double > &  unknowns,
Vector< double > &  residuals 
)

Global residual fct.

68  {
69  // Loop over primary unknowns
70  for (unsigned j=0;j<N_primary;j++)
71  {
72 
73  // Mash 'em up
74  double alpha=1.0/double(5*N_primary);
75  double u=unknowns[j];
76  double u_combined=u;
77  for (unsigned k=0;k<N_primary;k++)
78  {
79  if (k!=j)
80  {
81  u_combined+=unknowns[k]*alpha;
82  }
83  }
84 
85  // Contact force
86  double fc=unknowns[N_primary+j];
87 
88  // Eqn numbers
89  unsigned displ_eqn=j;
90  unsigned contact_eqn=N_primary+j;
91 
92  // Equilibrium equation
93  //=====================
94  double N=double(N_primary);
95  residuals[displ_eqn]=Stiffness*u_combined-
96  Force*(2.0*j+2.0+alpha*N+alpha*N*N-2.0*alpha*j-2.0*alpha)/2.0
97  +fc;
98 
99  // Contact equation
100  //=================
101 
102  // Old version
103  //------------
105  ("--old_version"))
106  {
107 
108  // Equation for "melt" rate
109  if (u<U_max)
110  {
111  // "Lower left" quadrant of (u-U_max,fc) space:
112  // Linear variation with m forces things back to m=0
113  residuals[contact_eqn]=fc;
114  }
115  else
116  {
117  // Lower right quadrant of (u-U_max,fc) space
118  if (fc<0.0)
119  {
120  residuals[contact_eqn]=fc;
121  }
122  // Upper right quadrant of (u-U_max,fc) space
123  else
124  {
125  // Linear variation forces things back to U_max and maintains
126  // continuity with upper left and lower right quadrants
127  residuals[contact_eqn]=u-U_max;
128  }
129  }
130  }
131  // Completely smooth surface for melt rate residual
132  //-------------------------------------------------
134  ("--completely_smooth"))
135  {
136  double phi=atan2(fc,(U_max-u));
137  if (phi<0) phi+=2.0*MathematicalConstants::Pi;
138 
139  // Quadratic fit to periodic polynomial that's only
140  // above zero between phi=90 and 180 degrees.
141  double t0 = 768.0/77.0/0.3141592653589793E1*phi-2176.0/77.0/(
142  0.3141592653589793E1*0.3141592653589793E1)*phi*phi+128.0/7.0/(
143  0.3141592653589793E1*0.3141592653589793E1*0.3141592653589793E1)*
144  phi*phi*phi
145  -256.0/77.0/(0.3141592653589793E1*0.3141592653589793E1*
146  0.3141592653589793E1*
147  0.3141592653589793E1)*phi*phi*phi*phi;
148 
149  residuals[contact_eqn]=(fc*fc+(U_max-u)*(U_max-u))*t0;
150  }
151  // Single kink
152  //------------
154  ("--single_kink"))
155  {
156  // Piecewise linear variation with a single kink
157  if ((U_max-u)>fc)
158  {
159  residuals[contact_eqn]=fc;
160  }
161  else
162  {
163  residuals[contact_eqn]=(U_max-u);
164  }
165  }
166 
167  // Kuhn Tucker
168  //------------
170  ("--kuhn_tucker"))
171  {
172  residuals[contact_eqn]=fc*(U_max-u);
173  }
174  else
175  {
176  oomph_info << "Please specify which method you want to use for\n"
177  << "the enforcement of the contact condition: \n";
179  abort();
180  }
181  }
182  }
AnnoyingScalar atan2(const AnnoyingScalar &y, const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:139
@ N
Definition: constructor.cpp:22
RealScalar alpha
Definition: level1_cplx_impl.h:151
char char char int int * k
Definition: level2_impl.h:374
double Pi
Definition: two_d_biharmonic.cc:235
unsigned N_primary
Definition: spring_contact.cc:50
double U_max
Max. displacement.
Definition: spring_contact.cc:45
double Stiffness
Spring stiffness.
Definition: spring_contact.cc:42
double Force
Force.
Definition: spring_contact.cc:39
void doc_available_flags()
Document available command line flags.
Definition: oomph_utilities.cc:676
bool command_line_flag_has_been_set(const std::string &flag)
Definition: oomph_utilities.cc:501
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References alpha, atan2(), oomph::CommandLineArgs::command_line_flag_has_been_set(), oomph::CommandLineArgs::doc_available_flags(), Force, j, k, N, N_primary, oomph::oomph_info, BiharmonicTestFunctions2::Pi, Stiffness, and U_max.

Referenced by SegregatedFSICollapsibleChannelProblem< ELEMENT >::actions_before_newton_convergence_check(), SegregatedFSICollapsibleChannelProblem< ELEMENT >::actions_before_segregated_convergence_check(), BaseCoupling< M, O >::checkResidual(), oomph::SpineLineMarangoniFluidInterfaceElement< ELEMENT >::fill_in_contribution_to_jacobian(), oomph::FixedVolumeSpineLineMarangoniFluidInterfaceElement< ELEMENT >::fill_in_contribution_to_jacobian(), oomph::SpineAxisymmetricMarangoniSurfactantFluidInterfaceElement< ELEMENT >::fill_in_contribution_to_jacobian(), oomph::SpineLineMarangoniSurfactantFluidInterfaceElement< ELEMENT >::fill_in_contribution_to_jacobian(), BrethertonElement< ELEMENT >::get_jacobian(), TwoNodePoissonElement::get_jacobian(), oomph::Hijacked< ELEMENT >::get_residuals(), main(), BrethertonProblem< ELEMENT >::parameter_study(), plot_it(), set_spurious_solution(), and HomogenisationProblem< ELEMENT >::sub_solve().

◆ plot_it()

void GlobalFct::plot_it ( const std::string  filename)

Plot "landscape" of residuals (only for 2D problems!)

212  {
213  if (N_primary!=1)
214  {
215  oomph_info << "Skipping plot_it()\n";
216  return;
217  }
218 
219  ofstream outfile;
220  outfile.open(filename.c_str());
221  Vector<double> x(2);
222  Vector<double> f(2);
224  double x_min=0.0;
225  double x_max=10.0;
226  double y_min=-5.0;
227  double y_max=5.0;
228 
229  unsigned nplot=100;
230  outfile << "ZONE I=" << nplot << ", J=" << nplot << std::endl;
231  for (unsigned i=0;i<nplot;i++)
232  {
233  x[0]=x_min+(x_max-x_min)*double(i)/double(nplot-1);
234  for (unsigned j=0;j<nplot;j++)
235  {
236  x[1]=y_min+(y_max-y_min)*double(j)/double(nplot-1);
238  outfile << x[0] << " "
239  << x[1] << " "
240  << f[0] << " "
241  << f[1] << "\n" ;
242  }
243  }
244  outfile.close();
245 
246  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
void get_residuals(const Vector< double > &param, const Vector< double > &unknowns, Vector< double > &residuals)
Global residual fct.
Definition: spring_contact.cc:65
string filename
Definition: MergeRestartFiles.py:39
dictionary params
Definition: Particles2023AnalysisHung.py:35
list x
Definition: plotDoE.py:28

References f(), MergeRestartFiles::filename, get_residuals(), i, j, N_primary, oomph::oomph_info, Particles2023AnalysisHung::params, and plotDoE::x.

Referenced by oomph::StefanBoltzmannHelper::bin_helper(), oomph::FishMesh< ELEMENT >::build_mesh(), main(), and oomph::StefanBoltzmannHelper::setup_stefan_boltzmann_visibility().

◆ reset()

void GlobalFct::reset ( Vector< double > &  unknowns)

Reset unknowns to some nontrivial garbage.

54  {
55  unsigned n=N_primary*2;
56  unknowns.resize(n);
57  for (unsigned j=0;j<n;j++)
58  {
59  unknowns[j]=double(j)+20.5;
60  }
61  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11

References j, n, and N_primary.

Referenced by main().

◆ set_spurious_solution()

void GlobalFct::set_spurious_solution ( Vector< double > &  unknowns)

Set unknowns to spurious solution.

188  {
189  Force=100.0;
190  N_primary=1;
191 
192  Vector<double> param;
193  unknowns.resize(2);
194  Vector<double> residuals(2);
195 
196  // Displacement
198 
199  // Contact force
200  unknowns[1]=-0.5*BlackBoxFDNewtonSolver::Tol;
201 
202  // Get residuals
203  get_residuals(param,unknowns, residuals);
204  oomph_info << "Residual for spurious solution: "
205  << residuals[0] << " "
206  << residuals[1] << "\n";
207  }
double Tol
Definition: fourier_decomposed_helmholtz_bc_elements.h:921

References Force, get_residuals(), N_primary, oomph::oomph_info, Stiffness, and oomph::ToleranceForFourierDecomposedHelmholtzOuterBoundary::Tol.

Referenced by main().

Variable Documentation

◆ Force

double GlobalFct::Force =0.0

Force.

Referenced by get_residuals(), main(), and set_spurious_solution().

◆ N_primary

unsigned GlobalFct::N_primary =1

Number of primary variables. Equal to number of raw "displacement" variables for contact problem; total number of degrees of freedom in that case is twice as big because of the unknown contact forces.

Referenced by get_residuals(), main(), plot_it(), reset(), and set_spurious_solution().

◆ Stiffness

double GlobalFct::Stiffness =1.0

Spring stiffness.

Referenced by get_residuals(), and set_spurious_solution().

◆ U_max

double GlobalFct::U_max =5.5

Max. displacement.

Referenced by get_residuals(), and main().