00001
00002
00003
00004
00005
00006 #ifndef AMROC_PROBLEM_H
00007 #define AMROC_PROBLEM_H
00008
00009 #include "acousticsv3.h"
00010 #undef NAUX
00011 #define NAUX 5
00012
00013 #include "ClpProblem.h"
00014
00015 #define OWN_GFMAMRSOLVER
00016 #include "ClpStdGFMProblem.h"
00017 #include "ClpF77GFMFileOutput.h"
00018 #include "AMRGFMInterpolation.h"
00019 #include "StatCPTLevelSet.h"
00020 #include "F77Interfaces/F77BrepOutput.h"
00021
00022 #define MaxIntPoints (20)
00023
00024 class SolverSpecific :
00025 public AMRGFMSolver<VectorType,FixupType,FlagType,DIM> {
00026 typedef VectorType::InternalDataType DataType;
00027 typedef AMRGFMSolver<VectorType,FixupType,FlagType,DIM> base;
00028 public:
00029 typedef F77BrepOutput<VectorType,DIM> brep_output_type;
00030 typedef AMRGFMInterpolation<VectorType,FixupType,FlagType,DIM> interpolation_type;
00031 typedef ClpF77GFMFileOutput<VectorType,FixupType,FlagType,AuxType,DIM> output_type;
00032 typedef interpolation_type::point_type point_type;
00033
00034 SolverSpecific(IntegratorSpecific& integ,
00035 base::initial_condition_type& init,
00036 base::boundary_conditions_type& bc) : base(integ, init, bc) {
00037 SetLevelTransfer(new F77LevelTransfer<VectorType,DIM>(f_prolong, f_restrict));
00038 SetFileOutput(new ClpF77GFMFileOutput<VectorType,FixupType,FlagType,AuxType,DIM>(*this,integ,f_flgout));
00039 SetFixup(new FixupSpecific(integ));
00040 SetFlagging(new FlaggingSpecific(*this));
00041 AddGFM(new GhostFluidMethod<VectorType,DIM>(new F77GFMBoundary<VectorType,DIM>(f_ibndrfl),
00042 new StatCPTLevelSet<DataType,DIM>()));
00043 _BrepOutput = new brep_output_type(new interpolation_type(*this),f_out);
00044 _Interpolation = new interpolation_type(*this);
00045 _NIntPoints = 0;
00046 _IntName = "ptrack.txt";
00047 }
00048
00049 ~SolverSpecific() {
00050 DeleteGFM(_GFM[0]);
00051 delete _Flagging;
00052 delete _Fixup;
00053 delete _BrepOutput;
00054 delete _Interpolation;
00055 }
00056
00057 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00058 base::register_at(Ctrl,prefix);
00059 IntCtrl = base::LocCtrl.getSubDevice("TrackPressure");
00060 RegisterAt(IntCtrl,"NPoints",_NIntPoints);
00061 char VariableName[32];
00062 for (int nc=0; nc<MaxIntPoints; nc++) {
00063 for (int d=0; d<base::Dim(); d++) {
00064 std::sprintf(VariableName,"Point(%d,%d)",nc+1,d+1);
00065 RegisterAt(IntCtrl,VariableName,_IntPoints[nc](d));
00066 _IntPoints[nc](d) = 0.0;
00067 }
00068 }
00069 RegisterAt(IntCtrl,"FileName",_IntName);
00070 if (_BrepOutput) _BrepOutput->register_at(base::LocCtrl,prefix);
00071 }
00072 virtual void register_at(ControlDevice& Ctrl) {
00073 base::register_at(Ctrl);
00074 }
00075
00076 virtual void update() {
00077 base::update();
00078 if (_BrepOutput) _BrepOutput->update();
00079 }
00080
00081 virtual void SetupData() {
00082 base::SetupData();
00083 _Interpolation->SetupData(base::PGH(), base::NGhosts());
00084 if (_BrepOutput) _BrepOutput->SetupData(base::PGH(), base::NGhosts());
00085 }
00086
00087 virtual void Output() {
00088 if (CurrentTime(base::GH(),0) == base::LastOutputTime()) return;
00089
00090 int num_vertices=0, num_edges=0;
00091 const DataType* vertices=0;
00092 const int* edges=0;
00093
00094 if (!((CPTLevelSet<DataType,DIM> *)base::GFM(0).GetLevelSetP())->GetBrep(num_vertices,vertices,num_edges,edges))
00095 return;
00096
00097 _BrepOutput->WriteOut(base::U(),num_vertices,vertices,num_edges,edges);
00098
00099 base::Output();
00100 }
00101
00102 virtual void Advance(double& t, double& dt) {
00103 base::Advance(t,dt);
00104 if (_NIntPoints<=0 || _NIntPoints>MaxIntPoints) return;
00105
00106 int me = MY_PROC;
00107
00108 for (register int l=0; l<=FineLevel(base::GH()); l++) {
00109 int Time = CurrentTime(base::GH(),l);
00110 int press_cnt = base::Dim()+4;
00111 ((output_type*) _FileOutput)->Transform(base::U(), base::Work(), Time, l,
00112 press_cnt, base::t[l]);
00113 }
00114
00115 DataType* p = new DataType[_NIntPoints];
00116 _Interpolation->PointsValues(base::Work(),base::t[0],_NIntPoints,_IntPoints,p);
00117 _Interpolation->ArrayCombine(VizServer,_NIntPoints,p);
00118
00119
00120 if (me == VizServer) {
00121 std::ofstream outfile;
00122 std::ostream* out;
00123 outfile.open(_IntName.c_str(), std::ios::out | std::ios::app);
00124 out = new std::ostream(outfile.rdbuf());
00125 *out << base::t[0];
00126 for (int ns=0; ns<_NIntPoints; ns++)
00127 *out << " " << p[ns];
00128 *out << std::endl;
00129 outfile.close();
00130 delete out;
00131 }
00132
00133 delete [] p;
00134 }
00135
00136 protected:
00137 brep_output_type* _BrepOutput;
00138 interpolation_type* _Interpolation;
00139 ControlDevice IntCtrl;
00140 int _NIntPoints;
00141 point_type _IntPoints[MaxIntPoints];
00142 std::string _IntName;
00143 };