PenaltyIBMethod::PenaltyIBMethod(const std::string& object_name, Pointer<Database> input_db, bool register_for_restart) : IBMethod(object_name, input_db, register_for_restart) { // NOTE: Parent class constructor registers class with the restart manager, sets object // name. // Initialize object with data read from the input and restart databases. bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) getFromRestart(); if (input_db) getFromInput(input_db, from_restart); return; } // PenaltyIBMethod
KnifeFishKinematics::KnifeFishKinematics( const std::string& object_name, SAMRAI::tbox::Pointer<SAMRAI::tbox::Database> input_db, IBTK::LDataManager* l_data_manager, SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM> > patch_hierarchy, bool register_for_restart) : ConstraintIBKinematics(object_name,input_db,l_data_manager,register_for_restart), d_kinematics_vel(NDIM), d_shape(NDIM), d_current_time(0.0) { // NOTE: Parent class constructor registers class with the restart manager, sets object name. //Set the size of vectors. const StructureParameters& struct_param = getStructureParameters(); const int coarsest_ln = struct_param.getCoarsestLevelNumber(); const int finest_ln = struct_param.getFinestLevelNumber(); TBOX_ASSERT(coarsest_ln == finest_ln); const std::vector<std::pair<int,int> >& idx_range = struct_param.getLagIdxRange(); const int nodes_body = idx_range[0].second - idx_range[0].first; for(int d = 0; d < NDIM; ++d) { d_kinematics_vel[d].resize(nodes_body); d_shape[d].resize(nodes_body); } SAMRAI::tbox::Array<double> forward_swim_vel; if(input_db->keyExists("forward_swim_vel")) { forward_swim_vel = input_db->getDoubleArray("forward_swim_vel"); TBOX_ASSERT( forward_swim_vel.getSize() == NDIM ); } else { TBOX_ERROR(" KnifefishKinematics::KnifefishKinematics() :: Forward swimming velocity does not exist in the InputDatabase \n\n" << std::endl ); } for (unsigned int d = 0; d < NDIM; ++d) std::fill(d_kinematics_vel[d].begin(), d_kinematics_vel[d].end(), forward_swim_vel[d]); bool from_restart = RestartManager::getManager()->isFromRestart(); if(from_restart) { getFromRestart(); } // set current velocity using current time for initial and restarted runs. setKnifefishSpecificVelocity(d_current_time); return; } //KnifeFishKinematics
IBHierarchyIntegrator::IBHierarchyIntegrator( const std::string& object_name, Pointer<Database> input_db, Pointer<IBStrategy> ib_method_ops, Pointer<INSHierarchyIntegrator> ins_hier_integrator, bool register_for_restart) : HierarchyIntegrator(object_name, input_db, register_for_restart) { #if !defined(NDEBUG) TBOX_ASSERT(ib_method_ops); TBOX_ASSERT(ins_hier_integrator); #endif // Set the IB method operations objects. d_ib_method_ops = ib_method_ops; d_ib_method_ops->registerIBHierarchyIntegrator(this); // Register the fluid solver as a child integrator of this integrator object // and reuse the variables and variable contexts of the INS solver. d_ins_hier_integrator = ins_hier_integrator; registerChildHierarchyIntegrator(d_ins_hier_integrator); d_u_var = d_ins_hier_integrator->getVelocityVariable(); d_p_var = d_ins_hier_integrator->getPressureVariable(); d_f_var = d_ins_hier_integrator->getBodyForceVariable(); d_q_var = d_ins_hier_integrator->getFluidSourceVariable(); d_current_context = d_ins_hier_integrator->getCurrentContext(); d_scratch_context = d_ins_hier_integrator->getScratchContext(); d_new_context = d_ins_hier_integrator->getNewContext(); VariableDatabase<NDIM>* var_db = VariableDatabase<NDIM>::getDatabase(); d_ib_context = var_db->getContext(d_object_name + "::IB"); // Set some default values. d_integrator_is_initialized = false; d_time_stepping_type = MIDPOINT_RULE; d_regrid_cfl_interval = 0.0; d_regrid_cfl_estimate = 0.0; d_error_on_dt_change = true; d_warn_on_dt_change = false; // Do not allocate a workload variable by default. d_workload_var.setNull(); d_workload_idx = -1; // Initialize object with data read from the input and restart databases. bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) getFromRestart(); if (input_db) getFromInput(input_db, from_restart); return; } // IBHierarchyIntegrator
GeneralizedIBMethod::GeneralizedIBMethod(const std::string& object_name, Pointer<Database> input_db, bool register_for_restart) : IBMethod(object_name, input_db, register_for_restart) { // NOTE: Parent class constructor registers class with the restart manager, sets object // name. // Initialize object with data read from the input and restart databases. bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) getFromRestart(); if (input_db) getFromInput(input_db, from_restart); // Indicate all Lagrangian data needs ghost values to be refilled, and that // all intermediate data needs to be initialized. d_N_current_needs_ghost_fill = true; d_N_new_needs_ghost_fill = true; return; } // GeneralizedIBMethod
IBImplicitStaggeredHierarchyIntegrator::IBImplicitStaggeredHierarchyIntegrator( const std::string& object_name, Pointer<Database> input_db, Pointer<IBImplicitStrategy> ib_implicit_ops, Pointer<INSStaggeredHierarchyIntegrator> ins_hier_integrator, bool register_for_restart) : IBHierarchyIntegrator(object_name, input_db, ib_implicit_ops, ins_hier_integrator, register_for_restart), d_ib_implicit_ops(ib_implicit_ops) { // Setup IB ops object to use "fixed" Lagrangian-Eulerian coupling // operators. d_ib_implicit_ops->setUseFixedLEOperators(true); // Initialize object with data read from the input and restart databases. bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) getFromRestart(); return; } // IBImplicitStaggeredHierarchyIntegrator
MainRestartData::MainRestartData( const string& object_name, std::shared_ptr<tbox::Database> input_db): d_object_name(object_name) { TBOX_ASSERT(input_db); tbox::RestartManager::getManager()->registerRestartItem(d_object_name, this); /* * Initialize object with data read from given input/restart databases. */ bool is_from_restart = tbox::RestartManager::getManager()->isFromRestart(); if (is_from_restart) { getFromRestart(); } getFromInput(input_db, is_from_restart); /* if not starting from restart file, set loop_time and iteration_number */ if (!is_from_restart) { d_loop_time = d_start_time; d_iteration_number = 0; } }
OscillatingCylinderKinematics::OscillatingCylinderKinematics(const std::string& object_name, Pointer<Database> input_db, LDataManager* l_data_manager, Pointer<PatchHierarchy<NDIM> > /*patch_hierarchy*/, bool register_for_restart) : ConstraintIBKinematics(object_name, input_db, l_data_manager, register_for_restart), d_prescribed_trans_vel(0.0), d_current_time(0.0) { // NOTE: Parent class constructor registers class with the restart manager, sets object name. // Get kinematic parameters from the input file if (input_db->keyExists("frequency")) { d_freq = input_db->getDouble("frequency"); pout << "FREQUENCY ================= " << d_freq << "\n\n\n"; } else { TBOX_ERROR( " OscillatingCylinderKinematics::OscillatingCylinderKinematics() :: frequency of cylinder does not exist " "in the InputDatabase \n\n" << std::endl); } if (input_db->keyExists("U_infinity")) { d_Uinf = input_db->getDouble("U_infinity"); pout << "U_INFINITY ================= " << d_Uinf << "\n\n\n"; } else { TBOX_ERROR( " OscillatingCylinderKinematics::OscillatingCylinderKinematics() :: maximum speed of cylinder does not " "exist in the InputDatabase \n\n" << std::endl); } // Set the size of vectors. const StructureParameters& struct_param = getStructureParameters(); const int coarsest_ln = struct_param.getCoarsestLevelNumber(); const int finest_ln = struct_param.getFinestLevelNumber(); const int total_levels = finest_ln - coarsest_ln + 1; const std::vector<std::pair<int, int> >& idx_range = struct_param.getLagIdxRange(); if (total_levels > 1) { TBOX_ERROR( " OscillatingCylinderKinematics::OscillatingCylinderKinematics() :: Total levels > 1, OscillatingCylinder " "should be places on only one level \n\n" << std::endl); } // d_vec_coord.resize(number_lag_points); // d_vec_amp.resize(number_lag_points); d_new_kinematics_vel.resize(total_levels); d_current_kinematics_vel.resize(total_levels); for (int ln = 0; ln < total_levels; ++ln) { const int nodes_this_ln = idx_range[ln].second - idx_range[ln].first; d_new_kinematics_vel[ln].resize(NDIM); d_current_kinematics_vel[ln].resize(NDIM); for (int d = 0; d < NDIM; ++d) { d_new_kinematics_vel[ln][d].resize(nodes_this_ln); d_current_kinematics_vel[ln][d].resize(nodes_this_ln); } } bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) { getFromRestart(); } // set current velocity using current time for initial and restarted runs. setOscillatingCylinderSpecificVelocity(d_current_time); return; } // OscillatingCylinderKinematics
RigidBodyKinematics::RigidBodyKinematics(const std::string& object_name, Pointer<Database> input_db, LDataManager* l_data_manager, Pointer<PatchHierarchy<NDIM> > /*patch_hierarchy*/, bool register_for_restart) : ConstraintIBKinematics(object_name, input_db, l_data_manager, register_for_restart), d_parser_time(0.0), d_center_of_mass(3, 0.0), d_incremented_angle_from_reference_axis(3, 0.0), d_tagged_pt_position(3, 0.0) { // NOTE: Parent class constructor registers class with the restart manager, sets object name. // Read-in kinematics velocity functions for (int d = 0; d < NDIM; ++d) { const std::string postfix = "_function_" + std::to_string(d); std::string key_name = "kinematics_velocity" + postfix; if (input_db->isString(key_name)) { d_kinematicsvel_function_strings.push_back(input_db->getString(key_name)); } else { d_kinematicsvel_function_strings.push_back("0.0"); TBOX_WARNING("RigidBodyKinematics::RigidBodyKinematics() :\n" << " no function corresponding to key " << key_name << "found for dimension = " << d << "; using kinematics_vel = 0.0. " << std::endl); } d_kinematicsvel_parsers.push_back(new mu::Parser()); d_kinematicsvel_parsers.back()->SetExpr(d_kinematicsvel_function_strings.back()); d_all_parsers.push_back(d_kinematicsvel_parsers.back()); } // Define constants and variables for the parsers. for (std::vector<mu::Parser*>::const_iterator cit = d_all_parsers.begin(); cit != d_all_parsers.end(); ++cit) { // Various names for pi. (*cit)->DefineConst("pi", PII); (*cit)->DefineConst("Pi", PII); (*cit)->DefineConst("PI", PII); // Variables (*cit)->DefineVar("T", &d_parser_time); (*cit)->DefineVar("t", &d_parser_time); for (int d = 0; d < NDIM; ++d) { const std::string postfix = std::to_string(d); (*cit)->DefineVar("X" + postfix, d_parser_posn.data() + d); (*cit)->DefineVar("x" + postfix, d_parser_posn.data() + d); (*cit)->DefineVar("X_" + postfix, d_parser_posn.data() + d); (*cit)->DefineVar("x_" + postfix, d_parser_posn.data() + d); } } // Set the size of vectors. const StructureParameters& struct_param = getStructureParameters(); const int coarsest_ln = struct_param.getCoarsestLevelNumber(); const int finest_ln = struct_param.getFinestLevelNumber(); const int total_levels = finest_ln - coarsest_ln + 1; d_kinematics_vel.resize(total_levels); const std::vector<std::pair<int, int> >& idx_range = struct_param.getLagIdxRange(); for (int ln = 0; ln < total_levels; ++ln) { const int nodes_this_ln = idx_range[ln].second - idx_range[ln].first; d_kinematics_vel[ln].resize(NDIM); for (int d = 0; d < NDIM; ++d) { d_kinematics_vel[ln][d].resize(nodes_this_ln); } } bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) { getFromRestart(); setRigidBodySpecificVelocity( d_current_time, d_incremented_angle_from_reference_axis, d_center_of_mass, d_tagged_pt_position); setShape(d_current_time, d_incremented_angle_from_reference_axis); } return; } // RigidBodyKinematics
CVODEModel::CVODEModel( const string& object_name, const Dimension& dim, std::shared_ptr<CellPoissonFACSolver> fac_solver, std::shared_ptr<Database> input_db, std::shared_ptr<CartesianGridGeometry> grid_geom): RefinePatchStrategy(), CoarsenPatchStrategy(), d_object_name(object_name), d_dim(dim), d_soln_var(new CellVariable<double>(dim, "soln", 1)), d_FAC_solver(fac_solver), d_grid_geometry(grid_geom) { /* * set up variables and contexts */ VariableDatabase* variable_db = VariableDatabase::getDatabase(); d_cur_cxt = variable_db->getContext("CURRENT"); d_scr_cxt = variable_db->getContext("SCRATCH"); d_soln_cur_id = variable_db->registerVariableAndContext(d_soln_var, d_cur_cxt, IntVector(d_dim, 0)); d_soln_scr_id = variable_db->registerVariableAndContext(d_soln_var, d_scr_cxt, IntVector(d_dim, 1)); #ifdef USE_FAC_PRECONDITIONER d_diff_var.reset(new SideVariable<double>(d_dim, "diffusion", hier::IntVector::getOne(d_dim), 1)); d_diff_id = variable_db->registerVariableAndContext(d_diff_var, d_cur_cxt, IntVector(d_dim, 0)); /* * Set default values for preconditioner. */ d_use_neumann_bcs = false; d_current_soln_time = 0.; #endif /* * Print solver data. */ d_print_solver_info = false; /* * Counters. */ d_number_rhs_eval = 0; d_number_precond_setup = 0; d_number_precond_solve = 0; /* * Boundary condition initialization. */ if (d_dim == Dimension(2)) { d_scalar_bdry_edge_conds.resize(NUM_2D_EDGES); for (int ei = 0; ei < NUM_2D_EDGES; ++ei) { d_scalar_bdry_edge_conds[ei] = BOGUS_BDRY_DATA; } d_scalar_bdry_node_conds.resize(NUM_2D_NODES); d_node_bdry_edge.resize(NUM_2D_NODES); for (int ni = 0; ni < NUM_2D_NODES; ++ni) { d_scalar_bdry_node_conds[ni] = BOGUS_BDRY_DATA; d_node_bdry_edge[ni] = BOGUS_BDRY_DATA; } d_bdry_edge_val.resize(NUM_2D_EDGES); MathUtilities<double>::setVectorToSignalingNaN(d_bdry_edge_val); } else if (d_dim == Dimension(3)) { d_scalar_bdry_face_conds.resize(NUM_3D_FACES); for (int fi = 0; fi < NUM_3D_FACES; ++fi) { d_scalar_bdry_face_conds[fi] = BOGUS_BDRY_DATA; } d_scalar_bdry_edge_conds.resize(NUM_3D_EDGES); d_edge_bdry_face.resize(NUM_3D_EDGES); for (int ei = 0; ei < NUM_3D_EDGES; ++ei) { d_scalar_bdry_edge_conds[ei] = BOGUS_BDRY_DATA; d_edge_bdry_face[ei] = BOGUS_BDRY_DATA; } d_scalar_bdry_node_conds.resize(NUM_3D_NODES); d_node_bdry_face.resize(NUM_3D_NODES); for (int ni = 0; ni < NUM_3D_NODES; ++ni) { d_scalar_bdry_node_conds[ni] = BOGUS_BDRY_DATA; d_node_bdry_face[ni] = BOGUS_BDRY_DATA; } d_bdry_face_val.resize(NUM_3D_FACES); MathUtilities<double>::setVectorToSignalingNaN(d_bdry_face_val); } /* * Initialize object with data read from given input/restart databases. */ bool is_from_restart = RestartManager::getManager()->isFromRestart(); if (is_from_restart) { getFromRestart(); } getFromInput(input_db, is_from_restart); #ifdef USE_FAC_PRECONDITIONER /* * Construct outerface variable to hold boundary flags and Neumann fluxes. */ if (d_use_neumann_bcs) { d_flag_var.reset(new OuterfaceVariable<int>(d_dim, "bdryflag", 1)); d_flag_id = variable_db->registerVariableAndContext(d_flag_var, d_cur_cxt, IntVector(d_dim, 0)); d_neuf_var.reset(new OuterfaceVariable<double>(d_dim, "neuflux", 1)); d_neuf_id = variable_db->registerVariableAndContext(d_neuf_var, d_cur_cxt, IntVector(d_dim, 0)); } else { d_flag_id = -1; d_neuf_id = -1; } /* * Set boundary types for FAC preconditioner. * bdry_types holds a flag where 0 = dirichlet, 1 = neumann */ if (d_dim == Dimension(2)) { for (int i = 0; i < NUM_2D_EDGES; ++i) { d_bdry_types[i] = 0; if (d_scalar_bdry_edge_conds[i] == BdryCond::DIRICHLET) d_bdry_types[i] = 0; if (d_scalar_bdry_edge_conds[i] == BdryCond::NEUMANN) d_bdry_types[i] = 1; } } else if (d_dim == Dimension(3)) { for (int i = 0; i < NUM_3D_FACES; ++i) { d_bdry_types[i] = 0; if (d_scalar_bdry_face_conds[i] == BdryCond::DIRICHLET) d_bdry_types[i] = 0; if (d_scalar_bdry_face_conds[i] == BdryCond::NEUMANN) d_bdry_types[i] = 1; } } #endif /* * Postprocess boundary data from input/restart values. Note: scalar * quantity in this problem cannot have reflective boundary conditions * so we reset them to BdryCond::FLOW. */ if (d_dim == Dimension(2)) { for (int i = 0; i < NUM_2D_EDGES; ++i) { if (d_scalar_bdry_edge_conds[i] == BdryCond::REFLECT) { d_scalar_bdry_edge_conds[i] = BdryCond::FLOW; } } for (int i = 0; i < NUM_2D_NODES; ++i) { if (d_scalar_bdry_node_conds[i] == BdryCond::XREFLECT) { d_scalar_bdry_node_conds[i] = BdryCond::XFLOW; } if (d_scalar_bdry_node_conds[i] == BdryCond::YREFLECT) { d_scalar_bdry_node_conds[i] = BdryCond::YFLOW; } if (d_scalar_bdry_node_conds[i] != BOGUS_BDRY_DATA) { d_node_bdry_edge[i] = CartesianBoundaryUtilities2::getEdgeLocationForNodeBdry( i, d_scalar_bdry_node_conds[i]); } } } else if (d_dim == Dimension(3)) { for (int i = 0; i < NUM_3D_FACES; ++i) { if (d_scalar_bdry_face_conds[i] == BdryCond::REFLECT) { d_scalar_bdry_face_conds[i] = BdryCond::FLOW; } } for (int i = 0; i < NUM_3D_EDGES; ++i) { if (d_scalar_bdry_edge_conds[i] == BdryCond::XREFLECT) { d_scalar_bdry_edge_conds[i] = BdryCond::XFLOW; } if (d_scalar_bdry_edge_conds[i] == BdryCond::YREFLECT) { d_scalar_bdry_edge_conds[i] = BdryCond::YFLOW; } if (d_scalar_bdry_edge_conds[i] == BdryCond::ZREFLECT) { d_scalar_bdry_edge_conds[i] = BdryCond::ZFLOW; } if (d_scalar_bdry_edge_conds[i] != BOGUS_BDRY_DATA) { d_edge_bdry_face[i] = CartesianBoundaryUtilities3::getFaceLocationForEdgeBdry( i, d_scalar_bdry_edge_conds[i]); } } for (int i = 0; i < NUM_3D_NODES; ++i) { if (d_scalar_bdry_node_conds[i] == BdryCond::XREFLECT) { d_scalar_bdry_node_conds[i] = BdryCond::XFLOW; } if (d_scalar_bdry_node_conds[i] == BdryCond::YREFLECT) { d_scalar_bdry_node_conds[i] = BdryCond::YFLOW; } if (d_scalar_bdry_node_conds[i] == BdryCond::ZREFLECT) { d_scalar_bdry_node_conds[i] = BdryCond::ZFLOW; } if (d_scalar_bdry_node_conds[i] != BOGUS_BDRY_DATA) { d_node_bdry_face[i] = CartesianBoundaryUtilities3::getFaceLocationForNodeBdry( i, d_scalar_bdry_node_conds[i]); } } } }
INSHierarchyIntegrator::INSHierarchyIntegrator(const std::string& object_name, Pointer<Database> input_db, Pointer<Variable<NDIM> > U_var, Pointer<Variable<NDIM> > P_var, Pointer<Variable<NDIM> > F_var, Pointer<Variable<NDIM> > Q_var, bool register_for_restart) : HierarchyIntegrator(object_name, input_db, register_for_restart), d_U_var(U_var), d_P_var(P_var), d_F_var(F_var), d_Q_var(Q_var), d_U_init(NULL), d_P_init(NULL), d_default_bc_coefs(d_object_name + "::default_bc_coefs", Pointer<Database>(NULL)), d_bc_coefs(NDIM, static_cast<RobinBcCoefStrategy<NDIM>*>(NULL)), d_traction_bc_type(TRACTION), d_F_fcn(NULL), d_Q_fcn(NULL) { // Set some default values. d_integrator_is_initialized = false; d_viscous_time_stepping_type = TRAPEZOIDAL_RULE; d_convective_time_stepping_type = ADAMS_BASHFORTH; d_init_convective_time_stepping_type = MIDPOINT_RULE; d_num_cycles = 1; d_cfl_max = 1.0; d_using_vorticity_tagging = false; d_Omega_max = 0.0; d_normalize_pressure = false; d_normalize_velocity = false; d_convective_op_type = "DEFAULT"; d_convective_difference_form = ADVECTIVE; d_convective_op_input_db = new MemoryDatabase(d_object_name + "::convective_op_input_db"); d_creeping_flow = false; d_regrid_max_div_growth_factor = 1.1; d_U_scale = 1.0; d_P_scale = 1.0; d_F_scale = 1.0; d_Q_scale = 1.0; d_Omega_scale = 1.0; d_Div_U_scale = 1.0; d_output_U = true; d_output_P = true; d_output_F = false; d_output_Q = false; d_output_Omega = true; d_output_Div_U = true; d_velocity_solver = NULL; d_pressure_solver = NULL; // Setup default boundary condition objects that specify homogeneous // Dirichlet (solid-wall) boundary conditions for the velocity. for (unsigned int d = 0; d < NDIM; ++d) { d_default_bc_coefs.setBoundaryValue(2 * d, 0.0); d_default_bc_coefs.setBoundaryValue(2 * d + 1, 0.0); } registerPhysicalBoundaryConditions( std::vector<RobinBcCoefStrategy<NDIM>*>(NDIM, &d_default_bc_coefs)); // Setup physical boundary conditions objects. d_U_star_bc_coefs.resize(NDIM); for (unsigned int d = 0; d < NDIM; ++d) { d_U_star_bc_coefs[d] = new INSIntermediateVelocityBcCoef(d, d_bc_coefs); } d_Phi_bc_coef = new INSProjectionBcCoef(d_bc_coefs); // Initialize object with data read from the input and restart databases. bool from_restart = RestartManager::getManager()->isFromRestart(); if (from_restart) getFromRestart(); if (input_db) getFromInput(input_db, from_restart); // Initialize an advection velocity variable. NOTE: Patch data are // allocated for this variable only when an advection-diffusion solver is // registered with the INSHierarchyIntegrator. d_U_adv_diff_var = new FaceVariable<NDIM, double>(d_object_name + "::U_adv_diff"); return; } // INSHierarchyIntegrator