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

Factory Initializer Objects #484

Merged
merged 7 commits into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 4 additions & 1 deletion examples/cavity_benchmark/cavity.C
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// GRINS
#include "grins/simulation.h"
#include "grins/simulation_builder.h"
#include "grins/simulation_initializer.h"

// GRVY
#ifdef GRINS_HAVE_GRVY
Expand Down Expand Up @@ -72,7 +73,9 @@ int main(int argc, char* argv[])

// Initialize libMesh library.
libMesh::LibMeshInit libmesh_init(argc, argv);


GRINS::SimulationInitializer initializer;

GRINS::SimulationBuilder sim_builder;

GRINS::Simulation grins( libMesh_inputfile,
Expand Down
2 changes: 2 additions & 0 deletions examples/elastic_sheet/stretching_sheet.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <iostream>

// GRINS
#include "grins/simulation_initializer.h"
#include "grins/simulation_builder.h"
#include "grins/simulation.h"

Expand Down Expand Up @@ -98,6 +99,7 @@ int main(int argc, char* argv[])
grvy_timer.BeginTimer("Initialize Solver");
#endif

GRINS::SimulationInitializer initializer;
GRINS::SimulationBuilder sim_builder;
GRINS::SharedPtr<GRINS::SolverFactory> solver_factory( new GRINS::DisplacementContinuationSolverFactory );
sim_builder.attach_solver_factory(solver_factory);
Expand Down
6 changes: 4 additions & 2 deletions examples/inflating_sheet/inflating_sheet.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <iostream>

// GRINS
#include "grins/simulation_initializer.h"
#include "grins/simulation_builder.h"
#include "grins/simulation.h"

Expand Down Expand Up @@ -65,12 +66,13 @@ int main(int argc, char* argv[])

// Initialize libMesh library.
libMesh::LibMeshInit libmesh_init(argc, argv);

libMesh::out << "Starting GRINS with command:\n";
for (int i=0; i != argc; ++i)
libMesh::out << argv[i] << ' ';
libMesh::out << std::endl;


GRINS::SimulationInitializer initializer;
GRINS::SimulationBuilder sim_builder;

GRINS::SharedPtr<GRINS::SolverFactory> sheet_factory( new GRINS::InflatingSheetSolverFactory );
Expand Down
28 changes: 10 additions & 18 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,11 @@ libgrins_la_SOURCES += boundary_conditions/src/parsed_function_factory_helper.C
libgrins_la_SOURCES += boundary_conditions/src/parsed_function_dirichlet_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/constant_function_dirichlet_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/parsed_function_dirichlet_old_style_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/homogeneous_dirichlet_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/prescribed_vector_value_dirichlet_old_style_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/isothermal_dirichlet_old_style_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/symmetry_type_bc_factories.C
libgrins_la_SOURCES += boundary_conditions/src/pressure_pinning.C
libgrins_la_SOURCES += boundary_conditions/src/catalytic_wall_instantiate.C
libgrins_la_SOURCES += boundary_conditions/src/catalycity_factory_abstract.C
libgrins_la_SOURCES += boundary_conditions/src/catalycity_factories.C
libgrins_la_SOURCES += boundary_conditions/src/catalycity_factory_old_style_base.C
libgrins_la_SOURCES += boundary_conditions/src/catalycity_factories_old_style.C
libgrins_la_SOURCES += boundary_conditions/src/catalycity_base.C
libgrins_la_SOURCES += boundary_conditions/src/constant_catalycity.C
libgrins_la_SOURCES += boundary_conditions/src/arrhenius_catalycity.C
Expand All @@ -53,16 +48,12 @@ libgrins_la_SOURCES += boundary_conditions/src/neumann_bc_parsed.C
libgrins_la_SOURCES += boundary_conditions/src/neumann_bc_factory_abstract.C
libgrins_la_SOURCES += boundary_conditions/src/neumann_bc_old_style_factory_abstract.C
libgrins_la_SOURCES += boundary_conditions/src/parsed_function_neumann_bc_factory_helper.C
libgrins_la_SOURCES += boundary_conditions/src/parsed_function_neumann_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/parsed_function_neumann_old_style_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/homogeneous_neumann_bc_factory.C
libgrins_la_SOURCES += boundary_conditions/src/gas_recombination_catalytic_wall_neumann_bc_factory_impl.C
libgrins_la_SOURCES += boundary_conditions/src/gas_solid_catalytic_wall_neumann_bc_factory_impl.C
libgrins_la_SOURCES += boundary_conditions/src/catalytic_wall_neumann_bc_factory_common.C
libgrins_la_SOURCES += boundary_conditions/src/catalytic_wall_neumann_bc_factory_base.C
libgrins_la_SOURCES += boundary_conditions/src/catalytic_wall_neumann_bc_old_style_factory_base.C
libgrins_la_SOURCES += boundary_conditions/src/gas_catalytic_wall_neumann_bc_factories.C
libgrins_la_SOURCES += boundary_conditions/src/gas_catalytic_wall_neumann_bc_old_style_factories.C
libgrins_la_SOURCES += boundary_conditions/src/boundary_condition_factory_initializer.C

# src/common
libgrins_la_SOURCES += common/src/builder_helper.C
Expand Down Expand Up @@ -150,17 +141,11 @@ libgrins_la_SOURCES += physics/src/parsed_source_term.C
libgrins_la_SOURCES += physics/src/physics_naming.C
libgrins_la_SOURCES += physics/src/convection_diffusion.C
libgrins_la_SOURCES += physics/src/physics_factory_base.C
libgrins_la_SOURCES += physics/src/physics_factory_basic.C
libgrins_la_SOURCES += physics/src/physics_factory_with_core.C
libgrins_la_SOURCES += physics/src/physics_factory_incompressible_flow.C
libgrins_la_SOURCES += physics/src/physics_factory_incompressible_turb_flow.C
libgrins_la_SOURCES += physics/src/physics_factory_heat_transfer.C
libgrins_la_SOURCES += physics/src/physics_factory_variable_density_flow.C
libgrins_la_SOURCES += physics/src/physics_factory_plane_stress_solids.C
libgrins_la_SOURCES += physics/src/physics_factory_one_d_stress_solids.C
libgrins_la_SOURCES += physics/src/physics_factory_reacting_flows.C
libgrins_la_SOURCES += physics/src/physics_builder.C
libgrins_la_SOURCES += physics/src/variable_pinning.C
libgrins_la_SOURCES += physics/src/physics_factory_initializer.C

# src/properties files
libgrins_la_SOURCES += properties/src/parsed_property_base.C
Expand Down Expand Up @@ -225,12 +210,13 @@ libgrins_la_SOURCES += solver/src/steady_mesh_adaptive_solver.C
libgrins_la_SOURCES += solver/src/solver_parsing.C
libgrins_la_SOURCES += solver/src/time_stepping_parsing.C
libgrins_la_SOURCES += solver/src/unsteady_mesh_adaptive_solver.C
libgrins_la_SOURCES += solver/src/simulation_initializer.C

# src/strategies files
libgrins_la_SOURCES += strategies/src/strategies_parsing.C
libgrins_la_SOURCES += strategies/src/error_estimator_factory_base.C
libgrins_la_SOURCES += strategies/src/error_estimator_factory_basic.C
libgrins_la_SOURCES += strategies/src/adjoint_error_estimator_factories.C
libgrins_la_SOURCES += strategies/src/error_estimator_factory_initializer.C
libgrins_la_SOURCES += strategies/src/error_estimator_options.C
libgrins_la_SOURCES += strategies/src/adaptive_time_stepping_options.C
libgrins_la_SOURCES += strategies/src/mesh_adaptivity_options.C
Expand All @@ -240,6 +226,7 @@ libgrins_la_SOURCES += variables/src/variable_warehouse.C
libgrins_la_SOURCES += variables/src/variable_factory.C
libgrins_la_SOURCES += variables/src/variable_builder.C
libgrins_la_SOURCES += variables/src/default_variable_builder.C
libgrins_la_SOURCES += variables/src/variable_factory_initializer.C

# src/utilities files
libgrins_la_SOURCES += utilities/src/grins_version.C
Expand Down Expand Up @@ -326,6 +313,7 @@ include_HEADERS += boundary_conditions/include/grins/catalytic_wall_neumann_bc_f
include_HEADERS += boundary_conditions/include/grins/catalytic_wall_neumann_bc_old_style_factory_base.h
include_HEADERS += boundary_conditions/include/grins/gas_catalytic_wall_neumann_bc_factories.h
include_HEADERS += boundary_conditions/include/grins/gas_catalytic_wall_neumann_bc_old_style_factories.h
include_HEADERS += boundary_conditions/include/grins/boundary_condition_factory_initializer.h

# src/common headers
include_HEADERS += common/include/grins/common.h
Expand Down Expand Up @@ -437,6 +425,7 @@ include_HEADERS += physics/include/grins/physics_factory_one_d_stress_solids.h
include_HEADERS += physics/include/grins/physics_factory_reacting_flows.h
include_HEADERS += physics/include/grins/physics_builder.h
include_HEADERS += physics/include/grins/variable_pinning.h
include_HEADERS += physics/include/grins/physics_factory_initializer.h

# src/properties headers
include_HEADERS += properties/include/grins/property_types.h
Expand Down Expand Up @@ -510,12 +499,14 @@ include_HEADERS += solver/include/grins/solver_names.h
include_HEADERS += solver/include/grins/time_stepping_parsing.h
include_HEADERS += solver/include/grins/simulation_parsing.h
include_HEADERS += solver/include/grins/unsteady_mesh_adaptive_solver.h
include_HEADERS += solver/include/grins/simulation_initializer.h

# src/strategies headers
include_HEADERS += strategies/include/grins/strategies_parsing.h
include_HEADERS += strategies/include/grins/error_estimator_factory_base.h
include_HEADERS += strategies/include/grins/error_estimator_factory_basic.h
include_HEADERS += strategies/include/grins/adjoint_error_estimator_factories.h
include_HEADERS += strategies/include/grins/error_estimator_factory_initializer.h
include_HEADERS += strategies/include/grins/error_estimator_options.h
include_HEADERS += strategies/include/grins/adaptive_time_stepping_options.h
include_HEADERS += strategies/include/grins/mesh_adaptivity_options.h
Expand All @@ -531,6 +522,7 @@ include_HEADERS += variables/include/grins/variable_warehouse.h
include_HEADERS += variables/include/grins/variable_factory.h
include_HEADERS += variables/include/grins/variable_builder.h
include_HEADERS += variables/include/grins/default_variable_builder.h
include_HEADERS += variables/include/grins/variable_factory_initializer.h

# src/utilities headers
include_HEADERS += $(top_builddir)/src/utilities/include/grins/grins_version.h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@
//
//-----------------------------------------------------------------------el-

// These classes
#include "grins/catalycity_factories_old_style.h"
#ifndef GRINS_BOUNDARY_CONDITION_FACTORY_INITIALIZER_H
#define GRINS_BOUNDARY_CONDITION_FACTORY_INITIALIZER_H

namespace GRINS
{
// Instantiate and register factories
ConstantCatalycityFactoryOldStyle grins_factory_constant_catalycity_old_style("constant_old_style");
ArrheniusCatalycityFactoryOldStyle grins_factory_arrhenius_catalycity_old_style("arrhenius_old_style");
PowerLawCatalycityFactoryOldStyle grins_factory_power_law_catalycity_old_style("power_old_style");
} // end namespace GRINS
//! Initialize all Factory objects related to boundary conditions
/*! To avoid symbol stripping from static linking, we use this
class to initialize/register the boundary condition factory objects.

Relevant discussion: http://stackoverflow.com/questions/5202142/static-variable-initialization-over-a-library*/
class BoundaryConditionFactoryInitializer
{
public:
BoundaryConditionFactoryInitializer();
~BoundaryConditionFactoryInitializer(){}
};
}

#endif // GRINS_BOUNDARY_CONDITION_FACTORY_INITIALIZER_H
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

// GRINS
#include "grins/dirichlet_bc_factory_function_old_style_base.h"
#include "grins/string_utils.h"

// libMesh
#include "libmesh/const_function.h"

namespace GRINS
{
Expand All @@ -50,6 +54,28 @@ namespace GRINS

};

libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >
inline
IsothermalDirichletOldStyleBCFactory::build_func( const GetPot& input,
MultiphysicsSystem& /*system*/,
std::vector<std::string>& var_names,
const std::string& section )
{
libmesh_assert_equal_to(DirichletBCFactoryAbstract::_bc_ids->size(), 1 );
libmesh_assert_equal_to(var_names.size(), 1 );

std::string bc_id_string = StringUtilities::T_to_string<BoundaryID>( *(_bc_ids->begin()) );

std::string input_var = section+"/T_wall_"+bc_id_string;

if( !input.have_variable(input_var) )
libmesh_error_msg("ERROR: Could not find input variable "+input_var+"!");

libMesh::Number value = input(input_var, 0.0);

return libMesh::UniquePtr<libMesh::FunctionBase<libMesh::Number> >( new libMesh::ConstFunction<libMesh::Number>(value) );
}

} // end namespace GRINS

#endif // GRINS_ISOTHERMAL_DIRICHLET_OLD_STYLE_BC_FACTORY_H
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ namespace GRINS

};

template<typename FunctionType>
inline
SharedPtr<NeumannBCAbstract>
ParsedFunctionNeumannOldStyleBCFactory<FunctionType>::build_neumann_func( const GetPot& input,
MultiphysicsSystem& system,
const FEVariablesBase& fe_var,
const std::string& section )
{
libmesh_assert_equal_to( this->_bc_ids->size(), 1 );

std::string flux_input = section+"/"+this->flux_input()+"_"+
StringUtilities::T_to_string<unsigned int>( *(this->_bc_ids->begin()) );

// Make sure flux input specified and consistent with var_names size
this->check_for_flux(input,flux_input,fe_var.active_var_names());

return this->build_neumman_func_common( input, system, fe_var, flux_input );
}

template<typename FunctionType>
class TractionOldStyleBCFactory : public ParsedFunctionNeumannOldStyleBCFactory<FunctionType>
{
Expand Down
Loading