Skip to content

Commit bb42d74

Browse files
Add user metrics reporting
1 parent 2024f39 commit bb42d74

File tree

4 files changed

+902
-734
lines changed

4 files changed

+902
-734
lines changed

src/SELF_DGModel2D_t.f90

+37
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module SELF_DGModel2D_t
6464
procedure :: SourceMethod => sourcemethod_DGModel2D_t
6565
procedure :: SetBoundaryCondition => setboundarycondition_DGModel2D_t
6666
procedure :: SetGradientBoundaryCondition => setgradientboundarycondition_DGModel2D_t
67+
procedure :: ReportMetrics => ReportMetrics_DGModel2D_t
6768

6869
procedure :: UpdateSolution => UpdateSolution_DGModel2D_t
6970

@@ -149,6 +150,42 @@ subroutine Free_DGModel2D_t(this)
149150

150151
endsubroutine Free_DGModel2D_t
151152

153+
subroutine ReportMetrics_DGModel2D_t(this)
154+
!! Base method for reporting the entropy of a model
155+
!! to stdout. Only override this procedure if additional
156+
!! reporting is needed. Alternatively, if you think
157+
!! additional reporting would be valuable for all models,
158+
!! open a pull request with modifications to this base
159+
!! method.
160+
implicit none
161+
class(DGModel2D_t), intent(inout) :: this
162+
! Local
163+
character(len=20) :: modelTime
164+
character(len=20) :: minv, maxv
165+
character(len=:), allocatable :: str
166+
integer :: ivar
167+
168+
169+
! Copy the time and entropy to a string
170+
write (modelTime, "(ES16.7E3)") this%t
171+
172+
do ivar = 1, this%nvar
173+
write (maxv, "(ES16.7E3)") maxval(this%solution%interior(:, :, :, ivar))
174+
write (minv, "(ES16.7E3)") minval(this%solution%interior(:, :, :, ivar))
175+
176+
! Write the output to STDOUT
177+
open (output_unit, ENCODING='utf-8')
178+
write (output_unit, '(1x, A," : ")', ADVANCE='no') __FILE__
179+
str = 'tᵢ ='//trim(modelTime)
180+
write (output_unit, '(A)', ADVANCE='no') str
181+
str = ' | min('//trim(this%solution%meta(ivar)%name)//'), max('//trim(this%solution%meta(ivar)%name)//') = '//minv//" , "//maxv
182+
write (output_unit, '(A)', ADVANCE='yes') str
183+
end do
184+
185+
call this%ReportUserMetrics()
186+
187+
end subroutine ReportMetrics_DGModel2D_t
188+
152189
subroutine SetSolutionFromEqn_DGModel2D_t(this,eqn)
153190
implicit none
154191
class(DGModel2D_t),intent(inout) :: this

src/SELF_DGModel3D_t.f90

+37
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module SELF_DGModel3D_t
6262
procedure :: SourceMethod => sourcemethod_DGModel3D_t
6363
procedure :: SetBoundaryCondition => setboundarycondition_DGModel3D_t
6464
procedure :: SetGradientBoundaryCondition => setgradientboundarycondition_DGModel3D_t
65+
procedure :: ReportMetrics => ReportMetrics_DGModel3D_t
6566

6667
procedure :: UpdateSolution => UpdateSolution_DGModel3D_t
6768

@@ -147,6 +148,42 @@ subroutine Free_DGModel3D_t(this)
147148

148149
endsubroutine Free_DGModel3D_t
149150

151+
subroutine ReportMetrics_DGModel3D_t(this)
152+
!! Base method for reporting the entropy of a model
153+
!! to stdout. Only override this procedure if additional
154+
!! reporting is needed. Alternatively, if you think
155+
!! additional reporting would be valuable for all models,
156+
!! open a pull request with modifications to this base
157+
!! method.
158+
implicit none
159+
class(DGModel3D_t), intent(inout) :: this
160+
! Local
161+
character(len=20) :: modelTime
162+
character(len=20) :: minv, maxv
163+
character(len=:), allocatable :: str
164+
integer :: ivar
165+
166+
167+
! Copy the time and entropy to a string
168+
write (modelTime, "(ES16.7E3)") this%t
169+
170+
do ivar = 1, this%nvar
171+
write (maxv, "(ES16.7E3)") maxval(this%solution%interior(:, :, :, :, ivar))
172+
write (minv, "(ES16.7E3)") minval(this%solution%interior(:, :, :, :, ivar))
173+
174+
! Write the output to STDOUT
175+
open (output_unit, ENCODING='utf-8')
176+
write (output_unit, '(1x, A," : ")', ADVANCE='no') __FILE__
177+
str = 'tᵢ ='//trim(modelTime)
178+
write (output_unit, '(A)', ADVANCE='no') str
179+
str = ' | min('//trim(this%solution%meta(ivar)%name)//'), max('//trim(this%solution%meta(ivar)%name)//') = '//minv//" , "//maxv
180+
write (output_unit, '(A)', ADVANCE='yes') str
181+
end do
182+
183+
call this%ReportUserMetrics()
184+
185+
end subroutine ReportMetrics_DGModel3D_t
186+
150187
subroutine SetSolutionFromEqn_DGModel3D_t(this,eqn)
151188
implicit none
152189
class(DGModel3D_t),intent(inout) :: this

src/SELF_LinearEuler2D_t.f90

+46
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ module self_LinearEuler2D_t
7474
procedure :: flux2d => flux2d_LinearEuler2D_t
7575
procedure :: riemannflux2d => riemannflux2d_LinearEuler2D_t
7676
!procedure :: source2d => source2d_LinearEuler2D_t
77+
procedure :: SphericalSoundWave => SphericalSoundWave_LinearEuler2D_t
7778

7879
endtype LinearEuler2D_t
7980

@@ -188,4 +189,49 @@ pure function riemannflux2d_LinearEuler2D_t(this,sL,sR,dsdx,nhat) result(flux)
188189

189190
endfunction riemannflux2d_LinearEuler2D_t
190191

192+
subroutine SphericalSoundWave_LinearEuler2D_t(this, rhoprime, Lr, x0, y0)
193+
!! This subroutine sets the initial condition for a weak blast wave
194+
!! problem. The initial condition is given by
195+
!!
196+
!! \begin{equation}
197+
!! \begin{aligned}
198+
!! \rho &= \rho_0 + \rho' \exp\left( -\ln(2) \frac{(x-x_0)^2 + (y-y_0)^2}{L_r^2} \right)
199+
!! u &= 0 \\
200+
!! v &= 0 \\
201+
!! E &= \frac{P_0}{\gamma - 1} + E \exp\left( -\ln(2) \frac{(x-x_0)^2 + (y-y_0)^2}{L_e^2} \right)
202+
!! \end{aligned}
203+
!! \end{equation}
204+
!!
205+
implicit none
206+
class(LinearEuler2D_t), intent(inout) :: this
207+
real(prec), intent(in) :: rhoprime, Lr, x0, y0
208+
! Local
209+
integer :: i, j, iEl
210+
real(prec) :: x, y, rho, r, E
211+
212+
print *, __FILE__, " : Configuring weak blast wave initial condition. "
213+
print *, __FILE__, " : rhoprime = ", rhoprime
214+
print *, __FILE__, " : Lr = ", Lr
215+
print *, __FILE__, " : x0 = ", x0
216+
print *, __FILE__, " : y0 = ", y0
217+
218+
do concurrent(i=1:this%solution%N + 1, j=1:this%solution%N + 1, &
219+
iel=1:this%mesh%nElem)
220+
x = this%geometry%x%interior(i, j, iEl, 1, 1) - x0
221+
y = this%geometry%x%interior(i, j, iEl, 1, 2) - y0
222+
r = sqrt(x**2 + y**2)
223+
224+
rho = (rhoprime)*exp(-log(2.0_prec)*r**2/Lr**2)
225+
226+
this%solution%interior(i, j, iEl, 1) = rho
227+
this%solution%interior(i, j, iEl, 2) = 0.0_prec
228+
this%solution%interior(i, j, iEl, 3) = 0.0_prec
229+
this%solution%interior(i, j, iEl, 4) = rho*this%c*this%c
230+
231+
end do
232+
233+
call this%ReportMetrics()
234+
235+
end subroutine SphericalSoundWave_LinearEuler2D_t
236+
191237
endmodule self_LinearEuler2D_t

0 commit comments

Comments
 (0)