36 #include "SphereGeometryBoundaryCondition.hpp"
37 #include "NodeBasedCellPopulation.hpp"
39 template<
unsigned DIM>
41 c_vector<double, DIM> centre,
45 mCentreOfSphere(centre),
46 mRadiusOfSphere(radius),
47 mMaximumDistance(distance)
54 EXCEPTION(
"A NodeBasedCellPopulation must be used with this boundary condition object.");
58 EXCEPTION(
"This boundary condition is not implemented in 1D.");
62 template<
unsigned DIM>
65 return mCentreOfSphere;
68 template<
unsigned DIM>
71 return mRadiusOfSphere;
74 template<
unsigned DIM>
79 cell_iter != this->mpCellPopulation->End();
83 c_vector<double,DIM> cell_location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
84 double radius = norm_2(cell_location - mCentreOfSphere);
85 assert(radius != 0.0);
88 if (fabs(radius - mRadiusOfSphere) > mMaximumDistance)
91 c_vector<double, DIM> location_on_sphere =
92 mCentreOfSphere + mRadiusOfSphere*(cell_location - mCentreOfSphere)/radius;
94 unsigned node_index = this->mpCellPopulation->GetLocationIndexUsingCell(*cell_iter);
95 Node<DIM>* p_node = this->mpCellPopulation->GetNode(node_index);
102 template<
unsigned DIM>
105 bool condition_satisfied =
true;
109 cell_iter != this->mpCellPopulation->End();
113 c_vector<double,DIM> cell_location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
114 double radius = norm_2(cell_location - mCentreOfSphere);
117 if (fabs(radius - mRadiusOfSphere) > mMaximumDistance)
120 condition_satisfied =
false;
124 return condition_satisfied;
127 template<
unsigned DIM>
130 *rParamsFile <<
"\t\t\t<CentreOfSphere>";
131 for (
unsigned index=0; index != DIM-1U; index++)
133 *rParamsFile << mCentreOfSphere[index] <<
",";
135 *rParamsFile << mCentreOfSphere[DIM-1] <<
"</CentreOfSphere>\n";
137 *rParamsFile <<
"\t\t\t<RadiusOfSphere>" << mRadiusOfSphere <<
"</RadiusOfSphere>\n";
138 *rParamsFile <<
"\t\t\t<MaximumDistance>" << mMaximumDistance <<
"</MaximumDistance>\n";
AbstractCellPopulation< ELEMENT_DIM, ELEMENT_DIM > * mpCellPopulation
void ImposeBoundaryCondition(const std::map< Node< DIM > *, c_vector< double, DIM > > &rOldLocations)
bool VerifyBoundaryCondition()
#define EXCEPTION(message)
double GetRadiusOfSphere() const
void OutputCellPopulationBoundaryConditionParameters(out_stream &rParamsFile)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
SphereGeometryBoundaryCondition(AbstractCellPopulation< DIM > *pCellPopulation, c_vector< double, DIM > centre, double radius, double distance=1e-5)
c_vector< double, SPACE_DIM > & rGetModifiableLocation()
virtual void OutputCellPopulationBoundaryConditionParameters(out_stream &rParamsFile)=0
const c_vector< double, DIM > & rGetCentreOfSphere() const