-
Notifications
You must be signed in to change notification settings - Fork 236
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
implement WENO limiter for DG method #5929
Open
YiminJin
wants to merge
22
commits into
geodynamics:main
Choose a base branch
from
YiminJin:weno
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ce09083
implement WENO limiter for DG method
b6aaaca
correct spelling mistakes
68e633c
add necessary headers for compilation without unity build
4bfb4a8
reformat the .prm file for limiter settings
13ed3c4
Update source/simulator/parameters.cc
YiminJin 95edb8a
change boundary_preserving to bound_preserving
b0c4e8f
replace 'boundary preserving' by 'bound preserving'
a53c298
add citations for WENO limiter and KXRCF indicator
9d46a62
scale the characteristic mesh spacing by the diameter of Omega
06e7cb8
add viscoelastic_beam_modified benchmark with WENO limiter
36ff891
add viscoelastic_bending_beam benchmark with WENO limiter
0a25a71
add rotate_shape benchmark with WENO limiter
7103a42
add rotate_shape benchmark with bound-preserving limiter
59f361b
replace Patterns::Double() by Patterns::List(Patterns::Double()) for …
d6a1a0e
supplement comments for KXRCF indicator and WENO limiter
92b5d90
supplement the documentation for KXRCF indicator
e305776
Update source/simulator/parameters.cc
YiminJin f5cbc1c
Update source/simulator/parameters.cc
YiminJin 4667dbc
reformat the .prm file for limiter settings
aea41a4
remove the .prm.bak files
fa78f1e
fix bug: missing case: comments behind parameter value
3c8173e
correct the parameter entries related with DG limiter
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,21 @@ | ||
# Like rotate_shape_supg but with discontinuous Galerkin method | ||
# and bound-preserving limiter | ||
|
||
set Dimension = 2 | ||
|
||
include rotate_shape_supg.prm | ||
|
||
set Output directory = output-rotate-shape-dg-bp | ||
|
||
subsection Discretization | ||
set Use discontinuous temperature discretization = true | ||
set Use discontinuous composition discretization = true | ||
subsection Stabilization parameters | ||
set Limiter for discontinuous temperature solution = bound preserving | ||
set Limiter for discontinuous composition solution = bound preserving | ||
set Global temperature maximum = 1 | ||
set Global temperature minimum = 0 | ||
set Global composition maximum = 1 | ||
set Global composition minimum = 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,26 @@ | ||
# Like rotate_shape_supg but with discontinuous Galerkin method | ||
# and WENO limiter | ||
|
||
set Dimension = 2 | ||
|
||
include rotate_shape_supg.prm | ||
|
||
set Output directory = output-rotate-shape-dg-weno | ||
|
||
subsection Discretization | ||
set Use discontinuous temperature discretization = true | ||
set Use discontinuous composition discretization = true | ||
subsection Stabilization parameters | ||
set Limiter for discontinuous temperature solution = WENO | ||
set Limiter for discontinuous composition solution = WENO | ||
end | ||
end | ||
|
||
subsection Postprocess | ||
subsection Visualization | ||
set List of output variables = kxrcf indicator | ||
subsection KXRCF indicator | ||
set Name of advection field = C_1 | ||
end | ||
end | ||
end |
33 changes: 33 additions & 0 deletions
33
benchmarks/viscoelastic_beam_modified/20km_opentopbot_weno.prm
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,33 @@ | ||
# This parameter file modifies the benchmark 20kmh_05drho.prm to use the WENO limiter | ||
# for viscoelastic stress components. | ||
|
||
include $ASPECT_SOURCE_DIR/benchmarks/viscoelastic_bending_beam/20km_opentopbot.prm | ||
|
||
set Output directory = 20kmh_05drho_weno | ||
|
||
|
||
subsection Discretization | ||
subsection Stabilization parameters | ||
# Use WENO limiter for viscoelastic stress components, while using the | ||
# bound-preserving limiter for the chemical field | ||
set Limiter for discontinuous composition solution = WENO, WENO, WENO, bound preserving | ||
# In this benchmark, the spurious oscillations at the boundaries of the beam | ||
# are extremely serious, so we set the linear weight of neighbor cells one | ||
# magnitude greater than the default value to make the reconstructed solution | ||
# smoother. | ||
set WENO linear weight of neighbor cells = 0.01 | ||
# The global maximum and minimum values are only used by the chemical field. | ||
set Global composition maximum = 1.0 | ||
set Global composition minimum = 0.0 | ||
end | ||
end | ||
|
||
# Visualize the KXRCF indicator for ve_stress_xy | ||
subsection Postprocess | ||
subsection Visualization | ||
set List of output variables = material properties, strain rate, kxrcf indicator | ||
subsection KXRCF indicator | ||
set Name of advection field = ve_stress_xy | ||
end | ||
end | ||
end |
32 changes: 32 additions & 0 deletions
32
benchmarks/viscoelastic_bending_beam/viscoelastic_bending_beam_weno.prm
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,32 @@ | ||
# This parameter file modifies the benchmark viscoealastic_bending_beam.prm | ||
# to use the WENO limiter for viscoelastic stress components. | ||
|
||
include $ASPECT_SOURCE_DIR/benchmarks/viscoelastic_bending_beam/viscoelastic_bending_beam.prm | ||
|
||
set Output directory = output_viscoelastic_bending_beam_weno | ||
|
||
subsection Discretization | ||
subsection Stabilization parameters | ||
# Use WENO limiter for viscoelastic stress components, while using the | ||
# bound-preserving limiter for the chemical field | ||
set Limiter for discontinuous composition solution = WENO, WENO, WENO, bound preserving | ||
# In this benchmark, the spurious oscillations at the boundaries of the beam | ||
# are extremely serious, so we set the linear weight of neighbor cells one | ||
# magnitude greater than the default value to make the reconstructed solution | ||
# smoother. | ||
set WENO linear weight of neighbor cells = 0.01 | ||
# The global maximum and minimum values are only used by the chemical field. | ||
set Global composition maximum = 1.0 | ||
set Global composition minimum = 0.0 | ||
end | ||
end | ||
|
||
# Visualize the KXRCF indicator for ve_stress_xy | ||
subsection Postprocess | ||
subsection Visualization | ||
set List of output variables = material properties, strain rate, kxrcf indicator | ||
subsection KXRCF indicator | ||
set Name of advection field = ve_stress_xy | ||
end | ||
end | ||
end |
75 changes: 75 additions & 0 deletions
75
contrib/utilities/update_scripts/prm_files/reformat_limiter_settings.py
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,75 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
""" This script changes 'Use limiter for discontinuous temperature/composition solution' | ||
to 'limiter for discontinuous temperature/composition solution' in order to allow users | ||
to specify different limiters for different fields | ||
""" | ||
|
||
|
||
import sys | ||
import os | ||
import re | ||
import argparse | ||
|
||
__author__ = 'The authors of the ASPECT code' | ||
__copyright__ = 'Copyright 2024, ASPECT' | ||
__license__ = 'GNU GPL 2 or later' | ||
|
||
# Add the ASPECT root directory to the path so we can import from the aspect_data module | ||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..')) | ||
import python.scripts.aspect_input as aspect | ||
|
||
|
||
|
||
def reformat_limiter_settings(parameters): | ||
"""change 'Use limiter for discontinuous temperature/composition solution' | ||
to 'limiter for discontinuous temperature/composition solution' in order to allow users | ||
to specify different limiters for different fields | ||
""" | ||
|
||
old_entries = ["Use limiter for discontinuous temperature solution", | ||
"Use limiter for discontinuous composition solution"] | ||
new_entries = ["Limiter for discontinuous temperature solution", | ||
"Limiter for discontinuous composition solution"] | ||
|
||
# go to the subsection | ||
if "Discretization" in parameters: | ||
if "Stabilization parameters" in parameters["Discretization"]["value"]: | ||
subsection = parameters["Discretization"]["value"]["Stabilization parameters"]["value"] | ||
|
||
for i in range(0,2): | ||
if old_entries[i] in subsection: | ||
|
||
# Delete the old entry | ||
use_limiter = subsection[old_entries[i]]["value"] | ||
del subsection[old_entries[i]] | ||
|
||
# If limiter is used, then set the value of the new entry to "bound preserving" | ||
if use_limiter == "true": | ||
subsection[new_entries[i]] = {"comment" : "", | ||
"value" : "bound preserving", | ||
"type" : "parameter", | ||
"alignment spaces": 1} | ||
|
||
return parameters | ||
|
||
|
||
|
||
def main(input_file, output_file): | ||
"""Echo the input arguments to standard output""" | ||
parameters = aspect.read_parameter_file(input_file) | ||
parameters = reformat_limiter_settings(parameters) | ||
aspect.write_parameter_file(parameters, output_file) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
prog='ASPECT .prm file reformatter', | ||
description='Reformats ASPECT .prm files to follow our general formatting guidelines. See the documentation of this script for details.') | ||
parser.add_argument('input_file', type=str, help='The .prm file to reformat') | ||
parser.add_argument('output_file', type=str, help='The .prm file to write the reformatted file to') | ||
args = parser.parse_args() | ||
|
||
sys.exit(main(args.input_file, args.output_file)) |
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
80 changes: 80 additions & 0 deletions
80
include/aspect/postprocess/visualization/kxrcf_indicator.h
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,80 @@ | ||
/* | ||
Copyright (C) 2011 - 2022 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_postprocess_visualization_kxrcf_indicator_h | ||
#define _aspect_postprocess_visualization_kxrcf_indicator_h | ||
|
||
#include <aspect/postprocess/visualization.h> | ||
#include <aspect/simulator_access.h> | ||
|
||
|
||
namespace aspect | ||
{ | ||
namespace Postprocess | ||
{ | ||
namespace VisualizationPostprocessors | ||
{ | ||
/** | ||
* A class derived that implements a function that provides the | ||
* KXRCF indicator for a given advection field on each cell for | ||
* graphical output. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add an explanation what the KXRCF indicator is. What does it stand for and what does it mean to have a high KXRCF in a cell? |
||
*/ | ||
template <int dim> | ||
class KXRCFIndicator : public CellDataVectorCreator<dim>, | ||
public SimulatorAccess<dim> | ||
{ | ||
public: | ||
/** | ||
* Constructor. | ||
*/ | ||
KXRCFIndicator(); | ||
|
||
/** | ||
* @copydoc CellDataVectorCreator<dim>::execute() | ||
*/ | ||
std::pair<std::string, std::unique_ptr<Vector<float>>> | ||
execute () 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: | ||
/** | ||
* A parameter that tells us for which advection field the | ||
* KXRCF indicator should be visualized. | ||
*/ | ||
unsigned int field_index; | ||
}; | ||
} | ||
} | ||
} | ||
|
||
#endif |
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
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.
Have you tested this script? You will likely need to apply it anyway to all files that currently use the BP limiter in benchmarks/ cookbooks/ and tests/. An easy way to apply the script is to run the file
contrib/utilities/update_scripts/update_all_files.sh
.