00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "PlaneBoundaryCondition.hpp"
00030 #include "AbstractCentreBasedCellPopulation.hpp"
00031
00032 template<unsigned DIM>
00033 PlaneBoundaryCondition<DIM>::PlaneBoundaryCondition(AbstractCellPopulation<DIM>* pCellPopulation,
00034 c_vector<double, DIM> point,
00035 c_vector<double, DIM> normal)
00036 : AbstractCellPopulationBoundaryCondition<DIM>(pCellPopulation),
00037 mPointOnPlane(point)
00038 {
00039 assert( (dynamic_cast<AbstractCentreBasedCellPopulation<DIM>*>(this->mpCellPopulation)) || (this->mpCellPopulation == NULL));
00040
00041 assert(norm_2(normal) > 0.0);
00042 mNormalToPlane = normal/norm_2(normal);
00043 }
00044
00045 template<unsigned DIM>
00046 const c_vector<double, DIM>& PlaneBoundaryCondition<DIM>::rGetPointOnPlane() const
00047 {
00048 return mPointOnPlane;
00049 }
00050
00051 template<unsigned DIM>
00052 const c_vector<double, DIM>& PlaneBoundaryCondition<DIM>::rGetNormalToPlane() const
00053 {
00054 return mNormalToPlane;
00055 }
00056
00057 template<unsigned DIM>
00058 void PlaneBoundaryCondition<DIM>::ImposeBoundaryCondition()
00059 {
00060 if (DIM==2)
00061 {
00062 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
00063 cell_iter != this->mpCellPopulation->End();
00064 ++cell_iter)
00065 {
00067 c_vector<double, DIM> cell_location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
00068
00069 unsigned node_index = this->mpCellPopulation->GetLocationIndexUsingCell(*cell_iter);
00070 Node<DIM>* p_node = this->mpCellPopulation->GetNode(node_index);
00071
00072 if (inner_prod(cell_location - mPointOnPlane,mNormalToPlane) > 0.0)
00073 {
00074 c_vector<double, 2> tangent;
00075 tangent(0) = -mNormalToPlane(1);
00076 tangent(1) = mNormalToPlane(0);
00077
00078 c_vector<double, 2> intersection = mPointOnPlane + inner_prod(tangent,cell_location- mPointOnPlane)*tangent;
00079
00080 p_node->rGetModifiableLocation() = intersection;
00081 }
00082 }
00083 }
00084 else
00085 {
00086 EXCEPTION("PlaneBoundaryCondition is not yet implemented in 1D or 3D");
00087 }
00088 }
00089
00090 template<unsigned DIM>
00091 bool PlaneBoundaryCondition<DIM>::VerifyBoundaryCondition()
00092 {
00093 bool condition_satisfied = true;
00094
00095 if (DIM==2)
00096 {
00097 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
00098 cell_iter != this->mpCellPopulation->End();
00099 ++cell_iter)
00100 {
00101 c_vector<double, DIM> cell_location = this->mpCellPopulation->GetLocationOfCellCentre(*cell_iter);
00102
00103 if ( inner_prod(cell_location - mPointOnPlane,mNormalToPlane) > 0.0 )
00104 {
00105 condition_satisfied = false;
00106 break;
00107 }
00108 }
00109 }
00110 else
00111 {
00112 EXCEPTION("PlaneBoundaryCondition is not yet implemented in 1D or 3D");
00113 }
00114
00115 return condition_satisfied;
00116 }
00117
00118 template<unsigned DIM>
00119 void PlaneBoundaryCondition<DIM>::OutputCellPopulationBoundaryConditionParameters(out_stream& rParamsFile)
00120 {
00121 *rParamsFile << "\t\t\t<PointOnPlane>";
00122 for (unsigned index=0; index != DIM-1U; index++)
00123 {
00124 *rParamsFile << mPointOnPlane[index] << ",";
00125 }
00126 *rParamsFile << mPointOnPlane[DIM-1] << "</PointOnPlane> \n";
00127
00128 *rParamsFile << "\t\t\t<NormalToPlane>";
00129 for (unsigned index=0; index != DIM-1U; index++)
00130 {
00131 *rParamsFile << mNormalToPlane[index] << ",";
00132 }
00133 *rParamsFile << mNormalToPlane[DIM-1] << "</NormalToPlane> \n";
00134
00135
00136 AbstractCellPopulationBoundaryCondition<DIM>::OutputCellPopulationBoundaryConditionParameters(rParamsFile);
00137 }
00138
00140
00142
00143 template class PlaneBoundaryCondition<1>;
00144 template class PlaneBoundaryCondition<2>;
00145 template class PlaneBoundaryCondition<3>;
00146
00147
00148 #include "SerializationExportWrapperForCpp.hpp"
00149 EXPORT_TEMPLATE_CLASS_SAME_DIMS(PlaneBoundaryCondition)