Chaste Commit::baa90ac2819b962188b7562f2326be23c47859a7
PlanarPolarisedFarhadifarForce.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 "PlanarPolarisedFarhadifarForce.hpp"
37
38template<unsigned DIM>
40 : FarhadifarForce<DIM>(),
41 mPlanarPolarisedLineTensionMultiplier(2.0)
42{
43}
44
45template<unsigned DIM>
49
50template<unsigned DIM>
52{
53 return mPlanarPolarisedLineTensionMultiplier;
54}
55
56template<unsigned DIM>
58{
59 mPlanarPolarisedLineTensionMultiplier = planarPolarisedLineTensionMultiplier;
60}
61
62template<unsigned DIM>
64{
65 // Find the indices of the elements owned by each node
66 std::set<unsigned> elements_containing_nodeA = pNodeA->rGetContainingElementIndices();
67 std::set<unsigned> elements_containing_nodeB = pNodeB->rGetContainingElementIndices();
68
69 // Find common elements
70 std::set<unsigned> shared_elements;
71 std::set_intersection(elements_containing_nodeA.begin(),
72 elements_containing_nodeA.end(),
73 elements_containing_nodeB.begin(),
74 elements_containing_nodeB.end(),
75 std::inserter(shared_elements, shared_elements.begin()));
76
77 // Check that the nodes have a common edge
78 assert(!shared_elements.empty());
79
80 // Since each internal edge is visited twice in the loop above, we have to use half the line tension parameter
81 // for each visit.
82 double line_tension_parameter_in_calculation = this->mLineTensionParameter/2.0;
83
84 // If the edge corresponds to a single element, then the cell is on the boundary
85 if (shared_elements.size() == 1)
86 {
87 line_tension_parameter_in_calculation = this->mBoundaryLineTensionParameter;
88 }
89
90 // Get the vector between the two vertices
91 c_vector<double, 2> vector = pNodeB->rGetLocation() - pNodeA->rGetLocation();
92 double theta = atan2(fabs(vector(1)), fabs(vector(0)));
93
94 if ((theta > 0.25*M_PI) && (theta < 0.75*M_PI))
95 {
96 line_tension_parameter_in_calculation *= mPlanarPolarisedLineTensionMultiplier;
97 }
98
99 return line_tension_parameter_in_calculation;
100}
101
102template<unsigned DIM>
104{
105 return this->mLineTensionParameter;
106}
107
108template<unsigned DIM>
110{
111 return this->mBoundaryLineTensionParameter;
112}
113
114
115template<unsigned DIM>
117{
118 *rParamsFile << "\t\t\t<PlanarPolarisedLineTensionMultiplier>" << mPlanarPolarisedLineTensionMultiplier << "</PlanarPolarisedLineTensionMultiplier>\n";
119
120 // Call method on direct parent class
122}
123
124// Explicit instantiation
128
129// Serialization for Boost >= 1.36
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void OutputForceParameters(out_stream &rParamsFile)
Definition Node.hpp:59
std::set< unsigned > & rGetContainingElementIndices()
Definition Node.cpp:300
const c_vector< double, SPACE_DIM > & rGetLocation() const
Definition Node.cpp:139
void SetPlanarPolarisedLineTensionMultiplier(double planarPolarisedLineTensionMultiplier)
void OutputForceParameters(out_stream &rParamsFile)