8 #ifndef ASSEMBLE_COUPLING_H_
9 #define ASSEMBLE_COUPLING_H_
33 const std::string u_var_name =
"u",
const std::string v_var_name =
34 "v",
const std::string w_var_name =
"w") :
38 u_var { input_system.variable_number(u_var_name) },
39 v_var { input_system.variable_number(v_var_name) },
40 w_var { input_system.variable_number(w_var_name) },
41 dof_map { input_system.get_dof_map() },
56 const libMesh::MeshBase&
mesh;
57 const unsigned int dim;
80 const libMesh::Elem* elem_dummy = mesh.elem(idx);
81 elem = mesh.elem(idx);
82 dof_map.dof_indices(elem_dummy, dof_indices);
83 dof_map.dof_indices(elem_dummy, dof_indices_u, u_var);
84 dof_map.dof_indices(elem_dummy, dof_indices_v, v_var);
85 dof_map.dof_indices(elem_dummy, dof_indices_w, w_var);
86 n_dofs = dof_indices.size();
87 n_dofs_u = dof_indices_u.size();
88 n_dofs_v = dof_indices_v.size();
89 n_dofs_w = dof_indices_w.size();
96 libMesh::DenseMatrix<libMesh::Number>
Me;
118 Me.resize(system_type_AAA.
n_dofs, system_type_BBB.
n_dofs);
120 Me_uu.reposition(system_type_AAA.
u_var * system_type_AAA.
n_dofs_u,
124 Me_uv.reposition(system_type_AAA.
u_var * system_type_AAA.
n_dofs_u,
128 Me_uw.reposition(system_type_AAA.
u_var * system_type_AAA.
n_dofs_u,
132 Me_vu.reposition(system_type_AAA.
v_var * system_type_AAA.
n_dofs_v,
136 Me_vv.reposition(system_type_AAA.
v_var * system_type_AAA.
n_dofs_v,
140 Me_vw.reposition(system_type_AAA.
v_var * system_type_AAA.
n_dofs_v,
144 Me_wu.reposition(system_type_AAA.
w_var * system_type_AAA.
n_dofs_w,
148 Me_wv.reposition(system_type_AAA.
w_var * system_type_AAA.
n_dofs_w,
152 Me_ww.reposition(system_type_AAA.
w_var * system_type_AAA.
n_dofs_w,
159 const std::vector<std::vector<libMesh::Real> >& corrected_phi_AAA,
160 const std::vector<std::vector<libMesh::Real> >& corrected_phi_BBB,
161 const std::vector<libMesh::Real>& JxW,
double L2_coupling_const)
163 L2_Coupling(Me_uu, qp, corrected_phi_AAA, corrected_phi_BBB,
167 L2_Coupling(Me_vv, qp, corrected_phi_AAA, corrected_phi_BBB,
171 L2_Coupling(Me_ww, qp, corrected_phi_AAA, corrected_phi_BBB,
178 const std::vector<std::vector<libMesh::RealGradient> >& corrected_dphi_sysAAA,
179 const std::vector<std::vector<libMesh::RealGradient> >& corrected_dphi_sysBBB,
180 const std::vector<libMesh::Real>& JxW,
181 const libMesh::Number H1_coupling_const)
183 unsigned int n_components = 3;
185 system_type_BBB.
u_var, n_components, n_components,
186 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
191 system_type_BBB.
v_var, n_components, n_components,
192 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
197 system_type_BBB.
w_var, n_components, n_components,
198 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
203 system_type_BBB.
u_var, n_components, n_components,
204 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
209 system_type_BBB.
v_var, n_components, n_components,
210 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
215 system_type_BBB.
w_var, n_components, n_components,
216 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
221 system_type_BBB.
u_var, n_components, n_components,
222 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
227 system_type_BBB.
v_var, n_components, n_components,
228 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
233 system_type_BBB.
w_var, n_components, n_components,
234 corrected_dphi_sysAAA, corrected_dphi_sysBBB,
252 const libMesh::Parallel::Communicator *
m_comm;
282 typedef std::map<std::string, libMesh::PetscMatrix<libMesh::Number>*>::iterator
Matrix_iterator;
283 typedef std::map<std::string, libMesh::PetscVector<libMesh::Number>*>::iterator
Vector_iterator;
294 m_bHasAssembled_BIG {
false },
295 m_bHasDefinedMeshRestrictions {
false }
310 libMesh::MeshBase& BIGMesh);
313 libMesh::MeshBase& R_BIGMesh);
315 template<
typename libMesh_MatrixType>
317 libMesh::MeshBase& microMesh)
319 libMesh::EquationSystems* EqSystemPtr = NULL;
320 libMesh::PetscMatrix<libMesh::Number>* Matrix_mediator_micro_Ptr = NULL;
321 libMesh::PetscMatrix<libMesh::Number>* Matrix_mediator_BIG_Ptr = NULL;
322 libMesh::PetscMatrix<libMesh::Number>* Matrix_mediator_mediator_Ptr =
325 if (!m_micro_EquationSystemMap.count(name))
328 EqSystemPtr =
new libMesh::EquationSystems(microMesh);
330 Matrix_mediator_micro_Ptr =
new libMesh_MatrixType(
332 Matrix_mediator_BIG_Ptr =
new libMesh_MatrixType(microMesh.comm());
333 Matrix_mediator_mediator_Ptr =
new libMesh_MatrixType(
336 m_micro_EquationSystemMap.insert(std::make_pair(name, EqSystemPtr));
337 m_couplingMatrixMap_mediator_micro.insert(
338 std::make_pair(name, Matrix_mediator_micro_Ptr));
340 m_couplingMatrixMap_mediator_BIG.insert(
341 std::make_pair(name, Matrix_mediator_BIG_Ptr));
343 m_couplingMatrixMap_mediator_mediator.insert(
344 std::make_pair(name, Matrix_mediator_mediator_Ptr));
346 m_bHasAssembled_micro.insert(std::make_pair(name,
false));
347 m_bUseH1Coupling.insert(std::make_pair(name,
false));
352 std::cerr <<
" *** Warning: micro system " << name
353 <<
" already exists!" << std::endl;
354 EqSystemPtr = m_micro_EquationSystemMap[name];
361 libMesh::MeshBase& R_microMesh);
364 libMesh::MeshBase& interMesh);
367 const std::string& name, libMesh::MeshBase& mediatorMesh);
371 double coupling_rigidity,
double coupling_width);
374 const std::vector<std::vector<libMesh::Real> >& lambda_weights,
375 const std::vector<std::vector<libMesh::Real> >& phi_inter,
376 std::vector<std::vector<libMesh::Real> >& phi_corrected);
379 const std::vector<std::vector<libMesh::Real> >& lambda_weights,
380 const std::vector<std::vector<libMesh::RealGradient> >& phi_inter,
381 std::vector<std::vector<libMesh::RealGradient> >& phi_corrected);
383 void get_lambdas(
const unsigned int dim,
const libMesh::FEType& fe_t,
384 const libMesh::Elem* base_elem,
385 const std::vector<libMesh::Point>& phys_points,
386 std::vector<libMesh::Point>& ref_points,
387 std::vector<std::vector<libMesh::Real> >& lambda_weights);
390 const std::string& name);
393 const std::string& name);
396 const std::string& name);
405 const std::string& outputRoot =
"coupling");
414 libMesh::PetscMatrix<libMesh::Number>& coupling_matrix,
417 const std::unordered_multimap<int,int>& inter_table
421 const std::string BIG_name,
422 const std::string micro_name,
423 const std::string inter_name,
424 const std::string mediator_name,
426 const libMesh::MeshBase& mesh_R_BIG,
427 const libMesh::MeshBase& mesh_R_micro,
429 const std::unordered_map<
int,std::pair<int,int> >&
430 full_intersection_pairs_map,
431 const std::unordered_map<
int,std::pair<int,int> >&
432 full_intersection_restricted_pairs_map,
433 const std::unordered_map<int,int>&
434 local_intersection_meshI_to_inter_map,
435 const std::unordered_multimap<int,int>& inter_table_mediator_BIG,
436 const std::unordered_multimap<int,int>& inter_table_mediator_micro,
437 const std::string BIG_type =
"Elasticity",
438 const std::string micro_type =
"Elasticity",
439 bool bSameElemsType =
true);
442 const std::string BIG_name,
443 const std::string micro_name,
444 const std::string inter_name,
445 const std::string mediator_name,
447 const libMesh::MeshBase& mesh_R_BIG,
448 const libMesh::MeshBase& mesh_R_micro,
450 const std::unordered_map<
int,std::pair<int,int> >&
451 full_intersection_pairs_map,
452 const std::unordered_map<
int,std::pair<int,int> >&
453 full_intersection_restricted_pairs_map,
454 const std::unordered_map<int,int>&
455 local_intersection_meshI_to_inter_map,
456 const std::unordered_multimap<int,int>& inter_table_mediator_BIG,
457 const std::unordered_multimap<int,int>& inter_table_mediator_micro,
458 const std::string BIG_type =
"Elasticity",
459 const std::string micro_type =
"Elasticity",
460 bool bSameElemsType =
true);
libMesh::PetscMatrix< libMesh::Number > & get_BIG_coupling_matrix(const std::string &name)
void check_coupling_construction_3D_parallel(const std::string BIG_name, const std::string micro_name, const std::string inter_name, const std::string mediator_name, const libMesh::MeshBase &mesh_R_BIG, const libMesh::MeshBase &mesh_R_micro, const std::unordered_map< int, std::pair< int, int > > &full_intersection_pairs_map, const std::unordered_map< int, std::pair< int, int > > &full_intersection_restricted_pairs_map, const std::unordered_map< int, int > &local_intersection_meshI_to_inter_map, const std::unordered_multimap< int, int > &inter_table_mediator_BIG, const std::unordered_multimap< int, int > &inter_table_mediator_micro, const std::string BIG_type="Elasticity", const std::string micro_type="Elasticity", bool bSameElemsType=true)
void add_H1_coupling_matrix(const libMesh_fe_addresses_3 &system_type_AAA, const libMesh_fe_addresses_3 &system_type_BBB, int qp, const std::vector< std::vector< libMesh::RealGradient > > &corrected_dphi_sysAAA, const std::vector< std::vector< libMesh::RealGradient > > &corrected_dphi_sysBBB, const std::vector< libMesh::Real > &JxW, const libMesh::Number H1_coupling_const)
libMesh::DenseSubMatrix< libMesh::Number > Me_uv
libMesh::EquationSystems & set_BIG_EquationSystem(const std::string &name, libMesh::MeshBase &BIGMesh)
const libMesh::Parallel::Communicator * m_comm
void get_lambdas(const unsigned int dim, const libMesh::FEType &fe_t, const libMesh::Elem *base_elem, const std::vector< libMesh::Point > &phys_points, std::vector< libMesh::Point > &ref_points, std::vector< std::vector< libMesh::Real > > &lambda_weights)
libMesh_fe_addresses_3(libMesh::System &input_system, const std::string u_var_name="u", const std::string v_var_name="v", const std::string w_var_name="w")
std::map< std::string, libMesh::EquationSystems * > m_mediator_EquationSystemMap
const bool MASTER_debug_coupling_assemble
std::pair< std::string, libMesh::EquationSystems * > m_BIG_EquationSystem
libMesh::DenseSubMatrix< libMesh::Number > Me_uw
std::vector< libMesh::dof_id_type > dof_indices_v
void set_matrices(libMesh_fe_addresses_3 &system_type_AAA, libMesh_fe_addresses_3 &system_type_BBB)
libMesh::DenseSubMatrix< libMesh::Number > Me_vw
void print_matrix_BIG_info(const std::string &name)
std::map< std::string, double > m_coupling_widthMap
const libMesh::DofMap & dof_map
std::map< std::string, double > m_coupling_rigidityMap
std::map< std::string, libMesh::EquationSystems * > m_inter_EquationSystemMap
std::map< std::string, libMesh::EquationSystems * > m_R_micro_EquationSystemMap
void set_corrected_shape_gradients(const std::vector< std::vector< libMesh::Real > > &lambda_weights, const std::vector< std::vector< libMesh::RealGradient > > &phi_inter, std::vector< std::vector< libMesh::RealGradient > > &phi_corrected)
void print_matrix_micro_info(const std::string &name)
libMesh::EquationSystems & add_inter_EquationSystem(const std::string &name, libMesh::MeshBase &interMesh)
std::map< std::string, libMesh::EquationSystems * > m_micro_EquationSystemMap
bool m_bHasDefinedMeshRestrictions
libMesh::DenseSubMatrix< libMesh::Number > Me_wu
libMesh::DenseSubMatrix< libMesh::Number > Me_uu
std::map< std::string, libMesh::EquationSystems * >::iterator EqSystem_iterator
std::map< std::string, libMesh::PetscMatrix< libMesh::Number > * >::iterator Matrix_iterator
libMesh::DenseSubMatrix< libMesh::Number > Me_ww
libMesh::EquationSystems & add_micro_EquationSystem(const std::string &name, libMesh::MeshBase µMesh)
void assemble_coupling_elasticity_3D_parallel(const std::string BIG_name, const std::string micro_name, const std::string inter_name, const std::string mediator_name, const libMesh::MeshBase &mesh_R_BIG, const libMesh::MeshBase &mesh_R_micro, const std::unordered_map< int, std::pair< int, int > > &full_intersection_pairs_map, const std::unordered_map< int, std::pair< int, int > > &full_intersection_restricted_pairs_map, const std::unordered_map< int, int > &local_intersection_meshI_to_inter_map, const std::unordered_multimap< int, int > &inter_table_mediator_BIG, const std::unordered_multimap< int, int > &inter_table_mediator_micro, const std::string BIG_type="Elasticity", const std::string micro_type="Elasticity", bool bSameElemsType=true)
void use_H1_coupling(std::string name)
void print_matrix_mediator_info(const std::string &name)
libMesh::DenseSubMatrix< libMesh::Number > Me_vu
libMesh::PetscMatrix< libMesh::Number > & get_mediator_coupling_matrix(const std::string &name)
const libMesh::MeshBase & mesh
std::pair< std::string, libMesh::EquationSystems * > m_R_BIG_EquationSystem
void set_coupling_parameters(const std::string &name, double coupling_rigidity, double coupling_width)
Set physical parameters.
libMesh::DenseSubMatrix< libMesh::Number > Me_wv
libMesh::DenseMatrix< libMesh::Number > Me
const bool MASTER_bPerfLog_assemble_coupling
std::map< std::string, bool > m_bHasAssembled_micro
assemble_coupling_matrices(const libMesh::Parallel::Communicator &comm)
std::map< std::string, bool > m_bUseH1Coupling
void build_L2_coupling_matrix(const libMesh_fe_addresses_3 &system_type_AAA, const libMesh_fe_addresses_3 &system_type_BBB, int qp, const std::vector< std::vector< libMesh::Real > > &corrected_phi_AAA, const std::vector< std::vector< libMesh::Real > > &corrected_phi_BBB, const std::vector< libMesh::Real > &JxW, double L2_coupling_const)
libMesh::PetscMatrix< libMesh::Number > & get_micro_coupling_matrix(const std::string &name)
~assemble_coupling_matrices()
std::map< std::string, libMesh::PetscVector< libMesh::Number > * >::iterator Vector_iterator
std::vector< libMesh::dof_id_type > dof_indices
libMesh::DenseSubMatrix< libMesh::Number > Me_vv
void print_matrices_matlab(const std::string &name, const std::string &outputRoot="coupling")
std::map< std::string, libMesh::PetscMatrix< libMesh::Number > * > m_couplingMatrixMap_mediator_mediator
std::map< std::string, libMesh::PetscMatrix< libMesh::Number > * > m_couplingMatrixMap_mediator_BIG
void set_corrected_shapes(const std::vector< std::vector< libMesh::Real > > &lambda_weights, const std::vector< std::vector< libMesh::Real > > &phi_inter, std::vector< std::vector< libMesh::Real > > &phi_corrected)
void print_PETSC_matrices(const std::string &name, const std::string &outputRoot="coupling")
std::map< std::string, libMesh::PetscMatrix< libMesh::Number > * > m_couplingMatrixMap_mediator_micro
void prepare_coupling_preallocation(libMesh::PetscMatrix< libMesh::Number > &coupling_matrix, libMesh_fe_addresses_3 &row_addresses, libMesh_fe_addresses_3 &col_addresses, const std::unordered_multimap< int, int > &inter_table)
std::vector< libMesh::dof_id_type > dof_indices_w
void use_L2_coupling(std::string name)
std::vector< libMesh::dof_id_type > dof_indices_u
libMesh::EquationSystems & add_mediator_EquationSystem(const std::string &name, libMesh::MeshBase &mediatorMesh)
libMesh::EquationSystems & set_Restricted_BIG_EquationSystem(const std::string &name, libMesh::MeshBase &R_BIGMesh)
libMesh::EquationSystems & add_Restricted_micro_EquationSystem(const std::string &name, libMesh::MeshBase &R_microMesh)
const libMesh::Elem * elem
libMesh::System & eq_system
libMesh::UniquePtr< libMesh::FEBase > fe_unique_ptr