[cig-commits] [commit] master: Indent new files. (863083c)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Tue May 20 12:36:20 PDT 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/9426f368c65e0bdeb35a670fbb60f450e51ba1ac...4f4b96e0569b8be211d2d72b283391b5d08b4e1d
>---------------------------------------------------------------
commit 863083c8d8e025f0293ee7494b0f3611f70b8dc3
Author: Wolfgang Bangerth <bangerth at math.tamu.edu>
Date: Tue May 20 14:35:28 2014 -0500
Indent new files.
>---------------------------------------------------------------
863083c8d8e025f0293ee7494b0f3611f70b8dc3
include/aspect/initial_conditions/solidus.h | 6 +-
source/initial_conditions/solidus.cc | 322 ++++++++++++++--------------
2 files changed, 164 insertions(+), 164 deletions(-)
diff --git a/include/aspect/initial_conditions/solidus.h b/include/aspect/initial_conditions/solidus.h
index 03ef57a..d07c31c 100644
--- a/include/aspect/initial_conditions/solidus.h
+++ b/include/aspect/initial_conditions/solidus.h
@@ -37,7 +37,7 @@ namespace aspect
*/
class MeltingCurve
{
- public:
+ public:
/**
* Read the data file into the class.
@@ -59,7 +59,7 @@ namespace aspect
* Number of data points in the melting curve data.
*/
unsigned int n_points;
- private:
+ private:
/**
* Data array for temperature.
*/
@@ -161,7 +161,7 @@ namespace aspect
/**
* Data class for melting curve
*/
- MeltingCurve solidus_curve;
+ MeltingCurve solidus_curve;
};
}
}
diff --git a/source/initial_conditions/solidus.cc b/source/initial_conditions/solidus.cc
index 2fbf9ef..279c205 100644
--- a/source/initial_conditions/solidus.cc
+++ b/source/initial_conditions/solidus.cc
@@ -28,85 +28,85 @@
namespace aspect
{
- namespace InitialConditions
+ namespace InitialConditions
+ {
+ void MeltingCurve::read(const std::string &filename)
{
- void MeltingCurve::read(const std::string &filename)
+ data_filename=filename;
+ std::ifstream in(data_filename.c_str(), std::ios::in);
+ char temp[256];
+ std::string T_Unit,P_Unit;
+ n_points=0;
+ if (in.fail())return;
+ in.getline(temp,256);
+ in>>T_Unit>>P_Unit;
+ in.getline(temp,256);
+ while (!in.eof())
{
- data_filename=filename;
- std::ifstream in(data_filename.c_str(), std::ios::in);
- char temp[256];
- std::string T_Unit,P_Unit;
- n_points=0;
- if(in.fail())return;
- in.getline(temp,256);
- in>>T_Unit>>P_Unit;
- in.getline(temp,256);
- while(!in.eof())
+ double T,p;
+ in>>T>>p;
+ if (!in.fail())
{
- double T,p;
- in>>T>>p;
- if(!in.fail())
+ //Unit switching
+ if (T_Unit=="C")
+ {
+ T+=273.15; // Degree C to K
+ }
+ else if (T_Unit!="K")
{
- //Unit switching
- if(T_Unit=="C")
- {
- T+=273.15; // Degree C to K
- }
- else if(T_Unit!="K")
- {
- AssertThrow(false,ExcMessage ("Unit of the first column of melting curve data "
- "has to be one of the following: C/K."))
- }
-
- is_radius=false; // Second column is pressure
- if(P_Unit=="kbar")
- p*=1.e8; // kbar to Pa
- else if(P_Unit=="GPa")
- p*=1.e9; // GPa to Pa
- else
- {
- is_radius=true; // Second column is radius instead of pressure
- if(P_Unit=="km")
- p*=1.e3; // km to meters
- else if(P_Unit!="m")
- AssertThrow(false,ExcMessage ("Unit of the second column of melting curve data "
- "has to be one of the following: Pa/Gpa/km/m."))
- }
- T_array.push_back(T);
- P_or_R_array.push_back(p);
- n_points++;
+ AssertThrow(false,ExcMessage ("Unit of the first column of melting curve data "
+ "has to be one of the following: C/K."))
}
- in.getline(temp,256);
+
+ is_radius=false; // Second column is pressure
+ if (P_Unit=="kbar")
+ p*=1.e8; // kbar to Pa
+ else if (P_Unit=="GPa")
+ p*=1.e9; // GPa to Pa
+ else
+ {
+ is_radius=true; // Second column is radius instead of pressure
+ if (P_Unit=="km")
+ p*=1.e3; // km to meters
+ else if (P_Unit!="m")
+ AssertThrow(false,ExcMessage ("Unit of the second column of melting curve data "
+ "has to be one of the following: Pa/Gpa/km/m."))
+ }
+ T_array.push_back(T);
+ P_or_R_array.push_back(p);
+ n_points++;
}
+ in.getline(temp,256);
}
+ }
- double MeltingCurve::T(const double p, const double radius) const
+ double MeltingCurve::T(const double p, const double radius) const
+ {
+ double T_value,P_or_R_value=is_radius?radius:p;
+ if (T_array.size()==0)return(0);
+ for (unsigned i=1; i<n_points; i++)
{
- double T_value,P_or_R_value=is_radius?radius:p;
- if(T_array.size()==0)return(0);
- for(unsigned i=1;i<n_points;i++)
+ if ( (i==n_points-1) ||
+ (is_radius && P_or_R_value>P_or_R_array[i]) ||
+ (!is_radius && P_or_R_value<P_or_R_array[i]) )
{
- if( (i==n_points-1) ||
- (is_radius && P_or_R_value>P_or_R_array[i]) ||
- (!is_radius && P_or_R_value<P_or_R_array[i]) )
- {
- T_value=T_array[i-1]+(T_array[i]-T_array[i-1])/(P_or_R_array[i]-P_or_R_array[i-1])*(P_or_R_value-P_or_R_array[i-1]);
- return(T_value);
- }
+ T_value=T_array[i-1]+(T_array[i]-T_array[i-1])/(P_or_R_array[i]-P_or_R_array[i-1])*(P_or_R_value-P_or_R_array[i-1]);
+ return(T_value);
}
- AssertThrow(false,ExcMessage(std::string("Something wrong with the melting curve data ")+ data_filename ));
- return(-1);
}
-
+ AssertThrow(false,ExcMessage(std::string("Something wrong with the melting curve data ")+ data_filename ));
+ return(-1);
}
+ }
+
namespace InitialConditions
{
template <int dim>
Solidus<dim>::Solidus ():
- solidus_curve()
+ solidus_curve()
{}
template <int dim>
@@ -114,52 +114,52 @@ namespace aspect
Solidus<dim>::
initial_temperature (const Point<dim> &position) const
{
- double T_min,T_litho;
- double T_solidus,T_perturbation;
- double litho_thick_theta;
- double lateral_perturbation;
- double Depth=this->geometry_model->depth(position);
-
- AssertThrow(solidus_curve.is_radius==true,ExcMessage("The solidus curve has to be radius dependent."));
- AssertThrow(solidus_curve.n_points!=0,ExcMessage("Error eading solidus file."));
- const GeometryModel::SphericalShell<dim> *spherical_geometry_model=
- dynamic_cast< const GeometryModel::SphericalShell<dim> *>(this->geometry_model);
- AssertThrow(spherical_geometry_model!=0,
- ExcMessage("This initial condition can only be used with spherical shell geometry model."));
- T_min=(this->get_boundary_temperature()).minimal_temperature();
-
- // In case of spherical shell calculate spherical coordinates
- const Tensor<1,dim> scoord = spherical_surface_coordinates(position);
- if(dim==2)
+ double T_min,T_litho;
+ double T_solidus,T_perturbation;
+ double litho_thick_theta;
+ double lateral_perturbation;
+ double Depth=this->geometry_model->depth(position);
+
+ AssertThrow(solidus_curve.is_radius==true,ExcMessage("The solidus curve has to be radius dependent."));
+ AssertThrow(solidus_curve.n_points!=0,ExcMessage("Error eading solidus file."));
+ const GeometryModel::SphericalShell<dim> *spherical_geometry_model=
+ dynamic_cast< const GeometryModel::SphericalShell<dim> *>(this->geometry_model);
+ AssertThrow(spherical_geometry_model!=0,
+ ExcMessage("This initial condition can only be used with spherical shell geometry model."));
+ T_min=(this->get_boundary_temperature()).minimal_temperature();
+
+ // In case of spherical shell calculate spherical coordinates
+ const Tensor<1,dim> scoord = spherical_surface_coordinates(position);
+ if (dim==2)
{
- // Use a sine as lateral perturbation that is scaled to the opening angle of the geometry.
- // This way the perturbation is alway 0 at the model boundaries.
- const double opening_angle = spherical_geometry_model->opening_angle()*numbers::PI/180.0;
- lateral_perturbation = std::sin(lateral_wave_number_1*scoord[1]*numbers::PI/opening_angle);
+ // Use a sine as lateral perturbation that is scaled to the opening angle of the geometry.
+ // This way the perturbation is alway 0 at the model boundaries.
+ const double opening_angle = spherical_geometry_model->opening_angle()*numbers::PI/180.0;
+ lateral_perturbation = std::sin(lateral_wave_number_1*scoord[1]*numbers::PI/opening_angle);
}
- else if(dim==3)
+ else if (dim==3)
{
- // Spherical harmonics are only defined for order <= degree
- // and degree >= 0. Verify that it is indeed.
- Assert ( std::abs(lateral_wave_number_2) <= lateral_wave_number_1,
- ExcMessage ("Spherical harmonics can only be computed for "
- "order <= degree."));
- Assert ( lateral_wave_number_1 >= 0,
- ExcMessage ("Spherical harmonics can only be computed for "
- "degree >= 0."));
- // use a spherical harmonic function as lateral perturbation
- lateral_perturbation = boost::math::spherical_harmonic_r(lateral_wave_number_1,lateral_wave_number_2,scoord[2],scoord[1]);
+ // Spherical harmonics are only defined for order <= degree
+ // and degree >= 0. Verify that it is indeed.
+ Assert ( std::abs(lateral_wave_number_2) <= lateral_wave_number_1,
+ ExcMessage ("Spherical harmonics can only be computed for "
+ "order <= degree."));
+ Assert ( lateral_wave_number_1 >= 0,
+ ExcMessage ("Spherical harmonics can only be computed for "
+ "degree >= 0."));
+ // use a spherical harmonic function as lateral perturbation
+ lateral_perturbation = boost::math::spherical_harmonic_r(lateral_wave_number_1,lateral_wave_number_2,scoord[2],scoord[1]);
}
- litho_thick_theta=litho_thick-magnitude_lith*lateral_perturbation;
- T_litho=solidus_curve.T(0,spherical_geometry_model->R1-litho_thick_theta)+deltaT;
+ litho_thick_theta=litho_thick-magnitude_lith*lateral_perturbation;
+ T_litho=solidus_curve.T(0,spherical_geometry_model->R1-litho_thick_theta)+deltaT;
- if(litho_thick_theta>0 && Depth<litho_thick_theta)
- T_solidus=T_min+(T_litho-T_min)*(Depth/litho_thick_theta);
- else
- T_solidus=solidus_curve.T(0,sqrt(position.square()))+deltaT;
+ if (litho_thick_theta>0 && Depth<litho_thick_theta)
+ T_solidus=T_min+(T_litho-T_min)*(Depth/litho_thick_theta);
+ else
+ T_solidus=solidus_curve.T(0,sqrt(position.square()))+deltaT;
- T_perturbation=Depth/( this->geometry_model->maximal_depth() )*magnitude_T*lateral_perturbation;
- return T_solidus+T_perturbation;
+ T_perturbation=Depth/( this->geometry_model->maximal_depth() )*magnitude_T*lateral_perturbation;
+ return T_solidus+T_perturbation;
}
@@ -190,53 +190,53 @@ namespace aspect
{
prm.enter_subsection("Solidus");
{
- prm.declare_entry ("Supersolidus","0e0",
- Patterns::Double (),
- "The difference from solidus, use this number to generate initial conditions "
- "that close to solidus instead of exactly at solidus. Use small negative number"
- " in this parameter to prevent large melting generation at the beginning. "
- " Units: K ");
- prm.declare_entry ("Lithosphere thickness","0",
+ prm.declare_entry ("Supersolidus","0e0",
+ Patterns::Double (),
+ "The difference from solidus, use this number to generate initial conditions "
+ "that close to solidus instead of exactly at solidus. Use small negative number"
+ " in this parameter to prevent large melting generation at the beginning. "
+ " Units: K ");
+ prm.declare_entry ("Lithosphere thickness","0",
+ Patterns::Double (0),
+ "The thickness of lithosphere thickness. Units: m");
+ prm.enter_subsection("Perturbation");
+ {
+ prm.declare_entry ("Temperature amplitude", "0e0",
Patterns::Double (0),
- "The thickness of lithosphere thickness. Units: m");
- prm.enter_subsection("Perturbation");
- {
- prm.declare_entry ("Temperature amplitude", "0e0",
- Patterns::Double (0),
- "The amplitude of the initial spherical temperature perturbation in (K)");
- prm.declare_entry ("Lithosphere thickness amplitude", "0e0",
- Patterns::Double (),
- "The amplitude of the initial lithosphere thickness perturbation in (m)");
- prm.declare_entry ("Lateral wave number one","3",
- Patterns::Integer(),
- "Doubled first lateral wave number of the harmonic perturbation. "
- "Equals the spherical harmonic degree in 3D spherical shells. "
- "In all other cases one equals half of a sine period over "
- "the model domain. This allows for single up-/downswings. "
- "Negative numbers reverse the sign of the perturbation but are "
- "not allowed for the spherical harmonic case.");
- prm.declare_entry ("Lateral wave number two", "2",
- Patterns::Integer (),
- "Doubled second lateral wave number of the harmonic perturbation. "
- "Equals the spherical harmonic order in 3D spherical shells. "
- "In all other cases one equals half of a sine period over "
- "the model domain. This allows for single up-/downswings. "
- "Negative numbers reverse the sign of the perturbation.");
- }
- prm.leave_subsection();
- prm.enter_subsection ("Data");
- {
- prm.declare_entry ("Solidus filename", "",
- Patterns::Anything(),
- "The solidus data filename. It is a function of radius or pressure "
- "in the following format: \n"
- "Line 1: Header \n"
- "Line 2: Unit of temperature (C/K) "
- "Unit of pressure (GPa/kbar) or radius (km/m) \n"
- "Line 3~: Column of solidus temperature Column of radius/pressure \n"
- "See data/initial_temperature/solidus.Mars as an example.");
- }
- prm.leave_subsection();
+ "The amplitude of the initial spherical temperature perturbation in (K)");
+ prm.declare_entry ("Lithosphere thickness amplitude", "0e0",
+ Patterns::Double (),
+ "The amplitude of the initial lithosphere thickness perturbation in (m)");
+ prm.declare_entry ("Lateral wave number one","3",
+ Patterns::Integer(),
+ "Doubled first lateral wave number of the harmonic perturbation. "
+ "Equals the spherical harmonic degree in 3D spherical shells. "
+ "In all other cases one equals half of a sine period over "
+ "the model domain. This allows for single up-/downswings. "
+ "Negative numbers reverse the sign of the perturbation but are "
+ "not allowed for the spherical harmonic case.");
+ prm.declare_entry ("Lateral wave number two", "2",
+ Patterns::Integer (),
+ "Doubled second lateral wave number of the harmonic perturbation. "
+ "Equals the spherical harmonic order in 3D spherical shells. "
+ "In all other cases one equals half of a sine period over "
+ "the model domain. This allows for single up-/downswings. "
+ "Negative numbers reverse the sign of the perturbation.");
+ }
+ prm.leave_subsection();
+ prm.enter_subsection ("Data");
+ {
+ prm.declare_entry ("Solidus filename", "",
+ Patterns::Anything(),
+ "The solidus data filename. It is a function of radius or pressure "
+ "in the following format: \n"
+ "Line 1: Header \n"
+ "Line 2: Unit of temperature (C/K) "
+ "Unit of pressure (GPa/kbar) or radius (km/m) \n"
+ "Line 3~: Column of solidus temperature Column of radius/pressure \n"
+ "See data/initial_temperature/solidus.Mars as an example.");
+ }
+ prm.leave_subsection();
}
prm.leave_subsection();
}
@@ -253,22 +253,22 @@ namespace aspect
{
prm.enter_subsection("Solidus");
{
- deltaT=prm.get_double("Supersolidus");
- litho_thick=prm.get_double("Lithosphere thickness");
- prm.enter_subsection("Perturbation");
- {
- magnitude_T = prm.get_double("Temperature amplitude");
- magnitude_lith = prm.get_double("Lithosphere thickness amplitude");
- lateral_wave_number_1 = prm.get_integer ("Lateral wave number one");
- lateral_wave_number_2 = prm.get_integer ("Lateral wave number two");
- }
- prm.leave_subsection();
- prm.enter_subsection("Data");
- {
- solidus_filename=prm.get ("Solidus filename");
- solidus_curve.read(solidus_filename);
- }
- prm.leave_subsection();
+ deltaT=prm.get_double("Supersolidus");
+ litho_thick=prm.get_double("Lithosphere thickness");
+ prm.enter_subsection("Perturbation");
+ {
+ magnitude_T = prm.get_double("Temperature amplitude");
+ magnitude_lith = prm.get_double("Lithosphere thickness amplitude");
+ lateral_wave_number_1 = prm.get_integer ("Lateral wave number one");
+ lateral_wave_number_2 = prm.get_integer ("Lateral wave number two");
+ }
+ prm.leave_subsection();
+ prm.enter_subsection("Data");
+ {
+ solidus_filename=prm.get ("Solidus filename");
+ solidus_curve.read(solidus_filename);
+ }
+ prm.leave_subsection();
}
prm.leave_subsection();
}
More information about the CIG-COMMITS
mailing list