Skip to content

Commit b75e191

Browse files
Merge branch 'develop' of github.com:febiosoftware/FEBioHeat into develop
2 parents e3fa347 + 6c3ffc1 commit b75e191

10 files changed

+103
-62
lines changed

FEBioHeat/FEHeatSolidDomain.cpp

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "FEHeatSolidDomain.h"
2-
#include "FECore/FEModel.h"
2+
#include <FECore/FEModel.h>
33
#include <FECore/Integrate.h>
44
using namespace std::placeholders;
55

66
//-----------------------------------------------------------------------------
77
//! constructor
8-
FEHeatSolidDomain::FEHeatSolidDomain(FEModel* pfem) : FESolidDomain(pfem), FEHeatDomain(pfem), m_dof(pfem)
8+
FEHeatSolidDomain::FEHeatSolidDomain(FEModel* pfem) : FESolidDomain(pfem), m_dof(pfem)
99
{
1010
m_pMat = 0;
1111

@@ -30,49 +30,10 @@ void FEHeatSolidDomain::ConductionMatrix(FELinearSystem& ls)
3030

3131
//-----------------------------------------------------------------------------
3232
// Calculate the capacitance matrix
33-
void FEHeatSolidDomain::CapacitanceMatrix(FELinearSystem& ls, double dt)
33+
void FEHeatSolidDomain::CapacitanceMatrix(FELinearSystem& ls)
3434
{
35-
vector<int> lm;
36-
vector<double> fe;
37-
38-
FEDofList& dofs = m_dof;
39-
assert(dofs.Size()==1);
40-
int dofT = dofs[0];
41-
42-
// get the mesh
43-
FEMesh& mesh = *GetMesh();
44-
45-
// loop over all elements in domain
46-
for (int i=0; i<(int) m_Elem.size(); ++i)
47-
{
48-
FESolidElement& el = m_Elem[i];
49-
int ne = el.Nodes();
50-
51-
// element capacitance matrix
52-
FEElementMatrix kc(ne, ne);
53-
ElementCapacitance(el, kc, dt);
54-
55-
// set up the LM matrix
56-
UnpackLM(el, lm);
57-
kc.SetIndices(lm);
58-
kc.SetNodes(el.m_node);
59-
60-
// assemble into global matrix
61-
ls.Assemble(kc);
62-
63-
// we also need to assemble this in the right-hand side
64-
fe.resize(ne, 0.0);
65-
for (int i = 0; i<ne; ++i)
66-
{
67-
fe[i] = mesh.Node(el.m_node[i]).get(dofT);
68-
}
69-
70-
// multiply with me
71-
fe = kc*fe;
72-
73-
// assemble this vector to the right-hand side
74-
ls.AssembleRHS(lm, fe);
75-
}
35+
auto fp = bind(&FEHeatSolidDomain::ElementCapacitance, this, _1, _2);
36+
AssembleSolidDomain(*this, ls, fp);
7637
}
7738

7839
//-----------------------------------------------------------------------------
@@ -92,6 +53,40 @@ void FEHeatSolidDomain::HeatSource(FEGlobalVector& R, FEHeatSource& hs)
9253
}
9354
}
9455

56+
void FEHeatSolidDomain::CapacitanceLoad(FEGlobalVector& R)
57+
{
58+
auto fp = bind(&FEHeatSolidDomain::ElementCapacitanceLoad, this, _1, _2);
59+
AssembleSolidDomain(*this, R, fp);
60+
}
61+
62+
void FEHeatSolidDomain::ElementCapacitanceLoad(FESolidElement& el, vector<double>& fe)
63+
{
64+
FETimeInfo& ti = GetFEModel()->GetTime();
65+
double dt = ti.timeIncrement;
66+
67+
double c = m_pMat->Capacitance();
68+
double d = m_pMat->Density();
69+
double alpha = c * d / dt;
70+
71+
zero(fe);
72+
double* w = el.GaussWeights();
73+
int ne = el.Nodes();
74+
int ni = el.GaussPoints();
75+
for (int n = 0; n < ni; ++n)
76+
{
77+
FEMaterialPoint& mp = *el.GetMaterialPoint(n);
78+
FEHeatMaterialPoint* pt = (mp.ExtractData<FEHeatMaterialPoint>());
79+
80+
double Ti = pt->m_T;
81+
double* H = el.H(n);
82+
double J = detJt(el, n);
83+
for (int i = 0; i < ne; ++i)
84+
{
85+
fe[i] += alpha * H[i] * Ti * J * w[n];
86+
}
87+
}
88+
}
89+
9590
//-----------------------------------------------------------------------------
9691
//! calculate element contribution to heat source term
9792
void FEHeatSolidDomain::ElementHeatSource(FEHeatSource& hs, FESolidElement& el, vector<double>& fe)
@@ -129,8 +124,11 @@ void FEHeatSolidDomain::ElementConduction(FESolidElement& el, matrix& ke)
129124
}
130125

131126
//-----------------------------------------------------------------------------
132-
void FEHeatSolidDomain::ElementCapacitance(FESolidElement &el, matrix &ke, double dt)
127+
void FEHeatSolidDomain::ElementCapacitance(FESolidElement &el, matrix &ke)
133128
{
129+
FETimeInfo& ti = GetFEModel()->GetTime();
130+
double dt = ti.timeIncrement;
131+
134132
// zero stiffness matrix
135133
ke.zero();
136134

@@ -168,6 +166,8 @@ void FEHeatSolidDomain::Update(const FETimeInfo& tp)
168166
FEHeatMaterialPoint* pt = (mp.ExtractData<FEHeatMaterialPoint>());
169167
assert(pt);
170168

169+
pt->m_T = el.Evaluate(T, n);
170+
171171
vec3d gradT = gradient(el, T, n);
172172
mat3ds D = m_pMat->Conductivity(mp);
173173
pt->m_q = -(D*gradT);

FEBioHeat/FEHeatSolidDomain.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ class FEModel;
1111
class FEHeatDomain
1212
{
1313
public:
14-
FEHeatDomain(FEModel* pfem) : m_pfem(pfem) {}
14+
FEHeatDomain() {}
1515
virtual ~FEHeatDomain(){}
1616
virtual void ConductionMatrix (FELinearSystem& ls) = 0;
17-
virtual void CapacitanceMatrix(FELinearSystem& ls, double dt) = 0;
17+
virtual void CapacitanceMatrix(FELinearSystem& ls) = 0;
1818
virtual void HeatSource(FEGlobalVector& R, FEHeatSource& hs) = 0;
19-
20-
FEModel* GetFEModel() { return m_pfem; }
21-
22-
protected:
23-
FEModel* m_pfem;
19+
virtual void CapacitanceLoad(FEGlobalVector& R) = 0;
2420
};
2521

2622
//-----------------------------------------------------------------------------
@@ -41,29 +37,34 @@ class FEHeatSolidDomain : public FESolidDomain, public FEHeatDomain
4137

4238
//! Update state data
4339
void Update(const FETimeInfo& tp) override;
40+
41+
const FEDofList& GetDOFList() const { return m_dof; }
4442

4543
public: // overloaded from FEHeatDomain
4644

4745
//! Calculate the conduction stiffness
4846
void ConductionMatrix(FELinearSystem& ls) override;
4947

5048
//! Calculate capacitance stiffness matrix
51-
void CapacitanceMatrix(FELinearSystem& ls, double dt) override;
49+
void CapacitanceMatrix(FELinearSystem& ls) override;
5250

5351
// evaluate heat source
5452
void HeatSource(FEGlobalVector& R, FEHeatSource& hs) override;
53+
54+
// evaluate capacitance load
55+
void CapacitanceLoad(FEGlobalVector& R) override;
5556

5657
protected:
5758
//! calculate the conductive element stiffness matrix
5859
void ElementConduction(FESolidElement& el, matrix& ke);
5960

6061
//! calculate the capacitance element stiffness matrix
61-
void ElementCapacitance(FESolidElement& el, matrix& ke, double dt);
62+
void ElementCapacitance(FESolidElement& el, matrix& ke);
6263

6364
//! calculate element contribution to heat source term
6465
void ElementHeatSource(FEHeatSource& hs, FESolidElement& el, vector<double>& fe);
6566

66-
const FEDofList& GetDOFList() const { return m_dof; }
67+
void ElementCapacitanceLoad(FESolidElement& el, vector<double>& fe);
6768

6869
protected:
6970
FEHeatTransferMaterial* m_pMat;

FEBioHeat/FEHeatSolver.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ bool FEHeatSolver::Init()
7272
return true;
7373
}
7474

75+
void FEHeatSolver::ForceVector(FEGlobalVector& R)
76+
{
77+
FELinearSolver::ForceVector(R);
78+
79+
FEModel& fem = *GetFEModel();
80+
FEAnalysis* pstep = fem.GetCurrentStep();
81+
bool btransient = (pstep->m_nanalysis == FEHeatAnalysis::TRANSIENT);
82+
83+
if (btransient)
84+
{
85+
// for a dynamic analysis add the capacitance load
86+
for (int i = 0; i < pstep->Domains(); ++i)
87+
{
88+
FEHeatDomain& bd = dynamic_cast<FEHeatDomain&>(*pstep->Domain(i));
89+
bd.CapacitanceLoad(R);
90+
}
91+
}
92+
}
93+
7594
//-----------------------------------------------------------------------------
7695
//! Calculate the global stiffness matrix. This function simply calls
7796
//! HeatStiffnessMatrix() for each domain which will calculate the
@@ -99,7 +118,7 @@ bool FEHeatSolver::StiffnessMatrix(FELinearSystem& LS)
99118
// for a dynamic analysis add the capacitance matrix
100119
if (btransient)
101120
{
102-
bd.CapacitanceMatrix(LS, tp.timeIncrement);
121+
bd.CapacitanceMatrix(LS);
103122
}
104123
}
105124

FEBioHeat/FEHeatSolver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class FEHeatSolver : public FELinearSolver
2121

2222
protected: // from FELinearSolver
2323

24+
void ForceVector(FEGlobalVector& R) override;
25+
2426
//! calculate the stiffness matrix
2527
bool StiffnessMatrix(FELinearSystem& LS) override;
2628

FEBioHeat/FEIsotropicFourier.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#include "FEIsotropicFourier.h"
22

3-
//-----------------------------------------------------------------------------
4-
// define the parameter list
53
BEGIN_FECORE_CLASS(FEIsotropicFourier, FEMaterial)
64
ADD_PARAMETER(m_rho, FE_RANGE_GREATER(0.0), "density")->setUnits(UNIT_DENSITY);
75
ADD_PARAMETER(m_k , FE_RANGE_GREATER(0.0), "k")->setUnits("W/L.T");
86
ADD_PARAMETER(m_c , FE_RANGE_GREATER(0.0), "c")->setUnits("E/M.T");
97
END_FECORE_CLASS();
108

11-
//-----------------------------------------------------------------------------
9+
FEIsotropicFourier::FEIsotropicFourier(FEModel* pfem) : FEHeatTransferMaterial(pfem)
10+
{
11+
m_rho = 1;
12+
m_k = 0;
13+
m_c = 0;
14+
}
15+
1216
mat3ds FEIsotropicFourier::Conductivity(FEMaterialPoint& mp)
1317
{
1418
return mat3dd(m_k);

FEBioHeat/FEIsotropicFourier.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#pragma once
22
#include "FEHeatTransferMaterial.h"
33

4-
//-----------------------------------------------------------------------------
5-
// Isotropic Fourer heat-transfer material
4+
// Isotropic Fourier heat-transfer material
65
class FEIsotropicFourier : public FEHeatTransferMaterial
76
{
87
public:
9-
FEIsotropicFourier(FEModel* pfem) : FEHeatTransferMaterial(pfem) {}
8+
FEIsotropicFourier(FEModel* pfem);
109

1110
public:
1211
double m_k; //!< heat conductivity

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# FEBioHeat
2+
The FEBioHeat plugin implements a solver for the heat transfer equation that can be used with [febio](https://febio.org/).
3+
It currently supports steady-state and transient heat transfer analyses and assumes Fourier's law for calculating the heat flux.
4+
5+
Supported boundary conditions are:
6+
* Zero and prescribed temperature
7+
* Prescribed heat flux
8+
* Convective heat flux
9+
* Gap heat flux (enforces continuous heat flux across an interface)
10+
11+
Supported body loads are:
12+
* Constant heat source
13+
* Bio-heat
14+
15+
For transient problems, the initial temperature can be prescribed.
16+

doc/FEBioHeat_Theory_Manual.docx

92.1 KB
Binary file not shown.

doc/FEBioHeat_Theory_Manual.pdf

178 KB
Binary file not shown.

doc/FEBioHeat_User_Manual.docx

1.26 KB
Binary file not shown.

0 commit comments

Comments
 (0)