Skip to content
Snippets Groups Projects
Commit 95170c35 authored by Matti Pellika's avatar Matti Pellika
Browse files

Added placeholder for homology computation plugin.

parent 938a86ef
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "CellComplex.h" #include "CellComplex.h"
CellComplex::CellComplex( std::vector<GEntity*> domain, std::vector<GEntity*> subdomain ){ CellComplex::CellComplex( std::vector<GEntity*> domain, std::vector<GEntity*> subdomain ){
_domain = domain; _domain = domain;
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "GVertex.h" #include "GVertex.h"
// Abstract class representing an elemtary cell of a cell complex. // Abstract class representing an elemtary cell of a cell complex.
class Cell class Cell
{ {
...@@ -498,7 +497,7 @@ class CombinedCell : public Cell{ ...@@ -498,7 +497,7 @@ class CombinedCell : public Cell{
// A class representing a cell complex made out of a finite element mesh. // A class representing a cell complex made out of a finite element mesh.
class CellComplex class CellComplex
{ {
protected: private:
// the domain in the model which this cell complex covers // the domain in the model which this cell complex covers
std::vector<GEntity*> _domain; std::vector<GEntity*> _domain;
...@@ -527,14 +526,14 @@ class CellComplex ...@@ -527,14 +526,14 @@ class CellComplex
protected: protected:
// enqueue cells in queue if they are not there already // enqueue cells in queue if they are not there already
virtual void enqueueCells(std::list<Cell*>& cells, void enqueueCells(std::list<Cell*>& cells,
std::queue<Cell*>& Q, std::set<Cell*, Less_Cell>& Qset); std::queue<Cell*>& Q, std::set<Cell*, Less_Cell>& Qset);
// remove cell from the queue set // remove cell from the queue set
virtual void removeCellQset(Cell*& cell, std::set<Cell*, Less_Cell>& Qset); void removeCellQset(Cell*& cell, std::set<Cell*, Less_Cell>& Qset);
// insert cells into this cell complex // insert cells into this cell complex
//virtual void insert_cells(bool subdomain, bool boundary); //virtual void insert_cells(bool subdomain, bool boundary);
virtual void insert_cells(bool subdomain, bool boundary); void insert_cells(bool subdomain, bool boundary);
public: public:
CellComplex( std::vector<GEntity*> domain, std::vector<GEntity*> subdomain, std::set<Cell*, Less_Cell> cells ) { CellComplex( std::vector<GEntity*> domain, std::vector<GEntity*> subdomain, std::set<Cell*, Less_Cell> cells ) {
...@@ -571,68 +570,68 @@ class CellComplex ...@@ -571,68 +570,68 @@ class CellComplex
CellComplex( std::vector<GEntity*> domain, std::vector<GEntity*> subdomain ); CellComplex( std::vector<GEntity*> domain, std::vector<GEntity*> subdomain );
CellComplex(){} CellComplex(){}
virtual ~CellComplex(){} ~CellComplex(){}
// get the number of certain dimensional cells // get the number of certain dimensional cells
virtual int getSize(int dim){ return _cells[dim].size(); } int getSize(int dim){ return _cells[dim].size(); }
virtual int getDim() {return _dim; } int getDim() {return _dim; }
virtual std::set<Cell*, Less_Cell> getCells(int dim){ return _cells[dim]; } std::set<Cell*, Less_Cell> getCells(int dim){ return _cells[dim]; }
// iterators to the first and last cells of certain dimension // iterators to the first and last cells of certain dimension
virtual citer firstCell(int dim) {return _cells[dim].begin(); } citer firstCell(int dim) {return _cells[dim].begin(); }
virtual citer lastCell(int dim) {return _cells[dim].end(); } citer lastCell(int dim) {return _cells[dim].end(); }
// kappa for two cells of this cell complex // kappa for two cells of this cell complex
// implementation will vary depending on cell type // implementation will vary depending on cell type
virtual inline int kappa(Cell* sigma, Cell* tau) const { return sigma->kappa(tau); } inline int kappa(Cell* sigma, Cell* tau) const { return sigma->kappa(tau); }
// remove a cell from this cell complex // remove a cell from this cell complex
virtual void removeCell(Cell* cell); void removeCell(Cell* cell);
virtual void replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, bool co=false); void replaceCells(Cell* c1, Cell* c2, Cell* newCell, bool orMatch, bool co=false);
virtual void insertCell(Cell* cell); void insertCell(Cell* cell);
// check whether two cells both belong to subdomain or if neither one does // check whether two cells both belong to subdomain or if neither one does
virtual bool inSameDomain(Cell* c1, Cell* c2) const { return bool inSameDomain(Cell* c1, Cell* c2) const { return
( (!c1->inSubdomain() && !c2->inSubdomain()) || (c1->inSubdomain() && c2->inSubdomain()) ); } ( (!c1->inSubdomain() && !c2->inSubdomain()) || (c1->inSubdomain() && c2->inSubdomain()) ); }
// reduction of this cell complex // reduction of this cell complex
// removes reduction pairs of cell of dimension dim and dim-1 // removes reduction pairs of cell of dimension dim and dim-1
virtual int reduction(int dim); int reduction(int dim);
// useful functions for (co)reduction of cell complex // useful functions for (co)reduction of cell complex
virtual void reduceComplex(bool omitHighdim = false); void reduceComplex(bool omitHighdim = false);
virtual void coreduceComplex(bool omitlowDim = false); void coreduceComplex(bool omitlowDim = false);
// queued coreduction presented in Mrozek's paper // queued coreduction presented in Mrozek's paper
virtual int coreduction(Cell* generator); int coreduction(Cell* generator);
// add every volume, face and edge its missing boundary cells // add every volume, face and edge its missing boundary cells
//virtual void repairComplex(int i=3); // void repairComplex(int i=3);
// change non-subdomain cells to be in subdomain, subdomain cells to not to be in subdomain // change non-subdomain cells to be in subdomain, subdomain cells to not to be in subdomain
virtual void swapSubdomain(); void swapSubdomain();
virtual void removeSubdomain(); void removeSubdomain();
// print the vertices of cells of certain dimension // print the vertices of cells of certain dimension
virtual void printComplex(int dim); void printComplex(int dim);
// write this cell complex in 2.0 MSH ASCII format // write this cell complex in 2.0 MSH ASCII format
virtual int writeComplexMSH(const std::string &name); int writeComplexMSH(const std::string &name);
virtual int combine(int dim); int combine(int dim);
virtual int cocombine(int dim); int cocombine(int dim);
virtual void computeBettiNumbers(); void computeBettiNumbers();
virtual int getBettiNumber(int i) { if(i > -1 && i < 4) return _betti[i]; else return 0; } int getBettiNumber(int i) { if(i > -1 && i < 4) return _betti[i]; else return 0; }
virtual void makeDualComplex(){ void makeDualComplex(){
std::set<Cell*, Less_Cell> temp = _cells[0]; std::set<Cell*, Less_Cell> temp = _cells[0];
_cells[0] = _cells[3]; _cells[0] = _cells[3];
_cells[3] = temp; _cells[3] = temp;
......
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
//
// Contributed by Matti Pellikka
#include <stdlib.h>
#include "GmshConfig.h"
#include "GModel.h"
#include "CellComplex.h"
#include "HomologyComputation.h"
StringXNumber HomologyComputationOptions_Number[] = {
{GMSH_FULLRC, "test number", NULL, 1.},
};
StringXString HomologyComputationOptions_String[] = {
{GMSH_FULLRC, "test string", NULL, "test string"},
};
extern "C"
{
GMSH_Plugin *GMSH_RegisterHomologyComputationPlugin()
{
return new GMSH_HomologyComputationPlugin();
}
}
void GMSH_HomologyComputationPlugin::getName(char *name) const
{
strcpy(name, "Homology Computation");
}
void GMSH_HomologyComputationPlugin::getInfos(char *author, char *copyright,
char *help_text) const
{
strcpy(author, "Matti Pellikka");
strcpy(copyright, "C. Geuzaine, J.-F. Remacle");
strcpy(help_text,
"Plugin(HomologyComputation) is here!\n"
"\n"
"Plugin(HomologyComputation) creates a new view.\n");
}
int GMSH_HomologyComputationPlugin::getNbOptions() const
{
return sizeof(HomologyComputationOptions_Number) / sizeof(StringXNumber);
}
StringXNumber *GMSH_HomologyComputationPlugin::getOption(int iopt)
{
return &HomologyComputationOptions_Number[iopt];
}
int GMSH_HomologyComputationPlugin::getNbOptionsStr() const
{
return sizeof(HomologyComputationOptions_String) / sizeof(StringXString);
}
StringXString *GMSH_HomologyComputationPlugin::getOptionStr(int iopt)
{
return &HomologyComputationOptions_String[iopt];
}
void GMSH_HomologyComputationPlugin::catchErrorMessage(char *errorMessage) const
{
strcpy(errorMessage, "Homology Computation failed...");
}
PView *GMSH_HomologyComputationPlugin::execute(PView *v)
{
std::string testString = HomologyComputationOptions_String[0].def;
int testInt = (int)HomologyComputationOptions_Number[0].def;
GModel *m = GModel::current();
std::map<int, std::vector<GEntity*> > groups[4];
m->getPhysicalGroups(groups);
std::map<int, std::vector<double> > data;
std::vector<GEntity*> domain;
std::vector<GEntity*> subdomain;
// Here's the problem, linker cannot find the method for the constructor of
// CellComplex class, or any other methods coded in Geo/CellComplex.cpp
//CellComplex* testComplex = new CellComplex(domain, subdomain);
// insert homology fun here
PView *pv = new PView("homology", "ElementData", m, data, 0.);
Msg::Error("test.");
return 0;
}
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to <gmsh@geuz.org>.
//
// Contributed by Matti Pellikka
#ifndef _HOMOLOGY_COMPUTATION_H_
#define _HOMOLOGY_COMPUTATION_H_
#include <string>
#include "Plugin.h"
extern "C"
{
GMSH_Plugin *GMSH_RegisterHomologyComputationPlugin();
}
class GMSH_HomologyComputationPlugin : public GMSH_PostPlugin
{
public:
GMSH_HomologyComputationPlugin(){}
void getName(char *name) const;
void getInfos(char *author, char *copyright, char *helpText) const;
void catchErrorMessage(char *errorMessage) const;
int getNbOptions() const;
StringXNumber *getOption(int iopt);
int getNbOptionsStr() const;
StringXString *getOptionStr(int iopt);
PView *execute(PView *);
};
#endif
...@@ -33,7 +33,8 @@ SRC = Plugin.cpp PluginManager.cpp\ ...@@ -33,7 +33,8 @@ SRC = Plugin.cpp PluginManager.cpp\
Annotate.cpp Remove.cpp\ Annotate.cpp Remove.cpp\
Probe.cpp\ Probe.cpp\
HarmonicToTime.cpp ModulusPhase.cpp\ HarmonicToTime.cpp ModulusPhase.cpp\
FiniteElement.cpp FiniteElement.cpp\
HomologyComputation.cpp
OBJ = ${SRC:.cpp=${OBJEXT}} OBJ = ${SRC:.cpp=${OBJEXT}}
...@@ -339,3 +340,6 @@ FiniteElement${OBJEXT}: FiniteElement.cpp ../Common/GmshConfig.h ../Geo/GModel.h ...@@ -339,3 +340,6 @@ FiniteElement${OBJEXT}: FiniteElement.cpp ../Common/GmshConfig.h ../Geo/GModel.h
../Numeric/gmshTermOfFormulation.h ../Numeric/gmshFunction.h \ ../Numeric/gmshTermOfFormulation.h ../Numeric/gmshFunction.h \
../Numeric/GmshMatrix.h ../Numeric/gmshLinearSystemGmm.h \ ../Numeric/GmshMatrix.h ../Numeric/gmshLinearSystemGmm.h \
../Numeric/gmshLinearSystem.h ../Numeric/gmshLinearSystem.h
HomologyComputation${OBJEXT}: HomologyComputation.cpp Plugin.h \
../Geo/GModel.h ../Geo/GEntity.h ../Geo/CellComplex.h \
../Post/PView.h HomologyComputation.h
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "GSHHS.h" #include "GSHHS.h"
#include "FiniteElement.h" #include "FiniteElement.h"
#include "Context.h" #include "Context.h"
#include "HomologyComputation.h"
#if !defined(HAVE_NO_DLL) #if !defined(HAVE_NO_DLL)
#include <dlfcn.h> #include <dlfcn.h>
...@@ -228,6 +229,8 @@ void PluginManager::registerDefaultPlugins() ...@@ -228,6 +229,8 @@ void PluginManager::registerDefaultPlugins()
#endif #endif
allPlugins.insert(std::pair<const char*, GMSH_Plugin*> allPlugins.insert(std::pair<const char*, GMSH_Plugin*>
("FiniteElement", GMSH_RegisterFiniteElementPlugin())); ("FiniteElement", GMSH_RegisterFiniteElementPlugin()));
allPlugins.insert(std::pair<const char*, GMSH_Plugin*>
("HomologyComputation", GMSH_RegisterHomologyComputationPlugin()));
} }
#if defined(HAVE_FLTK) #if defined(HAVE_FLTK)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment