Skip to content
Snippets Groups Projects
Commit 8427807f authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent 6c90cc4c
No related branches found
No related tags found
No related merge requests found
...@@ -87,14 +87,14 @@ public: ...@@ -87,14 +87,14 @@ public:
return lsys->getFromSolution (it->second); return lsys->getFromSolution (it->second);
} }
{ {
std::map<gmshDofKey, std::vector<std::pair<gmshDofKey,double> > >::const_iterator itConstr = std::map<gmshDofKey, std::vector<std::pair<gmshDofKey,double> > >::
constraints.find(key); const_iterator itConstr = constraints.find(key);
if (itConstr != constraints.end()){ if (itConstr != constraints.end()){
double val = 0; double val = 0;
for (int i=0;i<itConstr->second.size();i++){ for (int i = 0; i < itConstr->second.size(); i++){
const gmshDofKey &dofKeyConstr = itConstr->second[i].first; const gmshDofKey &dofKeyConstr = itConstr->second[i].first;
double valConstr = itConstr->second[i].second; double valConstr = itConstr->second[i].second;
val += getDofValue (dofKeyConstr.v,dofKeyConstr.comp , dofKeyConstr.field) val += getDofValue(dofKeyConstr.v, dofKeyConstr.comp, dofKeyConstr.field)
* valConstr; * valConstr;
} }
return val; return val;
......
#ifndef _GMSH_ELASTICITY_H_ #ifndef _GMSH_ELASTICITY_H_
#define _GMSH_ELASTICITY_H_ #define _GMSH_ELASTICITY_H_
#include "gmshTermOfFormulation.h" #include "gmshTermOfFormulation.h"
#include "Gmsh.h" #include "Gmsh.h"
#include "GModel.h" #include "GModel.h"
...@@ -10,19 +11,19 @@ class gmshElasticityTerm : public gmshNodalFemTerm { ...@@ -10,19 +11,19 @@ class gmshElasticityTerm : public gmshNodalFemTerm {
double _E,_nu; double _E,_nu;
int _iField; int _iField;
protected: protected:
virtual int sizeOfR (MElement *e) const {return 3*e->getNumVertices();} virtual int sizeOfR(MElement *e) const { return 3 * e->getNumVertices(); }
virtual int sizeOfC (MElement *e) const {return 3*e->getNumVertices();} virtual int sizeOfC(MElement *e) const { return 3 * e->getNumVertices(); }
void getLocalDofR (MElement *e, int iRow, MVertex **vR, int *iCompR, int *iFieldR) const void getLocalDofR(MElement *e, int iRow, MVertex **vR, int *iCompR, int *iFieldR) const
{ {
*iCompR = iRow/e->getNumVertices(); *iCompR = iRow / e->getNumVertices();
int ithLocalVertex = iRow%e->getNumVertices(); int ithLocalVertex = iRow % e->getNumVertices();
*vR = e->getVertex (ithLocalVertex); *vR = e->getVertex(ithLocalVertex);
*iFieldR = _iField; *iFieldR = _iField;
} }
public: public:
gmshElasticityTerm (GModel *gm, double E, double nu, int iField = 1) : gmshElasticityTerm(GModel *gm, double E, double nu, int iField = 1) :
gmshNodalFemTerm(gm),_E(E),_nu(nu),_iField(iField){} gmshNodalFemTerm(gm), _E(E), _nu(nu), _iField(iField){}
void elementMatrix ( MElement *e, Double_Matrix & m) const; void elementMatrix(MElement *e, Double_Matrix & m) const;
}; };
#endif #endif
#ifndef _GMSH_LAPLACE_H_ #ifndef _GMSH_LAPLACE_H_
#define _GMSH_LAPLACE_H_ #define _GMSH_LAPLACE_H_
#include "gmshTermOfFormulation.h" #include "gmshTermOfFormulation.h"
#include "Gmsh.h" #include "Gmsh.h"
#include "GModel.h" #include "GModel.h"
...@@ -10,18 +11,19 @@ class gmshLaplaceTerm : public gmshNodalFemTerm { ...@@ -10,18 +11,19 @@ class gmshLaplaceTerm : public gmshNodalFemTerm {
const double _diffusivity; const double _diffusivity;
const int _iField ; const int _iField ;
protected: protected:
virtual int sizeOfR (MElement *e) const { return e->getNumVertices(); } virtual int sizeOfR(MElement *e) const { return e->getNumVertices(); }
virtual int sizeOfC (MElement *e) const { return e->getNumVertices(); } virtual int sizeOfC(MElement *e) const { return e->getNumVertices(); }
void getLocalDofR (MElement *e, int iRow, MVertex **vR, int *iCompR, int *iFieldR) const void getLocalDofR(MElement *e, int iRow, MVertex **vR, int *iCompR, int *iFieldR) const
{ {
*vR = e->getVertex (iRow); *vR = e->getVertex(iRow);
*iCompR = 0; *iCompR = 0;
*iFieldR = _iField; *iFieldR = _iField;
} }
public: public:
gmshLaplaceTerm (GModel *gm, double diffusivity = 1.0, int iField = 0) : gmshLaplaceTerm(GModel *gm, double diffusivity = 1.0, int iField = 0) :
gmshNodalFemTerm(gm),_diffusivity (diffusivity),_iField(iField){} gmshNodalFemTerm(gm), _diffusivity(diffusivity), _iField(iField){}
void elementMatrix ( MElement *e, Double_Matrix & m) const; void elementMatrix(MElement *e, Double_Matrix &m) const;
double getDiffusivity () const { return _diffusivity; } double getDiffusivity () const { return _diffusivity; }
}; };
#endif #endif
...@@ -19,9 +19,9 @@ class gmshTermOfFormulation { ...@@ -19,9 +19,9 @@ class gmshTermOfFormulation {
protected: protected:
GModel *_gm; GModel *_gm;
public: public:
gmshTermOfFormulation (GModel *gm) : _gm(gm) {} gmshTermOfFormulation(GModel *gm) : _gm(gm) {}
virtual void addToMatrix (gmshAssembler&) const = 0; virtual void addToMatrix(gmshAssembler&) const = 0;
virtual void addToRightHandSide (gmshAssembler&) const = 0; virtual void addToRightHandSide(gmshAssembler&) const = 0;
}; };
// a nodal finite element term : variables are always defined at nodes // a nodal finite element term : variables are always defined at nodes
...@@ -32,14 +32,17 @@ class gmshNodalFemTerm : public gmshTermOfFormulation { ...@@ -32,14 +32,17 @@ class gmshNodalFemTerm : public gmshTermOfFormulation {
virtual int sizeOfC(MElement*) const = 0; virtual int sizeOfC(MElement*) const = 0;
// return the number of rows of the element matrix // return the number of rows of the element matrix
virtual int sizeOfR(MElement*) const = 0; virtual int sizeOfR(MElement*) const = 0;
// in a given element, return the dof key associated to a given row of the local element matrix // in a given element, return the dof key associated to a given row
virtual void getLocalDofR (MElement *e, int iRow, MVertex **vR, int *iCompR, int *iFieldR) const = 0; // of the local element matrix
virtual void getLocalDofC (MElement *e, int iCol, MVertex **vC, int *iCompC, int *iFieldC) const virtual void getLocalDofR(MElement *e, int iRow, MVertex **vR,
int *iCompR, int *iFieldR) const = 0;
virtual void getLocalDofC(MElement *e, int iCol, MVertex **vC,
int *iCompC, int *iFieldC) const
{ {
getLocalDofR(e, iCol, vC, iCompC, iFieldC); getLocalDofR(e, iCol, vC, iCompC, iFieldC);
} }
public: public:
gmshNodalFemTerm (GModel *gm) : gmshTermOfFormulation(gm) {} gmshNodalFemTerm(GModel *gm) : gmshTermOfFormulation(gm) {}
virtual ~gmshNodalFemTerm (); virtual ~gmshNodalFemTerm ();
// compute the element matrix // compute the element matrix
virtual void elementMatrix(MElement *e, Double_Matrix &m) const = 0; virtual void elementMatrix(MElement *e, Double_Matrix &m) const = 0;
...@@ -50,8 +53,9 @@ class gmshNodalFemTerm : public gmshTermOfFormulation { ...@@ -50,8 +53,9 @@ class gmshNodalFemTerm : public gmshTermOfFormulation {
void addToMatrix(gmshAssembler &J,const std::vector<MElement*> &) const; void addToMatrix(gmshAssembler &J,const std::vector<MElement*> &) const;
void addToMatrix(gmshAssembler &Jac, Double_Matrix &localMatrix, MElement *e) const; void addToMatrix(gmshAssembler &Jac, Double_Matrix &localMatrix, MElement *e) const;
void addDirichlet(int physical, int dim, int comp, int field, const gmshFunction & e, gmshAssembler &); void addDirichlet(int physical, int dim, int comp, int field, const gmshFunction &e,
void addNeumann(int physical, int dim, int icomp, int field, const gmshFunction & e, gmshAssembler &);
void addNeumann(int physical, int dim, int icomp, int field, const gmshFunction &e,
gmshAssembler &); gmshAssembler &);
void addToRightHandSide(gmshAssembler &J, GEntity *ge) const; void addToRightHandSide(gmshAssembler &J, GEntity *ge) const;
void addToRightHandSide(gmshAssembler &r) const; void addToRightHandSide(gmshAssembler &r) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment