From 87547641dc46790f342760740704d7749012b8fb Mon Sep 17 00:00:00 2001
From: badia <badia_i@live.fr>
Date: Fri, 21 Jan 2022 09:01:19 +0100
Subject: [PATCH] add a new InterfaceField constructor

---
 src/field/InterfaceField.cpp | 16 ++++++++++++++++
 src/field/InterfaceField.h   |  2 ++
 2 files changed, 18 insertions(+)

diff --git a/src/field/InterfaceField.cpp b/src/field/InterfaceField.cpp
index 87f6213b..dd90c14b 100644
--- a/src/field/InterfaceField.cpp
+++ b/src/field/InterfaceField.cpp
@@ -73,6 +73,22 @@ namespace gmshddm
    }
  }
 
+ template< class T_Scalar, gmshfem::field::Form T_Form >
+ InterfaceField< T_Scalar, T_Form >::InterfaceField(const std::string &name, const domain::Interface &domains, const gmshfem::field::FunctionSpaceOfForm< T_Form > &type,const std::vector<std::vector<unsigned int>> & degree) :
+ InterfaceFieldInterface< T_Scalar >(name), _fields(domains.numberOfSubdomains())
+ {
+
+ if(domains.numberOfSubdomains() > degree.size()) {
+  throw gmshfem::common::Exception("Wrong size of degree");
+ }
+ for(unsigned int i = 0; i < domains.numberOfSubdomains(); ++i) {
+  for(auto it = domains[i].begin(); it != domains[i].end(); ++it) {
+    _fields[i].insert(std::make_pair(it->first, gmshfem::field::Field< T_Scalar, T_Form >(this->_name + "_" + std::to_string(i) + "_" + std::to_string(it->first), it->second, type, degree[i][it->first])));
+
+  }
+ }
+ }
+
     template< class T_Scalar, gmshfem::field::Form T_Form >
     InterfaceField< T_Scalar, T_Form >::InterfaceField(const InterfaceField< T_Scalar, T_Form > &other) :
       InterfaceFieldInterface< T_Scalar >(other._name), _fields(other._fields)
diff --git a/src/field/InterfaceField.h b/src/field/InterfaceField.h
index c728243f..2817bef2 100644
--- a/src/field/InterfaceField.h
+++ b/src/field/InterfaceField.h
@@ -42,6 +42,8 @@ namespace gmshddm
       InterfaceField();
       InterfaceField(const std::string &name, const domain::Interface &domains, const gmshfem::field::FunctionSpaceOfForm< T_Form > &type, const unsigned int degree = 1);
       InterfaceField(const std::string &name, const domain::Interface &domains, const gmshfem::field::FunctionSpaceOfForm< T_Form > &type, const std::vector<unsigned int> & degree);
+
+      InterfaceField(const std::string &name, const domain::Interface &domains, const gmshfem::field::FunctionSpaceOfForm< T_Form > &type, const std::vector<std::vector<unsigned int>> & degree);
       InterfaceField(const InterfaceField< T_Scalar, T_Form > &other);
       InterfaceField(InterfaceField< T_Scalar, T_Form > &&other);
       ~InterfaceField();
-- 
GitLab