https://github.com/geodynamics/citcoms
Tip revision: 8fe59c2154cf490dc6e8c885e0071c6dc29e20dd authored by Eh Tan on 25 June 2009, 19:06:53 UTC
Tagging v3.1.1 release
Tagging v3.1.1 release
Tip revision: 8fe59c2
BaseSVTInlet.cc
// -*- C++ -*-
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//<LicenseText>
//
// CitcomS.py by Eh Tan, Eun-seo Choi, and Pururav Thoutireddy.
// Copyright (C) 2002-2005, California Institute of Technology.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//</LicenseText>
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
#include "config.h"
#include "journal/diagnostics.h"
#include "global_defs.h"
#include "Boundary.h"
#include "Convertor.h"
#include "Exchanger/Sink.h"
#include "BaseSVTInlet.h"
extern "C" {
#include "element_definitions.h"
void check_bc_consistency(const All_variables *E);
void construct_id(const All_variables *E);
}
using Exchanger::Array2D;
using Exchanger::DIM;
using Exchanger::STRESS_DIM;
using Exchanger::Sink;
const unsigned vbcFlag[] = {VBX, VBY, VBZ};
const unsigned sbcFlag[] = {SBX, SBY, SBZ};
BaseSVTInlet::BaseSVTInlet(const Boundary& boundary,
const Sink& sink,
All_variables* e) :
Inlet(boundary, sink),
E(e),
s(sink.size()),
s_old(sink.size()),
v(sink.size()),
v_old(sink.size()),
t(sink.size()),
t_old(sink.size())
{
journal::debug_t debug("CitcomS-Exchanger");
debug << journal::at(__HERE__) << journal::endl;
// set CitcomS boundary flags
setVBCFlag();
setTBCFlag();
check_bc_consistency(E);
}
BaseSVTInlet::~BaseSVTInlet()
{}
void BaseSVTInlet::impose()
{
journal::debug_t debug("CitcomS-Exchanger");
debug << journal::at(__HERE__) << journal::endl;
// impose normal velocity and shear stress as BC for momentum eqn.
imposeSV();
// impose temperature BC for energy eqn.
imposeT();
}
// private functions
void BaseSVTInlet::setVBCFlag()
{
// BC: normal velocity and shear traction
const Boundary& boundary = dynamic_cast<const Boundary&>(mesh);
const int m = 1;
for(int i=0; i<boundary.size(); i++) {
int n = boundary.nodeID(i);
for(int d=0; d<DIM; ++d)
if(boundary.normal(d,i)) {
E->node[m][n] = E->node[m][n] | vbcFlag[d];
E->node[m][n] = E->node[m][n] & (~sbcFlag[d]);
} else {
E->node[m][n] = E->node[m][n] | sbcFlag[d];
E->node[m][n] = E->node[m][n] & (~vbcFlag[d]);
}
}
// reconstruct ID array to reflect changes in VBC
construct_id(E);
}
void BaseSVTInlet::setTBCFlag()
{
const int m = 1;
for(int i=0; i<mesh.size(); i++) {
int n = mesh.nodeID(i);
E->node[m][n] = E->node[m][n] | TBX;
E->node[m][n] = E->node[m][n] | TBY;
E->node[m][n] = E->node[m][n] | TBZ;
E->node[m][n] = E->node[m][n] & (~FBX);
E->node[m][n] = E->node[m][n] & (~FBY);
E->node[m][n] = E->node[m][n] & (~FBZ);
}
}
void BaseSVTInlet::imposeSV()
{
const int sidelow[3] = {SIDE_NORTH, SIDE_WEST, SIDE_BOTTOM};
const int sidehigh[3] = {SIDE_SOUTH, SIDE_EAST, SIDE_TOP};
const Boundary& boundary = dynamic_cast<const Boundary&>(mesh);
double N1, N2;
getTimeFactors(N1, N2);
const int m = 1;
for(int i=0; i<sink.size(); i++) {
int j = sink.meshNode(i);
int n = boundary.nodeID(j);
int q = E->sbc.node[m][n];
for(int d=0; d<DIM; d++)
if(E->node[m][n] & vbcFlag[d])
E->sphere.cap[m].VB[d+1][n] = N1 * v_old[d][i] + N2 * v[d][i];
if(E->node[m][n] & (SBX | SBY | SBZ))
for(int d=0; d<DIM; d++) {
int p;
if(boundary.normal(d,j) == -1)
p = sidelow[d];
else if(boundary.normal(d,j) == 1)
p = sidehigh[d];
else
continue;
for(int k=0; k<DIM; k++) {
E->sbc.SB[m][p][k+1][q] =
boundary.normal(d,j) *
( N1 * side_tractions(s_old, i, d, k) +
N2 * side_tractions(s, i, d, k) );
}
}
}
}
void BaseSVTInlet::imposeT()
{
journal::debug_t debugBC("CitcomS-imposeT");
debugBC << journal::at(__HERE__);
double N1, N2;
getTimeFactors(N1, N2);
const int m = 1;
for(int i=0; i<sink.size(); i++) {
int j = sink.meshNode(i);
int n = mesh.nodeID(j);
for(int d=0; d<DIM; d++)
E->sphere.cap[m].TB[d+1][n] = N1 * t_old[0][i] + N2 * t[0][i];
debugBC << E->sphere.cap[m].TB[1][n] << " "
<< E->sphere.cap[m].TB[2][n] << " "
<< E->sphere.cap[m].TB[3][n] << journal::newline;
}
debugBC << journal::endl;
(E->temperatures_conform_bcs)(E);
}
double BaseSVTInlet::side_tractions(const Array2D<double,STRESS_DIM>& stress,
int node, int normal_dir, int dim) const
{
const int stress_index[3][3] =
{ {0, 3, 4},
{3, 1, 5},
{4, 5, 2} };
return stress[ stress_index[normal_dir][dim] ][node];
}
// version
// $Id: BaseSVTInlet.cc 7643 2007-07-11 20:17:32Z tan2 $
// End of file