50 int main(
int argc,
char *argv[])
58 const char *mesh_file =
"../../data/star.mesh";
60 bool static_cond =
false;
61 int ser_ref_levels = 1;
62 int par_ref_levels = 1;
63 double newton_rel_tol = 1e-7;
64 double newton_abs_tol = 1e-12;
67 bool visualization =
false;
70 args.
AddOption(&mesh_file,
"-m",
"--mesh",
75 "Number of times to refine the mesh uniformly in serial.");
79 "Number of times to refine the mesh uniformly in parallel.");
81 "Finite element order (polynomial degree) or -1 for"
82 " isoparametric space.");
88 "Enable or disable GLVis visualization.");
89 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
90 "--no-static-condensation",
"Enable static condensation.");
93 "--relative-tolerance",
94 "Relative tolerance for the Newton solve.");
97 "--absolute-tolerance",
98 "Absolute tolerance for the Newton solve.");
101 "--newton-iterations",
102 "Maximum iterations for the Newton solve.");
131 for (
int l = 0; l < ref_levels; l++)
143 for (
int l = 0; l < par_ref_levels; l++)
228 nf->
Mult(solbv,resbv); resbv.
Neg();
229 gmres->
Mult(resbv, solbv);
235 std::cout <<
"energy =" << energy << std::endl;
248 std::cout <<
"Objective =" << obj << std::endl;
256 ob->
Mult(solbv, adjrhs);
259 gmres->
Mult(adjrhs, adjbv);
311 for (
int l = 0; l < 10; l++)
315 add(prmbv,prtbv,tmpbv);
319 nf->
Mult(solbv,resbv); resbv.
Neg();
325 gmres->
Mult(resbv,solbv);
328 double ld=(lQoI-gQoI)/lsc;
331 std::cout <<
"dx=" << lsc <<
" FD approximation=" << ld/nd
332 <<
" adjoint gradient=" << td
333 <<
" err=" << std::fabs(ld/nd-td) << std::endl;
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(), hypre will be finalized automatically at program exit.
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.
void Update(double *data, const Array< int > &bOffsets)
Update method.
int GetNE() const
Returns number of elements.
Abstract parallel finite element space.
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 SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
The BoomerAMG solver in hypre.
virtual void RegisterField(const std::string &field_name, GridFunction *gf)
Add a grid function to the collection.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
A class to handle Block diagonal preconditioners in a matrix-free implementation. ...
int Append(const T &el)
Append element 'el' to array, resize if necessary.
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
void SetPrintLevel(int print_level)
void SetMaxIter(int max_it)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
static void Init()
Singleton creation with Mpi::Init();.
void PrintUsage(std::ostream &out) const
Print the usage message.
void SetTime(double t)
Set physical time (for time-dependent simulations)
void SetAbsTol(double atol)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void SetRelTol(double rtol)
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...
FDualNumber< tbase > log(const FDualNumber< tbase > &f)
log([dual number])
double InnerProduct(HypreParVector *x, HypreParVector *y)
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
void PrintOptions(std::ostream &out) const
Print the options.
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
void SetLevelsOfDetail(int levels_of_detail_)
void Clear()
Clear the contents of the Mesh.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
virtual void Save() override
Class for parallel grid function.
A class to handle Block systems in a matrix-free implementation.
Class for parallel meshes.
void SetDiagonalBlock(int iblock, Operator *op)
Add a square block op in the block-entry (iblock, iblock).
Vector & GetBlock(int i)
Get the i-th vector in the block.
Arbitrary order "L2-conforming" discontinuous finite elements.
void Neg()
(*this) = -(*this)
bool Good() const
Return true if the command line options were parsed successfully.