[Getfem-commits] [getfem-commits] devel-logari81-internal-variables updated (afe03f8 -> d788e47)

2020-01-06 Thread Konstantinos Poulios via Getfem-commits
logari81 pushed a change to branch devel-logari81-internal-variables.

from afe03f8  adding a test
 new d56812c  Basic infrastructure for defining internal variables
 new d788e47  Remove replaced assembly instruction class


Summary of changes:
 src/getfem/getfem_generic_assembly.h| 14 +++-
 src/getfem/getfem_models.h  | 72 ---
 src/getfem_generic_assembly_compile_and_exec.cc | 96 ++---
 src/getfem_generic_assembly_workspace.cc| 36 +-
 src/getfem_models.cc| 39 ++
 5 files changed, 125 insertions(+), 132 deletions(-)



[Getfem-commits] (no subject)

2020-01-06 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit d56812c6dc2926e0978df1e15786ed07a687ecb7
Author: Konstantinos Poulios 
AuthorDate: Fri Jan 3 23:45:46 2020 +0100

Basic infrastructure for defining internal variables

 - no condensation functionality yet
---
 src/getfem/getfem_generic_assembly.h| 14 +++--
 src/getfem/getfem_models.h  | 72 -
 src/getfem_generic_assembly_compile_and_exec.cc | 12 +++--
 src/getfem_generic_assembly_workspace.cc| 36 -
 src/getfem_models.cc| 39 +-
 5 files changed, 125 insertions(+), 48 deletions(-)

diff --git a/src/getfem/getfem_generic_assembly.h 
b/src/getfem/getfem_generic_assembly.h
index ddd7266..3b7872b 100644
--- a/src/getfem/getfem_generic_assembly.h
+++ b/src/getfem/getfem_generic_assembly.h
@@ -265,7 +265,7 @@ namespace getfem {
 const model *md;
 const ga_workspace *parent_workspace;
 bool with_parent_variables;
-size_type nb_prim_dof, nb_tmp_dof;
+size_type nb_prim_dof, nb_intern_dof, first_intern_dof, nb_tmp_dof;
 
 void init();
 
@@ -280,6 +280,7 @@ namespace getfem {
   bgeot::multi_index qdims;  // For data having a qdim different than the
  // qdim of the fem or im_data (dim per dof for
  // dof data) and for constant variables.
+  const bool is_internal;
 
   size_type qdim() const {
 size_type q = 1;
@@ -289,9 +290,9 @@ namespace getfem {
 
   var_description(bool is_var, const mesh_fem *mf_, const im_data *imd_,
   gmm::sub_interval I_, const model_real_plain_vector *V_,
-  size_type Q)
+  size_type Q, bool is_intern_=false)
 : is_variable(is_var), is_fem_dofs(mf_ != 0), mf(mf_), imd(imd_),
-  I(I_), V(V_), qdims(1)
+  I(I_), V(V_), qdims(1), is_internal(is_intern_)
   {
 GMM_ASSERT1(Q > 0, "Bad dimension");
 qdims[0] = Q;
@@ -444,6 +445,9 @@ namespace getfem {
 void add_im_variable(const std::string , const im_data ,
  const gmm::sub_interval ,
  const model_real_plain_vector );
+void add_internal_im_variable(const std::string , const im_data ,
+  const gmm::sub_interval ,
+  const model_real_plain_vector );
 void add_fixed_size_variable(const std::string ,
  const gmm::sub_interval ,
  const model_real_plain_vector );
@@ -463,6 +467,8 @@ namespace getfem {
 
 bool variable_exists(const std::string ) const;
 
+bool is_internal_variable(const std::string ) const;
+
 const std::string _in_group(const std::string _name,
  const mesh ) const;
 
@@ -551,6 +557,8 @@ namespace getfem {
 bool include_empty_int_points() const;
 
 size_type nb_primary_dof() const { return nb_prim_dof; }
+size_type nb_internal_dof() const { return nb_intern_dof; }
+size_type first_internal_dof() const { return first_intern_dof; }
 size_type nb_temporary_dof() const { return nb_tmp_dof; }
 
 void add_temporary_interval_for_unreduced_variable(const std::string 
);
diff --git a/src/getfem/getfem_models.h b/src/getfem/getfem_models.h
index 175d337..8b8c7f2 100644
--- a/src/getfem/getfem_models.h
+++ b/src/getfem/getfem_models.h
@@ -151,6 +151,8 @@ namespace getfem {
   bool is_complex;  // The variable is complex numbers
   bool is_affine_dependent; // The variable depends in an affine way
 // to another variable.
+  bool is_internal; // An internal variable defined on integration
+// points, condensed out of the global system.
   bool is_fem_dofs; // The variable is the dofs of a fem
   size_type n_iter; // Number of versions of the variable stored.
   size_type n_temp_iter;// Number of additional temporary versions
@@ -198,7 +200,7 @@ namespace getfem {
   const std::string _var_ = std::string(""),
   mesh_im const *filter_mim_ = 0)
 : is_variable(is_var), is_disabled(false), is_complex(is_compl),
-  is_affine_dependent(false),
+  is_affine_dependent(false), is_internal(false),
   is_fem_dofs(mf_ != 0),
   n_iter(std::max(size_type(1), n_it)), n_temp_iter(0),
   default_iter(0), ptsc(0),
@@ -525,6 +527,9 @@ namespace getfem {
 /** States if a name corresponds to a declared data. */
 bool is_true_data(const std::string ) const;
 
+/** States if a variable is condensed out of the global system. */
+bool is_internal_variable(const std::string ) const;
+
 bool is_affine_dependent_variable(const std::string ) const;
 
 const std::string _variable(const 

[Getfem-commits] (no subject)

2020-01-06 Thread Konstantinos Poulios via Getfem-commits
branch: devel-logari81-internal-variables
commit d788e47a4897aee425275c7dbc1a16e9a4609a87
Author: Konstantinos Poulios 
AuthorDate: Mon Jan 6 12:40:35 2020 +0100

Remove replaced assembly instruction class
---
 src/getfem_generic_assembly_compile_and_exec.cc | 84 -
 1 file changed, 84 deletions(-)

diff --git a/src/getfem_generic_assembly_compile_and_exec.cc 
b/src/getfem_generic_assembly_compile_and_exec.cc
index 618f094..97b0446 100644
--- a/src/getfem_generic_assembly_compile_and_exec.cc
+++ b/src/getfem_generic_assembly_compile_and_exec.cc
@@ -4509,90 +4509,6 @@ namespace getfem {
 const size_type zero_=0;
   };
 
-  struct ga_instruction_matrix_assembly
-: public ga_instruction_matrix_assembly_base
-  {
-model_real_sparse_matrix , 
-const gmm::sub_interval , , , 
-const mesh_fem *mfn1, *mfn2, **mfg1, **mfg2;
-const im_data *imd1, *imd2;
-virtual int exec() {
-  GA_DEBUG_INFO("Instruction: matrix term assembly");
-
-  bool initialize = (ipt == 0) || interpolate || imd1 || imd2;
-  bool empty_weight = (coeff == scalar_type(0));
-  add_tensor_to_element_matrix(initialize, empty_weight); // t --> elem
-
-  if (ipt == nbpt-1 || interpolate || imd1 || imd2) { // finalize
-const mesh_fem *pmf1 = mfg1 ? *mfg1 : mfn1;
-const mesh_fem *pmf2 = mfg2 ? *mfg2 : mfn2;
-bool reduced = (pmf1 && pmf1->is_reduced())
-  || (pmf2 && pmf2->is_reduced());
-model_real_sparse_matrix  = reduced ? Kr : Kn;
-const gmm::sub_interval  = reduced ? Ir1 : In1;
-const gmm::sub_interval  = reduced ? Ir2 : In2;
-GA_DEBUG_ASSERT(I1.size() && I2.size(), "Internal error");
-
-scalar_type ninf = gmm::vect_norminf(elem);
-if (ninf == scalar_type(0)) return 0;
-
-size_type s1 = t.sizes()[0], s2 = t.sizes()[1];
-size_type cv1 = ctx1.convex_num(), cv2 = ctx2.convex_num();
-size_type N = 1;
-
-size_type ifirst1 = I1.first(), ifirst2 = I2.first();
-if (imd1) ifirst1 +=  s1*imd1->filtered_index_of_point(cv1, ipt);
-if (imd2) ifirst2 +=  s2*imd2->filtered_index_of_point(cv2, ipt);
-
-if (pmf1) {
-  if (!ctx1.is_convex_num_valid()) return 0;
-  N = ctx1.N();
-  size_type qmult1 = pmf1->get_qdim();
-  if (qmult1 > 1) qmult1 /= pmf1->fem_of_element(cv1)->target_dim();
-  populate_dofs_vector(dofs1, s1, ifirst1, qmult1,// --> dofs1
-   pmf1->ind_scalar_basic_dof_of_element(cv1));
-} else
-  populate_contiguous_dofs_vector(dofs1, s1, ifirst1); // --> dofs1
-
-if (pmf1 == pmf2 && (pmf1 ? (cv1 == cv2) : (s1 == s2))) {
-  if (ifirst1 == ifirst2) {
-add_elem_matrix(K, dofs1, dofs1, dofs1_sort, elem, ninf*1E-14, N);
-  } else {
-populate_dofs_vector(dofs2, dofs1.size(), ifirst2 - ifirst1, 
dofs1);
-add_elem_matrix(K, dofs1, dofs2, dofs1_sort, elem, ninf*1E-14, N);
-  }
-} else {
-  if (pmf2) {
-if (!ctx2.is_convex_num_valid()) return 0;
-N = std::max(N, ctx2.N());
-size_type qmult2 = pmf2->get_qdim();
-if (qmult2 > 1) qmult2 /= pmf2->fem_of_element(cv2)->target_dim();
-populate_dofs_vector(dofs2, s2, ifirst2, qmult2,// --> 
dofs2
- pmf2->ind_scalar_basic_dof_of_element(cv2));
-  } else
-populate_contiguous_dofs_vector(dofs2, s2, ifirst2); // --> dofs2
-  add_elem_matrix(K, dofs1, dofs2, dofs1_sort, elem, ninf*1E-14, N);
-}
-  }
-  return 0;
-}
-ga_instruction_matrix_assembly
-(const base_tensor _,
- model_real_sparse_matrix _, model_real_sparse_matrix _,
- const fem_interpolation_context _,
- const fem_interpolation_context _,
- const gmm::sub_interval _, const gmm::sub_interval _,
- const gmm::sub_interval _, const gmm::sub_interval _,
- const mesh_fem *mfn1_, const mesh_fem **mfg1_, const im_data *imd1_,
- const mesh_fem *mfn2_, const mesh_fem **mfg2_, const im_data *imd2_,
- const scalar_type , const scalar_type , const scalar_type _,
- const size_type _, const size_type _, bool interpolate_)
-  : ga_instruction_matrix_assembly_base
-(t_, ctx1_, ctx2_, a1, a2, coeff_, nbpt_, ipt_, interpolate_),
-Kr(Kr_), Kn(Kn_), Ir1(Ir1_), Ir2(Ir2_), In1(In1_), In2(In2_),
-mfn1(mfn1_), mfn2(mfn2_), mfg1(mfg1_), mfg2(mfg2_),
-imd1(imd1_), imd2(imd2_) {}
-  };
 
   struct ga_instruction_matrix_assembly_mf_mf
 : public ga_instruction_matrix_assembly_base