Skip to content

Commit 2bd5db4

Browse files
authored
Merge pull request #6681 from gassmoeller/split_radial_gravity_plugins
Split radial gravity plugins into separate files
2 parents a68f0c3 + fe7ae8f commit 2bd5db4

File tree

7 files changed

+269
-216
lines changed

7 files changed

+269
-216
lines changed

cookbooks/inner_core_convection/inner_core_convection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include <aspect/material_model/simple.h>
2222
#include <aspect/heating_model/interface.h>
23-
#include <aspect/gravity_model/radial.h>
23+
#include <aspect/gravity_model/radial_linear.h>
2424
#include <deal.II/base/parsed_function.h>
2525

2626
namespace aspect
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Changed: ASPECT's radial gravity plugins used to live in the same
2+
header and source files contrary to most of our other plugins, which
3+
each have one file per plugin. These plugins have been split into
4+
separate files. The old header file 'gravity_model/radial.h' is
5+
now deprecated and will be removed in the future. In addition,
6+
the 'radial earth-like' plugin, which was disabled a long time ago,
7+
was finally removed from the code.
8+
<br>
9+
(Rene Gassmoeller, 2025/09/22)

include/aspect/gravity_model/radial.h

Lines changed: 8 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -22,120 +22,13 @@
2222
#ifndef _aspect_gravity_model_radial_h
2323
#define _aspect_gravity_model_radial_h
2424

25-
#include <aspect/simulator_access.h>
26-
#include <aspect/gravity_model/interface.h>
27-
28-
namespace aspect
29-
{
30-
namespace GravityModel
31-
{
32-
/**
33-
* A class that describes gravity as a radial vector of constant
34-
* magnitude. The magnitude's value is read from the input file.
35-
*
36-
* @ingroup GravityModels
37-
*/
38-
template <int dim>
39-
class RadialConstant : public Interface<dim>, public SimulatorAccess<dim>
40-
{
41-
public:
42-
/**
43-
* Return the gravity vector as a function of position.
44-
*/
45-
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;
46-
47-
/**
48-
* Declare the parameters this class takes through input files.
49-
*/
50-
static
51-
void
52-
declare_parameters (ParameterHandler &prm);
53-
54-
/**
55-
* Read the parameters this class declares from the parameter file.
56-
*/
57-
void
58-
parse_parameters (ParameterHandler &prm) override;
59-
60-
private:
61-
/**
62-
* Magnitude of the gravity vector.
63-
*/
64-
double magnitude;
65-
};
66-
67-
68-
/**
69-
* This model has been removed due to its misleading name. The available
70-
* AsciiData gravity model (using default parameters) is much more
71-
* earth-like, since it uses the gravity profile used in the construction
72-
* of the Preliminary Reference Earth Model (PREM, Dziewonski and Anderson,
73-
* 1981).
74-
*
75-
* This is the model used and discussed in the step-32 tutorial program of
76-
* deal.II.
77-
*
78-
* @ingroup GravityModels
79-
*/
80-
template <int dim>
81-
class RadialEarthLike : public Interface<dim>, public SimulatorAccess<dim>
82-
{
83-
public:
84-
/**
85-
* Initialization.
86-
*/
87-
void initialize() override;
88-
89-
/**
90-
* Return the gravity vector as a function of position.
91-
*/
92-
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;
93-
};
94-
95-
96-
/**
97-
* A class that describes gravity as a radial vector of linearly
98-
* changing magnitude with depth.
99-
*
100-
* @ingroup GravityModels
101-
*/
102-
template <int dim>
103-
class RadialLinear : public Interface<dim>, public SimulatorAccess<dim>
104-
{
105-
public:
106-
/**
107-
* Return the gravity vector as a function of position.
108-
*/
109-
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;
110-
111-
/**
112-
* Declare the parameters this class takes through input files.
113-
*/
114-
static
115-
void
116-
declare_parameters (ParameterHandler &prm);
117-
118-
/**
119-
* Read the parameters this class declares from the parameter file.
120-
*/
121-
void
122-
parse_parameters (ParameterHandler &prm) override;
123-
124-
private:
125-
/**
126-
* Magnitude of the gravity vector at the surface, m/s^2
127-
*/
128-
double magnitude_at_surface;
129-
130-
/**
131-
* Magnitude of the gravity vector at the bottom, m/s^2.
132-
* 'Bottom' means at the maximum depth of the provided geometry, for
133-
* a full sphere this means the center.
134-
*/
135-
double magnitude_at_bottom;
136-
137-
};
138-
}
139-
}
25+
/**
26+
* @deprecated: This header file is deprecated. Use one of the specific
27+
* radial gravity profile headers below instead.
28+
*/
29+
#pragma message("WARNING: <aspect/include/gravity_model/radial.h> is deprecated. Use one of the specific radial gravity profiles instead.")
30+
31+
#include <aspect/gravity_model/radial_constant.h>
32+
#include <aspect/gravity_model/radial_linear.h>
14033

14134
#endif
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
Copyright (C) 2014 - 2019 by the authors of the ASPECT code.
3+
4+
This file is part of ASPECT.
5+
6+
ASPECT is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2, or (at your option)
9+
any later version.
10+
11+
ASPECT is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with ASPECT; see the file LICENSE. If not see
18+
<http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
#ifndef _aspect_gravity_model_radial_constant_h
23+
#define _aspect_gravity_model_radial_constant_h
24+
25+
#include <aspect/simulator_access.h>
26+
#include <aspect/gravity_model/interface.h>
27+
28+
namespace aspect
29+
{
30+
namespace GravityModel
31+
{
32+
/**
33+
* A class that describes gravity as a radial vector of constant
34+
* magnitude. The magnitude's value is read from the input file.
35+
*
36+
* @ingroup GravityModels
37+
*/
38+
template <int dim>
39+
class RadialConstant : public Interface<dim>, public SimulatorAccess<dim>
40+
{
41+
public:
42+
/**
43+
* Return the gravity vector as a function of position.
44+
*/
45+
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;
46+
47+
/**
48+
* Declare the parameters this class takes through input files.
49+
*/
50+
static
51+
void
52+
declare_parameters (ParameterHandler &prm);
53+
54+
/**
55+
* Read the parameters this class declares from the parameter file.
56+
*/
57+
void
58+
parse_parameters (ParameterHandler &prm) override;
59+
60+
private:
61+
/**
62+
* Magnitude of the gravity vector.
63+
*/
64+
double magnitude;
65+
};
66+
}
67+
}
68+
69+
#endif
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
Copyright (C) 2014 - 2019 by the authors of the ASPECT code.
3+
4+
This file is part of ASPECT.
5+
6+
ASPECT is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2, or (at your option)
9+
any later version.
10+
11+
ASPECT is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with ASPECT; see the file LICENSE. If not see
18+
<http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
#ifndef _aspect_gravity_model_radial_linear_h
23+
#define _aspect_gravity_model_radial_linear_h
24+
25+
#include <aspect/simulator_access.h>
26+
#include <aspect/gravity_model/interface.h>
27+
28+
namespace aspect
29+
{
30+
namespace GravityModel
31+
{
32+
/**
33+
* A class that describes gravity as a radial vector of linearly
34+
* changing magnitude with depth.
35+
*
36+
* @ingroup GravityModels
37+
*/
38+
template <int dim>
39+
class RadialLinear : public Interface<dim>, public SimulatorAccess<dim>
40+
{
41+
public:
42+
/**
43+
* Return the gravity vector as a function of position.
44+
*/
45+
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;
46+
47+
/**
48+
* Declare the parameters this class takes through input files.
49+
*/
50+
static
51+
void
52+
declare_parameters (ParameterHandler &prm);
53+
54+
/**
55+
* Read the parameters this class declares from the parameter file.
56+
*/
57+
void
58+
parse_parameters (ParameterHandler &prm) override;
59+
60+
private:
61+
/**
62+
* Magnitude of the gravity vector at the surface, m/s^2
63+
*/
64+
double magnitude_at_surface;
65+
66+
/**
67+
* Magnitude of the gravity vector at the bottom, m/s^2.
68+
* 'Bottom' means at the maximum depth of the provided geometry, for
69+
* a full sphere this means the center.
70+
*/
71+
double magnitude_at_bottom;
72+
73+
};
74+
}
75+
}
76+
77+
#endif
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
Copyright (C) 2011 - 2020 by the authors of the ASPECT code.
3+
4+
This file is part of ASPECT.
5+
6+
ASPECT is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2, or (at your option)
9+
any later version.
10+
11+
ASPECT is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with ASPECT; see the file LICENSE. If not see
18+
<http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
#include <aspect/gravity_model/radial_constant.h>
23+
24+
#include <aspect/geometry_model/interface.h>
25+
#include <aspect/coordinate_systems.h>
26+
27+
#include <deal.II/base/tensor.h>
28+
29+
namespace aspect
30+
{
31+
namespace GravityModel
32+
{
33+
template <int dim>
34+
Tensor<1,dim>
35+
RadialConstant<dim>::gravity_vector (const Point<dim> &p) const
36+
{
37+
if (p.norm() == 0.0)
38+
return Tensor<1,dim>();
39+
40+
const double r = p.norm();
41+
return -magnitude * p/r;
42+
}
43+
44+
45+
46+
template <int dim>
47+
void
48+
RadialConstant<dim>::declare_parameters (ParameterHandler &prm)
49+
{
50+
prm.enter_subsection("Gravity model");
51+
{
52+
prm.enter_subsection("Radial constant");
53+
{
54+
prm.declare_entry ("Magnitude", "9.81",
55+
Patterns::Double (),
56+
"Magnitude of the gravity vector in $m/s^2$. For positive values "
57+
"the direction is radially inward towards the center of the earth.");
58+
}
59+
prm.leave_subsection ();
60+
}
61+
prm.leave_subsection ();
62+
}
63+
64+
65+
66+
template <int dim>
67+
void
68+
RadialConstant<dim>::parse_parameters (ParameterHandler &prm)
69+
{
70+
prm.enter_subsection("Gravity model");
71+
{
72+
prm.enter_subsection("Radial constant");
73+
{
74+
magnitude = prm.get_double ("Magnitude");
75+
}
76+
prm.leave_subsection ();
77+
}
78+
prm.leave_subsection ();
79+
80+
AssertThrow (this->get_geometry_model().natural_coordinate_system() == Utilities::Coordinates::spherical ||
81+
this->get_geometry_model().natural_coordinate_system() == Utilities::Coordinates::ellipsoidal,
82+
ExcMessage ("Gravity model 'radial constant' should not be used with geometry models that "
83+
"do not have either a spherical or ellipsoidal natural coordinate system."));
84+
}
85+
}
86+
}
87+
88+
// explicit instantiations
89+
namespace aspect
90+
{
91+
namespace GravityModel
92+
{
93+
ASPECT_REGISTER_GRAVITY_MODEL(RadialConstant,
94+
"radial constant",
95+
"A gravity model in which the gravity has a constant magnitude "
96+
"and the direction is radial (pointing inward if the value "
97+
"is positive). The magnitude is read from the parameter "
98+
"file in subsection 'Radial constant'.")
99+
}
100+
}

0 commit comments

Comments
 (0)