forked from geodynamics/aspect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial_temperature.cc
More file actions
170 lines (139 loc) · 5.44 KB
/
initial_temperature.cc
File metadata and controls
170 lines (139 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
Copyright (C) 2011 - 2026 by the authors of the ASPECT code.
This file is part of ASPECT.
ASPECT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
ASPECT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ASPECT; see the file LICENSE. If not see
<http://www.gnu.org/licenses/>.
*/
#include <aspect/initial_temperature/interface.h>
#include <aspect/prescribed_solution/initial_temperature.h>
#include <aspect/geometry_model/interface.h>
namespace aspect
{
namespace PrescribedSolution
{
template <int dim>
InitialTemperature<dim>::InitialTemperature ()
:
prescribed_temperature_indicator_function(1)
{}
template <int dim>
void
InitialTemperature<dim>::initialize ()
{
initial_temperature_manager =
this->get_initial_temperature_manager_pointer();
}
template <int dim>
void
InitialTemperature<dim>::update ()
{
if (this->convert_output_to_years())
prescribed_temperature_indicator_function.set_time(this->get_time() / year_in_seconds);
else
prescribed_temperature_indicator_function.set_time(this->get_time());
}
template <int dim>
void
InitialTemperature<dim>::constrain_solution (const typename DoFHandler<dim>::active_cell_iterator &/*cell*/,
const std::vector<Point<dim>> &positions,
const std::vector<unsigned int> &component_indices,
std::vector<bool> &should_be_constrained,
std::vector<double> &solution)
{
const unsigned int temperature_index =
this->introspection().component_indices.temperature;
for (unsigned int q=0; q<positions.size(); ++q)
{
if (component_indices[q] != temperature_index)
continue;
const auto point =
this->get_geometry_model().cartesian_to_other_coordinates(positions[q], coordinate_system);
const double indicator =
prescribed_temperature_indicator_function.value(Utilities::convert_array_to_point<dim>(point.get_coordinates()), 0);
if (indicator > 0.5)
{
should_be_constrained[q] = true;
solution[q] = initial_temperature_manager->initial_temperature(positions[q]);
}
}
}
template <int dim>
void
InitialTemperature<dim>::declare_parameters (ParameterHandler &prm)
{
prm.enter_subsection("Prescribed solution");
{
prm.enter_subsection("Initial temperature");
{
prm.declare_entry("Coordinate system",
"cartesian",
Patterns::Selection("cartesian|spherical|depth"),
"A selection that determines the assumed coordinate "
"system for the indicator function variables. "
"Allowed values are `cartesian', `spherical', and `depth'.");
prm.enter_subsection("Indicator function");
{
Functions::ParsedFunction<dim>::declare_parameters(prm, 1);
}
prm.leave_subsection();
}
prm.leave_subsection();
}
prm.leave_subsection();
}
template <int dim>
void
InitialTemperature<dim>::parse_parameters (ParameterHandler &prm)
{
prm.enter_subsection("Prescribed solution");
{
prm.enter_subsection("Initial temperature");
{
coordinate_system =
Utilities::Coordinates::string_to_coordinate_system(prm.get("Coordinate system"));
prm.enter_subsection("Indicator function");
{
try
{
prescribed_temperature_indicator_function.parse_parameters(prm);
}
catch (...)
{
std::cerr << "ERROR: FunctionParser failed to parse\n"
<< "\t'Prescribed solution.Initial temperature.Indicator function'\n"
<< "with expression\n"
<< "\t'" << prm.get("Function expression") << "'\n";
throw;
}
}
prm.leave_subsection();
}
prm.leave_subsection();
}
prm.leave_subsection();
}
}
}
// explicit instantiations
namespace aspect
{
namespace PrescribedSolution
{
ASPECT_REGISTER_PRESCRIBED_SOLUTION(InitialTemperature,
"initial temperature",
"Prescribe the temperature in a selected region using the active "
"initial temperature model. The selected region is defined through "
"an indicator function. At locations where the indicator value is greater than 0.5, "
"the temperature is constrained to the initial temperature evaluated "
"at that position.")
}
}