Beispiel #1
0
	//! Compute the number of dof of given FEM
	void set (
			const getfem::mesh_fem & mf_Ut, const getfem::mesh_fem & mf_Pt,
			const std::vector<getfem::mesh_fem> & mf_Uv, const getfem::mesh_fem & mf_Pv,
			const getfem::mesh_fem & mf_coeft, const getfem::mesh_fem & mf_coefv
			)
	{
		Ut_ = mf_Ut.nb_dof(); 
		Pt_ = mf_Pt.nb_dof();
		ct_ = mf_coeft.nb_dof();
		Uv_ = 0;
		for (size_type i = 0; i<mf_Uv.size(); ++i) Uv_ += mf_Uv[i].nb_dof();
		Pv_ = mf_Pv.nb_dof();
		cv_ = mf_coefv.nb_dof();
		
		tissue_ = Pt_ + Ut_; 
		vessel_ = Pv_ + Uv_;
		tot_    = tissue_ + vessel_;
	}
Beispiel #2
0
void acoustics_problem::init(void) {
    cout << "Initializing problem..." << endl;

    // define the parameters

    residual = 1E-9; 
    std::string MESH_TYPE = PARAM.string_value("MESH_TYPE");
    std::string FEM_TYPE  = PARAM.string_value("FEM_TYPE");
    std::string INTEGRATION = PARAM.string_value("INTEGRATION");
    datafilename = "acoustics";
    k2 = PARAM.real_value("k2");
    c2 = PARAM.real_value("c2");
    a4 = PARAM.int_value("A4");

    omega = PARAM.int_value("omega");
    gama = PARAM.int_value("gama");
    

    cout << "MESH_TYPE=" << MESH_TYPE << "\n";
    cout << "FEM_TYPE="  << FEM_TYPE << "\n";
    cout << "INTEGRATION=" << INTEGRATION << "\n";

    // mesh
    std::string meshname("gmsh:../mesh/" + datafilename + ".msh");
    getfem::import_mesh(meshname, mesh);
    N = mesh.dim();
    mesh.optimize_structure();


    // set the finite element on the mf_u 
    getfem::pfem pf_u = getfem::fem_descriptor(FEM_TYPE);
    getfem::pintegration_method ppi = getfem::int_method_descriptor(INTEGRATION);

    mim.set_integration_method(mesh.convex_index(), ppi);
    mf_u.set_finite_element(mesh.convex_index(), pf_u);
    mf_rhs.set_finite_element(mesh.convex_index(), pf_u);
    mf_rhs.set_qdim(N);
}
Beispiel #3
0
bool acoustics_problem::solve(void) {
    cout << "Solving Problem..." << endl;

    // define the model to solve
    getfem::model model;

    // Main unknown of the problem
    model.add_fem_variable("u", mf_u, 2);
    plain_vector K(1);
    K[0] = k2;
    model.add_initialized_fixed_size_data("k2", K);
    getfem::add_Helmholtz_brick(model, mim, "u", "k2", omega);


    // TODO: model and boundary conditions definition
    /*// Laplacian with constant
    model.add_initialized_scalar_data("c2", c2);
    getfem::add_generic_elliptic_brick(model, mim, "u", "c2", omega);

    // other term in the Helmholtz equation
    model.add_initialized_scalar_data("k2", k2);
    getfem::add_mass_brick(model, mim, "u", "k2");
    */

    plain_vector G;
    gmm::resize(G, mf_rhs.nb_dof());


    // Neumann Boundary condition
    getfem::interpolation_function(mf_u, G, sol_g, a4);
    model.add_initialized_fem_data("g", mf_u, G);
    getfem::add_normal_source_term_brick(model, mim, "u", "g", a4);
    getfem::add_normal_source_term_brick(model, mim, "u", "g", gama);
    
    gmm::iteration iter(residual, 0, 40000);
    model.first_iter();

    // Null initial value
    gmm::resize(U, mf_u.nb_dof());
    gmm::clear(U);
    gmm::copy(U, model.set_real_variable("u", 1));

    // exporting to vtk format
    getfem::stored_mesh_slice sl;
    sl.build(mesh, getfem::slicer_none(), 4);

    getfem::vtk_export exp(datafilename + ".vtk");
    exp.exporting(mf_u);
    exp.write_point_data(mf_u, U, "sound");

    plain_vector F;
    gmm::resize(F, mf_rhs.nb_dof());
    getfem::interpolation_function(mf_rhs, F, sol_g);
    gmm::copy(F, model.set_real_variable("g"));

    iter.init();
    getfem::standard_solve(model, iter);
    gmm::copy(model.real_variable("u"), U);

    exp.write_point_data(mf_u, U, "sound");

    return (iter.converged());
}