
 



//////////////////////////////////////////////////////////////
// Dimensions
//////////////////////////////////////////////////////////////


// Center of hexahedron
centerX = 0.0;
centerY = 0.0;
centerZ = 0.0;


// Dimensions of hexahedron
DX  =   1.0;
DY  =   2.0;
DZ  =   0.5;




//////////////////////////////////////////////////////////////
// physical id's
//////////////////////////////////////////////////////////////

XSLAVE   =   1001;
XMASTER  =   2001;

YSLAVE   =   1101;  
YMASTER  =   2101;

ZSLAVE   =   1201;
ZMASTER  =   2201;



abc1st = 101;

vacuum = 501;

 
//////////////////////////////////////////////////////////////
// characteristic length scale
//////////////////////////////////////////////////////////////
CLPERIODICBOX = 0.10 * (DX+DY+DZ) / 3.0;


//////////////////////////////////////////////////////////////
// define all points
//////////////////////////////////////////////////////////////
p00=newp; Point(p00)={centerX - 0.5 * DX, centerY - 0.5 * DY, centerZ - 0.5 * DZ, CLPERIODICBOX};
p01=newp; Point(p01)={centerX + 0.5 * DX, centerY - 0.5 * DY, centerZ - 0.5 * DZ, CLPERIODICBOX};
p02=newp; Point(p02)={centerX + 0.5 * DX, centerY + 0.5 * DY, centerZ - 0.5 * DZ, CLPERIODICBOX};
p03=newp; Point(p03)={centerX - 0.5 * DX, centerY + 0.5 * DY, centerZ - 0.5 * DZ, CLPERIODICBOX};

p10=newp; Point(p10)={centerX - 0.5 * DX, centerY - 0.5 * DY, centerZ + 0.5 * DZ, CLPERIODICBOX};
p11=newp; Point(p11)={centerX + 0.5 * DX, centerY - 0.5 * DY, centerZ + 0.5 * DZ, CLPERIODICBOX};
p12=newp; Point(p12)={centerX + 0.5 * DX, centerY + 0.5 * DY, centerZ + 0.5 * DZ, CLPERIODICBOX};
p13=newp; Point(p13)={centerX - 0.5 * DX, centerY + 0.5 * DY, centerZ + 0.5 * DZ, CLPERIODICBOX};


/////////////////////////////////////////////////////////////
// define lines
/////////////////////////////////////////////////////////////

// lower xy plane
l10=newl; Line(l10) = {p10,p11};
l11=newl; Line(l11) = {p11,p12};
l12=newl; Line(l12) = {p12,p13};
l13=newl; Line(l13) = {p13,p10};

// upper xy plane
l00v=newl; Line(l00v) = {p00,p10};
l01v=newl; Line(l01v) = {p01,p11};
l02v=newl; Line(l02v) = {p02,p12};
l03v=newl; Line(l03v) = {p03,p13};

// vertical communication lines
l00=newl; Line(l00) = {p00,p01};
l01=newl; Line(l01) = {p01,p02};
l02=newl; Line(l02) = {p02,p03};
l03=newl; Line(l03) = {p03,p00};



//////////////////////////////////////////////////////////////
// slave surface for periodicity in z direction
//////////////////////////////////////////////////////////////
ll00=newl; Line Loop(ll00) = {l00,l01,l02,l03};

SURFSLAVEZ=news; Plane Surface(SURFSLAVEZ)={ll00};


//////////////////////////////////////////////////////////////
// master surface for periodicity in z direction
//////////////////////////////////////////////////////////////
ll10=newll; Line Loop(ll10) = {l10,l11,l12,l13};

SURFMASTERZ=news; Plane Surface(SURFMASTERZ)={ll10};


///////////////////////////////////////////////////////////////////////////////
// couple slave and master surface for periodicity in z direction
///////////////////////////////////////////////////////////////////////////////
Periodic Line { l00,l01,l02,l03 } = { l10,l11,l12,l13 };

Periodic Surface SURFSLAVEZ { l00,l01,l02,l03 } = SURFMASTERZ { l10,l11,l12,l13 };




//////////////////////////////////////////////////////////////
// slave surface for periodicity in x direction
//////////////////////////////////////////////////////////////
llslavex=newll; Line Loop(llslavex) = {l00v,-l13,-l03v,l03};

SURFSLAVEX=news; Plane Surface(SURFSLAVEX)={llslavex};



//////////////////////////////////////////////////////////////
// master surface for periodicity in x direction
//////////////////////////////////////////////////////////////
llmasterx=newll; Line Loop(llmasterx) = {l01v,l11,-l02v,-l01};

SURFMASTERX=news; Plane Surface(SURFMASTERX)={llmasterx};


///////////////////////////////////////////////////////////////////////////////
// couple slave and master surface for periodicity in x direction
///////////////////////////////////////////////////////////////////////////////
Periodic Line { l00v,l13,l03v,l03 } = { l01v,l11,l02v,l01 };

Periodic Surface SURFSLAVEX { l00v,-l13,-l03v,l03 } = SURFMASTERX { l01v,l11,-l02v,-l01 };


//Periodic Surface SURFSLAVEX { l00v,-l13,-l03v,l03 } = SURFMASTERX {-l01v,l01,102v,-111};










//////////////////////////////////////////////////////////////
// master surface for periodicity in y direction
//////////////////////////////////////////////////////////////
llmastery=newll; Line Loop(llmastery) = {l02,l03v,-l12,-l02v};

SURFMASTERY=news; Plane Surface(SURFMASTERY)={llmastery};


//////////////////////////////////////////////////////////////
// slave surface for periodicity in y direction
//////////////////////////////////////////////////////////////
llslavey=newll; Line Loop(llslavey) = {l00,l01v,-l10,-l00v};

SURFSLAVEY=news; Plane Surface(SURFSLAVEY)={llslavey};




///////////////////////////////////////////////////////////////////////////////
// couple slave and master surface for periodicity in y direction
///////////////////////////////////////////////////////////////////////////////

Periodic Line { l00,l01v,-l10,-l00v } = { l02,l03v,-l12,-l02v };

Periodic Surface SURFSLAVEY { l00,l01v,-l10,-l00v } = SURFMASTERY { l02,l03v,-l12,-l02v };




///////////////////////////////////////////////////////////////////////////////
// assign physical domain tags for master, slave and ABC boundary conditions
///////////////////////////////////////////////////////////////////////////////
Physical Surface (XSLAVE) = {SURFSLAVEX};
Physical Surface (XMASTER) = {SURFMASTERX};

Physical Surface (YSLAVE) = {SURFSLAVEY};
Physical Surface (YMASTER) = {SURFMASTERY};

Physical Surface (abc1st) = {SURFSLAVEZ,SURFMASTERZ};






///////////////////////////////////////////////////////////////////////////////
// mesh volume
///////////////////////////////////////////////////////////////////////////////

periodicboxsurfloop=newreg; Surface Loop(periodicboxsurfloop) = {SURFSLAVEY,SURFMASTERY,SURFSLAVEZ,SURFMASTERZ,SURFSLAVEX,SURFMASTERX};


BOXVOLUME=newv; Volume(BOXVOLUME) = {periodicboxsurfloop};



///////////////////////////////////////////////////////////////////////////////
// assign physical domain tags for volume
///////////////////////////////////////////////////////////////////////////////
Physical Volume(vacuum) = {BOXVOLUME};














