Skip to content

Commit

Permalink
Add test for bilinear least squares particle interpolation scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
hlokavarapu committed May 13, 2017
1 parent dfd3447 commit 6bea2d6
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 147 deletions.
30 changes: 14 additions & 16 deletions source/particle/interpolator/bilinear_least_squares.cc
Expand Up @@ -99,8 +99,8 @@ namespace aspect
A = 0;
r = 0;

// double max_value_for_particle_property = (particle_range.first)->second.get_properties()[property_index];
// double min_value_for_particle_property = (particle_range.first)->second.get_properties()[property_index];
double max_value_for_particle_property = (particle_range.first)->second.get_properties()[property_index];
double min_value_for_particle_property = (particle_range.first)->second.get_properties()[property_index];

unsigned int index = 0;
const double cell_diameter = found_cell->diameter();
Expand All @@ -116,10 +116,10 @@ namespace aspect
A(index,2) = (position[1] - approximated_cell_midpoint[1])/cell_diameter;
A(index,3) = (position[0] - approximated_cell_midpoint[0]) * (position[1] - approximated_cell_midpoint[1])/std::pow(cell_diameter,2);

// if (max_value_for_particle_property < particle_property_value)
// max_value_for_particle_property = particle_property_value;
// if (min_value_for_particle_property > particle_property_value)
// min_value_for_particle_property = particle_property_value;
if (min_value_for_particle_property > particle_property_value)
min_value_for_particle_property = particle_property_value;
if (max_value_for_particle_property < particle_property_value)
max_value_for_particle_property = particle_property_value;
}

dealii::LAPACKFullMatrix<double> B(matrix_dimension, matrix_dimension);
Expand Down Expand Up @@ -147,18 +147,16 @@ namespace aspect
const Point<dim> support_point = *itr;
// TODO: Removed const
double interpolated_value = c[0] +
c[1]*(support_point[0] - approximated_cell_midpoint[0])/cell_diameter +
c[2]*(support_point[1] - approximated_cell_midpoint[1])/cell_diameter +
c[3]*(support_point[0] - approximated_cell_midpoint[0])*(support_point[1] - approximated_cell_midpoint[1])/std::pow(cell_diameter,2);

// if (interpolated_value > max_value_for_particle_property)
// interpolated_value = max_value_for_particle_property;
// else if (interpolated_value < min_value_for_particle_property)
// interpolated_value = min_value_for_particle_property;


c[1]*(support_point[0] - approximated_cell_midpoint[0])/cell_diameter +
c[2]*(support_point[1] - approximated_cell_midpoint[1])/cell_diameter +
c[3]*(support_point[0] - approximated_cell_midpoint[0])*(support_point[1] - approximated_cell_midpoint[1])/std::pow(cell_diameter,2);

cell_properties[index_positions][property_index] = interpolated_value;

if (interpolated_value > max_value_for_particle_property)
interpolated_value = max_value_for_particle_property;
else if (interpolated_value < min_value_for_particle_property)
interpolated_value = min_value_for_particle_property;
}
return cell_properties;
}
Expand Down
131 changes: 0 additions & 131 deletions tests/particle_interpolator_bilinear.prm

This file was deleted.

2 changes: 2 additions & 0 deletions tests/particle_interpolator_bilinear_solkz.cc
@@ -0,0 +1,2 @@
#include "../benchmarks/solkz/compositional_fields/solkz_compositional_fields.cc"

117 changes: 117 additions & 0 deletions tests/particle_interpolator_bilinear_solkz.prm
@@ -0,0 +1,117 @@
# A description of the SolKZ benchmark using active particles
# to interpolate both density and viscosity onto the compositional
# fields for which a known solution is available. See the manual
# for more information.

set Additional shared libraries = ./libparticle_interpolator_bilinear_solkz.so

############### Global parameters

set Dimension = 2

set Start time = 0
set End time = 0

set Output directory = output

set Pressure normalization = volume

############### Parameters describing the model

subsection Geometry model
set Model name = box

subsection Box
set X extent = 1
set Y extent = 1
end
end

subsection Model settings
set Prescribed velocity boundary indicators =
set Tangential velocity boundary indicators = left, right, bottom, top
set Zero velocity boundary indicators =
end

subsection Material model
set Model name = SolKzCompositionalMaterial
end

subsection Gravity model
set Model name = vertical
end

############### Parameters describing the temperature field

subsection Boundary temperature model
set Model name = box
end

subsection Initial temperature model
set Model name = perturbed box
end

############### Parameters describing the discretization

subsection Discretization
set Stokes velocity polynomial degree = 2
set Use locally conservative discretization = false
set Use discontinuous composition discretization = true
end

subsection Mesh refinement
set Initial adaptive refinement = 0
set Initial global refinement = 5
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 = density_comp, viscosity_comp
set Compositional field methods = particles, particles
set Mapped particle properties = density_comp:function[0], viscosity_comp:function[1]
end

subsection Initial composition model
set Model name = function
subsection Function
set Variable names = x,z
set Function constants = pi=3.1415926, eta_b=1e6
set Function expression = -1 * sin(2*z) * cos(3*pi*x); exp(log(eta_b)*z)
end
end

############### Parameters describing what to do with the solution

subsection Postprocess
set List of postprocessors = particles, SolKzPostprocessor

subsection Particles
set Number of particles = 16384
set Time between data output = 0
set Data output format = vtu
set List of particle properties = function
set Integration scheme = rk2
set Interpolation scheme = cell average
set Maximum particles per cell = 16384
set Update ghost particles = true

subsection Function
set Number of components = 2
set Variable names = x, z
set Function constants = pi=3.1415926, eta_b=1e6
set Function expression = -1 * sin(2*z) * cos(3*pi*x); exp(log(eta_b)*z)
end

set Particle generator name = reference cell

subsection Generator
subsection Reference cell
set Number of particles per cell per direction = 4
end
end
end
end
24 changes: 24 additions & 0 deletions tests/particle_interpolator_bilinear_solkz/screen-output
@@ -0,0 +1,24 @@
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

Loading shared library <./libparticle_interpolator_bilinear_solkz.so>

Number of active cells: 1,024 (on 6 levels)
Number of degrees of freedom: 32,196 (8,450+1,089+4,225+9,216+9,216)

*** Timestep 0: t=0 years
Skipping temperature solve because RHS is zero.
Rebuilding Stokes preconditioner...
Solving Stokes system... 46+0 iterations.

Postprocessing:
Writing particle output: output-particle_interpolator_bilinear_solkz/particles/particles-00000
Errors u_L1, p_L1, u_L2, p_L2: 2.396693e-07, 3.813761e-04, 3.798509e-07, 1.430329e-03

Termination requested by criterion: end time


+---------------------------------------------+------------+------------+
+---------------------------------+-----------+------------+------------+
+---------------------------------+-----------+------------+------------+

14 changes: 14 additions & 0 deletions tests/particle_interpolator_bilinear_solkz/statistics
@@ -0,0 +1,14 @@
# 1: Time step number
# 2: Time (years)
# 3: Time step size (years)
# 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: Number of advected particles
# 13: Particle file name
0 0.000000000000e+00 0.000000000000e+00 1024 9539 4225 18432 0 46 47 46 16384 output-particle_interpolator_bilinear_solkz/output-particle_interpolator_bilinear_solkz/particles/particles-00000

0 comments on commit 6bea2d6

Please sign in to comment.