From 98d73709bff8f41902c4d2117d3c65b82e6cfcab Mon Sep 17 00:00:00 2001
From: Emilie Marchandise <emilie.marchandise@uclouvain.be>
Date: Fri, 7 May 2010 08:42:32 +0000
Subject: [PATCH] Added exportfunctions for Navier stokes 1D and gmsh
 postprocessing with probes

---
 Solver/function.cpp | 41 +++++++++++++++++++++++++++++++++++++++++
 Solver/function.h   |  2 ++
 2 files changed, 43 insertions(+)

diff --git a/Solver/function.cpp b/Solver/function.cpp
index 4c2aebbb9a..e72e4b0907 100644
--- a/Solver/function.cpp
+++ b/Solver/function.cpp
@@ -173,6 +173,47 @@ function *functionSumNew(const function *f0, const function *f1) {
   return new functionSum (f0, f1);
 }
 
+class functionProd : public function {
+  public:
+  fullMatrix<double> _f0, _f1;
+  void call(dataCacheMap *m, fullMatrix<double> &val) {
+    for(int i=0;i<val.size1();i++)
+      for(int j=0;j<val.size2();j++){
+        val(i,j)= _f0(i,j)*_f1(i,j);
+      }
+  }
+  functionProd(const function *f0, const function *f1):function(f0->getNbCol()){
+    if (f0->getNbCol() != f1->getNbCol()) {
+      Msg::Error("trying to compute product of 2 functions of different sizes\n");
+      throw;
+    }
+    setArgument (_f0, f0);
+    setArgument (_f1, f1);
+  }
+};
+
+function *functionProdNew(const function *f0, const function *f1) {
+  return new functionProd (f0, f1);
+}
+
+class functionExtractComp : public function {
+  public:
+  fullMatrix<double> _f0;
+  double _iComp;
+  void call(dataCacheMap *m, fullMatrix<double> &val) {
+    for(int i=0;i<val.size1();i++)
+        val(i,0)= _f0(i,_iComp);
+  }
+  functionExtractComp(const function *f0, const int iComp):function(1){
+    setArgument (_f0, f0);
+    _iComp = iComp;
+  }
+};
+
+function *functionExtractCompNew(const function *f0, const int iComp) {
+  return new functionExtractComp (f0, iComp);
+}
+
 
 class functionScale : public function {
   public:
diff --git a/Solver/function.h b/Solver/function.h
index 8233c422fb..dfac032bc4 100644
--- a/Solver/function.h
+++ b/Solver/function.h
@@ -248,7 +248,9 @@ class functionReplaceCache {
 functionConstant *functionConstantNew(const std::vector<double>&);
 functionConstant *functionConstantNew(double);
 function *functionSumNew (const function *f0, const function *f1);
+function *functionProdNew (const function *f0, const function *f1);
 function *functionScaleNew (const function *f0, const double s);
+function *functionExtractCompNew (const function *f0, const int iComp);
 
 class functionSolution : public function {
   static functionSolution *_instance;
-- 
GitLab