From aae3df2d26d8e243e410ff05c9fbf36179b6125b Mon Sep 17 00:00:00 2001
From: Eric Bechet <eric.bechet@ulg.ac.be>
Date: Tue, 20 Oct 2009 21:33:17 +0000
Subject: [PATCH]

---
 contrib/arc/highlevel.h        | 34 ++++++++++++++++++++++++++++++++--
 contrib/arc/mainElasticity.cpp |  2 +-
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/contrib/arc/highlevel.h b/contrib/arc/highlevel.h
index bbe919d35e..8ed6d0ab49 100644
--- a/contrib/arc/highlevel.h
+++ b/contrib/arc/highlevel.h
@@ -31,20 +31,24 @@ template<class T> struct TensorialTraits
   typedef T ValType;
   typedef T GradType[3];
   typedef T HessType[3][3];
+  static const int nb_basis_vectors=1; // par défaut considéré comme un scalaire
 };
 
-/*template<> struct TensorialTraits<double>
+template<> struct TensorialTraits<double>
 {
   typedef double ValType;
   typedef Vector GradType;
   typedef Tensor2 HessType;
+  static const int nb_basis_vectors=1; // scalaire
 };
 
+/*
 template<> struct TensorialTraits<Vector>
 {
   typedef Vector ValType;
   typedef Tensor2 GradType;
   typedef Tensor3 HessType;
+  static const int nb_basis_vectors=3; // trois vecteurs de base linéairement indépendants.
 };
 */
 
@@ -61,7 +65,7 @@ public:
 class SpaceBase // renvoie des clefs de dofs
 {
 public:
-  virtual void getDofs(MElement *e,std::vector<Dof> &vecD){};//=0;
+  virtual void getDofs(MElement *e,std::vector<Dof> &vecD)=0;
 };
 
 template<class T> class Space : public SpaceBase // renvoie des clefs de dofs et des fonctions de formes
@@ -74,6 +78,32 @@ public:
 };
 
 
+template<class T> class SpaceLagrange : public Space<T> //  approximation Lagrange ...
+{
+private:
+  int _iField;
+  Dof getLocalDof(MElement *e, int i) const
+  {
+    int iComp = i / e->getNumVertices();
+    int ithLocalVertex = i % e->getNumVertices();
+    return Dof(e->getVertex(ithLocalVertex)->getNum(),
+                Dof::createTypeWithTwoInts(iComp, _iField));
+  }
+
+public: 
+  SpaceLagrange(int iField):_iField(iField){};
+  virtual ~SpaceLagrange(){};
+  virtual void getDofsandSFs(MElement *e,std::vector<std::pair< Dof, Function<T>* > > &vecDFF){}
+  virtual void getSFs(std::vector<std::pair< Dof, Function<T>* > > &vecDFF){};//=0;
+  virtual void getDofs(MElement *e,std::vector<Dof> &vecD)
+  {
+    int ndofs= e->getNumVertices()*TensorialTraits<T>::nb_basis_vectors;
+    for (int i=0;i<ndofs;++i)
+    vecD.push_back(getLocalDof(e,i));
+  }
+};
+
+
 template<class T> class Field : public Function<T> // renvoie des valeurs de champ (ff*valeurs dofs), gradient , etc...
 {
 public: 
diff --git a/contrib/arc/mainElasticity.cpp b/contrib/arc/mainElasticity.cpp
index 5edae94b70..e39b9fe411 100644
--- a/contrib/arc/mainElasticity.cpp
+++ b/contrib/arc/mainElasticity.cpp
@@ -21,7 +21,7 @@ int main (int argc, char* argv[])
   fnl.func();
   fnl.func2();
   
-  
+  SpaceLagrange<double> L(123);
 
   // globals are still present in Gmsh
   GmshInitialize(argc, argv);
-- 
GitLab