Skip to content

Commit cd94c09

Browse files
committed
Increase ob for the RHS integrator.
1 parent 8195b80 commit cd94c09

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

miniapps/tools/reconstruction_lor.cpp

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
4444
const char *mesh_file = "../../data/star.mesh";
4545
int order_ho = 3;
4646
int order_im = 3;
47-
int lref = order_im+1; // 4
47+
int lref = order_im+1;
4848
int order_lo = 0;
4949
bool vis = true;
5050
bool useH1 = false;
@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
104104
int dim = mesh_im.Dimension();
105105

106106
// low-order refined mesh
107-
Mesh mesh_lo = Mesh::MakeRefined(mesh_im, lref, BasisType::ClosedUniform);
107+
Mesh mesh_lo = Mesh::MakeRefined(mesh_im, lref, BasisType::ClosedUniform); // GaussLobatto, ClosedUniform
108108

109109
// ======================================================
110110
// Create spaces
@@ -118,10 +118,12 @@ int main(int argc, char *argv[])
118118
FiniteElementCollection *fec_lo;
119119
FiniteElementCollection *fec_im;
120120
FiniteElementCollection *fec_hi;
121-
space = "L2";
121+
122+
std::cout<<"SK: order_im = "<<order_im<<", order_ho = "<<order_ho<<std::endl;
123+
122124
fec_lo = new L2_FECollection(order_lo, dim);
123-
fec_im = new L2_FECollection(order_im, dim);
124-
// fec_im = new H1_FECollection(order_im, dim);
125+
// fec_im = new L2_FECollection(order_im, dim);
126+
fec_im = new H1_FECollection(order_im, dim);
125127
fec_hi = new L2_FECollection(order_ho, dim);
126128

127129
FiniteElementSpace fespace_lo(&mesh_lo, fec_lo);
@@ -162,6 +164,17 @@ int main(int argc, char *argv[])
162164
M_hi.Assemble();
163165
M_hi.Finalize();
164166

167+
// Set up the right-hand side vector for the exact solution
168+
FunctionCoefficient RHO(RHO_exact);
169+
LinearForm b_lo(&fespace_lo);
170+
// b_lo.AddDomainIntegrator(new DomainLFIntegrator(RHO));
171+
DomainLFIntegrator *lf_integ = new DomainLFIntegrator(RHO);
172+
const IntegrationRule &ir_rhs = IntRules.Get(fespace_lo.GetFE(0)->GetGeomType(),
173+
2*order_lo + 2);
174+
lf_integ->SetIntRule(&ir_rhs);
175+
b_lo.AddDomainIntegrator(lf_integ);
176+
b_lo.Assemble();
177+
165178
// ======================================================
166179
// Defind GridTransfers
167180
// ======================================================
@@ -198,9 +211,18 @@ int main(int argc, char *argv[])
198211
std::cout<<"Compute GridFunctions"<<std::endl;
199212

200213
// STEP1: LO & EX projections
201-
202-
FunctionCoefficient RHO(RHO_exact);
203-
rho_lo.ProjectCoefficient(RHO);
214+
215+
// L2 projection of RHO onto rho_lo
216+
217+
// rho_lo.ProjectCoefficient(RHO); // This is not an L2 projection.
218+
SparseMatrix &M_mat_lo = M_lo.SpMat();
219+
CGSolver cg;
220+
cg.SetOperator(M_mat_lo);
221+
cg.SetRelTol(1e-16);
222+
cg.SetMaxIter(1000);
223+
cg.SetPrintLevel(0);
224+
rho_lo = 0.0;
225+
cg.Mult(b_lo, rho_lo); // Solve: M * rho_lo = b_lo
204226
rho_lo.SetTrueVector();
205227
rho_lo.SetFromTrueVector();
206228

0 commit comments

Comments
 (0)