20 #include "pism/util/fem/DirichletData.hh"
22 #include "pism/util/array/Scalar.hh"
23 #include "pism/util/array/Vector.hh"
24 #include "pism/util/Context.hh"
25 #include "pism/util/error_handling.hh"
26 #include "pism/util/Context.hh"
32 : m_indices(NULL), m_weight(1.0) {
47 if (indices != NULL) {
69 MPI_Comm com = values->
grid()->ctx()->com();
104 for (
int k = 0;
k < element.
n_chi();
k++) {
108 x_nodal[
k] = (*m_values)(i, j);
115 for (
int k = 0;
k < element.
n_chi();
k++) {
129 const int i = p.i(), j = p.j();
133 r_global[j][i] =
m_weight * (x_global[j][i] - (*m_values)(i,j));
143 const int i = p.i(), j = p.j();
147 r_global[j][i] = 0.0;
165 const int i = p.i(), j = p.j();
171 PetscErrorCode ierr = MatSetValuesBlockedStencil(
J, 1, &
row, 1, &
row, &identity,
173 PISM_CHK(ierr,
"MatSetValuesBlockedStencil");
200 for (
int k = 0;
k < element.
n_chi();
k++) {
204 x_nodal[
k] = (*m_values)(i, j);
211 for (
int k = 0;
k < element.
n_chi();
k++) {
225 const int i = p.i(), j = p.j();
229 r_global[j][i] =
m_weight * (x_global[j][i] - (*m_values)(i, j));
239 const int i = p.i(), j = p.j();
243 r_global[j][i].
u = 0.0;
244 r_global[j][i].
v = 0.0;
258 const double identity[4] = {
m_weight, 0,
263 const int i = p.i(), j = p.j();
269 PetscErrorCode ierr = MatSetValuesBlockedStencil(
J, 1, &
row, 1, &
row, identity,
271 PISM_CHK(ierr,
"MatSetValuesBlockedStencil");
PointsWithGhosts points(unsigned int stencil_width=0) const
Describes the PISM grid and the distribution of data across processors.
void failed()
Indicates a failure of a parallel section.
This class represents a 2D vector field (such as ice velocity) at a certain grid point.
virtual void end_access() const
Checks if an Array is allocated and calls DAVecRestoreArray.
virtual void begin_access() const
Checks if an Array is allocated and calls DAVecGetArray.
std::shared_ptr< const Grid > grid() const
Abstract class for reading, writing, allocating, and accessing a DA-based PETSc Vec (2D and 3D fields...
void enforce_homogeneous(const Element2 &element, double *x_e)
void fix_residual(double const *const *const x_global, double **r_global)
void fix_residual_homogeneous(double **r_global)
const array::Scalar * m_values
DirichletData_Scalar(const array::Scalar *indices, const array::Scalar *values, double weight=1.0)
void enforce(const Element2 &element, double *x_e)
void fix_residual(Vector2d const *const *const x_global, Vector2d **r_global)
DirichletData_Vector(const array::Scalar *indices, const array::Vector *values, double weight)
void enforce(const Element2 &element, Vector2d *x_e)
void fix_residual_homogeneous(Vector2d **r)
void enforce_homogeneous(const Element2 &element, Vector2d *x_e)
const array::Vector * m_values
double m_indices_e[q1::n_chi]
void finish(const array::Array *values)
void init(const array::Scalar *indices, const array::Array *values, double weight=1.0)
const array::Scalar * m_indices
void constrain(Element2 &element)
Constrain element, i.e. ensure that quadratures do not contribute to Dirichlet nodes by marking corre...
void local_to_global(unsigned int k, int &i, int &j) const
Convert a local degree of freedom index k to a global degree of freedom index (i,j).
void mark_row_invalid(unsigned int k)
Mark that the row corresponding to local degree of freedom k should not be updated when inserting int...
void nodal_values(const array::Scalar &x_global, int *result) const
Get nodal values of an integer mask.
void mark_col_invalid(unsigned int k)
Mark that the column corresponding to local degree of freedom k should not be updated when inserting ...
#define PISM_CHK(errcode, name)
static Vector3 row(const double A[3][3], size_t k)
static int weight(int M_ij, int M_n, double h_ij, double h_n)
void handle_fatal_errors(MPI_Comm com)