-
Notifications
You must be signed in to change notification settings - Fork 235
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
Test for multiple particle interpolation #6054
Merged
tjhei
merged 2 commits into
geodynamics:main
from
gassmoeller:test_for_multiple_particle_interpolation
Oct 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -289,6 +289,11 @@ namespace aspect | |
// A property component mask indicating for each particle world which particle properties need to be interpolated | ||
std::vector<ComponentMask> property_mask; | ||
|
||
// Mark for each advection field if it has been found in any particle world. We need to keep track of this to: | ||
// - make sure all fields tracked by particles are found in at least one particle world | ||
// - make sure that we do not interpolate the same field twice from different particle worlds | ||
std::vector<bool> advection_field_has_been_found(advection_fields.size(),false); | ||
|
||
for (unsigned int world_index = 0; world_index < particle_worlds.size(); ++world_index) | ||
{ | ||
const Particle::Property::Manager<dim> &particle_property_manager = particle_worlds[world_index].get_property_manager(); | ||
|
@@ -306,9 +311,13 @@ namespace aspect | |
// If not: assume we find it in another world. | ||
if (particle_property_manager.get_data_info().fieldname_exists(particle_property_and_component.first)) | ||
{ | ||
Assert (advection_field_has_been_found[advection_field] == false, | ||
ExcMessage("The same advection field is mapped to particle properties in different particle worlds. This is not supported.")); | ||
|
||
const unsigned int particle_property_index = particle_property_manager.get_data_info().get_position_by_field_name(particle_property_and_component.first) | ||
+ particle_property_and_component.second; | ||
|
||
advection_field_has_been_found[advection_field] = true; | ||
particle_property_indices[world_index].push_back({advection_field, particle_property_index}); | ||
property_mask[world_index].set(particle_property_index,true); | ||
} | ||
|
@@ -326,12 +335,18 @@ namespace aspect | |
ExcMessage("Can not automatically match particle properties to fields, because there are" | ||
"more fields that are marked as particle advected than particle properties")); | ||
|
||
advection_field_has_been_found[advection_field] = true; | ||
particle_property_indices[world_index].push_back({advection_field,particle_property_index}); | ||
property_mask[world_index].set(particle_property_index,true); | ||
} | ||
} | ||
} | ||
|
||
for (unsigned int advection_field=0; advection_field<advection_fields.size(); ++advection_field) | ||
Assert (advection_field_has_been_found[advection_field] == true, | ||
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. would you mind adding |
||
ExcMessage("An compositional field is marked as advected by particles, but no particle property exists that is mapped to this compositional field. " | ||
"Make sure that the particle property exists and is mapped to the compositional field in the parameter file.")); | ||
|
||
LinearAlgebra::BlockVector particle_solution; | ||
|
||
particle_solution.reinit(system_rhs, false); | ||
|
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,102 @@ | ||
# Test that we can activate multiple particle worlds and | ||
# interpolate properties from different particle worlds into | ||
# the compositional fields. | ||
|
||
set Dimension = 2 | ||
set End time = 0 | ||
set Use years in output instead of seconds = false | ||
set Number of particle worlds = 2 | ||
|
||
subsection Geometry model | ||
set Model name = box | ||
|
||
subsection Box | ||
set X extent = 0.9142 | ||
set Y extent = 1.0000 | ||
end | ||
end | ||
|
||
subsection Boundary velocity model | ||
set Tangential velocity boundary indicators = left, right | ||
set Zero velocity boundary indicators = bottom, top | ||
end | ||
|
||
subsection Material model | ||
set Model name = simple | ||
|
||
subsection Simple model | ||
set Reference density = 1010 | ||
set Viscosity = 1e2 | ||
set Thermal expansion coefficient = 0 | ||
set Density differential for compositional field 1 = -10 | ||
end | ||
end | ||
|
||
subsection Gravity model | ||
set Model name = vertical | ||
|
||
subsection Vertical | ||
set Magnitude = 10 | ||
end | ||
end | ||
|
||
subsection Initial temperature model | ||
set Model name = function | ||
|
||
subsection Function | ||
set Function expression = 0 | ||
end | ||
end | ||
|
||
subsection Compositional fields | ||
set Number of fields = 2 | ||
set Names of fields = anomaly, function | ||
set Compositional field methods = particles, particles | ||
set Mapped particle properties = anomaly: function, function: initial anomaly | ||
end | ||
|
||
subsection Initial composition model | ||
set Model name = function | ||
|
||
subsection Function | ||
set Variable names = x,z | ||
set Function constants = pi=3.1415926 | ||
set Function expression = 0.5*(1+tanh((0.2+0.02*cos(pi*x/0.9142)-z)/0.02)); 0.0 | ||
end | ||
end | ||
|
||
subsection Mesh refinement | ||
set Initial adaptive refinement = 0 | ||
set Strategy = composition | ||
set Initial global refinement = 1 | ||
set Time steps between mesh refinement = 0 | ||
end | ||
|
||
subsection Postprocess | ||
set List of postprocessors = velocity statistics, composition statistics, particles, visualization | ||
|
||
subsection Visualization | ||
set Output format = gnuplot | ||
end | ||
|
||
subsection Particles | ||
set Time between data output = 70 | ||
set Data output format = | ||
end | ||
end | ||
|
||
subsection Particles | ||
set List of particle properties = initial composition | ||
set Particle generator name = reference cell | ||
end | ||
|
||
subsection Particles 2 | ||
set List of particle properties = function | ||
set Particle generator name = reference cell | ||
|
||
subsection Function | ||
set Variable names = x,z | ||
set Function constants = pi=3.1415926 | ||
set Function expression = x | ||
end | ||
end |
20 changes: 20 additions & 0 deletions
20
tests/particle_multiple_worlds_interpolation/screen-output
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,20 @@ | ||
|
||
Number of active cells: 4 (on 2 levels) | ||
Number of degrees of freedom: 134 (50+9+25+25+25) | ||
|
||
*** Timestep 0: t=0 seconds, dt=0 seconds | ||
Skipping temperature solve because RHS is zero. | ||
Advecting particles... done. | ||
Advecting particles... done. | ||
Solving Stokes system... 9+0 iterations. | ||
|
||
Postprocessing: | ||
RMS, max velocity: 0.00308 m/s, 0.00465 m/s | ||
Compositions min/max/mass: 0.2285/0.6856/0.4527 // 0/0.4999/0.1902 | ||
Number of advected particles 16, 16 | ||
Writing graphical output: output-particle_multiple_worlds_interpolation/solution/solution-00000 | ||
|
||
Termination requested by criterion: end time | ||
|
||
|
||
|
59 changes: 59 additions & 0 deletions
59
tests/particle_multiple_worlds_interpolation/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,23 @@ | ||
# 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 Stokes solver | ||
# 10: Velocity iterations in Stokes preconditioner | ||
# 11: Schur complement iterations in Stokes preconditioner | ||
# 12: RMS velocity (m/s) | ||
# 13: Max. velocity (m/s) | ||
# 14: Minimal value for composition anomaly | ||
# 15: Maximal value for composition anomaly | ||
# 16: Global mass for composition anomaly | ||
# 17: Minimal value for composition function | ||
# 18: Maximal value for composition function | ||
# 19: Global mass for composition function | ||
# 20: Number of advected particles | ||
# 21: Number of advected particles (World 2) | ||
# 22: Visualization file name | ||
0 0.000000000000e+00 0.000000000000e+00 4 59 25 50 0 8 10 10 3.07552704e-03 4.65482045e-03 2.28550000e-01 6.85650000e-01 4.52704222e-01 0.00000000e+00 4.99913963e-01 1.90184427e-01 16 16 output-particle_multiple_worlds_interpolation/solution/solution-00000 |
116 changes: 116 additions & 0 deletions
116
tests/particle_multiple_worlds_interpolation_fail_1.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,116 @@ | ||
# Test that we can activate multiple particle worlds and | ||
# interpolate properties from different particle worlds into | ||
# the compositional fields. This test is supposed to fail | ||
# because one of the necessary particle properties does not | ||
# exist in any particle world. | ||
# | ||
# EXPECT FAILURE | ||
|
||
set Dimension = 2 | ||
set End time = 1 | ||
set Use years in output instead of seconds = false | ||
set Number of particle worlds = 2 | ||
|
||
subsection Geometry model | ||
set Model name = box | ||
|
||
subsection Box | ||
set X extent = 0.9142 | ||
set Y extent = 1.0000 | ||
end | ||
end | ||
|
||
subsection Boundary velocity model | ||
set Tangential velocity boundary indicators = left, right | ||
set Zero velocity boundary indicators = bottom, top | ||
end | ||
|
||
subsection Material model | ||
set Model name = simple | ||
|
||
subsection Simple model | ||
set Reference density = 1010 | ||
set Viscosity = 1e2 | ||
set Thermal expansion coefficient = 0 | ||
set Density differential for compositional field 1 = -10 | ||
end | ||
end | ||
|
||
subsection Gravity model | ||
set Model name = vertical | ||
|
||
subsection Vertical | ||
set Magnitude = 10 | ||
end | ||
end | ||
|
||
############### Parameters describing the temperature field | ||
# Note: The temperature plays no role in this model | ||
|
||
subsection Initial temperature model | ||
set Model name = function | ||
|
||
subsection Function | ||
set Function expression = 0 | ||
end | ||
end | ||
|
||
############### Parameters describing the compositional field | ||
# Note: The compositional field is what drives the flow | ||
# in this example | ||
|
||
subsection Compositional fields | ||
set Number of fields = 2 | ||
set Names of fields = anomaly, function | ||
set Compositional field methods = particles, particles | ||
set Mapped particle properties = anomaly: function, function: initial anomaly | ||
|
||
end | ||
|
||
subsection Initial composition model | ||
set Model name = function | ||
|
||
subsection Function | ||
set Variable names = x,z | ||
set Function constants = pi=3.1415926 | ||
set Function expression = 0.5*(1+tanh((0.2+0.02*cos(pi*x/0.9142)-z)/0.02)); 0.0 | ||
end | ||
end | ||
|
||
############### Parameters describing the discretization | ||
|
||
subsection Mesh refinement | ||
set Initial adaptive refinement = 0 | ||
set Strategy = composition | ||
set Initial global refinement = 4 | ||
set Time steps between mesh refinement = 0 | ||
set Coarsening fraction = 0.05 | ||
set Refinement fraction = 0.3 | ||
end | ||
|
||
############### Parameters describing what to do with the solution | ||
|
||
subsection Postprocess | ||
set List of postprocessors = velocity statistics, composition statistics, particles | ||
|
||
subsection Particles | ||
set Time between data output = 70 | ||
set Data output format = vtu | ||
end | ||
end | ||
|
||
subsection Particles | ||
set List of particle properties = #initial composition | ||
set Particle generator name = reference cell | ||
end | ||
|
||
subsection Particles 2 | ||
set List of particle properties = function | ||
set Particle generator name = reference cell | ||
|
||
subsection Function | ||
set Variable names = x,z | ||
set Function constants = pi=3.1415926 | ||
set Function expression = x | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
tests/particle_multiple_worlds_interpolation_fail_1/screen-output
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 @@ | ||
|
||
Number of active cells: 256 (on 5 levels) | ||
Number of degrees of freedom: 5,734 (2,178+289+1,089+1,089+1,089) | ||
|
||
*** Timestep 0: t=0 seconds, dt=0 seconds | ||
Skipping temperature solve because RHS is zero. | ||
Advecting particles... done. | ||
Advecting particles... done. | ||
|
||
An error occurred in file <initial_conditions.cc> in function | ||
(line in output replaced by default.sh script) | ||
The violated condition was: | ||
advection_field_has_been_found[advection_field] == true | ||
Additional information: | ||
An compositional field is marked as advected by particles, but no | ||
particle property exists that is mapped to this compositional field. | ||
Make sure that the particle property exists and is mapped to the | ||
compositional field in the parameter file. | ||
|
||
Stacktrace: | ||
(rest of the output replaced by default.sh script) |
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.
same here