50 int main(
int argc,
char *argv[])
54 MPI_Init(&argc, &argv);
55 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
56 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
59 const char *mesh_file =
"../../data/star.mesh";
61 bool static_cond =
false;
62 int ser_ref_levels = 1;
63 int par_ref_levels = 1;
64 double newton_rel_tol = 1e-7;
65 double newton_abs_tol = 1e-12;
68 bool visualization =
false;
71 args.
AddOption(&mesh_file,
"-m",
"--mesh",
76 "Number of times to refine the mesh uniformly in serial.");
80 "Number of times to refine the mesh uniformly in parallel.");
82 "Finite element order (polynomial degree) or -1 for"
83 " isoparametric space.");
89 "Enable or disable GLVis visualization.");
90 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
91 "--no-static-condensation",
"Enable static condensation.");
94 "--relative-tolerance",
95 "Relative tolerance for the Newton solve.");
98 "--absolute-tolerance",
99 "Absolute tolerance for the Newton solve.");
102 "--newton-iterations",
103 "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 double 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;
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 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.
void SetPrintLevel(int print_lvl)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
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.
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...
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.
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.