CellBasedPdeHandlerOnCuboid.cpp
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
00030
00031
00032
00033
00034
00035
00036 #include "CellBasedPdeHandlerOnCuboid.hpp"
00037 #include "ConstBoundaryCondition.hpp"
00038
00039 template<unsigned DIM>
00040 CellBasedPdeHandlerOnCuboid<DIM>::CellBasedPdeHandlerOnCuboid(AbstractCellPopulation<DIM>* pCellPopulation,
00041 bool deleteMemberPointersInDestructor)
00042 : CellBasedPdeHandler<DIM>(pCellPopulation, deleteMemberPointersInDestructor)
00043 {
00044 }
00045
00046 template<unsigned DIM>
00047 CellBasedPdeHandlerOnCuboid<DIM>::~CellBasedPdeHandlerOnCuboid()
00048 {
00049
00050 for (unsigned i=0; i<mConstBoundaryConditions.size(); i++)
00051 {
00052 delete mConstBoundaryConditions[i];
00053 }
00054 }
00055
00056 template<unsigned DIM>
00057 std::auto_ptr<BoundaryConditionsContainer<DIM,DIM,1> > CellBasedPdeHandlerOnCuboid<DIM>::ConstructBoundaryConditionsContainer(
00058 PdeAndBoundaryConditions<DIM>* pPdeAndBc,
00059 TetrahedralMesh<DIM,DIM>* pMesh)
00060 {
00061
00062 assert(DIM==2);
00063
00064 std::auto_ptr<BoundaryConditionsContainer<DIM,DIM,1> > p_bcc(new BoundaryConditionsContainer<DIM,DIM,1>(false));
00065
00066
00067
00068
00069 c_vector<bool,4> are_neumann_boundaries;
00070 are_neumann_boundaries[0] = false;
00071 are_neumann_boundaries[1] = true;
00072 are_neumann_boundaries[2] = false;
00073 are_neumann_boundaries[3] = true;
00074
00075
00076 c_vector<double,4> boundary_condition_values;
00077 boundary_condition_values[0] = 1.0;
00078 boundary_condition_values[1] = 1.0;
00079 boundary_condition_values[2] = 1.0;
00080 boundary_condition_values[3] = 1.0;
00081
00082
00083 for (unsigned i=0; i<mConstBoundaryConditions.size(); i++)
00084 {
00085 delete mConstBoundaryConditions[i];
00086 }
00087 mConstBoundaryConditions.clear();
00088
00089 mConstBoundaryConditions.push_back(new ConstBoundaryCondition<DIM>(boundary_condition_values[0]));
00090 mConstBoundaryConditions.push_back(new ConstBoundaryCondition<DIM>(boundary_condition_values[1]));
00091 mConstBoundaryConditions.push_back(new ConstBoundaryCondition<DIM>(boundary_condition_values[2]));
00092 mConstBoundaryConditions.push_back(new ConstBoundaryCondition<DIM>(boundary_condition_values[3]));
00093
00094 ChasteCuboid<DIM> cuboid = pMesh->CalculateBoundingBox();
00095
00096 double left = cuboid.rGetLowerCorner()[0];
00097 double bottom = cuboid.rGetLowerCorner()[1];
00098 double right = cuboid.rGetUpperCorner()[0];
00099 double top = cuboid.rGetUpperCorner()[1];
00100 double fudge_factor = 1e-6;
00101
00102
00103 for (typename TetrahedralMesh<DIM,DIM>::BoundaryElementIterator elem_iter = pMesh->GetBoundaryElementIteratorBegin();
00104 elem_iter != pMesh->GetBoundaryElementIteratorEnd();
00105 ++elem_iter)
00106 {
00107 double x_1 = (*elem_iter)->GetNodeLocation(0)[0];
00108
00109 double x_2 = (*elem_iter)->GetNodeLocation(1)[0];
00110
00111
00112 assert(!are_neumann_boundaries[0]);
00113
00114
00115
00116
00117
00118
00119
00120 if (are_neumann_boundaries[1])
00121 {
00122 if ( (x_1 > (right-fudge_factor) ) && (x_2 > (right-fudge_factor) ))
00123 {
00124 p_bcc->AddNeumannBoundaryCondition(*elem_iter, mConstBoundaryConditions[1]);
00125 }
00126 }
00127 assert(!are_neumann_boundaries[2]);
00128
00129
00130
00131
00132
00133
00134
00135 if (are_neumann_boundaries[3])
00136 {
00137 if ( (x_1 > (left+fudge_factor) ) && (x_2 < (left+fudge_factor) ))
00138 {
00139 p_bcc->AddNeumannBoundaryCondition(*elem_iter, mConstBoundaryConditions[3]);
00140 }
00141 }
00142 }
00143
00144
00145
00146 for (typename TetrahedralMesh<DIM,DIM>::BoundaryNodeIterator node_iter = pMesh->GetBoundaryNodeIteratorBegin();
00147 node_iter != pMesh->GetBoundaryNodeIteratorEnd();
00148 ++node_iter)
00149 {
00150
00151 double y = (*node_iter)->GetPoint()[1];
00152
00153 if (!are_neumann_boundaries[0])
00154 {
00155 if (y > top-fudge_factor)
00156 {
00157 p_bcc->AddDirichletBoundaryCondition(*node_iter, mConstBoundaryConditions[0]);
00158 }
00159 }
00160 assert(are_neumann_boundaries[1]);
00161
00162
00163
00164
00165
00166
00167
00168 if (!are_neumann_boundaries[2])
00169 {
00170 if (y < bottom+fudge_factor)
00171 {
00172 p_bcc->AddDirichletBoundaryCondition(*node_iter, mConstBoundaryConditions[2]);
00173 }
00174 }
00175 assert(are_neumann_boundaries[3]);
00176
00177
00178
00179
00180
00181
00182
00183 }
00184
00185 return p_bcc;
00186 }
00187
00188 template<unsigned DIM>
00189 void CellBasedPdeHandlerOnCuboid<DIM>::OutputParameters(out_stream& rParamsFile)
00190 {
00191 CellBasedPdeHandler<DIM>::OutputParameters(rParamsFile);
00192 }
00193
00194
00195 #include "SerializationExportWrapperForCpp.hpp"
00196 EXPORT_TEMPLATE_CLASS_SAME_DIMS(CellBasedPdeHandlerOnCuboid)
00197
00198
00199
00201
00202 template class CellBasedPdeHandlerOnCuboid<1>;
00203 template class CellBasedPdeHandlerOnCuboid<2>;
00204 template class CellBasedPdeHandlerOnCuboid<3>;