Skip to content

Commit

Permalink
Merge branch 'master' into varnurbs-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tzanio committed Jan 10, 2018
2 parents 5ae1cef + 155a5eb commit 0c3d7ad
Show file tree
Hide file tree
Showing 16 changed files with 1,105 additions and 935 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG
Expand Up @@ -10,11 +10,15 @@

Version 3.3.3 (development)
===========================

- Added variable order NURBS: for each space each knot vector in the mesh can
have a different order. The order information is now part of the finite
element space header in the NURBS mesh output, so NURBS meshes in the old
format need to be updated.

- Inherit finite element classes from the new base class TensorBasisElement,
whenever the basis can be represented by a tensor product of 1D bases.

- Added a new developer tool, config/sample-runs.sh, that extracts the sample
runs from all examples and miniapps and runs them. Optionally, it can save the
output from the execution to files, allowing comparison between different
Expand All @@ -38,6 +42,25 @@ Miscellaneous

- Add support for building a shared version of the MFEM library with GNU make.

API changes (that may affect existing code)
-----------
- Introduced a new enum, Matrix::DiagonalPolicy, that replaces the integer
parameters in a number of methods that perform elimination of rows and/or
columns in matrices. Examples of such methods are:
- in class SparseMatrix: EliminateRow(), EliminateCol(), EliminateRowCol(),
EliminateRowColMultipleRHS();
- in class BilinearForm: EliminateEssentialBC(), EliminateVDofs(),
EliminateEssentialBCFromDofs();
- in class StaticCondensation: EliminateReducedTrueDofs();
- in class BlockMatrix: EliminateRowCol().
Any existing code that uses these methods with an explicitly given (integer)
constants, will generate compilation errors - please replace such integers
with one of the new enum constants.

- Modified the virtual method AbstractSparseMatrix::EliminateZeroRows() and its
implementations in derived classes, to accept an optional 'threshold'
parameter, replacing hard-coded threshold values.


Version 3.3.2, released on Nov 10, 2017
=======================================
Expand Down
36 changes: 19 additions & 17 deletions fem/bilinearform.cpp
Expand Up @@ -574,7 +574,7 @@ void BilinearForm::FormSystemMatrix(const Array<int> &ess_tdof_list,
{
// Finish the matrix assembly and perform BC elimination, storing the
// eliminated part of the matrix.
const int keep_diag = 1;
const DiagonalPolicy keep_diag = DIAG_KEEP;
if (static_cond)
{
if (!static_cond->HasEliminatedBC())
Expand Down Expand Up @@ -698,36 +698,36 @@ void BilinearForm::ComputeElementMatrices()
}

void BilinearForm::EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
Vector &sol, Vector &rhs, int d)
Vector &sol, Vector &rhs, DiagonalPolicy dpolicy)
{
Array<int> ess_dofs, conf_ess_dofs;
fes->GetEssentialVDofs(bdr_attr_is_ess, ess_dofs);

if (fes->GetVSize() == height)
{
EliminateEssentialBCFromDofs(ess_dofs, sol, rhs, d);
EliminateEssentialBCFromDofs(ess_dofs, sol, rhs, dpolicy);
}
else
{
fes->GetRestrictionMatrix()->BooleanMult(ess_dofs, conf_ess_dofs);
EliminateEssentialBCFromDofs(conf_ess_dofs, sol, rhs, d);
EliminateEssentialBCFromDofs(conf_ess_dofs, sol, rhs, dpolicy);
}
}

void BilinearForm::EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
int d)
DiagonalPolicy dpolicy)
{
Array<int> ess_dofs, conf_ess_dofs;
fes->GetEssentialVDofs(bdr_attr_is_ess, ess_dofs);

if (fes->GetVSize() == height)
{
EliminateEssentialBCFromDofs(ess_dofs, d);
EliminateEssentialBCFromDofs(ess_dofs, dpolicy);
}
else
{
fes->GetRestrictionMatrix()->BooleanMult(ess_dofs, conf_ess_dofs);
EliminateEssentialBCFromDofs(conf_ess_dofs, d);
EliminateEssentialBCFromDofs(conf_ess_dofs, dpolicy);
}
}

Expand All @@ -749,23 +749,25 @@ void BilinearForm::EliminateEssentialBCDiag (const Array<int> &bdr_attr_is_ess,
}

void BilinearForm::EliminateVDofs(const Array<int> &vdofs,
Vector &sol, Vector &rhs, int d)
Vector &sol, Vector &rhs,
DiagonalPolicy dpolicy)
{
for (int i = 0; i < vdofs.Size(); i++)
{
int vdof = vdofs[i];
if ( vdof >= 0 )
{
mat -> EliminateRowCol (vdof, sol(vdof), rhs, d);
mat -> EliminateRowCol (vdof, sol(vdof), rhs, dpolicy);
}
else
{
mat -> EliminateRowCol (-1-vdof, sol(-1-vdof), rhs, d);
mat -> EliminateRowCol (-1-vdof, sol(-1-vdof), rhs, dpolicy);
}
}
}

void BilinearForm::EliminateVDofs(const Array<int> &vdofs, int d)
void BilinearForm::EliminateVDofs(const Array<int> &vdofs,
DiagonalPolicy dpolicy)
{
if (mat_e == NULL)
{
Expand All @@ -777,17 +779,17 @@ void BilinearForm::EliminateVDofs(const Array<int> &vdofs, int d)
int vdof = vdofs[i];
if ( vdof >= 0 )
{
mat -> EliminateRowCol (vdof, *mat_e, d);
mat -> EliminateRowCol (vdof, *mat_e, dpolicy);
}
else
{
mat -> EliminateRowCol (-1-vdof, *mat_e, d);
mat -> EliminateRowCol (-1-vdof, *mat_e, dpolicy);
}
}
}

void BilinearForm::EliminateEssentialBCFromDofs(
const Array<int> &ess_dofs, Vector &sol, Vector &rhs, int d)
const Array<int> &ess_dofs, Vector &sol, Vector &rhs, DiagonalPolicy dpolicy)
{
MFEM_ASSERT(ess_dofs.Size() == height, "incorrect dof Array size");
MFEM_ASSERT(sol.Size() == height, "incorrect sol Vector size");
Expand All @@ -796,19 +798,19 @@ void BilinearForm::EliminateEssentialBCFromDofs(
for (int i = 0; i < ess_dofs.Size(); i++)
if (ess_dofs[i] < 0)
{
mat -> EliminateRowCol (i, sol(i), rhs, d);
mat -> EliminateRowCol (i, sol(i), rhs, dpolicy);
}
}

void BilinearForm::EliminateEssentialBCFromDofs (const Array<int> &ess_dofs,
int d)
DiagonalPolicy dpolicy)
{
MFEM_ASSERT(ess_dofs.Size() == height, "incorrect dof Array size");

for (int i = 0; i < ess_dofs.Size(); i++)
if (ess_dofs[i] < 0)
{
mat -> EliminateRowCol (i, d);
mat -> EliminateRowCol (i, dpolicy);
}
}

Expand Down
89 changes: 52 additions & 37 deletions fem/bilinearform.hpp
Expand Up @@ -81,7 +81,7 @@ class BilinearForm : public Matrix
}

public:
/// Creates bilinear form associated with FE space *f.
/// Creates bilinear form associated with FE space @a *f.
BilinearForm(FiniteElementSpace *f);

BilinearForm(FiniteElementSpace *f, BilinearForm *bf, int ps = 0);
Expand All @@ -96,7 +96,7 @@ class BilinearForm : public Matrix
void EnableStaticCondensation();

/** Check if static condensation was actually enabled by a previous call to
EnableStaticCondensation. */
EnableStaticCondensation(). */
bool StaticCondensationIsEnabled() const { return static_cond; }

/// Return the trace FE space associated with static condensation.
Expand Down Expand Up @@ -239,38 +239,43 @@ class BilinearForm : public Matrix
virtual const Operator *GetRestriction() const
{ return fes->GetConformingRestriction(); }

/// Form a linear system, A X = B.
/** Form the linear system A X = B, corresponding to the current bilinear
form and b(.), by applying any necessary transformations such as:
eliminating boundary conditions; applying conforming constraints for
non-conforming AMR; static condensation; hybridization.
The GridFunction-size vector x must contain the essential b.c. The
BilinearForm and the LinearForm-size vector b must be assembled.
The GridFunction-size vector @a x must contain the essential b.c. The
BilinearForm and the LinearForm-size vector @a b must be assembled.
The vector X is initialized with a suitable initial guess: when using
hybridization, the vector X is set to zero; otherwise, the essential
entries of X are set to the corresponding b.c. and all other entries are
set to zero (copy_interior == 0) or copied from x (copy_interior != 0).
The vector @a X is initialized with a suitable initial guess: when using
hybridization, the vector @a X is set to zero; otherwise, the essential
entries of @a X are set to the corresponding b.c. and all other entries
are set to zero (@a copy_interior == 0) or copied from @a x
(@a copy_interior != 0).
This method can be called multiple times (with the same ess_tdof_list
This method can be called multiple times (with the same @a ess_tdof_list
array) to initialize different right-hand sides and boundary condition
values.
After solving the linear system, the finite element solution x can be
recovered by calling RecoverFEMSolution (with the same vectors X, b, and
x).
After solving the linear system, the finite element solution @a x can be
recovered by calling RecoverFEMSolution() (with the same vectors @a X,
@a b, and @a x).
NOTE: If there are no transformations, X simply reuses the data of x. */
NOTE: If there are no transformations, @a X simply reuses the data of
@a x. */
void FormLinearSystem(const Array<int> &ess_tdof_list, Vector &x, Vector &b,
SparseMatrix &A, Vector &X, Vector &B,
int copy_interior = 0);

/// Form the linear system matrix A, see FormLinearSystem for details.
/// Form the linear system matrix A, see FormLinearSystem() for details.
void FormSystemMatrix(const Array<int> &ess_tdof_list, SparseMatrix &A);

/// Recover the solution of a linear system formed with FormLinearSystem().
/** Call this method after solving a linear system constructed using the
FormLinearSystem method to recover the solution as a GridFunction-size
vector in x. Use the same arguments as in the FormLinearSystem call. */
FormLinearSystem() method to recover the solution as a GridFunction-size
vector in @a x. Use the same arguments as in the FormLinearSystem() call.
*/
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x);

/// Compute and store internally all element matrices.
Expand All @@ -286,42 +291,52 @@ class BilinearForm : public Matrix
void AssembleBdrElementMatrix(int i, const DenseMatrix &elmat,
Array<int> &vdofs, int skip_zeros = 1);

/** Eliminate essential boundary DOFs from the system. The array
'bdr_attr_is_ess' marks boundary attributes that constitute the essential
part of the boundary. If d == 0, the diagonal at the essential DOFs is
set to 1.0, otherwise it is left the same. */
/// Eliminate essential boundary DOFs from the system.
/** The array @a bdr_attr_is_ess marks boundary attributes that constitute
the essential part of the boundary. By default, the diagonal at the
essential DOFs is set to 1.0. This behavior is controlled by the argument
@a dpolicy. */
void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
Vector &sol, Vector &rhs, int d = 0);
Vector &sol, Vector &rhs,
DiagonalPolicy dpolicy = DIAG_ONE);

void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess, int d = 0);
/// Eliminate essential boundary DOFs from the system matrix.
void EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
DiagonalPolicy dpolicy = DIAG_ONE);
/// Perform elimination and set the diagonal entry to the given value
void EliminateEssentialBCDiag(const Array<int> &bdr_attr_is_ess,
double value);

/// Eliminate the given vdofs. NOTE: here, vdofs is a list of DOFs.
/// Eliminate the given @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
void EliminateVDofs(const Array<int> &vdofs, Vector &sol, Vector &rhs,
int d = 0);
DiagonalPolicy dpolicy = DIAG_ONE);

/** Eliminate the given vdofs storing the eliminated part internally; this
method works in conjunction with EliminateVDofsInRHS and allows
/// Eliminate the given @a vdofs, storing the eliminated part internally.
/** This method works in conjunction with EliminateVDofsInRHS() and allows
elimination of boundary conditions in multiple right-hand sides. In this
method, vdofs is a list of DOFs. */
void EliminateVDofs(const Array<int> &vdofs, int d = 0);

/** Similar to EliminateVDofs but here ess_dofs is a marker
(boolean) array on all vdofs (ess_dofs[i] < 0 is true). */
method, @a vdofs is a list of DOFs. */
void EliminateVDofs(const Array<int> &vdofs,
DiagonalPolicy dpolicy = DIAG_ONE);

/** @brief Similar to
EliminateVDofs(const Array<int> &, Vector &, Vector &, DiagonalPolicy)
but here @a ess_dofs is a marker (boolean) array on all vector-dofs
(@a ess_dofs[i] < 0 is true). */
void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs, Vector &sol,
Vector &rhs, int d = 0);
Vector &rhs, DiagonalPolicy dpolicy = DIAG_ONE);

/** Similar to EliminateVDofs but here ess_dofs is a marker
(boolean) array on all vdofs (ess_dofs[i] < 0 is true). */
void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs, int d = 0);
/** @brief Similar to EliminateVDofs(const Array<int> &, DiagonalPolicy) but
here @a ess_dofs is a marker (boolean) array on all vector-dofs
(@a ess_dofs[i] < 0 is true). */
void EliminateEssentialBCFromDofs(const Array<int> &ess_dofs,
DiagonalPolicy dpolicy = DIAG_ONE);
/// Perform elimination and set the diagonal entry to the given value
void EliminateEssentialBCFromDofsDiag(const Array<int> &ess_dofs,
double value);

/** Use the stored eliminated part of the matrix (see EliminateVDofs) to
modify r.h.s.; vdofs is a list of DOFs (non-directional, i.e. >= 0). */
/** @brief Use the stored eliminated part of the matrix (see
EliminateVDofs(const Array<int> &, DiagonalPolicy)) to modify the r.h.s.
@a b; @a vdofs is a list of DOFs (non-directional, i.e. >= 0). */
void EliminateVDofsInRHS(const Array<int> &vdofs, const Vector &x,
Vector &b);

Expand Down

0 comments on commit 0c3d7ad

Please sign in to comment.