36 #include "AbstractNumericalMethod.hpp"
37 #include "StepSizeException.hpp"
38 #include "Warnings.hpp"
39 #include "AbstractCentreBasedCellPopulation.hpp"
40 #include "NodeBasedCellPopulationWithBuskeUpdate.hpp"
41 #include "MeshBasedCellPopulationWithGhostNodes.hpp"
42 #include "CellBasedEventHandler.hpp"
44 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
46 : mpCellPopulation(nullptr),
47 mpForceCollection(nullptr),
48 mUseAdaptiveTimestep(false),
49 mUseUpdateNodeLocation(false),
50 mGhostNodeForcesEnabled(true)
55 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
60 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
63 mpCellPopulation = pPopulation;
68 mUseUpdateNodeLocation =
true;
69 WARNING(
"Non-Euler steppers are not yet implemented for NodeBasedCellPopulationWithBuskeUpdate");
74 mGhostNodeForcesEnabled =
true;
78 mGhostNodeForcesEnabled =
false;
82 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
85 mpForceCollection = pForces;
88 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
91 mUseAdaptiveTimestep = useAdaptiveTimestep;
94 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
97 return mUseAdaptiveTimestep;
100 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
106 node_iter != mpCellPopulation->rGetMesh().GetNodeIteratorEnd(); ++node_iter)
108 node_iter->ClearAppliedForce();
112 iter != mpForceCollection->end(); ++iter)
114 (*iter)->AddForceContribution(*mpCellPopulation);
123 if (mGhostNodeForcesEnabled)
129 std::vector<c_vector<double, SPACE_DIM> > forces_as_vector;
130 forces_as_vector.reserve(mpCellPopulation->GetNumNodes());
133 node_iter != mpCellPopulation->rGetMesh().GetNodeIteratorEnd(); ++node_iter)
135 double damping = mpCellPopulation->GetDampingConstant(node_iter->GetIndex());
136 forces_as_vector.push_back(node_iter->rGetAppliedForce()/damping);
141 return forces_as_vector;
144 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
147 std::vector<c_vector<double, SPACE_DIM> > current_locations;
148 current_locations.reserve(mpCellPopulation->GetNumNodes());
151 node_iter != mpCellPopulation->rGetMesh().GetNodeIteratorEnd();
154 current_locations.push_back(node_iter->rGetLocation());
157 return current_locations;
160 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
164 mpCellPopulation->SetNode(nodeIndex, new_point);
167 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
172 mpCellPopulation->CheckForStepSizeException(nodeIndex, displacement, dt);
176 if (!(e.
IsTerminal()) && (mUseAdaptiveTimestep==
false))
183 WARN_ONCE_ONLY(e.
what());
192 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
195 mUseUpdateNodeLocation = useUpdateNodeLocation;
198 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
201 return mUseUpdateNodeLocation;
204 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
207 std::string numerical_method_type = GetIdentifier();
209 *rParamsFile <<
"\t\t<" << numerical_method_type <<
">\n";
210 OutputNumericalMethodParameters(rParamsFile);
211 *rParamsFile <<
"\t\t</" << numerical_method_type <<
">\n";
214 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
217 *rParamsFile <<
"\t\t\t<UseAdaptiveTimestep>" << mUseAdaptiveTimestep <<
"</UseAdaptiveTimestep> \n";
218 *rParamsFile <<
"\t\t\t<UseUpdateNodeLocation>" << mUseUpdateNodeLocation <<
"</UseUpdateNodeLocation> \n";
219 *rParamsFile <<
"\t\t\t<GhostNodeForcesEnabled>" << mGhostNodeForcesEnabled <<
"</GhostNodeForcesEnabled> \n";
void SafeNodePositionUpdate(unsigned nodeIndex, c_vector< double, SPACE_DIM > newPosition)
virtual const char * what() const
virtual ~AbstractNumericalMethod()
static void BeginEvent(unsigned event)
void SetForceCollection(std::vector< boost::shared_ptr< AbstractForce< ELEMENT_DIM, SPACE_DIM > > > *pForces)
virtual void OutputNumericalMethodParameters(out_stream &rParamsFile)
void OutputNumericalMethodInfo(out_stream &rParamsFile)
bool HasAdaptiveTimestep()
void SetUseUpdateNodeLocation(bool useUpdateNodeLocation)
void SetUseAdaptiveTimestep(bool useAdaptiveTimestep)
void SetCellPopulation(AbstractOffLatticeCellPopulation< ELEMENT_DIM, SPACE_DIM > *pPopulation)
std::vector< c_vector< double, SPACE_DIM > > SaveCurrentLocations()
void DetectStepSizeExceptions(unsigned nodeIndex, c_vector< double, SPACE_DIM > &displacement, double dt)
static void EndEvent(unsigned event)
std::vector< c_vector< double, SPACE_DIM > > ComputeForcesIncludingDamping()
AbstractNumericalMethod()
bool GetUseUpdateNodeLocation()