36 #include "AbstractPdeModifier.hpp"
37 #include "VtkMeshWriter.hpp"
38 #include "ReplicatableVector.hpp"
39 #include "AveragedSourceEllipticPde.hpp"
40 #include "AveragedSourceParabolicPde.hpp"
42 template<
unsigned DIM>
45 bool isNeumannBoundaryCondition,
49 mpBoundaryCondition(pBoundaryCondition),
50 mIsNeumannBoundaryCondition(isNeumannBoundaryCondition),
53 mOutputGradient(false),
54 mOutputSolutionAtPdeNodes(false),
63 template<
unsigned DIM>
66 if (mDeleteFeMesh and mpFeMesh!=
nullptr)
76 template<
unsigned DIM>
82 template<
unsigned DIM>
85 return mpBoundaryCondition;
88 template<
unsigned DIM>
91 return mIsNeumannBoundaryCondition;
94 template<
unsigned DIM>
97 mDependentVariableName = rName;
100 template<
unsigned DIM>
103 return mDependentVariableName;
106 template<
unsigned DIM>
113 template<
unsigned DIM>
116 assert(HasAveragedSourcePde());
127 template<
unsigned DIM>
133 template<
unsigned DIM>
139 template<
unsigned DIM>
145 template<
unsigned DIM>
149 this->mOutputDirectory = outputDirectory;
151 if (mOutputSolutionAtPdeNodes)
156 mpVizPdeSolutionResultsFile = output_file_handler.
OpenOutputFile(
"results.vizpdesolution");
161 template<
unsigned DIM>
164 if (mOutputSolutionAtPdeNodes)
170 assert(mpFeMesh !=
nullptr);
171 assert(mDependentVariableName !=
"");
173 for (
unsigned i=0; i<mpFeMesh->GetNumNodes(); i++)
175 (*mpVizPdeSolutionResultsFile) << i <<
" ";
176 const c_vector<double,DIM>& r_location = mpFeMesh->GetNode(i)->rGetLocation();
177 for (
unsigned k=0; k<DIM; k++)
179 (*mpVizPdeSolutionResultsFile) << r_location[k] <<
" ";
182 assert(mSolution !=
nullptr);
184 (*mpVizPdeSolutionResultsFile) << solution_repl[i] <<
" ";
187 (*mpVizPdeSolutionResultsFile) <<
"\n";
193 std::ostringstream time_string;
195 std::string results_file =
"pde_results_" + mDependentVariableName +
"_" + time_string.str();
199 std::vector<double> pde_solution;
200 for (
unsigned i=0; i<mpFeMesh->GetNumNodes(); i++)
202 pde_solution.push_back(solution_repl[i]);
205 p_vtk_mesh_writer->
AddPointData(mDependentVariableName, pde_solution);
208 delete p_vtk_mesh_writer;
213 template<
unsigned DIM>
216 if (mOutputSolutionAtPdeNodes)
220 mpVizPdeSolutionResultsFile->close();
225 template<
unsigned DIM>
228 return mOutputGradient;
231 template<
unsigned DIM>
234 mOutputGradient = outputGradient;
237 template<
unsigned DIM>
240 mOutputSolutionAtPdeNodes = outputSolutionAtPdeNodes;
243 template<
unsigned DIM>
virtual void UpdateAtEndOfOutputTimeStep(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
void SetOutputGradient(bool outputGradient)
virtual void SetupSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation, std::string outputDirectory)
bool HasAveragedSourcePde()
static SimulationTime * Instance()
bool IsNeumannBoundaryCondition()
unsigned GetTimeStepsElapsed() const
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)=0
void SetDependentVariableName(const std::string &rName)
virtual void UpdateAtEndOfSolve(AbstractCellPopulation< DIM, DIM > &rCellPopulation)
void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
out_stream OpenOutputFile(const std::string &rFileName, std::ios_base::openmode mode=std::ios::out|std::ios::trunc) const
void SetOutputSolutionAtPdeNodes(bool outputSolutionAtPdeNodes)
AbstractPdeModifier(boost::shared_ptr< AbstractLinearPde< DIM, DIM > > pPde=NULL, boost::shared_ptr< AbstractBoundaryCondition< DIM > > pBoundaryCondition=boost::shared_ptr< AbstractBoundaryCondition< DIM > >(), bool isNeumannBoundaryCondition=true, Vec solution=nullptr)
void OutputSimulationModifierParameters(out_stream &rParamsFile)
std::string & rGetDependentVariableName()
boost::shared_ptr< AbstractBoundaryCondition< DIM > > GetBoundaryCondition()
void SetUpSourceTermsForAveragedSourcePde(TetrahedralMesh< DIM, DIM > *pMesh, std::map< CellPtr, unsigned > *pCellPdeElementMap=nullptr)
virtual ~AbstractPdeModifier()
TetrahedralMesh< DIM, DIM > * GetFeMesh() const
void AddPointData(std::string name, std::vector< double > data)
boost::shared_ptr< AbstractLinearPde< DIM, DIM > > GetPde()