Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for initing / seting up preconditioners with adaptivity #38

Merged
merged 25 commits into from
Feb 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b4da774
Changes in adaptivity_ex2.C for -Wshadow.
jwpeterson Feb 4, 2013
e17c79e
Changes in adaptivity_ex3.C for -Wshadow.
jwpeterson Feb 4, 2013
729541a
Changes in adaptivity_ex5.C for -Wshadow.
jwpeterson Feb 4, 2013
b657617
Changes in adjoints_ex1 for -Wshadow.
jwpeterson Feb 4, 2013
e6f444c
Changes in adjoints_ex2 for -Wshadow.
jwpeterson Feb 4, 2013
cccdb62
Changes in adjoints_ex3 for -Wshadow.
jwpeterson Feb 4, 2013
2b9c717
Changes in adjoints_ex4 for -Wshadow.
jwpeterson Feb 4, 2013
ba6afdd
Don't include deprecated o_string_stream header.
jwpeterson Feb 4, 2013
0dc8e2e
Fixes for unused variable warnings.
jwpeterson Feb 4, 2013
f957dea
Changes in adjoints_ex5 for -Wshadow.
jwpeterson Feb 4, 2013
6ccd84e
Changes in fem_system_ex1 for -Wshadow.
jwpeterson Feb 4, 2013
85a7e97
Changes in fem_system_ex2 for -Wshadow.
jwpeterson Feb 4, 2013
eb616e8
Changes in miscellaneous_ex3 for -Wshadow.
jwpeterson Feb 4, 2013
fe3039d
Changes in type_vector.h for -Wshadow.
jwpeterson Feb 4, 2013
1b4c2a7
Changes in miscellaneous_ex4.C for -Wshadow.
jwpeterson Feb 4, 2013
2375c2c
Changes in miscellaneous_ex7.C for -Wshadow.
jwpeterson Feb 4, 2013
0392b90
Changes in reduced_basis_ex1 for -Wshadow.
jwpeterson Feb 4, 2013
95d8003
Changes in reduced_basis_ex3 for -Wshadow.
jwpeterson Feb 4, 2013
1a5db52
Changes in reduced_basis_ex4 for -Wshadow.
jwpeterson Feb 4, 2013
3847f57
Changes in reduced_basis_ex5 for -Wshadow.
jwpeterson Feb 4, 2013
5bcca40
Changes in transient_ex1 for -Wshadow.
jwpeterson Feb 4, 2013
5e0f961
Changes in vector_fe_ex2 for -Wshadow.
jwpeterson Feb 4, 2013
14f5c71
Changes in vector_fe_ex3 for -Wshadow.
jwpeterson Feb 4, 2013
d99e3fc
Changes in reduced_basis_ex6 for -Wshadow.
jwpeterson Feb 5, 2013
213e204
fix for initing / seting up preconditioners with adaptivity
friedmud Feb 4, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/adaptivity/adaptivity_ex2/adaptivity_ex2.C
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,6 @@ int main (int argc, char** argv)
if(!read_solution)
{
// Print out the H1 norm of the saved solution, for verification purposes:
TransientLinearImplicitSystem& system =
equation_systems.get_system<TransientLinearImplicitSystem>
("Convection-Diffusion");
Real H1norm = system.calculate_norm(*system.solution, SystemNorm(H1));

std::cout << "Final H1 norm = " << H1norm << std::endl << std::endl;
Expand Down
12 changes: 6 additions & 6 deletions examples/adaptivity/adaptivity_ex3/adaptivity_ex3.C
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ void assemble_laplace(EquationSystems& es,
const MeshBase& mesh = es.get_mesh();

// The dimension that we are running
const unsigned int dim = mesh.mesh_dimension();
const unsigned int mesh_dim = mesh.mesh_dimension();

// Get a reference to the LinearImplicitSystem we are solving
LinearImplicitSystem& system = es.get_system<LinearImplicitSystem>("Laplace");
Expand All @@ -597,12 +597,12 @@ void assemble_laplace(EquationSystems& es,
// \p FEBase::build() member dynamically creates memory we will
// store the object as an \p AutoPtr<FEBase>. This can be thought
// of as a pointer that will clean up after itself.
AutoPtr<FEBase> fe (FEBase::build(dim, fe_type));
AutoPtr<FEBase> fe_face (FEBase::build(dim, fe_type));
AutoPtr<FEBase> fe (FEBase::build(mesh_dim, fe_type));
AutoPtr<FEBase> fe_face (FEBase::build(mesh_dim, fe_type));

// Quadrature rules for numerical integration.
AutoPtr<QBase> qrule(fe_type.default_quadrature_rule(dim));
AutoPtr<QBase> qface(fe_type.default_quadrature_rule(dim-1));
AutoPtr<QBase> qrule(fe_type.default_quadrature_rule(mesh_dim));
AutoPtr<QBase> qface(fe_type.default_quadrature_rule(mesh_dim-1));

// Tell the finite element object to use our quadrature rule.
fe->attach_quadrature_rule (qrule.get());
Expand Down Expand Up @@ -709,7 +709,7 @@ void assemble_laplace(EquationSystems& es,
Ke(i,j) += JxW[qp]*(dphi[i][qp]*dphi[j][qp]);

// We need a forcing function to make the 1D case interesting
if (dim == 1)
if (mesh_dim == 1)
for (unsigned int qp=0; qp<qrule->n_points(); qp++)
{
Real x = q_point[qp](0);
Expand Down
11 changes: 2 additions & 9 deletions examples/adaptivity/adaptivity_ex5/adaptivity_ex5.C
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,6 @@ int main (int argc, char** argv)
// vector assignment. Since only \p TransientLinearImplicitSystems
// (and systems derived from them) contain old solutions
// we need to specify the system type when we ask for it.
TransientLinearImplicitSystem & system =
equation_systems.get_system<TransientLinearImplicitSystem>("Convection-Diffusion");

*system.old_local_solution = *system.current_local_solution;

// The number of refinement steps per time step.
Expand All @@ -432,8 +429,7 @@ int main (int argc, char** argv)
system.solve();

// Print out the H1 norm, for verification purposes:
Real H1norm = system.calculate_norm(*system.solution, SystemNorm(H1));

H1norm = system.calculate_norm(*system.solution, SystemNorm(H1));
std::cout << "H1 norm = " << H1norm << std::endl;

// Possibly refine the mesh
Expand Down Expand Up @@ -515,10 +511,7 @@ int main (int argc, char** argv)
if(!read_solution)
{
// Print out the H1 norm of the saved solution, for verification purposes:
TransientLinearImplicitSystem& system =
equation_systems.get_system<TransientLinearImplicitSystem>
("Convection-Diffusion");
Real H1norm = system.calculate_norm(*system.solution, SystemNorm(H1));
H1norm = system.calculate_norm(*system.solution, SystemNorm(H1));

std::cout << "Final H1 norm = " << H1norm << std::endl << std::endl;

Expand Down
6 changes: 3 additions & 3 deletions examples/adjoints/adjoints_ex1/L-shaped.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class LaplaceSystem : public FEMSystem
public:
// Constructor
LaplaceSystem(EquationSystems& es,
const std::string& name,
const unsigned int number)
: FEMSystem(es, name, number),
const std::string& name_in,
const unsigned int number_in)
: FEMSystem(es, name_in, number_in),
_fe_family("LAGRANGE"), _fe_order(1),
_analytic_jacobians(true) { qoi.resize(2); }

Expand Down
6 changes: 3 additions & 3 deletions examples/adjoints/adjoints_ex2/L-shaped.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ class LaplaceSystem : public FEMSystem
public:
// Constructor
LaplaceSystem(EquationSystems& es,
const std::string& name,
const unsigned int number)
: FEMSystem(es, name, number),
const std::string& name_in,
const unsigned int number_in)
: FEMSystem(es, name_in, number_in),
_fe_family("LAGRANGE"), _fe_order(1),
_analytic_jacobians(true) { }

Expand Down
13 changes: 6 additions & 7 deletions examples/adjoints/adjoints_ex2/adjoints_ex2.C
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ int main (int argc, char** argv)
}
}
GetPot infile("general.in");
GetPot infile_l_shaped("l-shaped.in");

// Read in parameters from the input file
FEMParameters param;
Expand Down Expand Up @@ -364,12 +363,12 @@ int main (int argc, char** argv)
// Now that we have solved the adjoint, set the adjoint_already_solved boolean to true, so we dont solve unneccesarily in the error estimator
system.set_adjoint_already_solved(true);

GetPot infile("l-shaped.in");
GetPot infile_l_shaped("l-shaped.in");

Number sensitivity_QoI_0_0_computed = sensitivities[0][0];
Number sensitivity_QoI_0_0_exact = infile("sensitivity_0_0", 0.0);
Number sensitivity_QoI_0_0_exact = infile_l_shaped("sensitivity_0_0", 0.0);
Number sensitivity_QoI_0_1_computed = sensitivities[0][1];
Number sensitivity_QoI_0_1_exact = infile("sensitivity_0_1", 0.0);
Number sensitivity_QoI_0_1_exact = infile_l_shaped("sensitivity_0_1", 0.0);

std::cout << "Adaptive step " << a_step << ", we have " << mesh.n_active_elem()
<< " active elements and "
Expand Down Expand Up @@ -482,12 +481,12 @@ int main (int argc, char** argv)
// Now that we have solved the adjoint, set the adjoint_already_solved boolean to true, so we dont solve unneccesarily in the error estimator
system.set_adjoint_already_solved(true);

GetPot infile("l-shaped.in");
GetPot infile_l_shaped("l-shaped.in");

Number sensitivity_QoI_0_0_computed = sensitivities[0][0];
Number sensitivity_QoI_0_0_exact = infile("sensitivity_0_0", 0.0);
Number sensitivity_QoI_0_0_exact = infile_l_shaped("sensitivity_0_0", 0.0);
Number sensitivity_QoI_0_1_computed = sensitivities[0][1];
Number sensitivity_QoI_0_1_exact = infile("sensitivity_0_1", 0.0);
Number sensitivity_QoI_0_1_exact = infile_l_shaped("sensitivity_0_1", 0.0);

std::cout << "Adaptive step " << a_step << ", we have " << mesh.n_active_elem()
<< " active elements and "
Expand Down
6 changes: 3 additions & 3 deletions examples/adjoints/adjoints_ex3/coupled_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class CoupledSystem : public FEMSystem
public:
// Constructor
CoupledSystem(EquationSystems& es,
const std::string& name,
const unsigned int number)
: FEMSystem(es, name, number), Peclet(1.) {qoi.resize(1);}
const std::string& name_in,
const unsigned int number_in)
: FEMSystem(es, name_in, number_in), Peclet(1.) {qoi.resize(1);}

// Function to get computed QoI values

Expand Down
6 changes: 3 additions & 3 deletions examples/adjoints/adjoints_ex4/L-shaped.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class LaplaceSystem : public FEMSystem
public:
// Constructor
LaplaceSystem(EquationSystems& es,
const std::string& name,
const unsigned int number)
: FEMSystem(es, name, number),
const std::string& name_in,
const unsigned int number_in)
: FEMSystem(es, name_in, number_in),
_fe_family("LAGRANGE"), _fe_order(1),
_analytic_jacobians(true) { qoi.resize(2); }

Expand Down
5 changes: 1 addition & 4 deletions examples/adjoints/adjoints_ex5/adjoints_ex5.C
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,10 @@
#include "libmesh/solution_history.h"
#include "libmesh/memory_solution_history.h"

// Some (older) compilers do not offer full stream
// functionality, OStringStream works around this.
#include "libmesh/o_string_stream.h"

// C++ includes
#include <iostream>
#include <sys/time.h>
#include <iomanip>

void write_output(EquationSystems &es,
unsigned int a_step, // The adaptive step count
Expand Down
8 changes: 4 additions & 4 deletions examples/adjoints/adjoints_ex5/factoryfunction.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ using namespace libMesh;

class ExampleOneFunction : public FunctionBase<Number>
{
virtual Number operator() (const Point& p,
const Real time = 0)
virtual Number operator() (const Point& /*p*/,
const Real /*time*/)
{
return 1;
}

virtual void operator() (const Point& p,
const Real time,
virtual void operator() (const Point& /*p*/,
const Real /*time*/,
DenseVector<Number>& output)
{
for (unsigned int i=0; i != output.size(); ++i)
Expand Down
28 changes: 14 additions & 14 deletions examples/adjoints/adjoints_ex5/femparameters.C
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,17 @@ void FEMParameters::read(GetPot &input)
{
unsigned int myboundary =
input("periodic_boundaries", -1, i);
unsigned int pairedboundary = 0;
// unsigned int pairedboundary = 0;
RealVectorValue translation_vector;
if (dimension == 2)
switch (myboundary)
{
case 0:
pairedboundary = 2;
// pairedboundary = 2;
translation_vector = RealVectorValue(0., domain_edge_length);
break;
case 1:
pairedboundary = 3;
// pairedboundary = 3;
translation_vector = RealVectorValue(-domain_edge_width, 0);
break;
default:
Expand All @@ -304,15 +304,15 @@ void FEMParameters::read(GetPot &input)
switch (myboundary)
{
case 0:
pairedboundary = 5;
// pairedboundary = 5;
translation_vector = RealVectorValue(0., 0., domain_edge_height);
break;
case 1:
pairedboundary = 3;
// pairedboundary = 3;
translation_vector = RealVectorValue(0., domain_edge_length, 0.);
break;
case 2:
pairedboundary = 4;
// pairedboundary = 4;
translation_vector = RealVectorValue(-domain_edge_width, 0., 0.);
break;
default:
Expand Down Expand Up @@ -389,11 +389,11 @@ void FEMParameters::read(GetPot &input)
const std::string variable_set =
input("dirichlet_condition_variables", empty_string, i);

for (unsigned int i=0; i != variable_set.size(); ++i)
for (unsigned int j=0; j != variable_set.size(); ++j)
{
if (variable_set[i] == '1')
dirichlet_condition_variables[func_boundary].push_back(i);
else if (variable_set[i] != '0')
if (variable_set[j] == '1')
dirichlet_condition_variables[func_boundary].push_back(j);
else if (variable_set[j] != '0')
{
libMesh::out << "Unable to understand Dirichlet variable set"
<< variable_set << std::endl;
Expand Down Expand Up @@ -460,11 +460,11 @@ void FEMParameters::read(GetPot &input)
const std::string variable_set =
input("neumann_condition_variables", empty_string, i);

for (unsigned int i=0; i != variable_set.size(); ++i)
for (unsigned int j=0; j != variable_set.size(); ++j)
{
if (variable_set[i] == '1')
neumann_condition_variables[func_boundary].push_back(i);
else if (variable_set[i] != '0')
if (variable_set[j] == '1')
neumann_condition_variables[func_boundary].push_back(j);
else if (variable_set[j] != '0')
{
libMesh::out << "Unable to understand Neumann variable set"
<< variable_set << std::endl;
Expand Down
12 changes: 6 additions & 6 deletions examples/adjoints/adjoints_ex5/heatsystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ bool HeatSystem::element_time_derivative (bool request_jacobian,
}

// Perturb and accumulate dual weighted residuals
void HeatSystem::perturb_accumulate_residuals(const ParameterVector& parameters)
void HeatSystem::perturb_accumulate_residuals(const ParameterVector& parameters_in)
{
const unsigned int Np = parameters.size();
const unsigned int Np = parameters_in.size();

for (unsigned int j=0; j != Np; ++j)
{
Number old_parameter = *parameters[j];
Number old_parameter = *parameters_in[j];

*parameters[j] = old_parameter - dp;
*parameters_in[j] = old_parameter - dp;

this->assembly(true, false);

Expand All @@ -177,7 +177,7 @@ void HeatSystem::perturb_accumulate_residuals(const ParameterVector& parameters)
// But since we compute the residual already scaled by dt, there is no need for the * dt
R_minus_dp += -R_minus->dot(this->get_adjoint_solution(0));

*parameters[j] = old_parameter + dp;
*parameters_in[j] = old_parameter + dp;

this->assembly(true, false);

Expand All @@ -187,7 +187,7 @@ void HeatSystem::perturb_accumulate_residuals(const ParameterVector& parameters)

R_plus_dp += -R_plus->dot(this->get_adjoint_solution(0));

*parameters[j] = old_parameter;
*parameters_in[j] = old_parameter;

}
}
6 changes: 3 additions & 3 deletions examples/adjoints/adjoints_ex5/heatsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class HeatSystem : public FEMSystem
public:
// Constructor
HeatSystem(EquationSystems& es,
const std::string& name,
const unsigned int number)
: FEMSystem(es, name, number),
const std::string& name_in,
const unsigned int number_in)
: FEMSystem(es, name_in, number_in),
_k(1.0),
_fe_family("LAGRANGE"), _fe_order(1),
_analytic_jacobians(true), R_plus_dp(0.0), R_minus_dp(0.0), dp(1.e-6) { qoi.resize(1); }
Expand Down
6 changes: 3 additions & 3 deletions examples/fem_system/fem_system_ex1/naviersystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class NavierSystem : public FEMSystem
public:
// Constructor
NavierSystem(EquationSystems& es,
const std::string& name,
const unsigned int number)
: FEMSystem(es, name, number), Reynolds(1.), application(0) {}
const std::string& name_in,
const unsigned int number_in)
: FEMSystem(es, name_in, number_in), Reynolds(1.), application(0) {}

// System initialization
virtual void init_data ();
Expand Down
4 changes: 2 additions & 2 deletions examples/fem_system/fem_system_ex2/nonlinear_neohooke_cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ using namespace libMesh;
class NonlinearNeoHookeCurrentConfig {
public:
NonlinearNeoHookeCurrentConfig(
const std::vector<std::vector<RealGradient> >& dphi, GetPot& args) :
dphi(dphi) {
const std::vector<std::vector<RealGradient> >& dphi_in, GetPot& args) :
dphi(dphi_in) {
E = args("material/neohooke/e_modulus", 10000.0);
nu = args("material/neohooke/nu", 0.3);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/fem_system/fem_system_ex2/solid_system.C
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
// Bring in everything from the libMesh namespace
using namespace libMesh;

SolidSystem::SolidSystem(EquationSystems& es, const std::string& name,
const unsigned int number) :
FEMSystem(es, name, number) {
SolidSystem::SolidSystem(EquationSystems& es, const std::string& name_in,
const unsigned int number_in) :
FEMSystem(es, name_in, number_in) {

// Add a time solver. We are just looking at a steady state problem here.
this->time_solver = AutoPtr<TimeSolver>(new SteadySolver(*this));
Expand Down
4 changes: 2 additions & 2 deletions examples/miscellaneous/miscellaneous_ex3/miscellaneous_ex3.C
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Real sigma = 0.2;
// This function computes the Jacobian K(x)
void compute_jacobian (const NumericVector<Number>& soln,
SparseMatrix<Number>& jacobian,
NonlinearImplicitSystem& sys)
NonlinearImplicitSystem& /*sys*/)
{
// Get a reference to the equation system.
EquationSystems &es = *_equation_system;
Expand Down Expand Up @@ -213,7 +213,7 @@ void compute_jacobian (const NumericVector<Number>& soln,
// x is passed in the soln vector
void compute_residual (const NumericVector<Number>& soln,
NumericVector<Number>& residual,
NonlinearImplicitSystem& sys)
NonlinearImplicitSystem& /*sys*/)
{
EquationSystems &es = *_equation_system;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ int main (int argc, char** argv)

// Create an equation systems object.
EquationSystems equation_systems (mesh);
MeshRefinement mesh_refinement (mesh);

MeshTools::Generation::build_square (mesh,
16,
Expand Down
Loading