Page 1 of 1

Norm calculation

Posted: 07 Nov 2012, 16:39
by Franz Pichler
Hello everybody,

i am just trying to find a way to calculate the nonlinear change norm my own way.
Therefor i was searching around ion the source code and found the function
ComputeChange in the SolverUtils.

There is a case selection in there.
and one is called 'solution' where the norm of the difference in x and x0 is calculated. This x0 is the nonlinvalues member of the variable, if i got it right.
what i would like to do is to take just the norm of the solution, putting x0=0.
can anyone tell me if it is ok to put the x0 to zero in a solver that is not solving a linear system?

best regards
Franz

Re: Norm calculation

Posted: 08 Nov 2012, 13:44
by mika
Hi,

It may be worth noting that if relaxation is applied in connection with the nonlinear iteration, then this modification may have an unwanted impact on how the next nonlinear iterate is computed.

-Mika

Re: Norm calculation

Posted: 08 Nov 2012, 14:55
by Franz Pichler
Ah, thanks.
didn't think of that

Re: Norm calculation

Posted: 08 Nov 2012, 15:54
by raback
Hi

I don't see how setting x0=0 would be usefull since then the error would be estimated from |x|/|x|, rather than 2*|x-x0|/(|x|+|x0|).

-Peter

Re: Norm calculation

Posted: 08 Nov 2012, 16:06
by Franz Pichler
qeah,
what i wanted was just |x| wihtout dividing it. the reason is that the value allready is a relative difference between two solutions that i get from some other program.
I use it for adaptive timestepping.
I think i found a way around it now anyways.
I will just use the computenorm (solverutils ) function in my code and take over the complete timestepping control.
thanks anyways.

Another question though:

is there a way to get to the exported variables through the solver structure?
i understand that i can use Model % Solver % Variable to get the main variable.
But howe can i get the exported vaibales?
only by looping over all 99 variables?
best regardss Franz

Re: Norm calculation

Posted: 08 Nov 2012, 16:21
by raback
Try

Code: Select all

Var => VariableGet( Mesh % Variables,'My Variable')
IF(.NOT. ASSOCIATED(Var)) print *,'bummer'
-Peter

Re: Norm calculation

Posted: 08 Nov 2012, 16:24
by Franz Pichler
Thanks for the reply,
the thing is i wanted to autamtically loop over the variables.
i can loop over the solvers but i am not sure how to loop over all variables.
i write on the same stuff in this post:
viewtopic.php?f=3&t=2674

maybe its better if i do not post on it on several places,
hihi
sorry

best regards

Re: Norm calculation

Posted: 08 Nov 2012, 16:52
by raback
Hi, The following might be suitable for your purposes. There is no shortcut in the sense that you need to go through the list, and possibly skip some unwanted variables.

Code: Select all

    Var => Mesh % Variables
    DO WHILE( ASSOCIATED( Var ) )
      
      ! output not active
      IF ( .NOT. Var % Output ) THEN
        Var => Var % Next
        CYCLE
      END IF
      
      ! global variable
      IF ( SIZE( Var % Values ) == Var % DOFs ) THEN
        Var => Var % Next
        CYCLE
      END IF

      WRITE(VarName,'(A)') TRIM(Var % Name)
   END DO
-Peter