-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5902 from danieldouglas92/fluid_velocity_postproc…
…essor Add fluid velocity postprocessor
- Loading branch information
Showing
8 changed files
with
300 additions
and
5 deletions.
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,7 @@ | ||
Added: A postprocessor 'darcy velocity' that visualizes the fluid | ||
velocity in models with a compositional field named 'porosity'. | ||
This postprocessor is independent of the method the porosity is actually | ||
advected with, i.e. it could be static, advected with the Darcy velocity, | ||
or advected according to the two-phase flow equations. | ||
<br> | ||
(Daniel Douglas, 2024/06/13) |
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,57 @@ | ||
/* | ||
Copyright (C) 2011 - 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/>. | ||
*/ | ||
|
||
|
||
#ifndef _aspect_postprocess_visualization_darcy_velocity_h | ||
#define _aspect_postprocess_visualization_darcy_velocity_h | ||
|
||
#include <aspect/postprocess/visualization.h> | ||
#include <aspect/simulator_access.h> | ||
|
||
#include <deal.II/numerics/data_postprocessor.h> | ||
|
||
|
||
namespace aspect | ||
{ | ||
namespace Postprocess | ||
{ | ||
namespace VisualizationPostprocessors | ||
{ | ||
template <int dim> | ||
class DarcyVelocity | ||
: public DataPostprocessorVector<dim>, | ||
public SimulatorAccess<dim>, | ||
public Interface<dim> | ||
{ | ||
public: | ||
DarcyVelocity (); | ||
|
||
void | ||
evaluate_vector_field(const DataPostprocessorInputs::Vector<dim> &input_data, | ||
std::vector<Vector<double>> &computed_quantities) const override; | ||
|
||
std::string | ||
get_physical_units () const override; | ||
}; | ||
} | ||
} | ||
} | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
Copyright (C) 2011 - 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/postprocess/visualization/darcy_velocity.h> | ||
#include <aspect/utilities.h> | ||
#include <aspect/melt.h> | ||
#include <aspect/simulator.h> | ||
|
||
namespace aspect | ||
{ | ||
namespace Postprocess | ||
{ | ||
namespace VisualizationPostprocessors | ||
{ | ||
template <int dim> | ||
DarcyVelocity<dim>:: | ||
DarcyVelocity () | ||
: | ||
DataPostprocessorVector<dim> ("darcy_velocity", | ||
update_values | update_quadrature_points | update_gradients), | ||
Interface<dim>() | ||
{} | ||
|
||
|
||
|
||
template <int dim> | ||
std::string | ||
DarcyVelocity<dim>:: | ||
get_physical_units () const | ||
{ | ||
if (this->convert_output_to_years()) | ||
return "m/year"; | ||
else | ||
return "m/s"; | ||
} | ||
|
||
|
||
|
||
template <int dim> | ||
void | ||
DarcyVelocity<dim>:: | ||
evaluate_vector_field(const DataPostprocessorInputs::Vector<dim> &input_data, | ||
std::vector<Vector<double>> &computed_quantities) const | ||
{ | ||
AssertThrow(this->introspection().compositional_name_exists("porosity"), | ||
ExcMessage("The 'darcy velocity' postprocessor requires a compositional " | ||
"field called porosity.")); | ||
|
||
const unsigned int porosity_idx = this->introspection().find_composition_type(CompositionalFieldDescription::porosity); | ||
|
||
const double velocity_scaling_factor = | ||
this->convert_output_to_years() ? year_in_seconds : 1.0; | ||
|
||
MaterialModel::MaterialModelInputs<dim> in(input_data, this->introspection()); | ||
MaterialModel::MaterialModelOutputs<dim> out(in.n_evaluation_points(), this->n_compositional_fields()); | ||
MeltHandler<dim>::create_material_model_outputs(out); | ||
this->get_material_model().evaluate(in, out); | ||
MaterialModel::MeltOutputs<dim> *fluid_out = out.template get_additional_output<MaterialModel::MeltOutputs<dim>>(); | ||
AssertThrow(std::isfinite(fluid_out->fluid_viscosities[0]), | ||
ExcMessage("To compute the Darcy velocity the material model needs to provide the melt material model " | ||
"outputs. At least the fluid viscosity was not computed, or is not a number.")); | ||
|
||
for (unsigned int q=0; q<in.n_evaluation_points(); ++q) | ||
{ | ||
const double porosity = std::max(in.composition[q][porosity_idx], 1e-10); | ||
const Tensor<1,dim> gravity = this->get_gravity_model().gravity_vector(in.position[q]); | ||
const double solid_density = out.densities[q]; | ||
const double fluid_viscosity = fluid_out->fluid_viscosities[q]; | ||
const double fluid_density = fluid_out->fluid_densities[q]; | ||
const double permeability = fluid_out->permeabilities[q]; | ||
const Tensor<1,dim> solid_velocity = in.velocity[q]; | ||
const Tensor<1,dim> darcy_velocity = solid_velocity - | ||
permeability / fluid_viscosity / porosity * gravity * | ||
(solid_density - fluid_density) * velocity_scaling_factor; | ||
|
||
for (unsigned int k=0; k<dim; ++k) | ||
computed_quantities[q](k) = darcy_velocity[k]; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
// explicit instantiations | ||
namespace aspect | ||
{ | ||
namespace Postprocess | ||
{ | ||
namespace VisualizationPostprocessors | ||
{ | ||
ASPECT_REGISTER_VISUALIZATION_POSTPROCESSOR(DarcyVelocity, | ||
"darcy velocity", | ||
"A visualization output object that outputs the Darcy velocity " | ||
"vector. This postprocessor requires a compositional field named " | ||
"'porosity'." | ||
"\n\n" | ||
"Physical units: $\\frac{\\text{m}}{\\text{s}}$ or " | ||
"$\\frac{\\text{m}}{\\text{year}}$, depending on settings in the input 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
Number of active cells: 4 (on 2 levels) | ||
Number of degrees of freedom: 134 (50+9+25+25+25) | ||
|
||
*** Timestep 0: t=0 years, dt=0 years | ||
Solving temperature system... 0 iterations. | ||
Solving porosity system ... 0 iterations. | ||
Skipping bound_fluid composition solve because RHS is zero. | ||
Solving Stokes system... 7+0 iterations. | ||
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 6.2054e-17, 1.34414e-16, 0, 5.09696e-16 | ||
Relative nonlinear residual (total system) after nonlinear iteration 1: 5.09696e-16 | ||
|
||
|
||
Postprocessing: | ||
Writing graphical output: output-darcy_convection_step/solution/solution-00000 | ||
|
||
*** Timestep 1: t=103.11 years, dt=103.11 years | ||
Solving composition reactions... in 1 substep(s). | ||
Solving temperature system... 0 iterations. | ||
Solving porosity system ... 0 iterations. | ||
Skipping bound_fluid composition solve because RHS is zero. | ||
Solving Stokes system... 6+0 iterations. | ||
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 3.51395e-16, 1.5726e-16, 0, 2.2185e-16 | ||
Relative nonlinear residual (total system) after nonlinear iteration 1: 3.51395e-16 | ||
|
||
|
||
Postprocessing: | ||
|
||
*** Timestep 2: t=200 years, dt=96.8895 years | ||
Solving composition reactions... in 1 substep(s). | ||
Solving temperature system... 0 iterations. | ||
Solving porosity system ... 0 iterations. | ||
Skipping bound_fluid composition solve because RHS is zero. | ||
Solving Stokes system... 7+0 iterations. | ||
Relative nonlinear residuals (temperature, compositional fields, Stokes system): 1.14854e-16, 1.32969e-16, 0, 3.48944e-16 | ||
Relative nonlinear residual (total system) after nonlinear iteration 1: 3.48944e-16 | ||
|
||
|
||
Postprocessing: | ||
|
||
Termination requested by criterion: end time | ||
|
||
|
||
|
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
59 changes: 59 additions & 0 deletions
59
tests/darcy_convection_step/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