Skip to content
Snippets Groups Projects
Commit edd6e5f5 authored by Samuel Melchior's avatar Samuel Melchior
Browse files

First lines for projection

parent 589004ab
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ set(SRC
multiscaleLaplace.cpp
dgGroupOfElements.cpp
dgAlgorithm.cpp
dgMgAlgorithm.cpp
dgRungeKutta.cpp
dgRungeKuttaMultirate.cpp
dgConservationLaw.cpp
......
......@@ -242,6 +242,44 @@ void dgDofContainer::L2Projection(std::string functionName){
}
}
void dgDofContainer::Mesh2Mesh_BuildL2Projection(linearSystemCSR<double> &projector,dgDofContainer &donor){
// projector.allocate();
// projector.addToMatrix(,,);
/*nt nbCoarseNodes = 0; // OLD CODE
int nbCoarseElements = 0;
int r = 0;
for (int kFine = 0;kFine < fineGroups.getNbElementGroups();kFine++) {
int nbFineNodes = fineGroups.getElementGroup(kFine)->getNbNodes();
fineSol.getGroupProxy(kFine).scale(0);
for (int fineElement = 0 ; fineElement<fineGroups.getElementGroup(kFine)->getNbElements() ;++fineElement) {
for (int fineNodes = 0 ; fineNodes<nbFineNodes ;++fineNodes) {
int kCoarse = 0;
int c0 = 0;
for (int i = startIndex[r++]; i < startIndex[r] - 1; i++){
int c = columns[i];
for (;c-c0 < nbCoarseNodes*nbCoarseElements;kCoarse++) {
c0 += nbCoarseNodes*nbCoarseElements;
nbCoarseNodes = coarseGroups.getElementGroup(kCoarse)->getNbNodes();
nbCoarseElements = coarseGroups.getElementGroup(kCoarse)->getNbElements();
}
int coarseElement = (c-c0)/nbCoarseNodes;
int coarseNodes = c-c0-nbCoarseNodes*coarseElement;
for (int m = 0; m < nbFields; m++){
(fineSol.getGroupProxy(kFine))(fineNodes,fineElement*nbFields+m) += values[i]*(coarseSol.getGroupProxy(kCoarse))(coarseNodes,coarseElement*nbFields+m);
}
}
}
}*/
}
void dgDofContainer::Mesh2Mesh_ApplyL2Projection(linearSystemCSR<double> &projector,dgDofContainer &donor){
scale(0.);
int *startIndex;
int *columns;
double *values;
projector.getMatrix(startIndex,columns,values);
}
void dgDofContainer::exportGroupIdMsh(){
// the elementnodedata::export does not work !!
......
......@@ -3,6 +3,7 @@
#include <vector>
#include "fullMatrix.h"
#include "linearSystemCSR.h"
class dgGroupCollection;
class dgGroupOfElements;
......@@ -42,7 +43,8 @@ public:
void load(const std::string name);
void setAll(double v);
void L2Projection(std::string functionName);
void Mesh2Mesh_L2Projection(dgDofContainer &other);
void Mesh2Mesh_BuildL2Projection(linearSystemCSR<double> &projector,dgDofContainer &donor);
void Mesh2Mesh_ApplyL2Projection(linearSystemCSR<double> &projector,dgDofContainer &donor);
void exportMsh(const std::string name);
void exportGroupIdMsh();
void exportMultirateGroupMsh();
......
......@@ -168,6 +168,7 @@ dgGroupOfElements::~dgGroupOfElements(){
delete _elementVolume;
}
dgGroupOfFaces::~dgGroupOfFaces()
{
if (!_faces.size())return;
......
......@@ -291,7 +291,7 @@ public:
for (int k=0;k<_dofContainer->getNbFields();k++){
_value(i,k) = 0.0;
for (int j=0;j<fSize;j++){
_value(i,k) += solEl(j,k)*fs[j];
_value(i,k) += solEl(j,k)*fs[j];
}
}
}
......
......@@ -282,6 +282,31 @@ void sortColumns_(int NbLines,
delete[] count;
}
template<>
void linearSystemCSR<double>::getMatrix(INDEX_TYPE*& jptr,INDEX_TYPE*& ai,double*& a)
{
jptr = (INDEX_TYPE*) _jptr->array;
ai = (INDEX_TYPE*) _ai->array;
a = ( double * ) _a->array;
if (!sorted)
sortColumns_(_b->size(),
CSRList_Nbr(_a),
(INDEX_TYPE *) _ptr->array,
jptr,
ai,
a);
sorted = true;
}
#include "Bindings.h"
template<>
void linearSystemCSR<double>::registerBindings(binding *b)
{
classBinding *cb = b->addClass< linearSystemCSR<double> >("linearSystemCSRdouble");
// cb->setDescription("A GModel contains a geometrycal and it's mesh.");
}
#if defined(HAVE_GMM)
#include "gmm.h"
......
......@@ -11,6 +11,8 @@
#include "GmshMessage.h"
#include "linearSystem.h"
class binding;
typedef int INDEX_TYPE ;
typedef struct {
int nmax;
......@@ -83,6 +85,8 @@ class linearSystemCSR : public linearSystem<scalar> {
}
else ptr[position] = n;
}
virtual void getMatrix(INDEX_TYPE*& jptr,INDEX_TYPE*& ai,double*& a);
virtual scalar getFromMatrix (int row, int col) const
{
Msg::Error("getFromMatrix not implemented for CSR");
......@@ -110,6 +114,7 @@ class linearSystemCSR : public linearSystem<scalar> {
{
for(unsigned int i = 0; i < _b->size(); i++) (*_b)[i] = 0.;
}
static void registerBindings(binding *b);
};
template <class scalar>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment