52int main(
int argc,
char *argv[])
60 const char *mesh_file =
"../../data/star.mesh";
62 bool static_cond =
false;
63 int ser_ref_levels = 1;
64 int par_ref_levels = 1;
65 real_t newton_rel_tol = 1e-7;
66 real_t newton_abs_tol = 1e-12;
69 bool visualization =
false;
72 args.
AddOption(&mesh_file,
"-m",
"--mesh",
77 "Number of times to refine the mesh uniformly in serial.");
81 "Number of times to refine the mesh uniformly in parallel.");
83 "Finite element order (polynomial degree) or -1 for"
84 " isoparametric space.");
90 "Enable or disable GLVis visualization.");
91 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
92 "--no-static-condensation",
"Enable static condensation.");
95 "--relative-tolerance",
96 "Relative tolerance for the Newton solve.");
99 "--absolute-tolerance",
100 "Absolute tolerance for the Newton solve.");
103 "--newton-iterations",
104 "Maximum iterations for the Newton solve.");
132 (int)floor(log(10000./mesh.
GetNE())/log(2.)/
dim);
133 for (
int l = 0; l < ref_levels; l++)
145 for (
int l = 0; l < par_ref_levels; l++)
230 nf->
Mult(solbv,resbv); resbv.
Neg();
231 gmres->
Mult(resbv, solbv);
237 std::cout <<
"energy =" << energy << std::endl;
250 std::cout <<
"Objective =" << obj << std::endl;
258 ob->
Mult(solbv, adjrhs);
261 gmres->
Mult(adjrhs, adjbv);
313 for (
int l = 0; l < 10; l++)
317 add(prmbv,prtbv,tmpbv);
321 nf->
Mult(solbv,resbv); resbv.
Neg();
327 gmres->
Mult(resbv,solbv);
330 real_t ld=(lQoI-gQoI)/lsc;
333 std::cout <<
"dx=" << lsc <<
" FD approximation=" << ld/nd
334 <<
" adjoint gradient=" << td
335 <<
" err=" << std::fabs(ld/nd-td) << std::endl;
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
A class to handle Block diagonal preconditioners in a matrix-free implementation.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
A class to handle Block systems in a matrix-free implementation.
Operator & GetBlock(int i, int j)
Return a reference to block i,j.
A class to handle Vectors in a block fashion.
void Update(real_t *data, const Array< int > &bOffsets)
Update method.
Vector & GetBlock(int i)
Get the i-th vector in the block.
A coefficient that is constant across space and time.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
void SetCycle(int c)
Set time cycle (for time-dependent simulations)
void SetTime(real_t t)
Set physical time (for time-dependent simulations)
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the GMRES method.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void SetPrintLevel(int print_level)
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
void SetAbsTol(real_t atol)
Arbitrary order "L2-conforming" discontinuous finite elements.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void Clear()
Clear the contents of the Mesh.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
Class for parallel grid function.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
Class for parallel meshes.
Helper class for ParaView visualization data.
void SetLevelsOfDetail(int levels_of_detail_)
virtual void Save() override
void Randomize(int seed=0)
Set random values in the vector.
void Neg()
(*this) = -(*this)
void add(const Vector &v1, const Vector &v2, Vector &v)
real_t InnerProduct(HypreParVector *x, HypreParVector *y)