Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cookbooks/inner_core_convection/inner_core_convection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <aspect/material_model/simple.h>
#include <aspect/heating_model/interface.h>
#include <aspect/gravity_model/radial.h>
#include <aspect/gravity_model/radial_linear.h>
#include <deal.II/base/parsed_function.h>

namespace aspect
Expand Down
9 changes: 9 additions & 0 deletions doc/modules/changes/20250922_gassmoeller
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Changed: ASPECT's radial gravity plugins used to live in the same
header and source files contrary to most of our other plugins, which
each have one file per plugin. These plugins have been split into
separate files. The old header file 'gravity_model/radial.h' is
now deprecated and will be removed in the future. In addition,
the 'radial earth-like' plugin, which was disabled a long time ago,
was finally removed from the code.
<br>
(Rene Gassmoeller, 2025/09/22)
123 changes: 8 additions & 115 deletions include/aspect/gravity_model/radial.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,120 +22,13 @@
#ifndef _aspect_gravity_model_radial_h
#define _aspect_gravity_model_radial_h

#include <aspect/simulator_access.h>
#include <aspect/gravity_model/interface.h>

namespace aspect
{
namespace GravityModel
{
/**
* A class that describes gravity as a radial vector of constant
* magnitude. The magnitude's value is read from the input file.
*
* @ingroup GravityModels
*/
template <int dim>
class RadialConstant : public Interface<dim>, public SimulatorAccess<dim>
{
public:
/**
* Return the gravity vector as a function of position.
*/
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;

/**
* Declare the parameters this class takes through input files.
*/
static
void
declare_parameters (ParameterHandler &prm);

/**
* Read the parameters this class declares from the parameter file.
*/
void
parse_parameters (ParameterHandler &prm) override;

private:
/**
* Magnitude of the gravity vector.
*/
double magnitude;
};


/**
* This model has been removed due to its misleading name. The available
* AsciiData gravity model (using default parameters) is much more
* earth-like, since it uses the gravity profile used in the construction
* of the Preliminary Reference Earth Model (PREM, Dziewonski and Anderson,
* 1981).
*
* This is the model used and discussed in the step-32 tutorial program of
* deal.II.
*
* @ingroup GravityModels
*/
template <int dim>
class RadialEarthLike : public Interface<dim>, public SimulatorAccess<dim>
{
public:
/**
* Initialization.
*/
void initialize() override;

/**
* Return the gravity vector as a function of position.
*/
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;
};


/**
* A class that describes gravity as a radial vector of linearly
* changing magnitude with depth.
*
* @ingroup GravityModels
*/
template <int dim>
class RadialLinear : public Interface<dim>, public SimulatorAccess<dim>
{
public:
/**
* Return the gravity vector as a function of position.
*/
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;

/**
* Declare the parameters this class takes through input files.
*/
static
void
declare_parameters (ParameterHandler &prm);

/**
* Read the parameters this class declares from the parameter file.
*/
void
parse_parameters (ParameterHandler &prm) override;

private:
/**
* Magnitude of the gravity vector at the surface, m/s^2
*/
double magnitude_at_surface;

/**
* Magnitude of the gravity vector at the bottom, m/s^2.
* 'Bottom' means at the maximum depth of the provided geometry, for
* a full sphere this means the center.
*/
double magnitude_at_bottom;

};
}
}
/**
* @deprecated: This header file is deprecated. Use one of the specific
* radial gravity profile headers below instead.
*/
#pragma message("WARNING: <aspect/include/gravity_model/radial.h> is deprecated. Use one of the specific radial gravity profiles instead.")

#include <aspect/gravity_model/radial_constant.h>
#include <aspect/gravity_model/radial_linear.h>

#endif
69 changes: 69 additions & 0 deletions include/aspect/gravity_model/radial_constant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright (C) 2014 - 2019 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/>.
*/


#ifndef _aspect_gravity_model_radial_constant_h
#define _aspect_gravity_model_radial_constant_h

#include <aspect/simulator_access.h>
#include <aspect/gravity_model/interface.h>

namespace aspect
{
namespace GravityModel
{
/**
* A class that describes gravity as a radial vector of constant
* magnitude. The magnitude's value is read from the input file.
*
* @ingroup GravityModels
*/
template <int dim>
class RadialConstant : public Interface<dim>, public SimulatorAccess<dim>
{
public:
/**
* Return the gravity vector as a function of position.
*/
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;

/**
* Declare the parameters this class takes through input files.
*/
static
void
declare_parameters (ParameterHandler &prm);

/**
* Read the parameters this class declares from the parameter file.
*/
void
parse_parameters (ParameterHandler &prm) override;

private:
/**
* Magnitude of the gravity vector.
*/
double magnitude;
};
}
}

#endif
77 changes: 77 additions & 0 deletions include/aspect/gravity_model/radial_linear.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Copyright (C) 2014 - 2019 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/>.
*/


#ifndef _aspect_gravity_model_radial_linear_h
#define _aspect_gravity_model_radial_linear_h

#include <aspect/simulator_access.h>
#include <aspect/gravity_model/interface.h>

namespace aspect
{
namespace GravityModel
{
/**
* A class that describes gravity as a radial vector of linearly
* changing magnitude with depth.
*
* @ingroup GravityModels
*/
template <int dim>
class RadialLinear : public Interface<dim>, public SimulatorAccess<dim>
{
public:
/**
* Return the gravity vector as a function of position.
*/
Tensor<1,dim> gravity_vector (const Point<dim> &position) const override;

/**
* Declare the parameters this class takes through input files.
*/
static
void
declare_parameters (ParameterHandler &prm);

/**
* Read the parameters this class declares from the parameter file.
*/
void
parse_parameters (ParameterHandler &prm) override;

private:
/**
* Magnitude of the gravity vector at the surface, m/s^2
*/
double magnitude_at_surface;

/**
* Magnitude of the gravity vector at the bottom, m/s^2.
* 'Bottom' means at the maximum depth of the provided geometry, for
* a full sphere this means the center.
*/
double magnitude_at_bottom;

};
}
}

#endif
100 changes: 100 additions & 0 deletions source/gravity_model/radial_constant.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
Copyright (C) 2011 - 2020 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/gravity_model/radial_constant.h>

#include <aspect/geometry_model/interface.h>
#include <aspect/coordinate_systems.h>

#include <deal.II/base/tensor.h>

namespace aspect
{
namespace GravityModel
{
template <int dim>
Tensor<1,dim>
RadialConstant<dim>::gravity_vector (const Point<dim> &p) const
{
if (p.norm() == 0.0)
return Tensor<1,dim>();

const double r = p.norm();
return -magnitude * p/r;
}



template <int dim>
void
RadialConstant<dim>::declare_parameters (ParameterHandler &prm)
{
prm.enter_subsection("Gravity model");
{
prm.enter_subsection("Radial constant");
{
prm.declare_entry ("Magnitude", "9.81",
Patterns::Double (),
"Magnitude of the gravity vector in $m/s^2$. For positive values "
"the direction is radially inward towards the center of the earth.");
}
prm.leave_subsection ();
}
prm.leave_subsection ();
}



template <int dim>
void
RadialConstant<dim>::parse_parameters (ParameterHandler &prm)
{
prm.enter_subsection("Gravity model");
{
prm.enter_subsection("Radial constant");
{
magnitude = prm.get_double ("Magnitude");
}
prm.leave_subsection ();
}
prm.leave_subsection ();

AssertThrow (this->get_geometry_model().natural_coordinate_system() == Utilities::Coordinates::spherical ||
this->get_geometry_model().natural_coordinate_system() == Utilities::Coordinates::ellipsoidal,
ExcMessage ("Gravity model 'radial constant' should not be used with geometry models that "
"do not have either a spherical or ellipsoidal natural coordinate system."));
}
}
}

// explicit instantiations
namespace aspect
{
namespace GravityModel
{
ASPECT_REGISTER_GRAVITY_MODEL(RadialConstant,
"radial constant",
"A gravity model in which the gravity has a constant magnitude "
"and the direction is radial (pointing inward if the value "
"is positive). The magnitude is read from the parameter "
"file in subsection 'Radial constant'.")
}
}
Loading