TrilinosCouplings  Development
 All Classes Namespaces Files Functions Pages
Functions
example_CVFEM.cpp File Reference

Example solution of an Advection Diffusion equation on a quadrilateral or triangular mesh using the CVFEM. More...

#include "Intrepid_FunctionSpaceTools.hpp"
#include "Intrepid_CellTools.hpp"
#include "Intrepid_ArrayTools.hpp"
#include "Intrepid_Basis.hpp"
#include "Intrepid_HGRAD_QUAD_C1_FEM.hpp"
#include "Intrepid_HCURL_QUAD_I1_FEM.hpp"
#include "Intrepid_HGRAD_TRI_C1_FEM.hpp"
#include "Intrepid_HCURL_TRI_I1_FEM.hpp"
#include "Intrepid_RealSpaceTools.hpp"
#include "Intrepid_DefaultCubatureFactory.hpp"
#include "Intrepid_Cubature.hpp"
#include "Intrepid_CubatureControlVolume.hpp"
#include "Intrepid_CubatureControlVolumeSide.hpp"
#include "Intrepid_Utils.hpp"
#include "Epetra_Time.h"
#include "Epetra_Map.h"
#include "Epetra_SerialComm.h"
#include "Epetra_FECrsMatrix.h"
#include "Epetra_FEVector.h"
#include "Epetra_Import.h"
#include "Teuchos_oblackholestream.hpp"
#include "Teuchos_RCP.hpp"
#include "Teuchos_BLAS.hpp"
#include "Teuchos_GlobalMPISession.hpp"
#include "Teuchos_XMLParameterListHelpers.hpp"
#include "Shards_CellTopology.hpp"
#include "EpetraExt_RowMatrixOut.h"
#include "EpetraExt_MultiVectorOut.h"
#include "AztecOO.h"
#include "ml_MultiLevelPreconditioner.h"
#include "ml_epetra_utils.h"
#include "Sacado.hpp"
Include dependency graph for example_CVFEM.cpp:

Functions

template<typename Scalar >
const Scalar exactSolution (const Scalar &x, const Scalar &y)
 User-defined exact solution. More...
 
template<typename Scalar >
void advectionVelocity (Scalar advVel[2], const Scalar &x, const Scalar &y, const std::string problem)
 User-defined advection velocity. More...
 
template<typename Scalar1 , typename Scalar2 >
const Scalar1 diffusivity (const Scalar1 &x, const Scalar1 &y, const Scalar2 &epsilon, const bool variableEpsilon)
 User-defined diffusivity. More...
 
template<typename Scalar >
void exactSolutionGrad (Scalar gradExact[2], const Scalar &x, const Scalar &y)
 Computes gradient of the exact solution. Requires user-defined exact solution. More...
 
template<typename Scalar1 , typename Scalar2 >
const Scalar1 sourceTerm (Scalar1 &x, Scalar1 &y, Scalar2 &epsilon, const bool variableEpsilon, const std::string problem)
 Computes source term: f = -div(J_n). Requires user-defined exact solution and material parameters. More...
 
template<class ArrayOut , class ArrayIn >
void evaluateExactSolution (ArrayOut &exactSolutionValues, const ArrayIn &evaluationPoints)
 Computation of the exact solution at array of points in physical space. More...
 
template<class ArrayOut , class ArrayIn >
void evaluateExactSolutionGrad (ArrayOut &exactSolutionGradValues, const ArrayIn &evaluationPoints)
 Computation of the gradient of the exact solution at array of points in physical space. More...
 
template<class ArrayOut1 , class ArrayOut2 , class Scalar >
void createMesh (ArrayOut1 &elemToNode, ArrayOut2 &nodeCoords, ArrayOut1 &bcLeftId, ArrayOut1 &bcRightId, ArrayOut1 &bcTopId, ArrayOut1 &bcBotId, const std::string &meshType, const Scalar &meshSize)
 Create quadrilateral or triangle mesh on the domain [0,1]x[0,1]. More...
 
int main (int argc, char *argv[])
 

Detailed Description

Example solution of an Advection Diffusion equation on a quadrilateral or triangular mesh using the CVFEM.

 Advection diffusion system:

      - div (epsilon grad phi - u phi) = f in Omega
                                   phi = g on Gamma

   where
         u is the advection velocity
         epsilon is the diffusion coefficient
         f is a given source term


 Corresponding discrete linear system for nodal coefficients(x):

             Kx = b

        K - HGrad stiffness matrix
        b - right hand side vector
Author
K. Peterson
Remarks
Usage:
./TrilinosCouplings_Example_CVFEM.exe <input.xml>
Example requires an xml input file with mesh and solver settings.

NOTE: This problem does not currently work on more than one core (csief.nosp@m.er@s.nosp@m.andia.nosp@m..gov 3/17/16)

Function Documentation

template<typename Scalar >
void advectionVelocity ( Scalar  advVel[2],
const Scalar &  x,
const Scalar &  y,
const std::string  problem 
)

User-defined advection velocity.

Parameters
advVel[out] advection velocity evaluated at (x,y)
x[in] x-coordinate of the evaluation point
y[in] y-coordinate of the evaluation point

Referenced by sourceTerm().

template<class ArrayOut1 , class ArrayOut2 , class Scalar >
void createMesh ( ArrayOut1 &  elemToNode,
ArrayOut2 &  nodeCoords,
ArrayOut1 &  bcLeftId,
ArrayOut1 &  bcRightId,
ArrayOut1 &  bcTopId,
ArrayOut1 &  bcBotId,
const std::string &  meshType,
const Scalar &  meshSize 
)

Create quadrilateral or triangle mesh on the domain [0,1]x[0,1].

Parameters
elemToNode[out] Array with element to node mapping
nodeCoords[out] Array with nodal coordinates
bcLeftId[out] Array with ids of left boundary nodes,
bcRightId[out] Array with ids of right boundary nodes
bcTopId[out] Array with ids of top boundary nodes
bcBotId[out] Array with ids of bottom boundary nodes
meshType[in] Mesh type (quad or tri)
meshSize[in] Number of elements in each direction
template<typename Scalar1 , typename Scalar2 >
const Scalar1 diffusivity ( const Scalar1 &  x,
const Scalar1 &  y,
const Scalar2 &  epsilon,
const bool  variableEpsilon 
)

User-defined diffusivity.

Parameters
x[in] x-coordinate of the evaluation point
y[in] y-coordinate of the evaluation point
epsilon[in] diffusion coefficient from xml imput file
Returns
Value of the diffusivity at (x,y)

Referenced by sourceTerm().

template<class ArrayOut , class ArrayIn >
void evaluateExactSolution ( ArrayOut &  exactSolutionValues,
const ArrayIn &  evaluationPoints 
)

Computation of the exact solution at array of points in physical space.

Parameters
exactSolutionValues[out] Rank-2 (C,P) array with the values of the exact solution
evaluationPoints[in] Rank-3 (C,P,D) array with the evaluation points in physical frame
template<class ArrayOut , class ArrayIn >
void evaluateExactSolutionGrad ( ArrayOut &  exactSolutionGradValues,
const ArrayIn &  evaluationPoints 
)

Computation of the gradient of the exact solution at array of points in physical space.

Parameters
exactSolutionGradValues[out] Rank-3 (C,P,D) array with the values of the gradient of the exact solution
evaluationPoints[in] Rank-3 (C,P,D) array with the evaluation points in physical frame
template<typename Scalar >
const Scalar exactSolution ( const Scalar &  x,
const Scalar &  y 
)

User-defined exact solution.

Parameters
x[in] x-coordinate of the evaluation point
y[in] y-coordinate of the evaluation point
Returns
Value of the exact solution at (x,y)

Referenced by exactSolutionGrad(), and sourceTerm().

template<typename Scalar >
void exactSolutionGrad ( Scalar  gradExact[2],
const Scalar &  x,
const Scalar &  y 
)

Computes gradient of the exact solution. Requires user-defined exact solution.

Parameters
gradExact[out] gradient of the exact solution evaluated at (x,y)
x[in] x-coordinate of the evaluation point
y[in] y-coordinate of the evaluation point

References exactSolution().

Referenced by sourceTerm().

template<typename Scalar1 , typename Scalar2 >
const Scalar1 sourceTerm ( Scalar1 &  x,
Scalar1 &  y,
Scalar2 &  epsilon,
const bool  variableEpsilon,
const std::string  problem 
)

Computes source term: f = -div(J_n). Requires user-defined exact solution and material parameters.

Parameters
x[in] x-coordinate of the evaluation point
y[in] y-coordinate of the evaluation point
epsilon[in] diffusion coefficient
Returns
Source term corresponding to the user-defined exact solution evaluated at (x,y)

References advectionVelocity(), diffusivity(), exactSolution(), and exactSolutionGrad().