49 int main(
int argc,
char *argv[])
51 const char *mesh_file =
"../../data/star.vtk";
52 int ser_ref_levels = 1;
54 bool visualization =
false;
55 double newton_rel_tol = 1e-4;
56 double newton_abs_tol = 1e-6;
61 args.
AddOption(&mesh_file,
"-m",
"--mesh",
"Mesh file to use.");
65 "Number of times to refine the mesh uniformly in serial.");
69 "Order (degree) of the finite elements.");
75 "Enable or disable GLVis visualization.");
78 "--relative-tolerance",
79 "Relative tolerance for the Newton solve.");
82 "--absolute-tolerance",
83 "Absolute tolerance for the Newton solve.");
86 "--newton-iterations",
87 "Maximum iterations for the Newton solve.");
105 for (
int lev = 0; lev < ser_ref_levels; lev++)
186 nf->
Mult(solbv,resbv);
187 std::cout<<
"Norm residual="<<resbv.
Norml2()<<std::endl;
191 std::cout<<
"energy ="<< energy<<std::endl;
202 std::cout<<
"Objective ="<<obj<<std::endl;
208 ob->
Mult(solbv, adjrhs);
270 for (
int l = 0; l < 10; l++)
276 add(prmbv,prtbv,tmpbv);
283 double ld=(lQoI-gQoI)/lsc;
284 std::cout <<
"dx=" << lsc <<
" FD gradient=" << ld/nd
285 <<
" adjoint gradient=" << td
286 <<
" err=" << std::fabs(ld/nd-td) << std::endl;
Class for grid function - Vector with associated FE space.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
A class to handle Vectors in a block fashion.
A coefficient that is constant across space and time.
Helper class for ParaView visualization data.
double Norml2() const
Returns the l2 norm of the vector.
void Update(double *data, const Array< int > &bOffsets)
Update method.
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
void Randomize(int seed=0)
Set random values in the vector.
void add(const Vector &v1, const Vector &v2, Vector &v)
Operator & GetBlock(int i, int j)
Return a reference to block i,j.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void SetPrintLevel(int print_lvl)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetMaxIter(int max_it)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
Newton's method for solving F(x)=b for a given operator F.
void PrintUsage(std::ostream &out) const
Print the usage message.
void SetTime(double t)
Set physical time (for time-dependent simulations)
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
void SetAbsTol(double atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
double InnerProduct(HypreParVector *x, HypreParVector *y)
void PrintOptions(std::ostream &out) const
Print the options.
void SetLevelsOfDetail(int levels_of_detail_)
Arbitrary order H1-conforming (continuous) finite elements.
virtual void Save() override
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
A class to handle Block systems in a matrix-free implementation.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Vector & GetBlock(int i)
Get the i-th vector in the block.
Arbitrary order "L2-conforming" discontinuous finite elements.
bool Good() const
Return true if the command line options were parsed successfully.