]> https://gitweb.dealii.org/ - dealii.git/commitdiff
simplex: compare_for_domination 11527/head
authorMarc Fehling <mafehling.git@gmail.com>
Thu, 14 Jan 2021 03:02:19 +0000 (20:02 -0700)
committerMarc Fehling <mafehling.git@gmail.com>
Thu, 14 Jan 2021 03:15:25 +0000 (20:15 -0700)
source/fe/fe_dgq.cc
source/fe/fe_q.cc
source/simplex/fe_lib.cc

index d5ff7a977a3e9e5d5cafa14bc9822fded5724882..f75719806e9d030b654bb3c2cca3b6bff1f9a2c0 100644 (file)
@@ -30,6 +30,8 @@
 
 #include <deal.II/lac/vector.h>
 
+#include <deal.II/simplex/fe_lib.h>
+
 #include <iostream>
 #include <memory>
 #include <sstream>
@@ -694,6 +696,16 @@ FE_DGQ<dim, spacedim>::compare_for_domination(
       else
         return FiniteElementDomination::other_element_dominates;
     }
+  else if (const Simplex::FE_DGP<dim, spacedim> *fe_dgp_other =
+             dynamic_cast<const Simplex::FE_DGP<dim, spacedim> *>(&fe_other))
+    {
+      if (this->degree < fe_dgp_other->degree)
+        return FiniteElementDomination::this_element_dominates;
+      else if (this->degree == fe_dgp_other->degree)
+        return FiniteElementDomination::either_element_can_dominate;
+      else
+        return FiniteElementDomination::other_element_dominates;
+    }
   else if (const FE_Nothing<dim> *fe_nothing =
              dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
     {
index b851a3e5a7721164b534b12bb89d1960797c0efa..607e267e3bfeb0d7f52d5f3911d23b300c2a9ec2 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <deal.II/lac/vector.h>
 
+#include <deal.II/simplex/fe_lib.h>
+
 #include <memory>
 #include <sstream>
 #include <vector>
@@ -206,6 +208,37 @@ FE_Q<dim, spacedim>::compare_for_domination(
       else
         return FiniteElementDomination::other_element_dominates;
     }
+  else if (const Simplex::FE_P<dim, spacedim> *fe_p_other =
+             dynamic_cast<const Simplex::FE_P<dim, spacedim> *>(&fe_other))
+    {
+      if (this->degree < fe_p_other->degree)
+        return FiniteElementDomination::this_element_dominates;
+      else if (this->degree == fe_p_other->degree)
+        return FiniteElementDomination::either_element_can_dominate;
+      else
+        return FiniteElementDomination::other_element_dominates;
+    }
+  else if (const Simplex::FE_WedgeP<dim, spacedim> *fe_wp_other =
+             dynamic_cast<const Simplex::FE_WedgeP<dim, spacedim> *>(&fe_other))
+    {
+      if (this->degree < fe_wp_other->degree)
+        return FiniteElementDomination::this_element_dominates;
+      else if (this->degree == fe_wp_other->degree)
+        return FiniteElementDomination::either_element_can_dominate;
+      else
+        return FiniteElementDomination::other_element_dominates;
+    }
+  else if (const Simplex::FE_PyramidP<dim, spacedim> *fe_pp_other =
+             dynamic_cast<const Simplex::FE_PyramidP<dim, spacedim> *>(
+               &fe_other))
+    {
+      if (this->degree < fe_pp_other->degree)
+        return FiniteElementDomination::this_element_dominates;
+      else if (this->degree == fe_pp_other->degree)
+        return FiniteElementDomination::either_element_can_dominate;
+      else
+        return FiniteElementDomination::other_element_dominates;
+    }
   else if (const FE_Nothing<dim, spacedim> *fe_nothing =
              dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other))
     {
index 78bfcdd0f0f1614ea259cbb8a1e76753401a36d5..1327c9f977ef3ab37825971acd8c9cb12e1f9af4 100644 (file)
@@ -16,6 +16,7 @@
 #include <deal.II/base/config.h>
 
 #include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_nothing.h>
 #include <deal.II/fe/fe_q.h>
 #include <deal.II/fe/fe_tools.h>
 
@@ -434,15 +435,55 @@ namespace Simplex
     const FiniteElement<dim, spacedim> &fe_other,
     const unsigned int                  codim) const
   {
-    (void)fe_other;
-    (void)codim;
-
-    Assert((dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other)),
-           ExcNotImplemented());
-    AssertDimension(dim, 2);
-    AssertDimension(this->degree, fe_other.tensor_degree());
+    Assert(codim <= dim, ExcImpossibleInDim(dim));
+
+    // vertex/line/face domination
+    // (if fe_other is derived from FE_DGP)
+    // ------------------------------------
+    if (codim > 0)
+      if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
+        // there are no requirements between continuous and discontinuous
+        // elements
+        return FiniteElementDomination::no_requirements;
+
+    // vertex/line/face domination
+    // (if fe_other is not derived from FE_DGP)
+    // & cell domination
+    // ----------------------------------------
+    if (const FE_P<dim, spacedim> *fe_p_other =
+          dynamic_cast<const FE_P<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_p_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_p_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Q<dim, spacedim> *fe_q_other =
+               dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_q_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_q_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Nothing<dim, spacedim> *fe_nothing =
+               dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other))
+      {
+        if (fe_nothing->is_dominating())
+          return FiniteElementDomination::other_element_dominates;
+        else
+          // the FE_Nothing has no degrees of freedom and it is typically used
+          // in a context where we don't require any continuity along the
+          // interface
+          return FiniteElementDomination::no_requirements;
+      }
 
-    return FiniteElementDomination::either_element_can_dominate;
+    Assert(false, ExcNotImplemented());
+    return FiniteElementDomination::neither_element_dominates;
   }
 
 
@@ -521,15 +562,52 @@ namespace Simplex
     const FiniteElement<dim, spacedim> &fe_other,
     const unsigned int                  codim) const
   {
-    (void)fe_other;
-    (void)codim;
-
-    Assert((dynamic_cast<const FE_DGQ<dim, spacedim> *>(&fe_other)),
-           ExcNotImplemented());
-    AssertDimension(dim, 2);
-    AssertDimension(this->degree, fe_other.tensor_degree());
+    Assert(codim <= dim, ExcImpossibleInDim(dim));
+
+    // vertex/line/face domination
+    // ---------------------------
+    if (codim > 0)
+      // this is a discontinuous element, so by definition there will
+      // be no constraints wherever this element comes together with
+      // any other kind of element
+      return FiniteElementDomination::no_requirements;
+
+    // cell domination
+    // ---------------
+    if (const FE_DGP<dim, spacedim> *fe_dgp_other =
+          dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_dgp_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_dgp_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_DGQ<dim, spacedim> *fe_dgq_other =
+               dynamic_cast<const FE_DGQ<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_dgq_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_dgq_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Nothing<dim, spacedim> *fe_nothing =
+               dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other))
+      {
+        if (fe_nothing->is_dominating())
+          return FiniteElementDomination::other_element_dominates;
+        else
+          // the FE_Nothing has no degrees of freedom and it is typically used
+          // in a context where we don't require any continuity along the
+          // interface
+          return FiniteElementDomination::no_requirements;
+      }
 
-    return FiniteElementDomination::either_element_can_dominate;
+    Assert(false, ExcNotImplemented());
+    return FiniteElementDomination::neither_element_dominates;
   }
 
 
@@ -630,14 +708,66 @@ namespace Simplex
     const FiniteElement<dim, spacedim> &fe_other,
     const unsigned int                  codim) const
   {
-    (void)fe_other;
-    (void)codim;
-
-    Assert((dynamic_cast<const Simplex::FE_P<dim, spacedim> *>(&fe_other)) ||
-             (dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other)),
-           ExcNotImplemented());
+    Assert(codim <= dim, ExcImpossibleInDim(dim));
+
+    // vertex/line/face domination
+    // (if fe_other is derived from FE_DGP)
+    // ------------------------------------
+    if (codim > 0)
+      if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
+        // there are no requirements between continuous and discontinuous
+        // elements
+        return FiniteElementDomination::no_requirements;
+
+
+    // vertex/line/face domination
+    // (if fe_other is not derived from FE_DGP)
+    // & cell domination
+    // ----------------------------------------
+    if (const FE_WedgeP<dim, spacedim> *fe_wp_other =
+          dynamic_cast<const FE_WedgeP<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_wp_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_wp_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_P<dim, spacedim> *fe_p_other =
+               dynamic_cast<const FE_P<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_p_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_p_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Q<dim, spacedim> *fe_q_other =
+               dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_q_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_q_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Nothing<dim> *fe_nothing =
+               dynamic_cast<const FE_Nothing<dim> *>(&fe_other))
+      {
+        if (fe_nothing->is_dominating())
+          return FiniteElementDomination::other_element_dominates;
+        else
+          // the FE_Nothing has no degrees of freedom and it is typically used
+          // in a context where we don't require any continuity along the
+          // interface
+          return FiniteElementDomination::no_requirements;
+      }
 
-    return FiniteElementDomination::this_element_dominates;
+    Assert(false, ExcNotImplemented());
+    return FiniteElementDomination::neither_element_dominates;
   }
 
 
@@ -812,14 +942,65 @@ namespace Simplex
     const FiniteElement<dim, spacedim> &fe_other,
     const unsigned int                  codim) const
   {
-    (void)fe_other;
-    (void)codim;
-
-    Assert((dynamic_cast<const Simplex::FE_P<dim, spacedim> *>(&fe_other)) ||
-             (dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other)),
-           ExcNotImplemented());
+    Assert(codim <= dim, ExcImpossibleInDim(dim));
+
+    // vertex/line/face domination
+    // (if fe_other is derived from FE_DGP)
+    // ------------------------------------
+    if (codim > 0)
+      if (dynamic_cast<const FE_DGP<dim, spacedim> *>(&fe_other) != nullptr)
+        // there are no requirements between continuous and discontinuous
+        // elements
+        return FiniteElementDomination::no_requirements;
+
+    // vertex/line/face domination
+    // (if fe_other is not derived from FE_DGP)
+    // & cell domination
+    // ----------------------------------------
+    if (const FE_PyramidP<dim, spacedim> *fe_pp_other =
+          dynamic_cast<const FE_PyramidP<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_pp_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_pp_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_P<dim, spacedim> *fe_p_other =
+               dynamic_cast<const FE_P<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_p_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_p_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Q<dim, spacedim> *fe_q_other =
+               dynamic_cast<const FE_Q<dim, spacedim> *>(&fe_other))
+      {
+        if (this->degree < fe_q_other->degree)
+          return FiniteElementDomination::this_element_dominates;
+        else if (this->degree == fe_q_other->degree)
+          return FiniteElementDomination::either_element_can_dominate;
+        else
+          return FiniteElementDomination::other_element_dominates;
+      }
+    else if (const FE_Nothing<dim, spacedim> *fe_nothing =
+               dynamic_cast<const FE_Nothing<dim, spacedim> *>(&fe_other))
+      {
+        if (fe_nothing->is_dominating())
+          return FiniteElementDomination::other_element_dominates;
+        else
+          // the FE_Nothing has no degrees of freedom and it is typically used
+          // in a context where we don't require any continuity along the
+          // interface
+          return FiniteElementDomination::no_requirements;
+      }
 
-    return FiniteElementDomination::this_element_dominates;
+    Assert(false, ExcNotImplemented());
+    return FiniteElementDomination::neither_element_dominates;
   }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.