1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
// Gmsh - Copyright (C) 1997-2010 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
#ifndef THERMIC_SOLVER_H
#define THERMIC_SOLVER_H
#include <map>
#include <string>
#include "GmshConfig.h"
#include "SVector3.h"
#include "dofManager.h"
#include "simpleFunction.h"
#include "functionSpace.h"
class GModel;
class PView;
class groupOfElements;
class gLevelset;
struct LagrangeMultiplierFieldT {
int _tag;
groupOfElements *g;
double _tau;
simpleFunction<double> *_f;
LagrangeMultiplierFieldT() : _tag(0), g(nullptr) {}
};
struct thermicField {
int _tag; // tag for the dofManager
groupOfElements *g; // support for this field
double _k; // diffusivity
thermicField() : _tag(0), g(nullptr) {}
};
struct BoundaryConditionT {
int _tag; // tag for the dofManager
enum location { UNDEF, ON_VERTEX, ON_EDGE, ON_FACE, ON_VOLUME };
location onWhat; // on vertices or elements
groupOfElements *g; // support for this BC
BoundaryConditionT() : _tag(0), onWhat(UNDEF), g(nullptr) {}
};
struct dirichletBCT : public BoundaryConditionT {
simpleFunction<double> *_f;
dirichletBCT() : BoundaryConditionT(), _f(nullptr) {}
};
struct neumannBCT : public BoundaryConditionT {
simpleFunction<double> *_f;
neumannBCT() : BoundaryConditionT(), _f(nullptr) {}
};
// a thermic solver ...
class thermicSolver {
protected:
GModel *pModel;
int _dim, _tag;
dofManager<double> *pAssembler;
FunctionSpace<double> *LagSpace;
FunctionSpace<double> *LagrangeMultiplierSpace;
// young modulus and poisson coefficient per physical
std::vector<thermicField> thermicFields;
std::vector<LagrangeMultiplierFieldT> LagrangeMultiplierFields;
// neumann BC
std::vector<neumannBCT> allNeumann;
// dirichlet BC
std::vector<dirichletBCT> allDirichlet;
public:
thermicSolver(int tag)
: _tag(tag), pAssembler(nullptr), LagSpace(nullptr), LagrangeMultiplierSpace(nullptr)
{
}
virtual ~thermicSolver()
{
if(LagSpace) delete LagSpace;
if(LagrangeMultiplierSpace) delete LagrangeMultiplierSpace;
if(pAssembler) delete pAssembler;
}
void assemble(linearSystem<double> *lsys);
virtual void setMesh(const std::string &meshFileName);
void cutMesh(gLevelset *ls);
void setThermicDomain(int phys, double k);
void setLagrangeMultipliers(int phys, double tau, int tag,
simpleFunction<double> *f);
void changeLMTau(int tag, double tau);
void setEdgeTemp(int edge, simpleFunction<double> *f);
void setFaceTemp(int face, simpleFunction<double> *f);
void solve();
double computeL2Norm(simpleFunction<double> *f);
double computeLagNorm(int tag, simpleFunction<double> *f);
#if defined(HAVE_POST)
virtual PView *buildTemperatureView(const std::string postFileName);
virtual PView *buildLagrangeMultiplierView(const std::string &postFileName);
PView *buildErrorEstimateView(const std::string &errorFileName,
simpleFunction<double> *sol);
#endif
};
#endif
|