Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
FluidSource.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#include "FluidSource.hpp"
37
38template<unsigned SPACE_DIM>
40 : mIndex(index),
41 mLocation(point.rGetLocation()),
42 mStrength(0.0),
43 mIsSourceAssociatedWithElement(false),
44 mAssociatedElementIndex(UINT_MAX)
45{
46}
47
48template<unsigned SPACE_DIM>
50 unsigned index,
51 c_vector<double, SPACE_DIM> location)
52 : mIndex(index),
53 mLocation(location),
54 mStrength(0.0),
55 mIsSourceAssociatedWithElement(false),
56 mAssociatedElementIndex(UINT_MAX)
57{
58}
59
60template<unsigned SPACE_DIM>
61FluidSource<SPACE_DIM>::FluidSource(unsigned index, double v1, double v2, double v3)
62 : mIndex(index),
63 mStrength(0.0),
64 mIsSourceAssociatedWithElement(false),
65 mAssociatedElementIndex(UINT_MAX)
66{
67 mLocation[0] = v1;
68 if (SPACE_DIM > 1)
69 {
70 mLocation[1] = v2;
71 if (SPACE_DIM > 2)
72 {
73 mLocation[2] = v3;
74 }
75 }
76}
77
78template<unsigned SPACE_DIM>
82
83template<unsigned SPACE_DIM>
85{
86 return mIndex;
87}
88
89template<unsigned SPACE_DIM>
91{
92 mIndex = index;
93}
94
95template<unsigned SPACE_DIM>
100
101template<unsigned SPACE_DIM>
102const c_vector<double, SPACE_DIM>& FluidSource<SPACE_DIM>::rGetLocation() const
103{
104 return mLocation;
105}
106
107template<unsigned SPACE_DIM>
109{
110 return mLocation;
111}
112
113template<unsigned SPACE_DIM>
115{
116 return mStrength;
117}
118
119template<unsigned SPACE_DIM>
121{
122 mStrength = strength;
123}
124
125template<unsigned SPACE_DIM>
127{
128 mIsSourceAssociatedWithElement = associated;
129}
130
131template<unsigned SPACE_DIM>
133{
134 return mIsSourceAssociatedWithElement;
135}
136
137template<unsigned SPACE_DIM>
139{
140 return mIsSourceAssociatedWithElement ? mAssociatedElementIndex : UINT_MAX;
141}
142
143template<unsigned SPACE_DIM>
144void FluidSource<SPACE_DIM>::SetAssociatedElementIndex(unsigned associatedElementIndex)
145{
146 mIsSourceAssociatedWithElement = true;
147 mAssociatedElementIndex = associatedElementIndex;
148}
149
150// Explicit instantiation
151template class FluidSource<1>;
152template class FluidSource<2>;
153template class FluidSource<3>;
bool IsSourceAssociatedWithElement()
double GetStrength() const
void SetStrength(double strength)
unsigned GetIndex() const
const c_vector< double, SPACE_DIM > & rGetLocation() const
unsigned GetAssociatedElementIndex() const
FluidSource(unsigned index, ChastePoint< SPACE_DIM > point)
c_vector< double, SPACE_DIM > & rGetModifiableLocation()
c_vector< double, SPACE_DIM > mLocation
void SetIfSourceIsAssociatedWithElement(bool associated)
ChastePoint< SPACE_DIM > GetPoint() const
void SetAssociatedElementIndex(unsigned associatedElementIndex)
void SetIndex(unsigned index)