42 #include <Epetra_ConfigDefs.h> 45 #include <Epetra_MpiComm.h> 47 #include <Epetra_SerialComm.h> 52 #include <lifev/core/fem/ReferenceFE.hpp> 53 #include <lifev/core/fem/QuadratureRule.hpp> 54 #include <lifev/core/fem/CurrentFE.hpp> 55 #include <lifev/core/filter/GetPot.hpp> 56 #include <lifev/core/mesh/RegionMesh.hpp> 57 #include <lifev/core/mesh/RegionMesh3DStructured.hpp> 58 #include <lifev/core/fem/DOF.hpp> 59 #include <lifev/core/filter/MeshWriter.hpp> 61 #include <lifev/core/mesh/MeshData.hpp> 66 using namespace LifeV;
68 int main (
int argc,
char** argv )
70 typedef FESpace < RegionMesh<LinearTetra>, MapEpetra > FESpaceTetra_Type;
71 typedef std::shared_ptr < FESpaceTetra_Type > FESpaceTetraPtr_Type;
73 typedef FESpace < RegionMesh<LinearHexa>, MapEpetra > FESpaceHexa_Type;
74 typedef std::shared_ptr < FESpaceHexa_Type > FESpaceHexaPtr_Type;
78 MPI_Init (&argc, &argv);
79 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_MpiComm (MPI_COMM_WORLD) );
81 std::shared_ptr<Epetra_Comm> Comm (
new Epetra_SerialComm);
84 UInt verbose = (Comm->MyPID() == 0);
91 const Real errArrayBilinear[2] = { 0.0312819802, 0. };
93 const Real errArrayQuadratic[12] = { 0.0136247667, 0.0005088372, 0.0005577494, 0.0005088372,
94 0.0136172446, 0.0005088372, 0.0004270717, 0.0005088372,
95 0.0136172446, 0.0005088372, 0.0004270717, 0.
98 const Real errArrayBubble[12] = { 0.0094702745, 3.584186e-10, 3.67611e-10, 3.584186e-10,
99 0.0094702745, 3.584186e-10, 0., 3.584186e-10,
100 0.0094702745, 3.584186e-10, 3.67611e-10, 3.584186e-10
103 const Real errArrayLinear[12] = { 0.010437463587, 0., 0., 0.,
104 0.010437463587, 0., 0., 0.,
105 0.010437463587, 0., 0., 0.
109 const std::string stringArrayP[12] = {
"P1 -> P0 ",
"P1 -> P1 ",
"P1 -> P1b",
"P1 -> P2 ",
110 "P1b -> P0 ",
"P1b -> P1 ",
"P1b -> P1b",
"P1b -> P2 ",
111 "P2 -> P0 ",
"P2 -> P1 ",
"P2 -> P1b",
"P2 -> P2 " 114 const std::string stringArrayQ[2] = {
"Q1 -> Q0 ",
"Q1 -> Q1 "};
119 std::shared_ptr<RegionMesh<LinearTetra> > fullMeshTetraPtr (
new RegionMesh<LinearTetra> ( Comm ) );
120 std::shared_ptr<RegionMesh<LinearHexa> > fullMeshHexaPtr (
new RegionMesh<LinearHexa> ( Comm ) );
122 GetPot dataFile (
"./data");
123 MeshData meshData (dataFile,
"interpolate/space_discretization");
124 readMesh (*fullMeshHexaPtr, meshData);
125 regularMesh3D ( *fullMeshTetraPtr, 1, nEl, nEl, nEl);
129 std::shared_ptr<RegionMesh<LinearHexa> > localMeshHexaPtr;
132 MeshPartitioner< RegionMesh<LinearHexa> > meshPartHexa;
135 meshPartHexa.doPartition ( fullMeshHexaPtr, Comm );
138 localMeshHexaPtr = meshPartHexa.meshPartition();
140 std::shared_ptr<RegionMesh<LinearTetra> > localMeshTetraPtr;
143 MeshPartitioner< RegionMesh<LinearTetra> > meshPartTetra;
146 meshPartTetra.doPartition ( fullMeshTetraPtr, Comm );
149 localMeshTetraPtr = meshPartTetra.meshPartition();
155 FESpaceTetraPtr_Type feSpaceP0 (
new FESpaceTetra_Type ( localMeshTetraPtr, feTetraP0, quadRuleTetra4pt,
156 quadRuleTria4pt, 3, Comm ) );
159 FESpaceTetraPtr_Type feSpaceP1 (
new FESpaceTetra_Type ( localMeshTetraPtr, feTetraP1, quadRuleTetra4pt,
160 quadRuleTria4pt, 3, Comm ) );
163 FESpaceTetraPtr_Type feSpaceP1Bubble (
new FESpaceTetra_Type ( localMeshTetraPtr, feTetraP1bubble, quadRuleTetra15pt,
164 quadRuleTria4pt, 3, Comm ) );
167 FESpaceTetraPtr_Type feSpaceP2 (
new FESpaceTetra_Type ( localMeshTetraPtr, feTetraP2, quadRuleTetra4pt,
168 quadRuleTria4pt, 3, Comm ) );
171 FESpaceHexaPtr_Type feSpaceQ0 (
new FESpaceHexa_Type ( localMeshHexaPtr, feHexaQ0, quadRuleHexa8pt,
172 quadRuleQuad4pt, 2, Comm ) );
175 FESpaceHexaPtr_Type feSpaceQ1 (
new FESpaceHexa_Type ( localMeshHexaPtr, feHexaQ1, quadRuleHexa8pt,
176 quadRuleQuad4pt, 2, Comm ) );
180 std::vector<FESpaceHexaPtr_Type > originalFeSpaceHexaVec (1), finalFeSpaceHexaVec (2);
181 std::vector<FESpaceTetraPtr_Type> originalFeSpaceTetraVec (3), finalFeSpaceTetraVec (4);
183 originalFeSpaceHexaVec[0] = feSpaceQ1;
184 finalFeSpaceHexaVec[0] = feSpaceQ0;
185 finalFeSpaceHexaVec[1] = feSpaceQ1;
187 originalFeSpaceTetraVec[0] = feSpaceP1;
188 originalFeSpaceTetraVec[1] = feSpaceP1Bubble;
189 originalFeSpaceTetraVec[2] = feSpaceP2;
191 finalFeSpaceTetraVec[0] = feSpaceP0;
192 finalFeSpaceTetraVec[1] = feSpaceP1;
193 finalFeSpaceTetraVec[2] = feSpaceP1Bubble;
194 finalFeSpaceTetraVec[3] = feSpaceP2;
200 std::cout <<
"\nA bilinear function is interpolated into Q1 vector. \nThen this FE vector is interpolated into Q0 and Q1 vectors. \nThese are the errors with respect to the analytical solution.\n";
202 check = check_interpolate (originalFeSpaceHexaVec, finalFeSpaceHexaVec, Unique, bilinearFunction, errArrayBilinear, stringArrayQ, 1e-10, time, verbose);
206 std::cout <<
"\nA linear function is interpolated into P1, P1b, P2 vectors. " 207 "\nThen these FE vectors are interpolated into the following finite elements \nand error with respect to the analytic solution are reported.\n";
209 check &= check_interpolate (originalFeSpaceTetraVec, finalFeSpaceTetraVec, Repeated, linearFunction, errArrayLinear, stringArrayP, 1e-10, time, verbose);
213 std::cout <<
"\nA quadratic function is interpolated into P1, P1b, P2 vectors. " 214 "\nThen these FE vectors are interpolated into the following finite elements \nand error with respect to the analytic solution are reported.\n";
216 check &= check_interpolate (originalFeSpaceTetraVec, finalFeSpaceTetraVec, Unique, quadraticFunction, errArrayQuadratic, stringArrayP, 1e-10, time, verbose);
220 std::cout <<
"\nA linear bubble function is interpolated into P1, P1b, P2 vectors. " 221 "\nThen these FE vectors are interpolated into the following finite elements \nand error with respect to the analytic solution are reported.\n";
223 check &= check_interpolate (originalFeSpaceTetraVec, finalFeSpaceTetraVec, Repeated, linearBubbleFunction, errArrayBubble, stringArrayP, 1e-10, time, verbose);
227 std::cout <<
"MPI Finalization" << std::endl;
235 std::cout <<
"\nTEST INTERPOLATE WAS SUCCESSFUL.\n\n";
239 std::cout <<
"\nTEST INTERPOLATE FAILED.\n\n";
254 Real linearFunction (
const Real& t,
const Real& x,
const Real& y,
const Real& z,
const ID& ic)
256 return 2 * x + -z + 4 + y * (ic + 1) + t;
260 Real linearBubbleFunction (
const Real& t,
const Real& x,
const Real& y,
const Real& z,
const ID& ic)
262 Real xx = std::max (x, 0.);
263 Real yy = std::max (y - x, 0.);
264 Real zz = std::max (z - y, 0.);
265 return 2 * x + -z + 4 + y * ic + t + xx * yy * zz * std::max (0.1 - xx - yy - zz, 0.);
268 Real quadraticFunction (
const Real& t,
const Real& x,
const Real& y,
const Real& z,
const ID& ic)
270 return 2 * x * x + t * y * y - z * z + x * y - x * z + 2 * y * z - x + y * (ic + 1) - z - 8;
273 Real bilinearFunction (
const Real& ,
const Real& x,
const Real& y,
const Real& z,
const ID& ic)
275 return x * y - x * z + 2 * y * z - x + y * (ic + 1) - z - 8;
int main(int argc, char **argv)