[cig-commits] r13151 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Oct 29 15:10:58 PDT 2008


Author: luis
Date: 2008-10-29 15:10:57 -0700 (Wed, 29 Oct 2008)
New Revision: 13151

Added:
   cs/cigma/trunk/src/DofHandler.cpp
   cs/cigma/trunk/src/DofHandler.h
Log:
Container for the basis function coefficients

Added: cs/cigma/trunk/src/DofHandler.cpp
===================================================================
--- cs/cigma/trunk/src/DofHandler.cpp	                        (rev 0)
+++ cs/cigma/trunk/src/DofHandler.cpp	2008-10-29 22:10:57 UTC (rev 13151)
@@ -0,0 +1,65 @@
+#include <cassert>
+#include "DofHandler.h"
+using namespace cigma;
+
+DofHandler::DofHandler()
+{
+    nno  = 0;
+    rank = 0;
+    dofs = 0;
+}
+
+DofHandler::DofHandler(int nno, int rank)
+{
+    this->nno = nno;
+    this->rank = rank;
+    this->dofs = new double[nno * rank];
+}
+
+DofHandler::~DofHandler()
+{
+    nno = 0;
+    rank = 0;
+    if (dofs != 0)
+    {
+        delete [] dofs;
+        dofs = 0;
+    }
+}
+
+void DofHandler::reinit(int nno, int rank)
+{
+    if (this->dofs)
+    {
+        delete [] this->dofs;
+    }
+    this->nno = nno;
+    this->rank = rank;
+    this->dofs = new double[nno*rank];
+}
+
+void DofHandler::setData(double *dofs)
+{
+    assert(nno > 0);
+    assert(rank > 0);
+    assert(this->dofs != 0);
+    for (int n = 0; n < nno*rank; n++)
+    {
+        this->dofs[n] = dofs[n];
+    }
+}
+
+void DofHandler::getData(int n, int *nodeIds, double *celldofs)
+{
+    assert(this->dofs != 0);
+    //assert((0 < n) && (n < nno));
+    for (int i = 0; i < n; i++)
+    {
+        const int id = nodeIds[i];
+        assert((0 <= id) && (id < nno));
+        for (int j = 0; j < rank; j++)
+        {
+            celldofs[rank * i + j] = this->dofs[rank * id + j];
+        }
+    }
+}

Added: cs/cigma/trunk/src/DofHandler.h
===================================================================
--- cs/cigma/trunk/src/DofHandler.h	                        (rev 0)
+++ cs/cigma/trunk/src/DofHandler.h	2008-10-29 22:10:57 UTC (rev 13151)
@@ -0,0 +1,35 @@
+#ifndef __CIGMA_DOF_HANDLER__
+#define __CIGMA_DOF_HANDLER__
+
+#include <boost/noncopyable.hpp>
+
+namespace cigma
+{
+    class DofHandler;
+}
+
+class cigma::DofHandler : private boost::noncopyable
+{
+public:
+    DofHandler();
+    DofHandler(int nno, int rank);
+    ~DofHandler();
+
+    int n_nodes() const;
+    int n_rank() const;
+
+    void reinit(int nno, int rank);
+    void setData(double *dofs);
+
+    void getData(int n, int *nodeIds, double *d);
+
+public:
+    int nno;
+    int rank;
+    double *dofs;
+};
+
+inline int cigma::DofHandler::n_nodes() const { return nno; }
+inline int cigma::DofHandler::n_rank() const { return rank; }
+
+#endif



More information about the CIG-COMMITS mailing list