CustomWeakFormHeatMoistureRK::CustomWeakFormHeatMoistureRK(double c_TT, double c_ww, double d_TT, double d_Tw, double d_wT, double d_ww, double k_TT, double k_ww, double T_ext, double w_ext, const std::string bdy_ext) : WeakForm<double>(2) { // Jacobian - volumetric. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, HERMES_ANY, new Hermes1DFunction<double>(-d_TT / c_TT), HERMES_SYM, HERMES_AXISYM_Y)); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 1, HERMES_ANY, new Hermes1DFunction<double>(-d_Tw / c_TT), HERMES_NONSYM, HERMES_AXISYM_Y)); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(1, 0, HERMES_ANY, new Hermes1DFunction<double>(-d_wT / c_ww), HERMES_NONSYM, HERMES_AXISYM_Y)); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(1, 1, HERMES_ANY, new Hermes1DFunction<double>(-d_ww / c_ww), HERMES_SYM, HERMES_AXISYM_Y)); // Jacobian - surface. add_matrix_form_surf(new WeakFormsH1::DefaultMatrixFormSurf<double>(0, 0, bdy_ext, new Hermes2DFunction<double>(-k_TT / c_TT), HERMES_AXISYM_Y)); add_matrix_form_surf(new WeakFormsH1::DefaultMatrixFormSurf<double>(1, 1, bdy_ext, new Hermes2DFunction<double>(-k_ww / c_ww), HERMES_AXISYM_Y)); // Residual - volumetric add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, HERMES_ANY, new Hermes1DFunction<double>(-d_TT / c_TT), HERMES_AXISYM_Y)); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, HERMES_ANY, new Hermes1DFunction<double>(-d_Tw / c_TT), HERMES_AXISYM_Y)); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(1, HERMES_ANY, new Hermes1DFunction<double>(-d_wT / c_ww), HERMES_AXISYM_Y)); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(1, HERMES_ANY, new Hermes1DFunction<double>(-d_ww / c_ww), HERMES_AXISYM_Y)); // Residual - surface. add_vector_form_surf(new WeakFormsH1::DefaultVectorFormSurf<double>(0, bdy_ext, new Hermes2DFunction<double>(k_TT / c_TT * T_ext), HERMES_AXISYM_Y)); add_vector_form_surf(new WeakFormsH1::DefaultResidualSurf<double>(0, bdy_ext, new Hermes2DFunction<double>(-k_TT / c_TT), HERMES_AXISYM_Y)); add_vector_form_surf(new WeakFormsH1::DefaultVectorFormSurf<double>(1, bdy_ext, new Hermes2DFunction<double>(k_ww / c_ww * w_ext), HERMES_AXISYM_Y)); add_vector_form_surf(new WeakFormsH1::DefaultResidualSurf<double>(1, bdy_ext, new Hermes2DFunction<double>(-k_ww / c_ww), HERMES_AXISYM_Y)); }
CustomWeakFormPoisson::CustomWeakFormPoisson(const std::string& mat_motor, double eps_motor, const std::string& mat_air, double eps_air) : WeakForm<double>(1) { // Jacobian. add_matrix_form(new WeakFormsH1::DefaultMatrixFormDiffusion<double>(0, 0, mat_motor, new Hermes1DFunction<double>(eps_motor))); add_matrix_form(new WeakFormsH1::DefaultMatrixFormDiffusion<double>(0, 0, mat_air, new Hermes1DFunction<double>(eps_air))); }
CustomWeakFormHeatRK1(std::string bdy_air, double alpha, double lambda, double heatcap, double rho, double time_step, double* current_time_ptr, double temp_init, double t_final, Solution* prev_time_sln) : WeakForm(1) { /* Jacobian */ // Contribution of the time derivative term. add_matrix_form(new WeakFormsH1::DefaultMatrixFormVol(0, 0, HERMES_ANY, new HermesFunction(1.0 / time_step))); // Contribution of the diffusion term. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, HERMES_ANY, new HermesFunction(lambda / (rho * heatcap)))); // Contribution of the Newton boundary condition. add_matrix_form_surf(new WeakFormsH1::DefaultMatrixFormSurf(0, 0, bdy_air, new HermesFunction(alpha / (rho * heatcap)))); // Residual. // Contribution of the time derivative term. add_vector_form(new WeakFormsH1::DefaultResidualVol(0, HERMES_ANY, new HermesFunction(1.0 / time_step))); // Contribution of the diffusion term. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, HERMES_ANY, new HermesFunction(lambda / (rho * heatcap)))); CustomVectorFormVol* vec_form_vol = new CustomVectorFormVol(0, time_step); vec_form_vol->ext.push_back(prev_time_sln); add_vector_form(vec_form_vol); // Contribution of the Newton boundary condition. add_vector_form_surf(new WeakFormsH1::DefaultResidualSurf(0, bdy_air, new HermesFunction(alpha / (rho * heatcap)))); // Contribution of the Newton boundary condition. add_vector_form_surf(new CustomVectorFormSurf(0, bdy_air, alpha, rho, heatcap, current_time_ptr, temp_init, t_final)); };
CustomWeakFormWaveRK::CustomWeakFormWaveRK(double c_squared) : WeakForm<double>(2) { // Stationary Jacobian. add_matrix_form(new MatrixFormVolWave_0_1); add_matrix_form(new MatrixFormVolWave_1_0(c_squared)); // Stationary Residual. add_vector_form(new VectorFormVolWave_0()); add_vector_form(new VectorFormVolWave_1(c_squared)); }
CustomWeakFormPoisson::CustomWeakFormPoisson(std::string area_1, double r, std::string area_2) : WeakForm<double>(1) { // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, area_1, new Hermes1DFunction<double>(r))); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, area_2, nullptr)); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, area_1, new Hermes1DFunction<double>(r))); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, area_2, nullptr)); }
WeakFormHelmholtz::WeakFormHelmholtz(double eps, double mu, double omega, double sigma, double beta, double E0, double h) : WeakForm<double>(2) { add_matrix_form(new MatrixFormHelmholtzEquation_real_real(0, 0, eps, omega, mu)); add_matrix_form(new MatrixFormHelmholtzEquation_real_imag(0, 1, mu, omega, sigma)); add_matrix_form(new MatrixFormHelmholtzEquation_imag_real(1, 0, mu, omega, sigma)); add_matrix_form(new MatrixFormHelmholtzEquation_imag_imag(1, 1, eps, mu, omega)); add_matrix_form_surf(new MatrixFormSurfHelmholtz_real_imag(0, 1, "Bdy_impedance", beta)); add_matrix_form_surf(new MatrixFormSurfHelmholtz_imag_real(1, 0, "Bdy_impedance", beta)); }
// Problems parameters WeakFormHelmholtz(double eps, double mu, double omega, double sigma, double beta, double E0, double h) : WeakForm(2) { add_matrix_form(new MatrixFormHelmholtzEquation_real_real(0, 0, eps, mu)); add_matrix_form(new MatrixFormHelmholtzEquation_real_imag(0, 1, mu, omega, sigma)); add_matrix_form(new MatrixFormHelmholtzEquation_imag_real(1, 0, mu, omega, sigma)); add_matrix_form(new MatrixFormHelmholtzEquation_imag_imag(1, 1, eps, mu, omega)); add_matrix_form_surf(new MatrixFormSurfHelmholtz_real_imag(0, 1, BDY_IMPEDANCE, beta)); add_matrix_form_surf(new MatrixFormSurfHelmholtz_imag_real(1, 0, BDY_IMPEDANCE, beta)); };
CustomWeakFormPoisson::CustomWeakFormPoisson(std::string mat_motor, double eps_motor, std::string mat_air, double eps_air) : WeakForm(1) { // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, mat_motor, new HermesFunction(eps_motor))); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, mat_air, new HermesFunction(eps_air))); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, mat_motor, new HermesFunction(eps_motor))); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, mat_air, new HermesFunction(eps_air))); }
CustomWeakFormPoisson::CustomWeakFormPoisson(std::string mat_al, Hermes::Hermes1DFunction<double>* lambda_al, std::string mat_cu, Hermes::Hermes1DFunction<double>* lambda_cu, Hermes::Hermes2DFunction<double>* src_term) : WeakForm<double>(1) { // Jacobian forms. add_matrix_form(new WeakFormsH1::DefaultMatrixFormDiffusion<double>(0, 0, mat_al, lambda_al)); add_matrix_form(new WeakFormsH1::DefaultMatrixFormDiffusion<double>(0, 0, mat_cu, lambda_cu)); // Residual forms. add_vector_form(new WeakFormsH1::DefaultVectorFormVol<double>(0, Hermes::HERMES_ANY, src_term)); };
CustomWeakForm::CustomWeakForm(std::string marker_bdy_right) : WeakForm<double>(1) { // Jacobian. add_matrix_form(new DefaultJacobianDiffusion<double>(0, 0)); add_matrix_form(new CustomJacobian(0, 0)); // Residual. add_vector_form(new DefaultResidualDiffusion<double>(0)); add_vector_form(new CustomResidual(0)); add_vector_form_surf(new DefaultVectorFormSurf<double>(0, marker_bdy_right, new Hermes::Hermes2DFunction<double>(1.0))); }
CustomWeakForm::CustomWeakForm(std::string mat_left) : WeakForm<double>(2) { // Jacobian forms. add_matrix_form(new WeakFormsH1::DefaultMatrixFormDiffusion<double>(0, 0)); add_matrix_form(new WeakFormsH1::DefaultMatrixFormDiffusion<double>(1, 1)); add_matrix_form(new CustomFormAdvection(1, 1, mat_left)); // Residual forms. add_vector_form(new WeakFormsH1::DefaultVectorFormVol<double>(0, Hermes::HERMES_ANY, new Hermes2DFunction<double>(100.0))); add_vector_form(new WeakFormsH1::DefaultVectorFormVol<double>(1, Hermes::HERMES_ANY, new Hermes2DFunction<double>(1.0))); };
CustomWeakFormWave::CustomWeakFormWave(double tau, double c_squared, Solution<double>* u_prev_sln, Solution<double>* v_prev_sln) : WeakForm<double>(2) { // Volumetric matrix forms. add_matrix_form(new WeakFormsH1::DefaultMatrixFormVol<double>(0, 1, HERMES_ANY, new Hermes2DFunction<double>(1.0), HERMES_NONSYM)); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(1, 0, HERMES_ANY, new Hermes1DFunction<double>(-c_squared), HERMES_NONSYM)); // Volumetric surface forms. add_vector_form(new VectorFormVolWave_0()); add_vector_form(new VectorFormVolWave_1(c_squared)); }
CustomWeakForm::CustomWeakForm(double K_squared) : WeakForm(1) { // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0)); add_matrix_form(new WeakFormsH1::DefaultMatrixFormVol(0, 0, HERMES_ANY, K_squared)); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0)); add_vector_form(new WeakFormsH1::DefaultResidualVol(0, HERMES_ANY, K_squared)); add_vector_form(new WeakFormsH1::DefaultVectorFormVol(0, HERMES_ANY, -K_squared)); }
CustomWeakForm::CustomWeakForm(CustomFunction* f) : WeakForm(1) { // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0)); add_matrix_form(new WeakFormsH1::DefaultMatrixFormVol(0, 0, HERMES_ANY, new HermesFunction(f->coeff1*f->coeff1))); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0)); add_vector_form(new WeakFormsH1::DefaultResidualVol(0, HERMES_ANY, new HermesFunction(f->coeff1*f->coeff1))); add_vector_form(new WeakFormsH1::DefaultVectorFormVol(0, HERMES_ANY, f)); }
CustomWeakFormPoisson::CustomWeakFormPoisson(const std::string& mat_motor, double eps_motor, const std::string& mat_air, double eps_air, Mesh* mesh) : WeakForm<double>(1), mat_motor(mat_motor), eps_motor(eps_motor), mat_air(mat_air), eps_air(eps_air), mesh(mesh) { // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, mat_motor, new Hermes1DFunction<double>(eps_motor))); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, mat_air, new Hermes1DFunction<double>(eps_air))); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, mat_motor, new Hermes1DFunction<double>(eps_motor))); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, mat_air, new Hermes1DFunction<double>(eps_air))); }
CustomWeakFormPoisson::CustomWeakFormPoisson(std::string mat_al, double lambda_al, std::string mat_cu, double lambda_cu, double vol_heat_src) : WeakForm(1) { // Jacobian forms - volumetric. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, mat_al, new HermesFunction(lambda_al))); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, mat_cu, new HermesFunction(lambda_cu))); // Residual forms - volumetric. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, mat_al, new HermesFunction(lambda_al))); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, mat_cu, new HermesFunction(lambda_cu))); add_vector_form(new WeakFormsH1::DefaultVectorFormVol(0, HERMES_ANY, new HermesFunction(-vol_heat_src))); };
CustomWeakFormPoissonDirichlet::CustomWeakFormPoissonDirichlet(std::string mat_al, double lambda_al, std::string mat_cu, double lambda_cu, double vol_heat_src) : WeakForm<double>(1) { // Jacobian forms - volumetric. add_matrix_form(new DefaultJacobianDiffusion<double>(0, 0, mat_al, new Hermes1DFunction<double>(lambda_al))); add_matrix_form(new DefaultJacobianDiffusion<double>(0, 0, mat_cu, new Hermes1DFunction<double>(lambda_cu))); // Residual forms - volumetric. add_vector_form(new DefaultResidualDiffusion<double>(0, mat_al, new Hermes1DFunction<double>(lambda_al))); add_vector_form(new DefaultResidualDiffusion<double>(0, mat_cu, new Hermes1DFunction<double>(lambda_cu))); add_vector_form(new DefaultVectorFormVol<double>(0, HERMES_ANY, new Hermes2DFunction<double>(-vol_heat_src))); };
CustomWeakForm::CustomWeakForm(bool JFNK, bool precondition_jacobian, bool precondition_jacobian_approx) : WeakForm<double>(1, JFNK) { // Jacobian forms - volumetric. if(!JFNK || precondition_jacobian) add_matrix_form(new JacobianFormVol(0, 0)); // Residual forms - volumetric. add_vector_form(new ResidualFormVol(0, new CustomRightHandSide())); // Preconditioning form. if(JFNK && precondition_jacobian_approx) add_matrix_form(new PrecondFormVol(0, 0)); }
CustomWeakFormPoisson::CustomWeakFormPoisson(const std::string& mat_motor, double eps_motor, const std::string& mat_air, double eps_air, bool is_matfree) : WeakForm<double>(1) { this->is_matfree = is_matfree; // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, mat_motor, new Hermes1DFunction<double>(eps_motor))); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<double>(0, 0, mat_air, new Hermes1DFunction<double>(eps_air))); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, mat_motor, new Hermes1DFunction<double>(eps_motor))); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<double>(0, mat_air, new Hermes1DFunction<double>(eps_air))); }
CustomWeakFormPoisson::CustomWeakFormPoisson(std::string mat_al, HermesFunction* lambda_al, std::string mat_cu, HermesFunction* lambda_cu, HermesFunction* src_term) : WeakForm(1) { // Jacobian forms. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, mat_al, lambda_al)); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, mat_cu, lambda_cu)); // Residual forms. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, mat_al, lambda_al)); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, mat_cu, lambda_cu)); add_vector_form(new WeakFormsH1::DefaultVectorFormVol(0, HERMES_ANY, src_term)); };
CustomWeakForm(std::string material_1, double eps_1, std::string material_2, double eps_2, bool adapt_eval, int adapt_order_increase, double adapt_rel_error_tol) : WeakForm(1) { MatrixFormLaplace* first_form = new MatrixFormLaplace(0, 0, material_1, eps_1); MatrixFormLaplace* second_form = new MatrixFormLaplace(0, 0, material_2, eps_2); if(adapt_eval) { first_form->adapt_order_increase = adapt_order_increase; second_form->adapt_order_increase = adapt_order_increase; first_form->adapt_rel_error_tol = adapt_rel_error_tol; second_form->adapt_rel_error_tol = adapt_rel_error_tol; } add_matrix_form(first_form); add_matrix_form(second_form); };
CustomWeakFormAcoustics::CustomWeakFormAcoustics(std::string bdy_newton, double rho, double sound_speed, double omega) : WeakForm<::complex>(1) { std::complex<double> ii = std::complex<double>(0.0, 1.0); // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion<::complex>(0, 0, HERMES_ANY, new Hermes1DFunction<::complex>(1.0 / rho), HERMES_SYM)); add_matrix_form(new WeakFormsH1::DefaultMatrixFormVol<::complex>(0, 0, HERMES_ANY, new Hermes2DFunction<::complex>(-sqr(omega) / rho / sqr(sound_speed)), HERMES_SYM)); add_matrix_form_surf(new WeakFormsH1::DefaultMatrixFormSurf<::complex>(0, 0, bdy_newton, new Hermes2DFunction<::complex>(-ii * omega / rho / sound_speed))); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion<::complex>(0, HERMES_ANY, new Hermes1DFunction<::complex>(1.0 / rho))); add_vector_form(new WeakFormsH1::DefaultResidualVol<::complex>(0, HERMES_ANY, new Hermes2DFunction<::complex>(-sqr(omega) / rho / sqr(sound_speed)))); add_vector_form_surf(new WeakFormsH1::DefaultResidualSurf<::complex>(0, bdy_newton, new Hermes2DFunction<::complex>(-ii * omega / rho / sound_speed))); }
WeakFormNSNewton::WeakFormNSNewton(bool Stokes, double Reynolds, double time_step, Solution<double>* x_vel_previous_time, Solution<double>* y_vel_previous_time) : WeakForm<double>(3), Stokes(Stokes), Reynolds(Reynolds), time_step(time_step), x_vel_previous_time(x_vel_previous_time), y_vel_previous_time(y_vel_previous_time) { BilinearFormSymVel* sym_form_0 = new BilinearFormSymVel(0, 0, Stokes, Reynolds, time_step); add_matrix_form(sym_form_0); BilinearFormSymVel* sym_form_1 = new BilinearFormSymVel(1, 1, Stokes, Reynolds, time_step); add_matrix_form(sym_form_1); BilinearFormNonsymVel_0_0* nonsym_vel_form_0_0 = new BilinearFormNonsymVel_0_0(0, 0, Stokes); add_matrix_form(nonsym_vel_form_0_0); BilinearFormNonsymVel_0_1* nonsym_vel_form_0_1 = new BilinearFormNonsymVel_0_1(0, 1, Stokes); add_matrix_form(nonsym_vel_form_0_1); BilinearFormNonsymVel_1_0* nonsym_vel_form_1_0 = new BilinearFormNonsymVel_1_0(1, 0, Stokes); add_matrix_form(nonsym_vel_form_1_0); BilinearFormNonsymVel_1_1* nonsym_vel_form_1_1 = new BilinearFormNonsymVel_1_1(1, 1, Stokes); add_matrix_form(nonsym_vel_form_1_1); BilinearFormNonsymXVelPressure* nonsym_velx_pressure_form = new BilinearFormNonsymXVelPressure(0, 2); add_matrix_form(nonsym_velx_pressure_form); BilinearFormNonsymYVelPressure* nonsym_vely_pressure_form = new BilinearFormNonsymYVelPressure(1, 2); add_matrix_form(nonsym_vely_pressure_form); VectorFormNS_0* F_0 = new VectorFormNS_0(0, Stokes, Reynolds, time_step); F_0->ext = Hermes::vector<MeshFunction<double>*>(x_vel_previous_time, y_vel_previous_time); add_vector_form(F_0); VectorFormNS_1* F_1 = new VectorFormNS_1(1, Stokes, Reynolds, time_step); F_1->ext = Hermes::vector<MeshFunction<double>*>(x_vel_previous_time, y_vel_previous_time); add_vector_form(F_1); VectorFormNS_2* F_2 = new VectorFormNS_2(2); add_vector_form(F_2); }
WeakFormNSNewton(bool Stokes, double Reynolds, double time_step, Solution* x_vel_previous_time, Solution* y_vel_previous_time) : WeakForm(3), Stokes(Stokes), Reynolds(Reynolds), time_step(time_step), x_vel_previous_time(x_vel_previous_time), y_vel_previous_time(y_vel_previous_time) { // Jacobian BilinearFormSymVel* sym_form_0 = new BilinearFormSymVel(0, 0, Stokes, Reynolds, time_step); add_matrix_form(sym_form_0); BilinearFormSymVel* sym_form_1 = new BilinearFormSymVel(1, 1, Stokes, Reynolds, time_step); add_matrix_form(sym_form_1); BilinearFormNonsymVel_0_0* nonsym_vel_form_0_0 = new BilinearFormNonsymVel_0_0(0, 0, Stokes); add_matrix_form(nonsym_vel_form_0_0); BilinearFormNonsymVel_0_1* nonsym_vel_form_0_1 = new BilinearFormNonsymVel_0_1(0, 1, Stokes); add_matrix_form(nonsym_vel_form_0_1); BilinearFormNonsymVel_1_0* nonsym_vel_form_1_0 = new BilinearFormNonsymVel_1_0(1, 0, Stokes); add_matrix_form(nonsym_vel_form_1_0); BilinearFormNonsymVel_1_1* nonsym_vel_form_1_1 = new BilinearFormNonsymVel_1_1(1, 1, Stokes); add_matrix_form(nonsym_vel_form_1_1); BilinearFormNonsymXVelPressure* nonsym_velx_pressure_form = new BilinearFormNonsymXVelPressure(0, 2); add_matrix_form(nonsym_velx_pressure_form); BilinearFormNonsymYVelPressure* nonsym_vely_pressure_form = new BilinearFormNonsymYVelPressure(1, 2); add_matrix_form(nonsym_vely_pressure_form); // Residual. VectorFormNS_0* F_0 = new VectorFormNS_0(0, Stokes, Reynolds, time_step); F_0->ext.push_back(x_vel_previous_time); add_vector_form(F_0); VectorFormNS_1* F_1 = new VectorFormNS_1(1, Stokes, Reynolds, time_step); F_1->ext.push_back(y_vel_previous_time); add_vector_form(F_1); VectorFormNS_2* F_2 = new VectorFormNS_2(2); add_vector_form(F_2); };
CustomWeakFormAcoustics(std::string bdy_newton, double rho, double sound_speed, double omega) : WeakForm(1) { scalar ii = cplx(0.0, 1.0); // Jacobian. add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, HERMES_ANY, new HermesFunction(1.0/rho), HERMES_SYM)); add_matrix_form(new WeakFormsH1::DefaultMatrixFormVol(0, 0, HERMES_ANY, new HermesFunction(-sqr(omega) / rho / sqr(sound_speed)), HERMES_SYM)); add_matrix_form_surf(new WeakFormsH1::DefaultMatrixFormSurf(0, 0, bdy_newton, new HermesFunction(-ii * omega / rho / sound_speed))); // Residual. add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, HERMES_ANY, new HermesFunction(1.0/rho))); add_vector_form(new WeakFormsH1::DefaultResidualVol(0, HERMES_ANY, new HermesFunction(-sqr(omega) / rho / sqr(sound_speed)))); add_vector_form_surf(new WeakFormsH1::DefaultResidualSurf(0, bdy_newton, new HermesFunction(-ii * omega / rho / sound_speed))); };
CustomWeakFormLinearElasticity::CustomWeakFormLinearElasticity(double E, double nu, double rho_g, std::string surface_force_bdy, double f0, double f1) : WeakForm(2) { double lambda = (E * nu) / ((1 + nu) * (1 - 2*nu)); double mu = E / (2*(1 + nu)); #ifdef USE_MULTICOMPONENT_FORMS // Jacobian matrix. // There is one multi-component and one single-component form since we want to exploit symmetry of the forms. add_multicomponent_matrix_form(new WeakFormsElasticity::DefaultJacobianElasticity_00_11( Hermes::vector<std::pair<unsigned int, unsigned int> >(make_pair(0, 0), make_pair(1, 1)), HERMES_ANY, lambda, mu)); add_matrix_form(new WeakFormsElasticity::DefaultJacobianElasticity_0_1(0, 1, lambda, mu)); // Residual. add_multicomponent_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_00_11( Hermes::vector<unsigned int>(0, 1), lambda, mu)); add_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_0_1(0, lambda, mu)); add_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_1_0(1, lambda, mu)); // Gravity loading. add_vector_form(new WeakFormsH1::DefaultVectorFormVol(1, HERMES_ANY, new HermesFunction(-rho_g))); // External forces. add_multicomponent_vector_form_surf(new WeakFormsH1::DefaultMultiComponentVectorFormSurf( Hermes::vector<unsigned int>(0, 1), surface_force_bdy, Hermes::vector<double>(f0, f1))); #else // SINGLE-COMPONENT FORMS. USEFUL FOR MULTIMESH, DO NOT REMOVE. // Jacobian. add_matrix_form(new WeakFormsElasticity::DefaultJacobianElasticity_0_0(0, 0, lambda, mu)); add_matrix_form(new WeakFormsElasticity::DefaultJacobianElasticity_0_1(0, 1, lambda, mu)); add_matrix_form(new WeakFormsElasticity::DefaultJacobianElasticity_1_1(1, 1, lambda, mu)); // Residual - first equation. add_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_0_0(0, HERMES_ANY, lambda, mu)); add_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_0_1(0, HERMES_ANY, lambda, mu)); // Surface force (first component). add_vector_form_surf(new WeakFormsH1::DefaultVectorFormSurf(0, surface_force_bdy, new HermesFunction(f0))); // Residual - second equation. add_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_1_0(1, HERMES_ANY, lambda, mu)); add_vector_form(new WeakFormsElasticity::DefaultResidualElasticity_1_1(1, HERMES_ANY, lambda, mu)); // Gravity loading in the second vector component. add_vector_form(new WeakFormsH1::DefaultVectorFormVol(1, HERMES_ANY, new HermesFunction(rho_g))); // Surface force (second component). add_vector_form_surf(new WeakFormsH1::DefaultVectorFormSurf(1, surface_force_bdy, new HermesFunction(f1))); #endif }
CustomWeakForm(double mu_r, double kappa) : WeakForm(1) { std::complex<double> ii = std::complex<double>(0.0, 1.0); // Jacobian. add_matrix_form(new WeakFormsHcurl::DefaultJacobianCurlCurl<std::complex<double> >(0, 0, HERMES_ANY, 1.0/mu_r)); add_matrix_form(new WeakFormsHcurl::DefaultMatrixFormVol<std::complex<double> >(0, 0, HERMES_ANY, -sqr(kappa))); add_matrix_form_surf(new WeakFormsHcurl::DefaultMatrixFormSurf<std::complex<double> >(0, 0, HERMES_ANY, -kappa*ii)); // Residual. add_vector_form(new WeakFormsHcurl::DefaultResidualCurlCurl<std::complex<double> >(0, HERMES_ANY, 1.0/mu_r)); add_vector_form(new WeakFormsHcurl::DefaultResidualVol<std::complex<double> >(0, HERMES_ANY, -sqr(kappa))); add_vector_form_surf(new WeakFormsHcurl::DefaultResidualSurf<std::complex<double> >(0, HERMES_ANY, -kappa*ii)); add_vector_form_surf(new CustomVectorFormSurf()); };
CustomWeakFormContinuousGalerkin::CustomWeakFormContinuousGalerkin(GalerkinMethod method, double epsilon) : WeakForm(1), fn_epsilon(new HermesFunction(epsilon)), fn_b1(new HermesFunction(ConstFlowField::b1)), fn_b2(new HermesFunction(ConstFlowField::b2)) { add_matrix_form(new WeakFormsH1::DefaultJacobianAdvection(0, 0, HERMES_ANY, fn_b1, fn_b2)); add_vector_form(new WeakFormsH1::DefaultResidualAdvection(0, HERMES_ANY, fn_b1, fn_b2)); add_matrix_form(new WeakFormsH1::DefaultJacobianDiffusion(0, 0, HERMES_ANY, fn_epsilon, HERMES_SYM)); add_vector_form(new WeakFormsH1::DefaultResidualDiffusion(0, HERMES_ANY, fn_epsilon)); if (method != CG) { add_matrix_form(new StabilizationJacobian(method, epsilon)); add_vector_form(new StabilizationResidual(method, epsilon)); } }
CustomWeakForm::CustomWeakForm(CustomRightHandSide* rhs, std::string bdy_left_right, double K) : WeakForm(1) { add_matrix_form(new CustomMatrixFormVol(0, 0)); add_vector_form(new CustomVectorFormVol(0, rhs)); add_vector_form_surf(new CustomVectorFormSurfRight(0, K, bdy_left_right)); add_vector_form_surf(new CustomVectorFormSurfLeft(0, K, bdy_left_right)); }
CustomWeakForm::CustomWeakForm(CustomRightHandSide* rhs) : WeakForm(1) { // Jacobian. add_matrix_form(new CustomMatrixFormVol(0, 0, rhs->epsilon)); // Residual. add_vector_form(new CustomVectorFormVol(0, rhs)); }