Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
FluidSource.hpp
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#ifndef _FLUIDSOURCE_HPP_
37#define _FLUIDSOURCE_HPP_
38
39#include "ChastePoint.hpp"
40
44template<unsigned SPACE_DIM>
46{
47
48private:
49
51 unsigned mIndex;
52
54 c_vector<double, SPACE_DIM> mLocation;
55
57 double mStrength;
58
61
64
65 friend class boost::serialization::access;
66
72 template<class Archive>
73 void serialize(Archive & archive, const unsigned int version)
74 {
75 archive & mStrength;
78 }
79
80public:
81
88 FluidSource(unsigned index, ChastePoint<SPACE_DIM> point);
89
96 FluidSource(unsigned index, c_vector<double, SPACE_DIM> location);
97
106 FluidSource(unsigned index, double v1=0.0, double v2=0.0, double v3=0.0);
107
111 ~FluidSource();
112
116 unsigned GetIndex() const;
117
123 void SetIndex(unsigned index);
124
129
136 const c_vector<double, SPACE_DIM>& rGetLocation() const;
137
143 c_vector<double, SPACE_DIM>& rGetModifiableLocation();
144
148 double GetStrength() const;
149
155 void SetStrength(double strength);
156
162 void SetIfSourceIsAssociatedWithElement(bool associated);
163
168
172 unsigned GetAssociatedElementIndex() const;
173
179 void SetAssociatedElementIndex(unsigned associatedElementIndex);
180};
181
182
184// Declare identifier for the serializer
186
187namespace boost
188{
189namespace serialization
190{
194template<class Archive, unsigned SPACE_DIM>
195inline void save_construct_data(
196 Archive & ar, const FluidSource<SPACE_DIM> * t, const unsigned int file_version)
197{
198
199 // Save data required to construct instance
200 for (unsigned i = 0; i < SPACE_DIM; i++)
201 {
202 //we archive coordinates of mLocation one by one
203 //this is because earlier version of boost (<1.40, I think) cannot archive c_vectors
204 double coord = t->rGetLocation()[i];
205 ar & coord;
206 }
207 unsigned index = t->GetIndex();
208 ar << index;
209
210}
211
215template<class Archive, unsigned SPACE_DIM>
216inline void load_construct_data(
217 Archive & ar, FluidSource<SPACE_DIM> * t, const unsigned int file_version)
218{
219 // Retrieve data from archive required to construct new instance of Node
220 c_vector<double,SPACE_DIM> location;
221 for (unsigned i=0; i<SPACE_DIM; i++)
222 {
223 double coordinate;
224 ar & coordinate;//resume coordinates one by one
225 location[i] = coordinate;
226 }
227
228 unsigned index;
229 ar >> index;
230
231 // Invoke inplace constructor to initialise instance
232 ::new(t)FluidSource<SPACE_DIM>(index, location);
233}
234
235}
236} // namespace ...
237
238#endif //_FLUIDSOURCE_HPP_
gcov doesn't like this file...
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
bool IsSourceAssociatedWithElement()
unsigned mIndex
double GetStrength() const
void SetStrength(double strength)
unsigned GetIndex() const
const c_vector< double, SPACE_DIM > & rGetLocation() const
bool mIsSourceAssociatedWithElement
unsigned mAssociatedElementIndex
unsigned GetAssociatedElementIndex() const
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)
double mStrength
void SetIndex(unsigned index)
void serialize(Archive &archive, const unsigned int version)