Skip to content

Commit 4deac06

Browse files
authored
Merge pull request geodynamics#6672 from tiannh7/add_timescale_TS
Add time scaling factor in TS
2 parents 219a2f2 + 347584d commit 4deac06

File tree

5 files changed

+544
-2
lines changed

5 files changed

+544
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Changed: Added a scaling factor to allow time steps to be specified
2+
in years instead of seconds.
3+
<br>
4+
(Ninghui Tian, 2025/09/20)

source/time_stepping/function.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ namespace aspect
3030
double
3131
Function<dim>::execute()
3232
{
33-
double new_time_step = function.value(Point<1>(this->get_time()));
33+
const double time_scale = this->convert_output_to_years() ? constants::year_in_seconds : 1.0;
34+
const double new_time_step = function.value(Point<1>(this->get_time()) / time_scale) * time_scale;
3435

3536
AssertThrow (new_time_step > 0,
3637
ExcMessage("The time step length for the each time step needs to be positive, "
@@ -52,7 +53,10 @@ namespace aspect
5253
Functions::ParsedFunction<1>::declare_parameters (prm, 1);
5354
prm.declare_entry("Function expression", "1.0",
5455
Patterns::Anything(),
55-
"Expression for the time step size as a function of 'time'.");
56+
"Expression for the time step size as a function of 'time'."
57+
"Units: years if the "
58+
"'Use years instead of seconds' parameter is set; "
59+
"seconds otherwise.");
5660
prm.declare_entry("Variable names", "time",
5761
Patterns::Anything(),
5862
"Name for the variable representing the current time.");
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# test "Time stepping::Function" plugin, based on box_end_time_1e7_terminate.prm
2+
3+
set Dimension = 2
4+
set CFL number = 1.0
5+
set End time = 1.5e4
6+
set Start time = 0
7+
set Adiabatic surface temperature = 0
8+
set Surface pressure = 0
9+
set Use years instead of seconds = true
10+
set Nonlinear solver scheme = single Advection, single Stokes
11+
12+
subsection Time stepping
13+
set List of model names = function
14+
15+
subsection Function
16+
set Function expression = if (time<5e3,2e2+1e2*cos(2*3.141*time/5e3),3e2+time/1e3)
17+
end
18+
end
19+
20+
subsection Gravity model
21+
set Model name = vertical
22+
end
23+
24+
subsection Geometry model
25+
set Model name = box
26+
27+
subsection Box
28+
set X extent = 1.2
29+
set Y extent = 1
30+
set Z extent = 1
31+
end
32+
end
33+
34+
subsection Initial temperature model
35+
set Model name = perturbed box
36+
end
37+
38+
subsection Material model
39+
set Model name = simple
40+
41+
subsection Simple model
42+
set Reference density = 1
43+
set Reference specific heat = 1250
44+
set Reference temperature = 1
45+
set Thermal conductivity = 1e-6
46+
set Thermal expansion coefficient = 2e-5
47+
set Viscosity = 1
48+
end
49+
end
50+
51+
subsection Mesh refinement
52+
set Initial adaptive refinement = 0
53+
set Initial global refinement = 3
54+
end
55+
56+
subsection Boundary velocity model
57+
set Tangential velocity boundary indicators = 1
58+
set Zero velocity boundary indicators = 0, 2, 3
59+
end
60+
61+
subsection Postprocess
62+
set List of postprocessors =
63+
end

0 commit comments

Comments
 (0)