Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
ExtrinsicPullModifier.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 "ExtrinsicPullModifier.hpp"
37
38template<unsigned DIM>
41 mApplyExtrinsicPullToAllNodes(true),
42 mSpeed(1.0)
43{
44}
45
46template<unsigned DIM>
50
51template<unsigned DIM>
53{
54 double epsilon = 0.8;
55
57 unsigned num_nodes = rCellPopulation.GetNumNodes();
58 ChasteCuboid<DIM> bounds = rCellPopulation.rGetMesh().CalculateBoundingBox();
59 double x_min = bounds.rGetLowerCorner()[0];
60 double x_max = bounds.rGetUpperCorner()[0];
61
62 if (mApplyExtrinsicPullToAllNodes)
63 {
64 // Pull on all nodes, with a constant strain rate
65 double width = x_max - x_min;
66 for (unsigned node_index=0; node_index<num_nodes; node_index++)
67 {
68 Node<DIM>* p_node = rCellPopulation.GetNode(node_index);
69 double speed = mSpeed * (p_node->rGetLocation()[0] - x_min) / width;
70
71 if (p_node->rGetLocation()[0] > x_min + epsilon)
72 {
73 p_node->rGetModifiableLocation()[0] += speed*dt;
74 }
75 }
76 }
77 else
78 {
79 // Pull on the right-most nodes only, with a constant speed
80 for (unsigned node_index=0; node_index<num_nodes; node_index++)
81 {
82 Node<DIM>* p_node = rCellPopulation.GetNode(node_index);
83 if (fabs(p_node->rGetLocation()[0] - x_max) < 0.1)
84 {
85 p_node->rGetModifiableLocation()[0] += mSpeed*dt;
86 }
87 }
88 }
89}
90
91template<unsigned DIM>
92void ExtrinsicPullModifier<DIM>::SetupSolve(AbstractCellPopulation<DIM,DIM>& rCellPopulation, std::string outputDirectory)
93{
94}
95
96template<unsigned DIM>
98{
99 mApplyExtrinsicPullToAllNodes = applyExtrinsicPullToAllNodes;
100}
101
102template<unsigned DIM>
104{
105 mSpeed = speed;
106}
107
108template<unsigned DIM>
110{
111 return mApplyExtrinsicPullToAllNodes;
112}
113
114template<unsigned DIM>
116{
117 return mSpeed;
118}
119
120template<unsigned DIM>
122{
123 *rParamsFile << "\t\t\t<ApplyExtrinsicPullToAllNodes>" << mApplyExtrinsicPullToAllNodes << "</ApplyExtrinsicPullToAllNodes>\n";
124 *rParamsFile << "\t\t\t<Speed>" << mSpeed << "</Speed>\n";
125
126 // Next, call method on direct parent class
128}
129
130// Explicit instantiation
131template class ExtrinsicPullModifier<1>;
132template class ExtrinsicPullModifier<2>;
133template class ExtrinsicPullModifier<3>;
134
135// Serialization for Boost >= 1.36
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)=0
virtual Node< SPACE_DIM > * GetNode(unsigned index)=0
virtual unsigned GetNumNodes()=0
AbstractMesh< ELEMENT_DIM, SPACE_DIM > & rGetMesh()
const ChastePoint< SPACE_DIM > & rGetUpperCorner() const
const ChastePoint< SPACE_DIM > & rGetLowerCorner() const
virtual void UpdateAtEndOfTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
void SetApplyExtrinsicPullToAllNodes(bool applyExtrinsicPullToAllNodes)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
Definition Node.hpp:59
c_vector< double, SPACE_DIM > & rGetModifiableLocation()
Definition Node.cpp:151
const c_vector< double, SPACE_DIM > & rGetLocation() const
Definition Node.cpp:139
double GetTimeStep() const
static SimulationTime * Instance()