Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/fem/tests/2ndtime/Source.f90
5227 views
1
FUNCTION Source( Model, n, f ) RESULT(h)
2
USE Lists
3
TYPE(Model_t) :: Model
4
INTEGER :: n
5
REAL(KIND=dp) :: g, f, h, x, s, Time, OldTime = 0
6
7
INTEGER :: i, Case = 1
8
TYPE(Variable_t), POINTER :: T, P
9
10
T => VariableGet( Model % Variables, 'Time' )
11
Time = T % Values(1)
12
P => VariableGet( Model % Variables, 'Potential' )
13
14
! First check the previous result
15
! -------------------------------
16
IF ( Time > OldTime + 1 + 1.0d-8 ) THEN
17
OldTime = FLOOR( Time )
18
x = Model % Nodes % x(1)
19
s = P % Values( P % Perm(1) )
20
SELECT CASE(Case)
21
CASE(1) ! can we parabola
22
IF ( ABS(f-0.5d0) > 1.0d-3 ) &
23
CALL Fatal( 'Source', 'Not able to integrate parabola?' )
24
Model % Solver % Matrix % Force = 0.0d0
25
P % Values = 0.0d0
26
P % PrevValues(:,:) = 0.0d0
27
CASE(2) ! how about third degree polynomial?
28
IF ( ABS(s-1.0d0/6.0d0) > 1.0d-3 ) &
29
CALL Fatal( 'Source', 'Not able 3rd deg polynomial ?' )
30
Model % Solver % Matrix % Force = 0.0d0
31
P % Values = 1.0d0
32
P % PrevValues(:,:) = 1.0d0
33
CASE(3) ! how about an exponential
34
IF ( ABS(s-EXP(1.0d0)) > 1.0d-3 ) &
35
CALL Fatal( 'Source', 'Not able to integrate sine?' )
36
Model % Solver % Matrix % Force = 0.0d0
37
P % Values = 0.0d0
38
P % PrevValues(:,:) = 0.0d0
39
END SELECT
40
Case = Case + 1
41
END IF
42
43
g = P % Values( P % Perm(n) )
44
45
Time = Time - FLOOR(Time)
46
IF ( ABS(Time) < 1.0d-8 ) Time = 1
47
48
! Then define new one
49
! -------------------
50
SELECT CASE(Case)
51
CASE(1) ! how about a parabola ?
52
h = 1
53
CASE(2) ! how about a third degree polynomial
54
h = Time
55
CASE(3) ! how about an exponential
56
h = g
57
CASE(4)
58
h = 0.0d0
59
END SELECT
60
END FUNCTION Source
61
62