Path: blob/devel/fem/tests/1dtests_MeshLevels/Source.f90
5253 views
FUNCTION Source( Model, n, f ) RESULT(h)1USE Lists2TYPE(Model_t) :: Model3INTEGER :: n4REAL(KIND=dp) :: f, h, x, s56INTEGER :: i, Step, OldStep = -17TYPE(Variable_t), POINTER :: T, P89T => VariableGet( Model % Variables, 'Time' )10Step = NINT( T % Values(1) )1112P => VariableGet( Model % Variables, 'Potential' )1314! First check the previous result15! -------------------------------16IF ( Step>1 .AND. Step /= OldStep ) THEN17DO i=1,Model % NumberOfNodes18x = Model % Nodes % x(i)19s = P % Values( P % Perm(i) )20SELECT CASE(Step)21CASE(2) ! can we solve a zero field ?22IF ( s /= 0 ) &23CALL Fatal( 'Source', 'Not able to integrate a zero field ?')24CASE(3) ! how about a parabola ?25IF ( ABS(s+(x**2-PI*x)/2) > 1.0d-8 ) &26CALL Fatal( 'Source', 'Not able to integrate parabola ?' )27CASE(4) ! how about a third degree polynomial28IF ( ABS(s+(x**3-PI**2*x)/6) > 1.0d-8 ) &29CALL Fatal( 'Source', 'Not able to integrate 3d deg polynomial?' )30CASE(5) ! how about a sine31IF ( ABS(s-2*sin(x)) > 1.0d-4 ) &32CALL Fatal( 'Source', 'Not able to integrate sine?' )33END SELECT34END DO35OldStep = Step36END IF3738! Then define new one39! -------------------40x = Model % Nodes % x(n)4142SELECT CASE(Step)43CASE(1) ! can we solve a zero field ?44h = 045CASE(2) ! how about a parabola ?46h = 147CASE(3) ! how about a third degree polynomial48h = x49CASE(4) ! how about a sine50h = f51CASE(5) ! how about a sine52h = f53END SELECT54END FUNCTION Source555657