-
Notifications
You must be signed in to change notification settings - Fork 242
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
Combine interpolating fields in one operation #6202
Merged
bobmyhill
merged 1 commit into
geodynamics:main
from
gassmoeller:unify_prescribing_fields
Mar 2, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Changed: Prescribed compositional fields are now copied from the material | ||
model output in one combined operation (instead of being copied field by field). | ||
This change improves the efficiency of the copy process. | ||
<br> | ||
(Rene Gassmoeller, 2025/02/28) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
Copyright (C) 2022 - 2024 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/material_model/simple.h> | ||
#include <aspect/simulator_access.h> | ||
|
||
namespace aspect | ||
{ | ||
namespace MaterialModel | ||
{ | ||
using namespace dealii; | ||
|
||
template <int dim> | ||
class PrescribedFieldsMaterial : public MaterialModel::Simple<dim> | ||
{ | ||
public: | ||
|
||
void evaluate(const MaterialModel::MaterialModelInputs<dim> &in, | ||
MaterialModel::MaterialModelOutputs<dim> &out) const override; | ||
|
||
void | ||
create_additional_named_outputs (MaterialModel::MaterialModelOutputs<dim> &out) const override; | ||
}; | ||
|
||
} | ||
} | ||
|
||
namespace aspect | ||
{ | ||
namespace MaterialModel | ||
{ | ||
|
||
template <int dim> | ||
void | ||
PrescribedFieldsMaterial<dim>:: | ||
evaluate(const MaterialModel::MaterialModelInputs<dim> &in, | ||
MaterialModel::MaterialModelOutputs<dim> &out) const | ||
{ | ||
Simple<dim>::evaluate(in, out); | ||
|
||
// set up variable to interpolate prescribed field outputs onto compositional fields | ||
PrescribedFieldOutputs<dim> *prescribed_field_out = out.template get_additional_output<PrescribedFieldOutputs<dim>>(); | ||
|
||
if (prescribed_field_out != nullptr) | ||
for (unsigned int i=0; i < in.n_evaluation_points(); ++i) | ||
{ | ||
const double y = in.position[i](1); | ||
for (unsigned int j=0; j<this->n_compositional_fields(); ++j) | ||
prescribed_field_out->prescribed_field_outputs[i][j] = y*j; | ||
} | ||
} | ||
|
||
|
||
template <int dim> | ||
void | ||
PrescribedFieldsMaterial<dim>::create_additional_named_outputs (MaterialModel::MaterialModelOutputs<dim> &out) const | ||
{ | ||
if (out.template get_additional_output<PrescribedFieldOutputs<dim>>() == nullptr) | ||
{ | ||
const unsigned int n_points = out.n_evaluation_points(); | ||
out.additional_outputs.push_back( | ||
std::make_unique<MaterialModel::PrescribedFieldOutputs<dim>> (n_points,this->n_compositional_fields())); | ||
} | ||
} | ||
} | ||
} | ||
|
||
// explicit instantiations | ||
namespace aspect | ||
{ | ||
namespace MaterialModel | ||
{ | ||
ASPECT_REGISTER_MATERIAL_MODEL(PrescribedFieldsMaterial, | ||
"prescribed fields material", | ||
"A simple material model that is like the " | ||
"'Simple' model, but creates multiple prescribed field outputs.") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# A testcase that demonstrates the named additional outputs postprocessor for multiple | ||
# named outputs. The test is based on prescribed_field_with_diffusion only | ||
# with more than one additional output. | ||
|
||
set Dimension = 2 | ||
set End time = 0 | ||
set Start time = 0 | ||
set Adiabatic surface temperature = 0 | ||
set Surface pressure = 0 | ||
set Use years in output instead of seconds = false | ||
|
||
subsection Gravity model | ||
set Model name = vertical | ||
|
||
subsection Vertical | ||
set Magnitude = 1.0 | ||
end | ||
end | ||
|
||
subsection Geometry model | ||
set Model name = box | ||
|
||
subsection Box | ||
set X extent = 1 | ||
set Y extent = 1 | ||
end | ||
end | ||
|
||
subsection Compositional fields | ||
set Number of fields = 3 | ||
set Names of fields = prescribed_1, prescribed_2, prescribed_3 | ||
set Compositional field methods = prescribed field, prescribed field, prescribed field | ||
end | ||
|
||
subsection Initial temperature model | ||
set Model name = function | ||
|
||
subsection Function | ||
set Function expression = 0.1 | ||
end | ||
end | ||
|
||
subsection Initial composition model | ||
set Model name = function | ||
|
||
subsection Function | ||
set Function expression = 0.0; 0.2; 0.3 | ||
end | ||
end | ||
|
||
subsection Material model | ||
set Model name = prescribed fields material | ||
|
||
subsection Simple model | ||
set Reference density = 1 | ||
set Reference specific heat = 1 | ||
set Reference temperature = 0 | ||
set Thermal conductivity = 1 | ||
set Thermal expansion coefficient = 1 | ||
set Viscosity = 1 | ||
end | ||
end | ||
|
||
subsection Mesh refinement | ||
set Initial adaptive refinement = 0 | ||
set Initial global refinement = 1 | ||
end | ||
|
||
subsection Boundary velocity model | ||
set Tangential velocity boundary indicators = 0, 1, 2, 3 | ||
end | ||
|
||
subsection Postprocess | ||
set List of postprocessors = visualization, composition statistics | ||
|
||
subsection Visualization | ||
set Interpolate output = false | ||
set List of output variables = named additional outputs | ||
set Number of grouped files = 0 | ||
set Output format = gnuplot | ||
set Time between graphical output = 0 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
Loading shared library <./libmultiple_prescribed_fields.debug.so> | ||
|
||
Number of active cells: 4 (on 2 levels) | ||
Number of degrees of freedom: 159 (50+9+25+25+25+25) | ||
|
||
*** Timestep 0: t=0 seconds, dt=0 seconds | ||
Solving temperature system... 0 iterations. | ||
Copying properties into prescribed compositional fields... done. | ||
Solving Stokes system (GMG)... 6+0 iterations. | ||
|
||
Postprocessing: | ||
Writing graphical output: output-multiple_prescribed_fields/solution/solution-00000 | ||
Compositions min/max/mass: 0/0/0 // 0/1/0.5 // 0/2/1 | ||
|
||
Termination requested by criterion: end time | ||
|
||
|
||
|
35 changes: 35 additions & 0 deletions
35
tests/multiple_prescribed_fields/solution/solution-00000.0000.gnuplot
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 1: Time step number | ||
# 2: Time (seconds) | ||
# 3: Time step size (seconds) | ||
# 4: Number of mesh cells | ||
# 5: Number of Stokes degrees of freedom | ||
# 6: Number of temperature degrees of freedom | ||
# 7: Number of degrees of freedom for all compositions | ||
# 8: Iterations for temperature solver | ||
# 9: Iterations for composition solver 1 | ||
# 10: Iterations for composition solver 2 | ||
# 11: Iterations for composition solver 3 | ||
# 12: Iterations for Stokes solver | ||
# 13: Velocity iterations in Stokes preconditioner | ||
# 14: Schur complement iterations in Stokes preconditioner | ||
# 15: Visualization file name | ||
# 16: Minimal value for composition prescribed_1 | ||
# 17: Maximal value for composition prescribed_1 | ||
# 18: Global mass for composition prescribed_1 | ||
# 19: Minimal value for composition prescribed_2 | ||
# 20: Maximal value for composition prescribed_2 | ||
# 21: Global mass for composition prescribed_2 | ||
# 22: Minimal value for composition prescribed_3 | ||
# 23: Maximal value for composition prescribed_3 | ||
# 24: Global mass for composition prescribed_3 | ||
0 0.000000000000e+00 0.000000000000e+00 4 59 25 75 0 4294967294 4294967294 4294967294 5 7 7 output-multiple_prescribed_fields/solution/solution-00000 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.00000000e+00 5.00000000e-01 0.00000000e+00 2.00000000e+00 1.00000000e+00 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for this change in ordering?