190class PlotRefOutputObserver
191:
public ITimeIntegratorObserver<TDomain, TAlgebra>
194 typedef ITimeIntegratorObserver<TDomain, TAlgebra> base_type;
195 typedef GridFunction<TDomain, TAlgebra> grid_function_type;
196 typedef VTKOutput<TDomain::dim> vtk_type;
198 PlotRefOutputObserver(SmartPtr<UserData<number, grid_function_type::dim> > spExactSol)
199 { m_spReference = spExactSol; }
202 PlotRefOutputObserver(
const char *ExactSol)
204 { m_spReference = make_sp(
new LuaUserData<number, grid_function_type::dim>(ExactSol)); }
206 PlotRefOutputObserver(
const char *ExactSol, SmartPtr<vtk_type> vtk)
208 { m_spReference = make_sp(
new LuaUserData<number, grid_function_type::dim>(ExactSol)); }
212 virtual ~PlotRefOutputObserver()
216 bool step_process(SmartPtr<grid_function_type> uNew,
int step, number time, number dt) OVERRIDE
218 UG_LOG(
"L2Error(\t"<< time <<
"\t) = \t" << L2Error(m_spReference, uNew,
"c", time, 4) << std::endl);
219 if (m_sp_vtk.valid())
221 SmartPtr<grid_function_type> ref = uNew->clone();
222 Interpolate<grid_function_type> (m_spReference, ref,
"c", time);
223 m_sp_vtk->print(
"MyReference", *ref, step, time);
233 SmartPtr<UserData<number, grid_function_type::dim> > m_spReference;
234 SmartPtr<vtk_type> m_sp_vtk;
242class IntegrationOutputObserver
243:
public ITimeIntegratorObserver<TDomain, TAlgebra>
246 typedef ITimeIntegratorObserver<TDomain, TAlgebra> base_type;
247 typedef GridFunction<TDomain, TAlgebra> grid_function_type;
248 typedef VTKOutput<TDomain::dim> vtk_type;
252 IntegralSpecs(
const char* cmp,
const char* subsets,
int quadOrder,
const char *idString) :
253 m_cmp(cmp), m_subsets(subsets), m_quadOrder(quadOrder), m_idString(idString)
256 std::string m_subsets;
258 std::string m_idString;
250 struct IntegralSpecs {
…};
262 IntegrationOutputObserver() : m_vIntegralData()
269 bool step_process(SmartPtr<grid_function_type> uNew,
int step, number time, number dt) OVERRIDE
272 for (
typename std::vector<IntegralSpecs>::iterator it = m_vIntegralData.begin();
273 it!=m_vIntegralData.end(); ++it)
275 number value=Integral(uNew, it->m_cmp.c_str(), it->m_subsets.c_str(), it->m_quadOrder);
276 UG_LOG(
"Integral(\t"<< it->m_idString <<
"\t"<< time <<
"\t)=\t" << value << std::endl);
285 void add_integral_specs(
const char* cmp,
const char* subsets,
int quadOrder,
const char* idString)
287 m_vIntegralData.push_back(IntegralSpecs(cmp, subsets, quadOrder, idString));
292 std::vector<IntegralSpecs> m_vIntegralData;