HeartSolver.hpp 3.81 KB
Newer Older
thomaskummer's avatar
thomaskummer committed
1
2
3
4
5
6
7
8
9
10
11
12
13
//
//  HeartSolver.cpp
//  LifeV
//
//  Created by Thomas Kummer on 03.05.16.
//  Copyright © 2016 Thomas Kummer. All rights reserved.
//

#ifndef _HEARTDATA_H_
#define _HEARTDATA_H_


#include <stdio.h>
thomaskummer's avatar
thomaskummer committed
14
#include <lifev/em/solver/EMSolver.hpp>
thomaskummer's avatar
thomaskummer committed
15
#include <lifev/em/solver/circulation/Circulation.hpp>
thomaskummer's avatar
thomaskummer committed
16
17


thomaskummer's avatar
thomaskummer committed
18
19
20
21

namespace LifeV
{

thomaskummer's avatar
thomaskummer committed
22
template <class EmSolver>
thomaskummer's avatar
thomaskummer committed
23
24
25
26
class HeartSolver {
   
public:
    
thomaskummer's avatar
thomaskummer committed
27
    HeartSolver(EmSolver& emSolver,  Circulation& circulationSolver) :
thomaskummer's avatar
thomaskummer committed
28
29
30
        M_emSolver          (emSolver),
        M_circulationSolver (circulationSolver)
    {};
thomaskummer's avatar
thomaskummer committed
31
    
thomaskummer's avatar
thomaskummer committed
32
    HeartSolver(const HeartSolver& heartSolver) :
thomaskummer's avatar
thomaskummer committed
33
34
35
36
37
38
        M_emSolver          (heartSolver.M_emSolver),
        M_circulationSolver (heartSolver.M_circulationSolver)
    {};

    
    
thomaskummer's avatar
thomaskummer committed
39
    //UserQueues(const UserQueues&) = delete;
thomaskummer's avatar
thomaskummer committed
40
41
42
    
    
    
thomaskummer's avatar
thomaskummer committed
43
44
    virtual ~HeartSolver() {};
    
thomaskummer's avatar
thomaskummer committed
45
46
47
48
    
    
    
    void preloadHeart(const VectorSmall<2>& endocardiaBC);
thomaskummer's avatar
thomaskummer committed
49
50

    
thomaskummer's avatar
thomaskummer committed
51
52
53
54
55
    
    
    
    
    
thomaskummer's avatar
thomaskummer committed
56
protected:
thomaskummer's avatar
thomaskummer committed
57
    
thomaskummer's avatar
thomaskummer committed
58
    
thomaskummer's avatar
thomaskummer committed
59
    EmSolver M_emSolver;
thomaskummer's avatar
thomaskummer committed
60
    Circulation M_circulationSolver;
thomaskummer's avatar
thomaskummer committed
61
62
    
    
thomaskummer's avatar
thomaskummer committed
63
64
65
66
    VectorSmall<2> M_pressure;
    VectorSmall<2> M_volume;

    
thomaskummer's avatar
thomaskummer committed
67
    
thomaskummer's avatar
thomaskummer committed
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
    
    
    
    
    Real patchForce (const Real& t, const Real& Tmax, const Real& tmax, const Real& tduration) const
    {
        bool time ( fmod(t-tmax+0.5*tduration, 700.) < tduration && fmod(t-tmax+0.5*tduration, 700.) > 0);
        Real force = std::pow( std::sin(fmod(t-tmax+0.5*tduration, 700.)*3.14159265359/tduration) , 2 ) * Tmax;
        return ( time ? force : 0 );
    }
    
    Real patchFunction (const Real& t, const Real&  X, const Real& Y, const Real& Z, const ID& /*i*/) const
    {
        Real disp = std::pow( std::sin(fmod(t, 700.) * 3.14159265359/300) , 2 )*15;
        return disp;
    }
    
    Real Iapp (const Real& t, const Real&  X, const Real& Y, const Real& Z, const ID& /*i*/) const
    {
        bool coords ( Y < -7. );
        //bool coords ( Y > 4. ); //( Y > 1.5 && Y < 3 );
        bool time ( fmod(t, 700.) < 4 && fmod(t, 700.) > 2);
        return ( coords && time ? 30 : 0 );
    }
    
    Real potentialMultiplyerFcn (const Real& t, const Real&  X, const Real& Y, const Real& Z, const ID& /*i*/) const
    {
        bool time ( fmod(t, 700.) < 4 && fmod(t, 700.) > 2);
        return 1.4 * time; // ( Y < 2.5 && Y > 0.5 ? 1.0 : 0.0 );
    }
    
thomaskummer's avatar
thomaskummer committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
    Real
    externalPower ( const VectorEpetra& dispCurrent,
                    const VectorEpetra& dispPrevious,
                    const boost::shared_ptr<ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > > dispETFESpace,
                    Real pressure,
                    Real dt,
                    const unsigned int bdFlag) const
    {
        VectorEpetra traction ( dispCurrent.map() );
        VectorEpetra velocity ( (dispCurrent - dispPrevious) / dt );
        
        MatrixSmall<3,3> Id;
        Id(0,0) = 1.; Id(0,1) = 0., Id(0,2) = 0.;
        Id(1,0) = 0.; Id(1,1) = 1., Id(1,2) = 0.;
        Id(2,0) = 0.; Id(2,1) = 0., Id(2,2) = 1.;
        
        {
            using namespace ExpressionAssembly;
            
            auto I = value(Id);
            auto Grad_u = grad( dispETFESpace, dispCurrent, 0);
            auto F =  Grad_u + I;
            auto FmT = minusT(F);
            auto J = det(F);
            auto p = value(pressure);
            
            QuadratureBoundary myBDQR (buildTetraBDQR (quadRuleTria7pt) );
            
            integrate ( boundary ( dispETFESpace->mesh(), bdFlag),
                       myBDQR,
                       dispETFESpace,
                       p * J * dot( FmT * Nface,  phi_i)
                       //p * J * dot( FmT * Nface,  phi_i)
                       //value(-1.0) * J * dot (vE1, FmT * Nface) * phi_i) >> intergral
                       ) >> traction;
            
            traction.globalAssemble();
        }
        
        return traction.dot(velocity);
    }
    
    
thomaskummer's avatar
thomaskummer committed
142
143
144
145
};

}

thomaskummer's avatar
thomaskummer committed
146
#endif