Norm calculation

Numerical methods and mathematical models of Elmer
Post Reply
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Norm calculation

Post 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
mika
Posts: 253
Joined: 15 Sep 2009, 07:44

Re: Norm calculation

Post 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
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Norm calculation

Post by Franz Pichler »

Ah, thanks.
didn't think of that
raback
Site Admin
Posts: 4871
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Norm calculation

Post 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
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Norm calculation

Post 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
raback
Site Admin
Posts: 4871
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Norm calculation

Post by raback »

Try

Code: Select all

Var => VariableGet( Mesh % Variables,'My Variable')
IF(.NOT. ASSOCIATED(Var)) print *,'bummer'
-Peter
Franz Pichler
Posts: 196
Joined: 29 Sep 2011, 12:25
Antispam: Yes

Re: Norm calculation

Post 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
raback
Site Admin
Posts: 4871
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Norm calculation

Post 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
Post Reply