Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input different coordinate systems in initial temperature function #1628

Merged
merged 2 commits into from
May 14, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion include/aspect/initial_temperature/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define _aspect_initial_temperature_function_h

#include <aspect/initial_temperature/interface.h>
#include <aspect/simulator_access.h>
#include <aspect/utilities.h>

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

Expand All @@ -39,7 +41,7 @@ namespace aspect
* @ingroup InitialTemperatures
*/
template <int dim>
class Function : public Interface<dim>
class Function : public Interface<dim>, public SimulatorAccess<dim>
{
public:
/**
Expand Down Expand Up @@ -78,6 +80,13 @@ namespace aspect
* A function object representing the temperature.
*/
Functions::ParsedFunction<dim> function;

/**
* The coordinate representation to evaluate the function. Possible
* choices are depth, cartesian and spherical.
*/
::aspect::Utilities::Coordinates::CoordinateSystem coordinate_system;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you actually need the ::aspect:: at the front. Same everywhere else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be needed to differentiate it from dealii::Utilities?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should find aspect::Utilities first when you just say Utilities. Can you try, @mbweller ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, and it didn't work. It didn't give a compilation error, it lost functionality. Specifically it didn't recognize set Coordinate system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this. If it compiles, it must work. Can you post what error message or fault you get?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1648.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't explain it. I just recompiled, and it works. Earlier it did not, and the only solution was to add ::aspect:: to Utilities:: ...


};
}
}
Expand Down
53 changes: 52 additions & 1 deletion source/initial_temperature/function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@


#include <aspect/initial_temperature/function.h>
#include <aspect/utilities.h>
#include <aspect/global.h>
#include <deal.II/base/signaling_nan.h>

#include <iostream>

Expand All @@ -38,7 +41,33 @@ namespace aspect
Function<dim>::
initial_temperature (const Point<dim> &position) const
{
return function.value(position);
if (coordinate_system == Utilities::Coordinates::CoordinateSystem::cartesian)
{
return function.value(position);
}
else if (coordinate_system == Utilities::Coordinates::CoordinateSystem::spherical)
{
const std_cxx11::array<double,dim> spherical_coordinates =
Utilities::Coordinates::cartesian_to_spherical_coordinates(position);
Point<dim> point;

for (unsigned int i = 0; i<dim; ++i)
point[i] = spherical_coordinates[i];

return function.value(point);
}
else if (coordinate_system == Utilities::Coordinates::CoordinateSystem::depth)
{
const double depth = this->get_geometry_model().depth(position);
Point<dim> point;
point(0) = depth;
return function.value(point);
}
else
{
AssertThrow(false, ExcNotImplemented());
return numbers::signaling_nan<double>();
}
}

template <int dim>
Expand All @@ -49,6 +78,24 @@ namespace aspect
{
prm.enter_subsection("Function");
{
/**
* Choose the coordinates to evaluate the maximum refinement level
* function. The function can be declared in dependence of depth,
* cartesian coordinates or spherical coordinates. Note that the order
* of spherical coordinates is r,phi,theta and not r,theta,phi, since
* this allows for dimension independent expressions.
*/
prm.declare_entry ("Coordinate system", "cartesian",
Patterns::Selection ("cartesian|spherical|depth"),
"A selection that determines the assumed coordinate "
"system for the function variables. Allowed values "
"are 'cartesian', 'spherical', and 'depth'. 'spherical' coordinates "
"are interpreted as r,phi or r,phi,theta in 2D/3D "
"respectively with theta being the polar angle.'depth' "
"will create a function, in which only the first "
"parameter is non-zero, which is interpreted to "
"be the depth of the point.");

Functions::ParsedFunction<dim>::declare_parameters (prm, 1);
}
prm.leave_subsection();
Expand All @@ -64,6 +111,10 @@ namespace aspect
prm.enter_subsection ("Initial temperature model");
{
prm.enter_subsection("Function");
{
coordinate_system = Utilities::Coordinates::string_to_coordinate_system(prm.get("Coordinate system"));
}

try
{
function.parse_parameters (prm);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This file was generated by the deal.II library.
# Date = 2017/5/13
# Time = 16:35:05
#
# For a description of the GNUPLOT format see the GNUPLOT manual.
#
# <x> <y> <temperature> <adiabatic_temperature> <adiabatic_pressure> <adiabatic_density> <adiabatic_density_derivative> <velocity_magnitude> <sinking_velocity> <Vs> <Vp> <viscosity> <vertical_heat_flux>
0 0 67.9302 0 0 3338.68 0 3.22061e-11 5.86585e-16 -1 -1 1e+22 -12106.8
0.055 0 67.9302 0 0 3338.68 0 3.22061e-11 5.86585e-16 -1 -1 1e+22 -12106.8

0 0 67.9302 0 0 3338.68 0 3.22061e-11 5.86585e-16 -1 -1 1e+22 -12106.8
0.055 0 67.9302 0 0 3338.68 0 3.22061e-11 5.86585e-16 -1 -1 1e+22 -12106.8


0.055 0 398.93 0 2040.3 3338.68 0 3.01397e-11 4.32654e-15 -1 -1 1e+22 28257
0.11 0 398.93 0 2040.3 3338.68 0 3.01397e-11 4.32654e-15 -1 -1 1e+22 28257

0.055 0 398.93 0 2040.3 3338.68 0 3.01397e-11 4.32654e-15 -1 -1 1e+22 28257
0.11 0 398.93 0 2040.3 3338.68 0 3.01397e-11 4.32654e-15 -1 -1 1e+22 28257


0.11 0 1199.02 0 4080.6 3338.68 0 2.78162e-11 1.17746e-14 -1 -1 1e+22 33088.1
0.165 0 1199.02 0 4080.6 3338.68 0 2.78162e-11 1.17746e-14 -1 -1 1e+22 33088.1

0.11 0 1199.02 0 4080.6 3338.68 0 2.78162e-11 1.17746e-14 -1 -1 1e+22 33088.1
0.165 0 1199.02 0 4080.6 3338.68 0 2.78162e-11 1.17746e-14 -1 -1 1e+22 33088.1


0.165 0 2425.26 0 6120.91 3338.68 0 2.52254e-11 2.29256e-14 -1 -1 1e+22 16919.3
0.22 0 2425.26 0 6120.91 3338.68 0 2.52254e-11 2.29256e-14 -1 -1 1e+22 16919.3

0.165 0 2425.26 0 6120.91 3338.68 0 2.52254e-11 2.29256e-14 -1 -1 1e+22 16919.3
0.22 0 2425.26 0 6120.91 3338.68 0 2.52254e-11 2.29256e-14 -1 -1 1e+22 16919.3


0.22 0 2596.97 0 8161.21 3338.68 0 2.23565e-11 3.7403e-14 -1 -1 1e+22 -25404.5
0.275 0 2596.97 0 8161.21 3338.68 0 2.23565e-11 3.7403e-14 -1 -1 1e+22 -25404.5

0.22 0 2596.97 0 8161.21 3338.68 0 2.23565e-11 3.7403e-14 -1 -1 1e+22 -25404.5
0.275 0 2596.97 0 8161.21 3338.68 0 2.23565e-11 3.7403e-14 -1 -1 1e+22 -25404.5


0.275 0 1980.8 0 10201.5 3338.68 0 1.91859e-11 5.40079e-14 -1 -1 1e+22 -36857.6
0.33 0 1980.8 0 10201.5 3338.68 0 1.91859e-11 5.40079e-14 -1 -1 1e+22 -36857.6

0.275 0 1980.8 0 10201.5 3338.68 0 1.91859e-11 5.40079e-14 -1 -1 1e+22 -36857.6
0.33 0 1980.8 0 10201.5 3338.68 0 1.91859e-11 5.40079e-14 -1 -1 1e+22 -36857.6


0.33 0 1070.67 0 12241.8 3338.68 0 1.5676e-11 6.93474e-14 -1 -1 1e+22 -32383.2
0.385 0 1070.67 0 12241.8 3338.68 0 1.5676e-11 6.93474e-14 -1 -1 1e+22 -32383.2

0.33 0 1070.67 0 12241.8 3338.68 0 1.5676e-11 6.93474e-14 -1 -1 1e+22 -32383.2
0.385 0 1070.67 0 12241.8 3338.68 0 1.5676e-11 6.93474e-14 -1 -1 1e+22 -32383.2


0.385 0 137.429 0 14282.1 3338.68 0 1.17736e-11 7.91563e-14 -1 -1 1e+22 -9203.93
0.44 0 137.429 0 14282.1 3338.68 0 1.17736e-11 7.91563e-14 -1 -1 1e+22 -9203.93

0.385 0 137.429 0 14282.1 3338.68 0 1.17736e-11 7.91563e-14 -1 -1 1e+22 -9203.93
0.44 0 137.429 0 14282.1 3338.68 0 1.17736e-11 7.91563e-14 -1 -1 1e+22 -9203.93


0.44 0 -78.5522 0 16322.4 3338.68 0 7.42512e-12 6.78152e-14 -1 -1 1e+22 -27484.9
0.495 0 -78.5522 0 16322.4 3338.68 0 7.42512e-12 6.78152e-14 -1 -1 1e+22 -27484.9

0.44 0 -78.5522 0 16322.4 3338.68 0 7.42512e-12 6.78152e-14 -1 -1 1e+22 -27484.9
0.495 0 -78.5522 0 16322.4 3338.68 0 7.42512e-12 6.78152e-14 -1 -1 1e+22 -27484.9


0.495 0 937.004 0 18362.7 3338.68 0 2.60971e-12 2.69319e-14 -1 -1 1e+22 260515
0.55 0 937.004 0 18362.7 3338.68 0 2.60971e-12 2.69319e-14 -1 -1 1e+22 260515

0.495 0 937.004 0 18362.7 3338.68 0 2.60971e-12 2.69319e-14 -1 -1 1e+22 260515
0.55 0 937.004 0 18362.7 3338.68 0 2.60971e-12 2.69319e-14 -1 -1 1e+22 260515