Skip to content

Commit 55fc501

Browse files
committed
Prescribed condition from initial composition
1 parent acdb223 commit 55fc501

File tree

7 files changed

+494
-16
lines changed

7 files changed

+494
-16
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Added: a new instance of 'initial composition' in the prescribed solution plugin system.
2+
<br>
3+
(Haoyuan Li, 2026/03/11)

doc/sphinx/parameters/Material_20model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Viscous stress may also be limited by a non-linear stress limiter that has a for
200200

201201
The value for the components of this formula and additional parameters are read from the parameter file in subsection &rsquo;Material model/Visco Plastic&rsquo;.
202202

203-
&lsquo;viscoelastic&rsquo;: An implementation of a simple linear viscoelastic rheology that only includes the deviatoric components of elasticity. Specifically, the viscoelastic rheology only takes into account the elastic shear strength (e.g., shear modulus), while the tensile and volumetric strength (e.g., Young&rsquo;s and bulk modulus) are not considered. The model is incompressible and allows specifying an arbitrary number of compositional fields, where each field represents a different rock type or component of the viscoelastic stress tensor. The stress tensor in 2d and 3d, respectively, contains 3 or 6 components. The compositional fields representing these components must be named and listed in a very specific format, which is designed to minimize mislabeling stress tensor components as distinct &rsquo;compositional rock types&rsquo; (or vice versa). For 2d models, the first six compositional fields of type stress must be labeled &rsquo;ve\_stress\_xx&rsquo;, &rsquo;ve\_stress\_yy&rsquo; and &rsquo;ve\_stress\_xy&rsquo;, &rsquo;ve\_stress\_xx\_old&rsquo;, &rsquo;ve\_stress\_yy\_old&rsquo; and &rsquo;ve\_stress\_xy\_old&rsquo;, In 3d, the first twelve compositional fields of type stress must be labeled &rsquo;ve\_stress\_xx&rsquo;, &rsquo;ve\_stress\_yy&rsquo;, &rsquo;ve\_stress\_zz&rsquo;, &rsquo;ve\_stress\_xy&rsquo;, &rsquo;ve\_stress\_xz&rsquo;, &rsquo;ve\_stress\_yz&rsquo;, &rsquo;ve\_stress\_xx\_old&rsquo;, &rsquo;ve\_stress\_yy\_old&rsquo;, &rsquo;ve\_stress\_zz\_old&rsquo;, &rsquo;ve\_stress\_xy\_old&rsquo;, &rsquo;ve\_stress\_xz\_old&rsquo;, &rsquo;ve\_stress\_yz\_old&rsquo;.
203+
&lsquo;viscoelastic&rsquo;: An implementation of a simple linear viscoelastic rheology that only includes the deviatoric components of elasticity. Specifically, the viscoelastic rheology only takes into account the elastic shear strength (e.g., shear modulus), while the tensile and volumetric strength (e.g., Young&rsquo;s and bulk modulus) are not considered. The model is incompressible and allows specifying an arbitrary number of compositional fields, where each field represents a different rock type or component of the viscoelastic stress tensor. The stress tensor in 2d and 3d, respectively, contains 3 or 6 components. The compositional fields representing these components must be named and listed in a very specific format, which is designed to minimize mislabeling stress tensor components as distinct &rsquo;compositional rock types&rsquo; (or vice versa). For 2d models, the first six compositional fields must be labeled &rsquo;stress\_xx&rsquo;, &rsquo;stress\_yy&rsquo; and &rsquo;stress\_xy&rsquo;, &rsquo;stress\_xx\_old&rsquo;, &rsquo;stress\_yy\_old&rsquo; and &rsquo;stress\_xy\_old&rsquo;, In 3d, the first twelve compositional fields must be labeled &rsquo;stress\_xx&rsquo;, &rsquo;stress\_yy&rsquo;, &rsquo;stress\_zz&rsquo;, &rsquo;stress\_xy&rsquo;, &rsquo;stress\_xz&rsquo;, &rsquo;stress\_yz&rsquo;, &rsquo;stress\_xx\_old&rsquo;, &rsquo;stress\_yy\_old&rsquo;, &rsquo;stress\_zz\_old&rsquo;, &rsquo;stress\_xy\_old&rsquo;, &rsquo;stress\_xz\_old&rsquo;, &rsquo;stress\_yz\_old&rsquo;.
204204

205205
Expanding the model to include non-linear viscous flow (e.g., diffusion/dislocation creep) and plasticity would produce a constitutive relationship commonly referred to as partial elastoviscoplastic (e.g., pEVP) in the geodynamics community. While extensively discussed and applied within the geodynamics literature, notable references include: Moresi et al. (2003), J. Comp. Phys., v. 184, p. 476-497. Gerya and Yuen (2007), Phys. Earth. Planet. Inter., v. 163, p. 83-105. Gerya (2010), Introduction to Numerical Geodynamic Modeling. Kaus (2010), Tectonophysics, v. 484, p. 36-47. Choi et al. (2013), J. Geophys. Res., v. 118, p. 2429-2444. Keller et al. (2013), Geophys. J. Int., v. 195, p. 1406-1442.
206206

doc/sphinx/parameters/Prescribed_20solution.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,34 @@
99
:name: parameters:Prescribed_20solution/List_20of_20model_20names
1010
**Default value:**
1111

12-
**Pattern:** [MultipleSelection initial temperature|temperature function|velocity function ]
12+
**Pattern:** [MultipleSelection initial composition|temperature function|velocity function ]
1313

1414
**Documentation:** A comma-separated list of prescribed solution models that will be used to compute the solution in certain regions. These plugins are loaded in the order given, and are combined via the operators listed in &rsquo;List of model operators&rsquo;.
1515

1616
The following prescribed solution models are available:
1717

18-
&lsquo;initial temperature&rsquo;: 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.
18+
&lsquo;initial composition&rsquo;: Prescribe compositional fields from the initial composition model within a region defined by an indicator function.
1919

2020
&lsquo;temperature function&rsquo;: Prescribe the temperature in terms of an explicit formula. The format of these functions follows the syntax understood by the muparser library.
2121

2222
&lsquo;velocity function&rsquo;: Prescribe the velocity in terms of an explicit formula. The format of these functions follows the syntax understood by the muparser library, see {ref}`sec:run-aspect:parameters-overview:muparser-format`.
2323
::::
2424

25-
(parameters:Prescribed_20solution/Initial_20temperature)=
26-
## **Subsection:** Prescribed solution / Initial temperature
27-
::::{dropdown} __Parameter:__ {ref}`Coordinate system<parameters:Prescribed_20solution/Initial_20temperature/Coordinate_20system>`
28-
:name: parameters:Prescribed_20solution/Initial_20temperature/Coordinate_20system
25+
(parameters:Prescribed_20solution/Initial_20composition)=
26+
## **Subsection:** Prescribed solution / Initial composition
27+
::::{dropdown} __Parameter:__ {ref}`Coordinate system<parameters:Prescribed_20solution/Initial_20composition/Coordinate_20system>`
28+
:name: parameters:Prescribed_20solution/Initial_20composition/Coordinate_20system
2929
**Default value:** cartesian
3030

3131
**Pattern:** [Selection cartesian|spherical|depth ]
3232

33-
**Documentation:** A selection that determines the assumed coordinate system for the indicator function variables. Allowed values are &lsquo;cartesian&rsquo;, &lsquo;spherical&rsquo;, and &lsquo;depth&rsquo;.
33+
**Documentation:** Coordinate system used for evaluating the indicator function.
3434
::::
3535

36-
(parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function)=
37-
## **Subsection:** Prescribed solution / Initial temperature / Indicator function
38-
::::{dropdown} __Parameter:__ {ref}`Function constants<parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function/Function_20constants>`
39-
:name: parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function/Function_20constants
36+
(parameters:Prescribed_20solution/Initial_20composition/Indicator_20function)=
37+
## **Subsection:** Prescribed solution / Initial composition / Indicator function
38+
::::{dropdown} __Parameter:__ {ref}`Function constants<parameters:Prescribed_20solution/Initial_20composition/Indicator_20function/Function_20constants>`
39+
:name: parameters:Prescribed_20solution/Initial_20composition/Indicator_20function/Function_20constants
4040
**Default value:**
4141

4242
**Pattern:** [Anything]
@@ -46,8 +46,8 @@ The following prescribed solution models are available:
4646
A typical example would be to set this runtime parameter to &lsquo;pi=3.1415926536&rsquo; and then use &lsquo;pi&rsquo; in the expression of the actual formula. (That said, for convenience this class actually defines both &lsquo;pi&rsquo; and &lsquo;Pi&rsquo; by default, but you get the idea.)
4747
::::
4848

49-
::::{dropdown} __Parameter:__ {ref}`Function expression<parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function/Function_20expression>`
50-
:name: parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function/Function_20expression
49+
::::{dropdown} __Parameter:__ {ref}`Function expression<parameters:Prescribed_20solution/Initial_20composition/Indicator_20function/Function_20expression>`
50+
:name: parameters:Prescribed_20solution/Initial_20composition/Indicator_20function/Function_20expression
5151
**Default value:** 0
5252

5353
**Pattern:** [Anything]
@@ -57,8 +57,8 @@ A typical example would be to set this runtime parameter to &lsquo;pi=3.14159265
5757
If the function you are describing represents a vector-valued function with multiple components, then separate the expressions for individual components by a semicolon.
5858
::::
5959

60-
::::{dropdown} __Parameter:__ {ref}`Variable names<parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function/Variable_20names>`
61-
:name: parameters:Prescribed_20solution/Initial_20temperature/Indicator_20function/Variable_20names
60+
::::{dropdown} __Parameter:__ {ref}`Variable names<parameters:Prescribed_20solution/Initial_20composition/Indicator_20function/Variable_20names>`
61+
:name: parameters:Prescribed_20solution/Initial_20composition/Indicator_20function/Variable_20names
6262
**Default value:** x,y,t
6363

6464
**Pattern:** [Anything]
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
Copyright (C) 2015 - 2022 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+
#ifndef _aspect_prescribed_solution_initial_composition_h
22+
#define _aspect_prescribed_solution_initial_composition_h
23+
24+
#include <aspect/initial_composition/interface.h>
25+
#include <aspect/prescribed_solution/interface.h>
26+
#include <aspect/simulator_access.h>
27+
28+
#include <deal.II/base/parsed_function.h>
29+
30+
namespace aspect
31+
{
32+
namespace PrescribedSolution
33+
{
34+
/**
35+
* Prescribe compositional fields using the initial composition model.
36+
* The region where the constraint applies is determined by an
37+
* indicator function.
38+
*/
39+
template <int dim>
40+
class InitialComposition
41+
: public Interface<dim>,
42+
public SimulatorAccess<dim>
43+
{
44+
public:
45+
46+
InitialComposition ();
47+
48+
/**
49+
* Store shared pointer to initial composition manager.
50+
*/
51+
void initialize () override;
52+
53+
/**
54+
* Update function time.
55+
*/
56+
void update () override;
57+
58+
/**
59+
* Declare parameters.
60+
*/
61+
static void declare_parameters (ParameterHandler &prm);
62+
63+
/**
64+
* Parse parameters.
65+
*/
66+
void parse_parameters (ParameterHandler &prm) override;
67+
68+
/**
69+
* Constrain compositional solution.
70+
*/
71+
void constrain_solution (const typename DoFHandler<dim>::active_cell_iterator &cell,
72+
const std::vector<Point<dim>> &positions,
73+
const std::vector<unsigned int> &component_indices,
74+
std::vector<bool> &should_be_constrained,
75+
std::vector<double> &solution) override;
76+
77+
private:
78+
79+
/**
80+
* Indicator function defining region where composition
81+
* is prescribed.
82+
*/
83+
Functions::ParsedFunction<dim> indicator_function;
84+
85+
/**
86+
* Coordinate system used for evaluating indicator.
87+
*/
88+
Utilities::Coordinates::CoordinateSystem coordinate_system;
89+
90+
/**
91+
* Pointer to initial composition manager.
92+
*/
93+
std::shared_ptr<const aspect::InitialComposition::Manager<dim>> initial_composition_manager;
94+
};
95+
}
96+
}
97+
98+
#endif
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
Copyright (C) 2011 - 2022 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/initial_composition/interface.h>
23+
#include <aspect/prescribed_solution/initial_composition.h>
24+
25+
namespace aspect
26+
{
27+
namespace PrescribedSolution
28+
{
29+
30+
template <int dim>
31+
InitialComposition<dim>::InitialComposition ()
32+
:
33+
indicator_function(1)
34+
{}
35+
36+
37+
38+
template <int dim>
39+
void
40+
InitialComposition<dim>::initialize ()
41+
{
42+
initial_composition_manager =
43+
this->get_initial_composition_manager_pointer();
44+
}
45+
46+
47+
48+
template <int dim>
49+
void
50+
InitialComposition<dim>::update ()
51+
{
52+
if (this->convert_output_to_years())
53+
indicator_function.set_time(this->get_time() / year_in_seconds);
54+
else
55+
indicator_function.set_time(this->get_time());
56+
}
57+
58+
59+
60+
template <int dim>
61+
void
62+
InitialComposition<dim>::constrain_solution (const typename DoFHandler<dim>::active_cell_iterator &,
63+
const std::vector<Point<dim>> &positions,
64+
const std::vector<unsigned int> &component_indices,
65+
std::vector<bool> &should_be_constrained,
66+
std::vector<double> &solution)
67+
{
68+
// Determine the component range corresponding to compositional fields.
69+
// These component indices are originally mapped from local DoFs and
70+
// determine which DoFs in the system belong to compositional fields.
71+
const unsigned int first_comp =
72+
this->introspection().component_indices.compositional_fields[0];
73+
74+
const unsigned int last_comp =
75+
this->introspection().component_indices.compositional_fields[this->introspection().n_compositional_fields-1];
76+
77+
const auto &geometry_model = this->get_geometry_model();
78+
79+
for (unsigned int q=0; q<positions.size(); ++q)
80+
{
81+
const unsigned int component = component_indices[q];
82+
83+
if (component < first_comp || component > last_comp)
84+
continue;
85+
86+
const auto point = geometry_model.cartesian_to_other_coordinates(
87+
positions[q], coordinate_system);
88+
89+
const double indicator = indicator_function.value(
90+
Utilities::convert_array_to_point<dim>(point.get_coordinates()));
91+
92+
if (indicator > 0.5)
93+
{
94+
const unsigned int field_index = component - first_comp;
95+
96+
solution[q] =
97+
initial_composition_manager->initial_composition(
98+
positions[q], field_index);
99+
100+
should_be_constrained[q] = true;
101+
}
102+
}
103+
}
104+
105+
106+
107+
template <int dim>
108+
void
109+
InitialComposition<dim>::declare_parameters (ParameterHandler &prm)
110+
{
111+
prm.enter_subsection("Prescribed solution");
112+
{
113+
prm.enter_subsection("Initial composition");
114+
{
115+
116+
prm.declare_entry("Coordinate system",
117+
"cartesian",
118+
Patterns::Selection("cartesian|spherical|depth"),
119+
"Coordinate system used for evaluating the indicator function.");
120+
121+
prm.enter_subsection("Indicator function");
122+
{
123+
Functions::ParsedFunction<dim>::declare_parameters(prm,1);
124+
}
125+
prm.leave_subsection();
126+
127+
}
128+
prm.leave_subsection();
129+
}
130+
prm.leave_subsection();
131+
}
132+
133+
134+
135+
template <int dim>
136+
void
137+
InitialComposition<dim>::parse_parameters (ParameterHandler &prm)
138+
{
139+
prm.enter_subsection("Prescribed solution");
140+
{
141+
prm.enter_subsection("Initial composition");
142+
{
143+
144+
coordinate_system =
145+
Utilities::Coordinates::string_to_coordinate_system(
146+
prm.get("Coordinate system"));
147+
148+
prm.enter_subsection("Indicator function");
149+
{
150+
indicator_function.parse_parameters(prm);
151+
}
152+
prm.leave_subsection();
153+
154+
}
155+
prm.leave_subsection();
156+
}
157+
prm.leave_subsection();
158+
}
159+
}
160+
}
161+
162+
163+
164+
namespace aspect
165+
{
166+
namespace PrescribedSolution
167+
{
168+
169+
ASPECT_REGISTER_PRESCRIBED_SOLUTION(InitialComposition,
170+
"initial composition",
171+
"Prescribe compositional fields from the initial composition model "
172+
"within a region defined by an indicator function.")
173+
174+
}
175+
}

0 commit comments

Comments
 (0)