36 #include "PlaneBoundaryCondition.hpp"
37 #include "AbstractCentreBasedCellPopulation.hpp"
38 #include "VertexBasedCellPopulation.hpp"
39 #include "RandomNumberGenerator.hpp"
41 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
43 c_vector<double, SPACE_DIM> point,
44 c_vector<double, SPACE_DIM> normal)
47 mUseJiggledNodesOnPlane(false)
49 assert(norm_2(normal) > 0.0);
53 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
59 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
62 return mNormalToPlane;
66 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
69 mUseJiggledNodesOnPlane = useJiggledNodesOnPlane;
72 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
75 return mUseJiggledNodesOnPlane;
78 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
84 EXCEPTION(
"PlaneBoundaryCondition requires a subclass of AbstractOffLatticeCellPopulation.");
91 double max_jiggle = 1e-4;
98 cell_iter != this->mpCellPopulation->End();
101 unsigned node_index = this->mpCellPopulation->GetLocationIndexUsingCell(*cell_iter);
104 c_vector<double, SPACE_DIM> node_location = p_node->
rGetLocation();
106 double signed_distance = inner_prod(node_location - mPointOnPlane, mNormalToPlane);
107 if (signed_distance > 0.0)
110 c_vector<double, SPACE_DIM> nearest_point;
111 if (mUseJiggledNodesOnPlane)
117 nearest_point = node_location - signed_distance*mNormalToPlane;
125 assert(SPACE_DIM==ELEMENT_DIM);
129 unsigned num_nodes = this->mpCellPopulation->GetNumNodes();
130 for (
unsigned node_index=0; node_index<num_nodes; node_index++)
133 c_vector<double, SPACE_DIM> node_location = p_node->
rGetLocation();
135 double signed_distance = inner_prod(node_location - mPointOnPlane, mNormalToPlane);
136 if (signed_distance > 0.0)
139 c_vector<double, SPACE_DIM> nearest_point;
140 if (mUseJiggledNodesOnPlane)
146 nearest_point = node_location - signed_distance*mNormalToPlane;
161 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
164 bool condition_satisfied =
true;
168 EXCEPTION(
"PlaneBoundaryCondition is not implemented in 1D");
173 cell_iter != this->mpCellPopulation->End();
176 c_vector<double, SPACE_DIM> cell_location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
178 if (inner_prod(cell_location - mPointOnPlane, mNormalToPlane) > 0.0)
180 condition_satisfied =
false;
186 return condition_satisfied;
189 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
192 *rParamsFile <<
"\t\t\t<PointOnPlane>";
193 for (
unsigned index=0; index != SPACE_DIM-1U; index++)
195 *rParamsFile << mPointOnPlane[index] <<
",";
197 *rParamsFile << mPointOnPlane[SPACE_DIM-1] <<
"</PointOnPlane>\n";
199 *rParamsFile <<
"\t\t\t<NormalToPlane>";
200 for (
unsigned index=0; index != SPACE_DIM-1U; index++)
202 *rParamsFile << mNormalToPlane[index] <<
",";
204 *rParamsFile << mNormalToPlane[SPACE_DIM-1] <<
"</NormalToPlane>\n";
205 *rParamsFile <<
"\t\t\t<UseJiggledNodesOnPlane>" << mUseJiggledNodesOnPlane <<
"</UseJiggledNodesOnPlane>\n";
#define EXCEPTION(message)
void ImposeBoundaryCondition(const std::map< Node< SPACE_DIM > *, c_vector< double, SPACE_DIM > > &rOldLocations)
static RandomNumberGenerator * Instance()
#define EXPORT_TEMPLATE_CLASS_ALL_DIMS(CLASS)
void OutputCellPopulationBoundaryConditionParameters(out_stream &rParamsFile)
const c_vector< double, SPACE_DIM > & rGetLocation() const
bool VerifyBoundaryCondition()
c_vector< double, SPACE_DIM > mNormalToPlane
PlaneBoundaryCondition(AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > *pCellPopulation, c_vector< double, SPACE_DIM > point, c_vector< double, SPACE_DIM > normal)
void SetUseJiggledNodesOnPlane(bool useJiggledNodesOnPlane)
const c_vector< double, SPACE_DIM > & rGetNormalToPlane() const
c_vector< double, SPACE_DIM > & rGetModifiableLocation()
virtual void OutputCellPopulationBoundaryConditionParameters(out_stream &rParamsFile)=0
bool GetUseJiggledNodesOnPlane()
const c_vector< double, SPACE_DIM > & rGetPointOnPlane() const