Skip to content

Commit

Permalink
Use common FEMParameters in adjoints_ex4
Browse files Browse the repository at this point in the history
  • Loading branch information
roystgnr committed Jun 3, 2015
1 parent 9bc3304 commit 7ab35df
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 137 deletions.
11 changes: 10 additions & 1 deletion examples/adjoints/adjoints_ex4/Makefile.am
@@ -1,3 +1,12 @@
BUILT_SOURCES = femparameters.C # femparameters.h
DISTCLEANFILES = $(BUILT_SOURCES)

femparameters.C: $(top_srcdir)/examples/adjoints/adjoints_ex1/femparameters.C
$(AM_V_GEN)$(LN_S) -f $< $@

#femparameters.h: $(top_srcdir)/examples/adjoints/adjoints_ex1/femparameters.h
# $(AM_V_GEN)$(LN_S) -f $< .

example_name = adjoints_ex4
check_SCRIPTS = run.sh
install_dir = $(examples_install_path)/adjoints/ex4
Expand All @@ -8,7 +17,7 @@ CLEANFILES = primal.out.* adjoint_*.out.*

# also need links for VPATH builds
if LIBMESH_VPATH_BUILD
BUILT_SOURCES = .linkstamp
BUILT_SOURCES += .linkstamp
.linkstamp:
-rm -f general.in && $(LN_S) -f $(srcdir)/general.in .
-rm -f lshaped.xda && $(LN_S) -f $(srcdir)/lshaped.xda .
Expand Down
2 changes: 1 addition & 1 deletion examples/adjoints/adjoints_ex4/adjoints_ex4.C
Expand Up @@ -219,7 +219,7 @@ int main (int argc, char** argv)
GetPot infile("general.in");

// Read in parameters from the input file
FEMParameters param;
FEMParameters param(init.comm());
param.read(infile);

// Skip this default-2D example if libMesh was compiled as 1D-only.
Expand Down
78 changes: 0 additions & 78 deletions examples/adjoints/adjoints_ex4/femparameters.C

This file was deleted.

193 changes: 136 additions & 57 deletions examples/adjoints/adjoints_ex4/femparameters.h
@@ -1,70 +1,149 @@

#ifndef __fem_parameters_h__
#define __fem_parameters_h__

#include "libmesh/libmesh_common.h"
#include "libmesh/dof_map.h"
#include "libmesh/enum_norm_type.h"
#include "libmesh/function_base.h"
#include "libmesh/getpot.h"
#include "libmesh/id_types.h"
#include "libmesh/parallel_object.h"
#include "libmesh/periodic_boundaries.h"
#include "libmesh/periodic_boundary.h"

#include <limits>
#include <map>
#include <string>
#include <vector>

#include "libmesh/libmesh_common.h"
#include "libmesh/getpot.h"

// Bring in everything from the libMesh namespace
using namespace libMesh;

class FEMParameters
class FEMParameters : public libMesh::ParallelObject
{
public:
FEMParameters() :
domainfile("lshaped.xda"),
coarserefinements(0),
solver_quiet(true),
reuse_preconditioner(false),
require_residual_reduction(true),
min_step_length(1e-5),
max_linear_iterations(200000), max_nonlinear_iterations(20),
relative_step_tolerance(1.e-7), relative_residual_tolerance(1.e-10),
initial_linear_tolerance(1.e-3), minimum_linear_tolerance(TOLERANCE*TOLERANCE),
linear_tolerance_multiplier(1.e-3),
nelem_target(30000), global_tolerance(0.0),
refine_fraction(0.3), coarsen_fraction(0.3), coarsen_threshold(10),
refine_uniformly(false),
max_adaptivesteps(1),
indicator_type("kelly"), patch_reuse(true),
fe_family(1, "LAGRANGE"), fe_order(1, 1),
analytic_jacobians(true), verify_analytic_jacobians(0.0),
print_solution_norms(false), print_solutions(false),
print_residual_norms(false), print_residuals(false),
print_jacobian_norms(false), print_jacobians(false) {}

void read(GetPot &input);

std::string domainfile;
unsigned int coarserefinements;

bool solver_quiet, reuse_preconditioner, require_residual_reduction;
Real min_step_length;
unsigned int max_linear_iterations, max_nonlinear_iterations;
Real relative_step_tolerance, relative_residual_tolerance,
initial_linear_tolerance, minimum_linear_tolerance,
linear_tolerance_multiplier;

unsigned int nelem_target;
Real global_tolerance;
Real refine_fraction, coarsen_fraction, coarsen_threshold;
bool refine_uniformly;
unsigned int max_adaptivesteps;

std::string indicator_type;
bool patch_reuse;

std::vector<std::string> fe_family;
std::vector<unsigned int> fe_order;

bool analytic_jacobians;
Real verify_analytic_jacobians;

bool print_solution_norms, print_solutions,
print_residual_norms, print_residuals,
print_jacobian_norms, print_jacobians;
FEMParameters(const libMesh::Parallel::Communicator &comm_in);

~FEMParameters();

void read(GetPot &input,
const std::vector<std::string>* other_variable_names = NULL);

// Parameters applicable to entire EquationSystems:

unsigned int initial_timestep, n_timesteps;
bool transient;
unsigned int deltat_reductions;
std::string timesolver_core;
libMesh::Real end_time, deltat, timesolver_theta,
timesolver_maxgrowth, timesolver_tolerance,
timesolver_upper_tolerance, steadystate_tolerance;
std::vector<libMesh::FEMNormType> timesolver_norm;

// Mesh generation

unsigned int dimension;
std::string domaintype, domainfile, elementtype;
libMesh::Real elementorder;
libMesh::Real domain_xmin, domain_ymin, domain_zmin;
libMesh::Real domain_edge_width, domain_edge_length, domain_edge_height;
unsigned int coarsegridx, coarsegridy, coarsegridz;
unsigned int coarserefinements, extrarefinements;
std::string mesh_redistribute_func;

// Mesh refinement

unsigned int nelem_target;
libMesh::Real global_tolerance;
libMesh::Real refine_fraction, coarsen_fraction, coarsen_threshold;
unsigned int max_adaptivesteps;
unsigned int initial_adaptivesteps;

// Output

unsigned int write_interval;
bool write_gmv_error, write_tecplot_error,
write_exodus_error,
output_xda, output_xdr,
output_bz2, output_gz,
output_gmv, output_tecplot,
output_exodus, output_nemesis;

// Types of Systems to create

std::vector<std::string> system_types;

// Parameters applicable to each system:

// Boundary and initial conditions

std::vector<libMesh::PeriodicBoundary> periodic_boundaries;

std::map<libMesh::subdomain_id_type, libMesh::FunctionBase<libMesh::Number> *>
initial_conditions;
std::map<libMesh::boundary_id_type, libMesh::FunctionBase<libMesh::Number> *>
dirichlet_conditions,
neumann_conditions;
std::map<libMesh::boundary_id_type, std::vector<unsigned int> >
dirichlet_condition_variables,
neumann_condition_variables;
std::map<int, std::map<libMesh::subdomain_id_type,
libMesh::FunctionBase<libMesh::Number> *> >
other_interior_functions;
std::map<int, std::map<libMesh::boundary_id_type,
libMesh::FunctionBase<libMesh::Number> *> >
other_boundary_functions;

// Execution type

bool run_simulation, run_postprocess;

// Approximation type

std::vector<std::string> fe_family;
std::vector<unsigned int> fe_order;
int extra_quadrature_order;

// Assembly options

bool analytic_jacobians;
libMesh::Real verify_analytic_jacobians;
libMesh::Real numerical_jacobian_h;

bool print_solution_norms, print_solutions,
print_residual_norms, print_residuals,
print_jacobian_norms, print_jacobians,
print_element_solutions,
print_element_residuals,
print_element_jacobians;

// Solver options

bool use_petsc_snes;
bool time_solver_quiet, solver_quiet, solver_verbose,
reuse_preconditioner, require_residual_reduction;
libMesh::Real min_step_length;
unsigned int max_linear_iterations, max_nonlinear_iterations;
libMesh::Real relative_step_tolerance, relative_residual_tolerance,
absolute_residual_tolerance,
initial_linear_tolerance, minimum_linear_tolerance,
linear_tolerance_multiplier;

// Initialization

unsigned int initial_sobolev_order;
unsigned int initial_extra_quadrature;

// Error indicators

bool refine_uniformly;
std::string indicator_type;
bool patch_reuse;
unsigned int sobolev_order;

// System-specific parameters file

std::string system_config_file;
};

#endif // __fem_parameters_h__

0 comments on commit 7ab35df

Please sign in to comment.