[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] r4995 - in /trunk/getfem: doc/sphinx/source/userdoc/ in
From: |
logari81 |
Subject: |
[Getfem-commits] r4995 - in /trunk/getfem: doc/sphinx/source/userdoc/ interface/src/ interface/src/scilab/demos/ interface/src/scilab/help/en... |
Date: |
Thu, 21 May 2015 10:19:59 -0000 |
Author: logari81
Date: Thu May 21 12:19:59 2015
New Revision: 4995
URL: http://svn.gna.org/viewcvs/getfem?rev=4995&view=rev
Log:
return the actual step size in Moore-Penrose continuation and some interface
and output improvements
Modified:
trunk/getfem/doc/sphinx/source/userdoc/model_continuation.rst
trunk/getfem/doc/sphinx/source/userdoc/model_generic_elliptic.rst
trunk/getfem/interface/src/gf_cont_struct_get.cc
trunk/getfem/interface/src/scilab/demos/demo_continuation.sce
trunk/getfem/interface/src/scilab/demos/demo_continuation_block.sce
trunk/getfem/interface/src/scilab/demos/demo_continuation_vee.sce
trunk/getfem/interface/src/scilab/help/en_US/gf_cont_struct_get.xml
trunk/getfem/interface/tests/matlab/demo_continuation.m
trunk/getfem/src/getfem/getfem_continuation.h
Modified: trunk/getfem/doc/sphinx/source/userdoc/model_continuation.rst
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/doc/sphinx/source/userdoc/model_continuation.rst?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/doc/sphinx/source/userdoc/model_continuation.rst
(original)
+++ trunk/getfem/doc/sphinx/source/userdoc/model_continuation.rst Thu May
21 12:19:59 2015
@@ -445,15 +445,16 @@
Subsequently, one step of the continuation is called by ::
- S.Moore_Penrose_continuation(U, lambda, T_U, T_lambda, h);
+ S.Moore_Penrose_continuation(U, lambda, T_U, T_lambda, h, h0);
After each call, a new point on a solution curve and the corresponding tangent
are returned in the variables ``U``, ``lambda`` and ``T_U``, ``T_lambda``. The
-step size for the next prediction is returned in ``h``. According to the chosen
-value of ``singularities``, the test functions for limit and bifurcation
points
-are evaluated at the end of each continuation step. Furthermore, if a smooth
-bifurcation point is detected, the procedure for numerical bifurcation is
-performed and an approximation of the branching point as well as tangents to
+step size for the next prediction is returned in ``h``. The size of the
+current step is returned in the optional argument ``h0``. According to the
+chosen value of ``singularities``, the test functions for limit and bifurcation
+points are evaluated at the end of each continuation step. Furthermore, if a
+smooth bifurcation point is detected, the procedure for numerical bifurcation
+is performed and an approximation of the branching point as well as tangents to
both bifurcating curves are saved in the continuation object ``S``. From
there, they can easily be recovered with member functions of ``S`` so that one
can initialise the continuation to trace either of the curves next time.
Modified: trunk/getfem/doc/sphinx/source/userdoc/model_generic_elliptic.rst
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/doc/sphinx/source/userdoc/model_generic_elliptic.rst?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/doc/sphinx/source/userdoc/model_generic_elliptic.rst
(original)
+++ trunk/getfem/doc/sphinx/source/userdoc/model_generic_elliptic.rst Thu May
21 12:19:59 2015
@@ -49,7 +49,7 @@
size_type getfem::add_generic_elliptic_brick(md, mim, varname, dataexpr,
region = -1);
-It adds a term with an arbitrary coefficient given by the expression
``dataexpr`` which as to be a regular expression of the high-level generic
assembly language (like "1", "sin(X[0])" or "Norm(u)" for instance) even
depending on model variables (except for the complex version where it has to be
a declared data of the model)
+It adds a term with an arbitrary coefficient given by the expression
``dataexpr`` which has to be a regular expression of the high-level generic
assembly language (like "1", "sin(X[0])" or "Norm(u)" for instance) even
depending on model variables (except for the complex version where it has to be
a declared data of the model)
Note that very general equations can be obtained with this brick. For instance,
linear anisotropic elasticity can be obtained with a tensor data. When an order
Modified: trunk/getfem/interface/src/gf_cont_struct_get.cc
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/gf_cont_struct_get.cc?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/interface/src/gf_cont_struct_get.cc (original)
+++ trunk/getfem/interface/src/gf_cont_struct_get.cc Thu May 21 12:19:59 2015
@@ -69,15 +69,42 @@
/address@hidden h = ('init step size')
Return an initial step size for address@hidden/
sub_command
- ("init step size", 0, 0, 0, 1,
-
+ ("init step size", 0, 0, 1, 1,
out.pop().from_scalar(ps->h_init());
+ );
+
+ /address@hidden h = ('min step size')
+ Return the minimum step size for address@hidden/
+ sub_command
+ ("min step size", 0, 0, 0, 1,
+ out.pop().from_scalar(ps->h_min());
+ );
+
+ /address@hidden h = ('max step size')
+ Return the maximum step size for address@hidden/
+ sub_command
+ ("max step size", 0, 0, 0, 1,
+ out.pop().from_scalar(ps->h_max());
+ );
+
+ /address@hidden h = ('step size decrement')
+ Return the decrement ratio of the step size for address@hidden/
+ sub_command
+ ("step size decrement", 0, 0, 0, 1,
+ out.pop().from_scalar(ps->h_dec());
+ );
+
+ /address@hidden h = ('step size increment')
+ Return the increment ratio of the step size for address@hidden/
+ sub_command
+ ("step size increment", 0, 0, 0, 1,
+ out.pop().from_scalar(ps->h_inc());
);
/address@hidden address@hidden tangent_sol, @scalar tangent_par] =
('compute tangent', @vec solution, @scalar parameter, @vec tangent_sol, @scalar
tangent_par)
Compute and return an updated address@hidden/
sub_command
- ("compute tangent", 4, 4, 0, 2,
+ ("compute tangent", 4, 4, 2, 2,
size_type nbdof = ps->linked_model().nb_dof();
darray x0 = in.pop().to_darray();
scalar_type gamma = in.pop().to_scalar();
@@ -99,7 +126,7 @@
computed tangent with respect to the parameter is determined by the
sign of address@hidden/
sub_command
- ("init Moore-Penrose continuation", 3, 3, 0, 3,
+ ("init Moore-Penrose continuation", 3, 3, 3, 3,
size_type nbdof = ps->linked_model().nb_dof();
darray x_ = in.pop().to_darray();
@@ -120,12 +147,13 @@
Compute one step of the Moore-Penrose continuation: Take the point
given by `solution` and `parameter`, the tangent given by `tangent_sol`
and `tangent_par`, and the step size `h`. Return a new point on the
- solution curve, the corresponding tangent and a step size for the next
- step. If the returned step size equals zero, the continuation has
- failed. Optionally, return the type of any detected singular point.
+ solution curve, the corresponding tangent, a step size for the next
+ step and optionally the current step size. If the returned step
+ size equals zero, the continuation has failed. Optionally, return
+ the type of any detected singular point.
NOTE: The new point need not to be saved in the model in the
address@hidden/
sub_command
- ("Moore-Penrose continuation", 5, 5, 0, 6,
+ ("Moore-Penrose continuation", 5, 5, 5, 7,
size_type nbdof = ps->linked_model().nb_dof();
darray x_ = in.pop().to_darray();
@@ -135,14 +163,17 @@
std::vector<double> tx(nbdof); gmm::copy(tx_, tx);
scalar_type tgamma = in.pop().to_scalar();
scalar_type h = in.pop().to_scalar();
-
- ps->Moore_Penrose_continuation(x, gamma, tx, tgamma, h);
+ scalar_type h0(0);
+
+ ps->Moore_Penrose_continuation(x, gamma, tx, tgamma, h, h0);
out.pop().from_dcvector(x);
out.pop().from_scalar(gamma);
out.pop().from_dcvector(tx);
out.pop().from_scalar(tgamma);
out.pop().from_scalar(h);
if (out.remaining())
+ out.pop().from_scalar(h0);
+ if (out.remaining())
out.pop().from_string(ps->get_sing_label().c_str());
);
@@ -153,7 +184,7 @@
and `tangent_par1` and the point given by `solution2` and `parameter2`
with the tangent given by `tangent_sol2` and address@hidden/
sub_command
- ("non-smooth bifurcation test", 8, 8, 0, 1,
+ ("non-smooth bifurcation test", 8, 8, 1, 1,
size_type nbdof = ps->linked_model().nb_dof();
darray x1_ = in.pop().to_darray();
@@ -181,7 +212,7 @@
the whole calculated graph when passing between different sub-domains
of address@hidden/
sub_command
- ("bifurcation test function", 0, 0, 0, 3,
+ ("bifurcation test function", 0, 0, 1, 3,
out.pop().from_scalar(ps->get_tau_bp_2());
if (out.remaining()) out.pop().from_dcvector(ps->get_alpha_hist());
Modified: trunk/getfem/interface/src/scilab/demos/demo_continuation.sce
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/scilab/demos/demo_continuation.sce?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/interface/src/scilab/demos/demo_continuation.sce
(original)
+++ trunk/getfem/interface/src/scilab/demos/demo_continuation.sce Thu May
21 12:19:59 2015
@@ -127,7 +127,7 @@
for step = 1:nbstep
//sleep(1000);
printf('\nbeginning of step %d\n', step);
- [U, lambda, T_U, T_lambda, h, sing_label] = ...
+ [U, lambda, T_U, T_lambda, h, h0, sing_label] = ...
gf_cont_struct_get(S, 'Moore-Penrose continuation',...
U, lambda, T_U, T_lambda, h);
if (h == 0) then
Modified: trunk/getfem/interface/src/scilab/demos/demo_continuation_block.sce
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/scilab/demos/demo_continuation_block.sce?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/interface/src/scilab/demos/demo_continuation_block.sce
(original)
+++ trunk/getfem/interface/src/scilab/demos/demo_continuation_block.sce Thu May
21 12:19:59 2015
@@ -288,7 +288,7 @@
// continue from the initial point
for step = 1:nbstep
printf('\nbeginning of step %d\n', step);
- [X, gm, T_X, T_gm, h, sing_label] = gf_cont_struct_get(S, ...
+ [X, gm, T_X, T_gm, h, h0, sing_label] = gf_cont_struct_get(S, ...
'Moore-Penrose continuation', X, gm, T_X, T_gm, h);
if (h == 0) then
printf('Continuation has failed.\n')
Modified: trunk/getfem/interface/src/scilab/demos/demo_continuation_vee.sce
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/scilab/demos/demo_continuation_vee.sce?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/interface/src/scilab/demos/demo_continuation_vee.sce
(original)
+++ trunk/getfem/interface/src/scilab/demos/demo_continuation_vee.sce Thu May
21 12:19:59 2015
@@ -259,7 +259,7 @@
// continue from the initial point
for step = 1:nbstep
printf('\nbeginning of step %d\n', step);
- [X, gm, T_X, T_gm, h, sing_label] = gf_cont_struct_get(S, ...
+ [X, gm, T_X, T_gm, h, h0, sing_label] = gf_cont_struct_get(S, ...
'Moore-Penrose continuation', X, gm, T_X, T_gm, h);
if (h == 0) then
printf('Continuation has failed.\n')
Modified: trunk/getfem/interface/src/scilab/help/en_US/gf_cont_struct_get.xml
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/src/scilab/help/en_US/gf_cont_struct_get.xml?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/interface/src/scilab/help/en_US/gf_cont_struct_get.xml
(original)
+++ trunk/getfem/interface/src/scilab/help/en_US/gf_cont_struct_get.xml Thu May
21 12:19:59 2015
@@ -62,8 +62,9 @@
given by <literal>solution</literal> and <literal>parameter</literal>,
the tangent given by <literal>tangent_sol</literal>
and <literal>tangent_par</literal>, and the step size
<literal>h</literal>. Return a new point on the
solution curve, the corresponding tangent and a step size for the next
- step. If the returned step size equals zero, the continuation has
- failed. Optionally, return the type of any detected singular point.
+ step and optionally the size of the current step. If the returned step
+ size equals zero, the continuation has failed. Optionally, return the
+ type of any detected singular point.
NOTE: The new point need not to be saved in the model in the end!
</para>
</listitem>
Modified: trunk/getfem/interface/tests/matlab/demo_continuation.m
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/interface/tests/matlab/demo_continuation.m?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/interface/tests/matlab/demo_continuation.m (original)
+++ trunk/getfem/interface/tests/matlab/demo_continuation.m Thu May 21
12:19:59 2015
@@ -118,7 +118,7 @@
% continue from the initial point
for step = 1:nbstep
disp(sprintf('\nbeginning of step %d', step));
- [U, lambda, T_U, T_lambda, h, sing_label] = ...
+ [U, lambda, T_U, T_lambda, h, h0, sing_label] = ...
gf_cont_struct_get(S, 'Moore-Penrose continuation', ...
U, lambda, T_U, T_lambda, h);
Modified: trunk/getfem/src/getfem/getfem_continuation.h
URL:
http://svn.gna.org/viewcvs/getfem/trunk/getfem/src/getfem/getfem_continuation.h?rev=4995&r1=4994&r2=4995&view=diff
==============================================================================
--- trunk/getfem/src/getfem/getfem_continuation.h (original)
+++ trunk/getfem/src/getfem/getfem_continuation.h Thu May 21 12:19:59 2015
@@ -351,7 +351,7 @@
diff = w_norm(Delta_X, Delta_Gamma);
if (noisy() > 1)
cout << " Correction " << std::setw(3) << it << ":"
- << " Gamma = " << std::fixed << std::setprecision(6) << 1e2*Gamma <<
" %"
+ << " Gamma = " << std::fixed << std::setprecision(6) << Gamma
<< " residual = " << std::scientific << std::setprecision(3) << res
<< " difference = " << std::scientific << std::setprecision(3) <<
diff
<< " cosang = " << std::fixed << std::setprecision(6)
@@ -365,7 +365,7 @@
}
}
if (noisy() == 1) cout << "Correction finished with Gamma = "
- << 1e2*Gamma << " %" << endl;
+ << Gamma << endl;
return converged;
}
@@ -387,7 +387,7 @@
// prediction
scaled_add(x, gamma, tx, tgamma, h, X, Gamma); // [X,Gamma] =
[x,gamma] + h * [tx,tgamma]
if (noisy() > 0)
- cout << "(TPD) Prediction : Gamma = " << 1e2*Gamma << " %"
+ cout << "(TPD) Prediction : Gamma = " << Gamma
<< " (for h = " << h << ", tgamma = " << tgamma << ")" << endl;
copy(tx, tgamma, tX, tGamma);
//correction
@@ -426,7 +426,7 @@
for (size_type i=0; i < 10 && (gmm::abs(h) >= h_min()); ++i) {
scaled_add(x0, gamma0, tx0, tgamma0, h, X, Gamma); // [X,Gamma] =
[x0,gamma0] + h * [tx0,tgamma0]
if (noisy() > 0)
- cout << "(TSBP) Prediction : Gamma = " << 1e2*Gamma << " %"
+ cout << "(TSBP) Prediction : Gamma = " << Gamma
<< " (for h = " << h << ", tgamma = " << tgamma << ")" << endl;
if (newton_corr(X, Gamma, tX, tGamma, tx0, tgamma0)) {
copy(X, Gamma, x0, gamma0);
@@ -487,7 +487,7 @@
for (size_type i = 0; i < 15; i++) {
scaled_add(x0, gamma0, tx0, tgamma0, h, X, Gamma); // [X,Gamma] =
[x0,gamma0] + h*[tx0,tgamma0]
if (noisy() > 0)
- cout << "(TNSBP) Prediction : Gamma = " << 1e2*Gamma << " %"
+ cout << "(TNSBP) Prediction : Gamma = " << Gamma
<< " (for h = " << h << ", tgamma = " << tgamma << ")" << endl;
if (newton_corr(X, Gamma, tX, tGamma, tx0, tgamma0)
&& (cosang(tX, tx0, tGamma, tgamma0) >= mcos)) {
@@ -601,7 +601,8 @@
/* Perform one step of the (non-smooth) Moore-Penrose continuation.
NOTE: The new point need not to be saved in the model in the end! */
void Moore_Penrose_continuation(VECT &x, double &gamma,
- VECT &tx, double &tgamma, double &h) {
+ VECT &tx, double &tgamma,
+ double &h, double &h0) {
bool converged, new_point = false, tangent_switched = false;
size_type it, step_dec = 0;
double tgamma0 = tgamma, Gamma, tGamma;
@@ -611,10 +612,11 @@
clear_sing_data();
do {
+ h0 = h;
// prediction
scaled_add(x, gamma, tx, tgamma, h, X, Gamma); //
[X,Gamma] = [x,gamma] + h*[tx,tgamma]
if (noisy() > 0)
- cout << " Prediction : Gamma = " << 1e2*Gamma << " %"
+ cout << " Prediction : Gamma = " << Gamma
<< " (for h = " << std::scientific << std::setprecision(3) << h
<< ", tgamma = " << tgamma << ")" << endl;
copy(tx, tgamma, tX, tGamma);
@@ -630,12 +632,12 @@
set_sing_label("limit point");
if (noisy() > 0) cout << "Limit point detected!" << endl;
}
- if (this->singularities > 1) {
+ if (this->singularities > 1) { // Treat bifurcations
if (noisy() > 0)
cout << "New point found, starting computing a test function "
<< "for bifurcations" << endl;
if (!tangent_switched) {
- if(test_smooth_bifurcation(X, Gamma, tX, tGamma)) {
+ if (test_smooth_bifurcation(X, Gamma, tX, tGamma)) {
set_sing_label("smooth bifurcation point");
if (noisy() > 0)
cout << "Smooth bifurcation point detected!" << endl;
@@ -675,6 +677,7 @@
copy(X, Gamma, x, gamma);
copy(tX, tGamma, tx, tgamma);
} else if (this->non_smooth && this->singularities > 1) {
+ h0 = h_min();
treat_nonsmooth_point(x, gamma, tx0, tgamma0, true);
if (gmm::vect_size(get_x_next()) > 0) {
if (test_limit_point(tGamma)) {
@@ -714,8 +717,14 @@
if (!new_point) {
cout << "Continuation has failed!" << endl;
- h = 0;
- }
+ h0 = h = 0;
+ }
+ }
+
+ void Moore_Penrose_continuation(VECT &x, double &gamma,
+ VECT &tx, double &tgamma, double &h) {
+ double h0;
+ Moore_Penrose_continuation(x, gamma, tx, tgamma, h, h0);
}
protected:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Getfem-commits] r4995 - in /trunk/getfem: doc/sphinx/source/userdoc/ interface/src/ interface/src/scilab/demos/ interface/src/scilab/help/en...,
logari81 <=