9 void ConvergenceStudy::Reset()
22 DGFaceErrors.SetSize(0);
23 DGFaceRates.SetSize(0);
30 bool norm_set =
false;
33 int order_quad = std::max(2, 2*order+1);
35 for (
int i=0; i < Geometry::NumGeom; ++i)
40 ParGridFunction *pgf =
dynamic_cast<ParGridFunction *
>(gf);
43 ParMesh *pmesh = pgf->ParFESpace()->GetParMesh();
70 void ConvergenceStudy::AddL2Error(GridFunction *gf,
71 Coefficient *scalar_u, VectorCoefficient *vector_u)
75 ParGridFunction *pgf =
dynamic_cast<ParGridFunction *
>(gf);
78 MPI_Comm comm = pgf->ParFESpace()->GetComm();
80 MPI_Comm_rank(comm, &rank);
82 if (rank==0) { print_flag = 1; }
83 tdofs = pgf->ParFESpace()->GlobalTrueVSize();
86 if (!tdofs) { tdofs = gf->FESpace()->GetTrueVSize(); }
91 L2Err = gf->ComputeL2Error(*scalar_u);
92 CoeffNorm = GetNorm(gf,scalar_u,
nullptr);
96 L2Err = gf->ComputeL2Error(*vector_u);
97 CoeffNorm = GetNorm(gf,
nullptr,vector_u);
101 MFEM_ABORT(
"Exact Solution Coefficient pointer is NULL");
103 L2Errors.Append(L2Err);
106 double val = (counter) ? log(L2Errors[counter-1]/L2Err)/log(2.0) : 0.0;
111 void ConvergenceStudy::AddGf(GridFunction *gf, Coefficient *scalar_u,
112 VectorCoefficient *grad,
113 Coefficient *ell_coeff,
114 JumpScaling jump_scaling)
116 cont_type = gf->FESpace()->FEColl()->GetContType();
120 "This constructor is intended for H1 or L2 Elements")
122 AddL2Error(gf,scalar_u,
nullptr);
126 double GradErr = gf->ComputeGradError(grad);
127 DErrors.Append(GradErr);
128 double err = sqrt(L2Errors[counter-1]*L2Errors[counter-1]+GradErr*GradErr);
129 EnErrors.Append(err);
132 double val = (dcounter) ? log(DErrors[dcounter-1]/GradErr)/log(2.0) : 0.0;
133 double eval = (dcounter) ? log(EnErrors[dcounter-1]/err)/log(2.0) : 0.0;
135 EnRates.Append(eval);
136 CoeffDNorm = GetNorm(gf,
nullptr,grad);
138 MFEM_VERIFY(counter == dcounter,
139 "Number of added solutions and derivatives do not match")
144 double DGErr = gf->ComputeDGFaceJumpError(scalar_u,ell_coeff,jump_scaling);
145 DGFaceErrors.Append(DGErr);
148 double val=(fcounter) ? log(DGFaceErrors[fcounter-1]/DGErr)/log(2.0):0.;
149 DGFaceRates.Append(val);
151 MFEM_VERIFY(fcounter == counter,
"Number of added solutions mismatch");
155 void ConvergenceStudy::AddGf(GridFunction *gf, VectorCoefficient *vector_u,
156 VectorCoefficient *curl, Coefficient *div)
158 cont_type = gf->FESpace()->FEColl()->GetContType();
160 AddL2Error(gf,
nullptr,vector_u);
162 bool derivative =
false;
165 DErr = gf->ComputeCurlError(curl);
166 CoeffDNorm = GetNorm(gf,
nullptr,curl);
171 DErr = gf->ComputeDivError(div);
173 CoeffDNorm = GetNorm(gf,div,
nullptr);
178 double err = sqrt(L2Errors[counter-1]*L2Errors[counter-1] + DErr*DErr);
179 DErrors.Append(DErr);
180 EnErrors.Append(err);
183 double val = (dcounter) ? log(DErrors[dcounter-1]/DErr)/log(2.0) : 0.0;
184 double eval = (dcounter) ? log(EnErrors[dcounter-1]/err)/log(2.0) : 0.0;
186 EnRates.Append(eval);
188 MFEM_VERIFY(counter == dcounter,
189 "Number of added solutions and derivatives do not match")
193 void ConvergenceStudy::Print(
bool relative, std::ostream &
out)
197 std::string title = (relative) ?
"Relative " :
"Absolute ";
199 out <<
" -------------------------------------------" <<
"\n";
200 out << std::setw(21) << title <<
"L2 Error " <<
"\n";
201 out <<
" -------------------------------------------"
203 out << std::right<< std::setw(11)<<
"DOFs "<< std::setw(13) <<
"Error ";
204 out << std::setw(15) <<
"Rate " <<
"\n";
205 out <<
" -------------------------------------------"
207 out << std::setprecision(4);
208 double d = (relative) ? CoeffNorm : 1.0;
209 for (
int i =0; i<counter; i++)
211 out << std::right << std::setw(10)<< ndofs[i] << std::setw(16)
212 << std::scientific << L2Errors[i]/d << std::setw(13)
213 << std::fixed << L2Rates[i] <<
"\n";
216 if (dcounter == counter)
221 case 0: dname =
"Grad";
break;
222 case 1: dname =
"Curl";
break;
223 case 2: dname =
"Div";
break;
224 case 3: dname =
"DG Grad";
break;
227 out <<
" -------------------------------------------" <<
"\n";
228 out << std::setw(21) << title << dname <<
" Error " <<
"\n";
229 out <<
" -------------------------------------------" <<
"\n";
230 out << std::right<<std::setw(11)<<
"DOFs "<< std::setw(13) <<
"Error";
231 out << std::setw(15) <<
"Rate " <<
"\n";
232 out <<
" -------------------------------------------"
234 out << std::setprecision(4);
235 d = (relative) ? CoeffDNorm : 1.0;
236 for (
int i =0; i<dcounter; i++)
238 out << std::right << std::setw(10)<< ndofs[i] << std::setw(16)
239 << std::scientific << DErrors[i]/d << std::setw(13)
240 << std::fixed << DRates[i] <<
"\n";
245 case 0: dname =
"H1";
break;
246 case 1: dname =
"H(Curl)";
break;
247 case 2: dname =
"H(Div)";
break;
248 case 3: dname =
"DG H1";
break;
255 sqrt(CoeffNorm*CoeffNorm + CoeffDNorm*CoeffDNorm):1.0;
257 out <<
" -------------------------------------------" <<
"\n";
258 out << std::setw(21) << title << dname <<
" Error " <<
"\n";
259 out <<
" -------------------------------------------" <<
"\n";
260 out << std::right<< std::setw(11)<<
"DOFs "<< std::setw(13);
262 out << std::setw(15) <<
"Rate " <<
"\n";
263 out <<
" -------------------------------------------"
265 out << std::setprecision(4);
266 for (
int i =0; i<dcounter; i++)
268 out << std::right << std::setw(10)<< ndofs[i] << std::setw(16)
269 << std::scientific << EnErrors[i]/d << std::setw(13)
270 << std::fixed << EnRates[i] <<
"\n";
275 if (cont_type == 3 && fcounter)
277 out <<
" -------------------------------------------" <<
"\n";
278 out <<
" DG Face Jump Error " <<
"\n";
279 out <<
" -------------------------------------------"
281 out << std::right<< std::setw(11)<<
"DOFs "<< std::setw(13);
283 out << std::setw(15) <<
"Rate " <<
"\n";
284 out <<
" -------------------------------------------"
286 out << std::setprecision(4);
287 for (
int i =0; i<fcounter; i++)
289 out << std::right << std::setw(10)<< ndofs[i] << std::setw(16)
290 << std::scientific << DGFaceErrors[i] << std::setw(13)
291 << std::fixed << DGFaceRates[i] <<
"\n";
Field is discontinuous across element interfaces.
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Base class for vector Coefficients that optionally depend on time and space.
double ComputeLpNorm(double p, Coefficient &coeff, Mesh &mesh, const IntegrationRule *irs[])
Compute the Lp norm of a function f. .
Mesh * GetMesh() const
Returns the mesh.
int GetMaxElementOrder() const
Return the maximum polynomial order.
FiniteElementSpace * FESpace()
OutStream err(std::cerr)
Global stream used by the library for standard error output. Initially it uses the same std::streambu...
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Field is continuous across element interfaces.
double ComputeGlobalLpNorm(double p, Coefficient &coeff, ParMesh &pmesh, const IntegrationRule *irs[])
Compute the global Lp norm of a function f. .
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)