In the following text the Attachments that were refused with the previous subittal
### file Secondary_domain.py
import getfem as gf
import numpy as np
gf.util_trace_level(1)
gf.util_warning_level(1)
# Mesh size
NX = 5
NY = 10
LX = 2. # Length
LY = 4. # Height
WX = 0.5 # Gap length between block 1 an block 2
fem_order = 2
# Mesh generation
m1 = gf.Mesh("import", "structured",
f"GT='GT_QK(2,1)';ORG=[0,0];SIZES=[{LX},{LY}];NSUBDIV=[{NX},{NY}]")
m2 = gf.Mesh("import", "structured",
f"GT='GT_QK(2,1)';ORG=[{LX+WX},0];SIZES=[{LX},{LY}];NSUBDIV=[{NX},{NY}]")
# Mesh region definition
XM1_RG = 11
XM2_RG = 21
XP1_RG = 12
XP2_RG = 22
YM1_RG = 13
YM2_RG = 23
YP1_RG = 14
YP2_RG = 24
m1.set_region(XM1_RG, m1.outer_faces_with_direction([-1,0], 1))
m2.set_region(XM2_RG, m2.outer_faces_with_direction([-1,0], 1))
m1.set_region(XP1_RG, m1.outer_faces_with_direction([1,0], 1))
m2.set_region(XP2_RG, m2.outer_faces_with_direction([1,0], 1))
m1.set_region(YM1_RG, m1.outer_faces_with_direction([0,-1], 1))
m2.set_region(YM2_RG, m2.outer_faces_with_direction([0,-1], 1))
m1.set_region(YP1_RG, m1.outer_faces_with_direction([0,1], 1))
m2.set_region(YP2_RG, m2.outer_faces_with_direction([0,1], 1))
# Integration methods
mim1 = gf.MeshIm(m1, 5)
mim2 = gf.MeshIm(m2, 5)
# Finite element methods
mf1 = gf.MeshFem(m1)
mf1.set_classical_fem(fem_order)
mf2 = gf.MeshFem(m2)
mf2.set_classical_fem(fem_order)
# Model
md = gf.Model("real")
md.add_initialized_data("epsilon", 1.) # Emissivity
md.add_initialized_data("sigma", 5.670374419e-8) # Stefan-Boltzmann constat
md.add_filtered_fem_variable("q1", mf1, XP1_RG)
md.add_filtered_fem_variable("q2", mf2, XM2_RG)
md.add_macro("temp_dist1", f"100+1.5*X(2)")
md.add_macro("temp_dist2", f"500-1.5*X(2)")
mf1.export_to_vtu("results.vtu", mf1, md.interpolation("temp_dist1", mf1), "Temperature 1")
md.add_standard_secondary_domain('block2', mim2, XM2_RG)
md.add_standard_secondary_domain('block1', mim1, XP1_RG)
#md.add_macro("R", "Norm(X-Secondary_Domain(X))") # distance
md.add_macro("R2", "Norm_sqr(X-Secondary_Domain(X))") # distance squared
md.add_macro("cos1", "-Normalized(X-Secondary_Domain(X)).Normal")
md.add_macro("cos2", "Normalized(X-Secondary_Domain(X)).Secondary_Domain(Normal)")
md.add_linear_twodomain_term(mim1, "(q1-(epsilon*sigma/pi)*pow(temp_dist1,4)*cos1*cos2/R2)*Test_q1", XP1_RG, "block2")
#md.add_linear_twodomain_term(mim1, "(q1-(epsilon*sigma/pi)*pow(temp_dist2,4)*cos1*cos2/R2)*Test_q1", XP1_RG, "block2")
md.add_linear_twodomain_term(mim2, "(q2-(epsilon*sigma/pi)*pow(temp_dist2,4)*cos1*cos2/R2)*Test_q2", XM2_RG, "block1")
md.variable_list()
md.solve("noisy")
print("from 1 to 2"); print(md.variable("q1"))
print()
print("from 2 to 1"); print(md.variable("q2"))
### file Secondary_domain_ASM_GENERIC.py
import getfem as gf
import numpy as np
gf.util_trace_level(1)
gf.util_warning_level(1)
# Mesh size
NX = 5
NY = 10
LX = 2. # Length
LY = 4. # Height
WX = 0.5 # Gap length between block 1 an block 2
fem_order = 2
# Mesh generation
m1 = gf.Mesh("import", "structured",
f"GT='GT_QK(2,1)';ORG=[0,0];SIZES=[{LX},{LY}];NSUBDIV=[{NX},{NY}]")
m2 = gf.Mesh("import", "structured",
f"GT='GT_QK(2,1)';ORG=[{LX+WX},0];SIZES=[{LX},{LY}];NSUBDIV=[{NX},{NY}]")
# Mesh region definition
XM1_RG = 11
XM2_RG = 21
XP1_RG = 12
XP2_RG = 22
YM1_RG = 13
YM2_RG = 23
YP1_RG = 14
YP2_RG = 24
m1.set_region(XM1_RG, m1.outer_faces_with_direction([-1,0], 1))
m2.set_region(XM2_RG, m2.outer_faces_with_direction([-1,0], 1))
m1.set_region(XP1_RG, m1.outer_faces_with_direction([1,0], 1))
m2.set_region(XP2_RG, m2.outer_faces_with_direction([1,0], 1))
m1.set_region(YM1_RG, m1.outer_faces_with_direction([0,-1], 1))
m2.set_region(YM2_RG, m2.outer_faces_with_direction([0,-1], 1))
m1.set_region(YP1_RG, m1.outer_faces_with_direction([0,1], 1))
m2.set_region(YP2_RG, m2.outer_faces_with_direction([0,1], 1))
# Integration methods
mim1 = gf.MeshIm(m1, 5)
mim2 = gf.MeshIm(m2, 5)
# Finite element methods
mf1 = gf.MeshFem(m1)
mf1.set_classical_fem(fem_order)
mf2 = gf.MeshFem(m2)
mf2.set_classical_fem(fem_order)
# Model
md = gf.Model("real")
md.add_initialized_data("epsilon", 1.) # Emissivity
md.add_initialized_data("sigma", 5.670374419e-8) # Stefan-Boltzmann constat
md.add_filtered_fem_variable("q1", mf1, XP1_RG)
md.add_filtered_fem_variable("q2", mf2, XM2_RG)
md.add_macro("temp_dist1", f"100+1.5*X(2)")
md.add_macro("temp_dist2", f"500-1.5*X(2)")
mf1.export_to_vtu("results.vtu", mf1, md.interpolation("temp_dist1", mf1), "Temperature 1")
md.add_standard_secondary_domain('block2', mim2, XM2_RG)
md.add_standard_secondary_domain('block1', mim1, XP1_RG)
#md.add_macro("R", "Norm(X-Secondary_Domain(X))") # distance
md.add_macro("R2", "Norm_sqr(X-Secondary_Domain(X))") # distance squared
md.add_macro("cos1", "-Normalized(X-Secondary_Domain(X)).Normal")
md.add_macro("cos2", "Normalized(X-Secondary_Domain(X)).Secondary_Domain(Normal)")
#md.add_linear_twodomain_term(mim1, "(q1-(epsilon*sigma/pi)*pow(temp_dist1,4)*cos1*cos2/R2)*Test_q1", XP1_RG, "block2")
#md.add_linear_twodomain_term(mim1, "(q1-(epsilon*sigma/pi)*pow(temp_dist2,4)*cos1*cos2/R2)*Test_q1", XP1_RG, "block2")
#md.add_linear_twodomain_term(mim2, "(q2-(epsilon*sigma/pi)*pow(temp_dist2,4)*cos1*cos2/R2)*Test_q2", XM2_RG, "block1")
#print("from 1 to 2"); print(md.variable("q1"))
#print()
#print("from 2 to 1"); print(md.variable("q2"))
md.variable_list()
#md.solve("noisy")
# TEST ASM_GENERIC
result_asm_1 = gf.asm_generic(mim1, 1, "(q1-(epsilon*sigma/pi)*pow(temp_dist1,4)*cos1*cos2/R2)*Test_q1", XP1_RG, md, 'Secondary_domain', "block2")
print("from 1 to 2"); print(result_asm_1)
print()
result_asm_2 = gf.asm_generic(mim2, 1, "(q2-(epsilon*sigma/pi)*pow(temp_dist2,4)*cos1*cos2/R2)*Test_q2", XM2_RG, md, 'Secondary_domain', "block1")
print("from 2 to 1"); print(result_asm_2)
print()