Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
SlidingBoundaryCondition.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 "SlidingBoundaryCondition.hpp"
37#include "AbstractCentreBasedCellPopulation.hpp"
38#include "VertexBasedCellPopulation.hpp"
39
40template<unsigned DIM>
42 double threshold)
43 : AbstractCellPopulationBoundaryCondition<DIM>(pCellPopulation),
44 mThreshold(threshold)
45{
46}
47
48template<unsigned DIM>
50{
51 return mThreshold;
52}
53
54template<unsigned DIM>
55void SlidingBoundaryCondition<DIM>::ImposeBoundaryCondition(const std::map<Node<DIM>*, c_vector<double, DIM> >& rOldLocations)
56{
58 if (dynamic_cast<AbstractOffLatticeCellPopulation<DIM>*>(this->mpCellPopulation) == nullptr)
59 {
60 EXCEPTION("SlidingBoundaryCondition requires a subclass of AbstractOffLatticeCellPopulation.");
61 }
62
63 ChasteCuboid<DIM> bounds = this->mpCellPopulation->rGetMesh().CalculateBoundingBox();
64 double x_min = bounds.rGetLowerCorner()[0];
65
66 // Loop over every node
67 for (unsigned node_index=0; node_index<this->mpCellPopulation->GetNumNodes(); node_index++)
68 {
69 Node<DIM>* p_node = this->mpCellPopulation->GetNode(node_index);
70
71 if (p_node->IsBoundaryNode())
72 {
73 c_vector<double, DIM> old_node_location;
74 old_node_location = rOldLocations.find(p_node)->second;
75
76 // If the node lies on the left, then revert its x coordinate
77 if (p_node->rGetLocation()[0] < x_min + mThreshold)
78 {
79 p_node->rGetModifiableLocation()[0] = old_node_location[0];
80 }
81 }
82 }
83}
84
85template<unsigned DIM>
87{
88 // Without further information, it is not possible to directly verify the boundary condition
89 return true;
90}
91
92template<unsigned DIM>
94{
95 *rParamsFile << "\t\t\t<Threshold>" << mThreshold << "</Threshold>\n";
96
97 // Call method on direct parent class
99}
100
101// Explicit instantiation
102template class SlidingBoundaryCondition<1>;
103template class SlidingBoundaryCondition<2>;
104template class SlidingBoundaryCondition<3>;
105
106// Serialization for Boost >= 1.36
#define EXCEPTION(message)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputCellPopulationBoundaryConditionParameters(out_stream &rParamsFile)=0
const ChastePoint< SPACE_DIM > & rGetLowerCorner() const
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
bool IsBoundaryNode() const
Definition Node.cpp:164
void OutputCellPopulationBoundaryConditionParameters(out_stream &rParamsFile)
void ImposeBoundaryCondition(const std::map< Node< DIM > *, c_vector< double, DIM > > &rOldLocations)
SlidingBoundaryCondition(AbstractCellPopulation< DIM > *pCellPopulation, double threshold=0.8)