12 template <
class TConv>
28 numrows = state.
Rows();
29 for(i=0; i<numrows; i++) {
30 REAL randnum = (rand()&1000)/999.;
31 incval(i,0) = range(i,0)*(STATE)randnum;
34 std::ofstream
log(
"conv.log");
38 int numcases = obj.NumCases();
43 for(icase = 0; icase < numcases; icase++) {
48 obj.ComputeTangent(Tangent,coefs,icase);
51 obj.
Residual(ReferenceResidual,icase);
54 EstimateRes.
Redim(ReferenceResidual.
Rows(),ReferenceResidual.
Cols());
55 Tangent.
Multiply(incval,EstimateRes);
59 REAL difnorm[10] = {0.};
61 for(interval = 1; interval < 10; interval++) {
66 for(i=0; i<numrows; i++) {
67 for(j=0; j<ncoefs; j++) {
68 actualstate(i,j) += (STATE)(interval/10.)*(STATE)incval(i,0)*(STATE)coefs[j];
72 obj.LoadState(actualstate);
73 obj.Residual(residual,icase);
75 residual -= ReferenceResidual;
78 residual = residual - EstimateRes*(STATE(interval/10.));
79 temp = EstimateRes*(STATE(interval/10.));
82 difnorm[interval] =
Norm(residual);
87 std::cout <<
"icase = " << icase << std::endl;
88 log <<
"icase = " << icase << std::endl;
90 for(interval = 2; interval<10; interval++) {
92 if(
fabs(difnorm[interval]) < REAL(1.e-12) ||
fabs(difnorm[interval-1]) <REAL(1.e-12)) {
93 std::cout <<
"residual too small\n";
94 log <<
"residual too small\n";
97 std::cout << (
log10(difnorm[interval])-
log10(difnorm[interval-1]))/
99 (
log10((
float)interval)-
log10(interval-1.0)) << std::endl;
100 log << (
log10(difnorm[interval])-
log10(difnorm[interval-1]))/
101 (
log10((
float)interval)-
log10(interval-1.0)) << std::endl;
127 template<
class TConv>
133 numrows = state.
Rows();
134 REAL randnum = (rand()&1000)/999.;
135 for(
int i=0; i<numrows; i++) {
136 incval(i,0) = range(i,0)*(STATE)randnum;
137 if(!direction_range) randnum = (rand()&1000)/999.;
140 std::ofstream
log(
"conv.log");
144 int numcases = obj.NumCasesCheckConv();
148 for(icase = 0; icase < numcases; icase++) {
152 obj.TangentCheckConv(state, Tangent,icase);
155 obj.ResidualCheckConv(state, ReferenceResidual,icase);
158 EstimateRes.
Redim(ReferenceResidual.
Rows(),ReferenceResidual.
Cols());
159 Tangent.
Multiply(incval,EstimateRes);
161 REAL difnorm[10] = {0.};
163 for(
int interval = 1; interval < 10; interval++)
169 for(
int i=0; i<numrows; i++)
171 actualstate(i) += (STATE)(interval/10.)*(STATE)incval(i,0);
174 obj.ResidualCheckConv(actualstate, residual,icase);
176 residual -= ReferenceResidual;
178 residual = residual - EstimateRes*(STATE(interval/10.));
180 difnorm[interval] =
Norm(residual);
181 std::cout <<
"difnorm = " << difnorm[interval];
185 std::cout <<
"icase = " << icase << std::endl;
186 log <<
"icase = " << icase << std::endl;
188 for(
int interval = 2; interval<10; interval++) {
190 if(
fabs(difnorm[interval]) < REAL(1.e-12) ||
fabs(difnorm[interval-1]) <REAL(1.e-12)) {
191 std::cout <<
"residual too small\n";
192 log <<
"residual too small\n";
195 std::cout << (
log10(difnorm[interval])-
log10(difnorm[interval-1]))/
197 (
log10((REAL)interval)-
log10(interval-1.0)) << std::endl;
198 log << (
log10(difnorm[interval])-
log10(difnorm[interval-1]))/
199 (
log10((REAL)interval)-
log10(interval-1.0)) << std::endl;
void CheckConvergence(TConv &obj, TPZFMatrix< STATE > &state, TPZFMatrix< STATE > &range, TPZVec< REAL > &coefs)
Implements a general procedure to check whether the class TConv implements a consistente tangent matr...
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
virtual void Residual(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &rhs, TPZFMatrix< TVar > &res)
Computes res = rhs - this * x.
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
Contains TPZMatrixclass which implements full matrix (using column major representation).
void TPZCheckConvergence(TConv &obj, TPZFMatrix< STATE > &state, TPZFMatrix< STATE > &range, bool direction_range=false)
int64_t Rows() const
Returns number of rows.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ log
virtual void Multiply(const TPZFMatrix< TVar > &A, TPZFMatrix< TVar > &res, int opt=0) const
It mutiplies itself by TPZMatrix<TVar>A putting the result in res.
int64_t Cols() const
Returns number of cols.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ log10
int64_t NElements() const
Returns the number of elements of the vector.