1212/* ---------------------------------------------------------------------------*/
1313#include " FemModule.h"
1414#include " ElementMatrix.h"
15+ #include " ElementMatrixHexQuad.h"
1516
1617/* ---------------------------------------------------------------------------*/
1718/* *
@@ -36,6 +37,7 @@ startInit()
3637 m_solve_linear_system = options ()->solveLinearSystem ();
3738 m_cross_validation = options ()->crossValidation ();
3839 m_petsc_flags = options ()->petscFlags ();
40+ m_hex_quad_mesh = options ()->hexQuadMesh ();
3941
4042 elapsedTime = platform::getRealTime () - elapsedTime;
4143 ArcaneFemFunctions::GeneralFunctions::printArcaneFemTime (traceMng ()," initialize" , elapsedTime);
@@ -188,15 +190,36 @@ _assembleLinearOperatorCpu()
188190 auto node_dof (m_dofs_on_nodes.nodeDoFConnectivityView ());
189191
190192 if (options ()->rho .isPresent ()) {
191- Real qdot = -rho / epsilon;
192- ArcaneFemFunctions::BoundaryConditions2D::applyConstantSourceToRhs (qdot, mesh (), node_dof, m_node_coord, rhs_values);
193+ Real f = -rho / epsilon;
194+ if (mesh ()->dimension () == 2 ) {
195+ if (m_hex_quad_mesh)
196+ ArcaneFemFunctions::BoundaryConditions2D::applyConstantSourceToRhsQuad4 (f, mesh (), node_dof, m_node_coord, rhs_values);
197+ else
198+ ArcaneFemFunctions::BoundaryConditions2D::applyConstantSourceToRhs (f, mesh (), node_dof, m_node_coord, rhs_values);
199+ }
200+
201+ if (mesh ()->dimension () == 3 ) {
202+ if (m_hex_quad_mesh)
203+ ArcaneFemFunctions::BoundaryConditions3D::applyConstantSourceToRhsHexa8 (f, mesh (), node_dof, m_node_coord, rhs_values);
204+ else
205+ ArcaneFemFunctions::BoundaryConditions3D::applyConstantSourceToRhs (f, mesh (), node_dof, m_node_coord, rhs_values);
206+ }
193207 }
194208
195209 auto applyBoundaryConditions = [&](auto BCFunctions) {
196210 BC::IArcaneFemBC* bc = options ()->boundaryConditions ();
197211 if (bc) {
198212 for (BC::INeumannBoundaryCondition* bs : bc->neumannBoundaryConditions ())
199- BCFunctions.applyNeumannToRhs (bs, node_dof, m_node_coord, rhs_values);
213+ if (mesh ()->dimension () == 2 )
214+ if (m_hex_quad_mesh)
215+ ArcaneFemFunctions::BoundaryConditions2D::applyNeumannToRhsQuad4 (bs, node_dof, m_node_coord, rhs_values);
216+ else
217+ ArcaneFemFunctions::BoundaryConditions2D::applyNeumannToRhs (bs, node_dof, m_node_coord, rhs_values);
218+ else
219+ if (m_hex_quad_mesh)
220+ ArcaneFemFunctions::BoundaryConditions3D::applyNeumannToRhsHexa8 (bs, node_dof, m_node_coord, rhs_values);
221+ else
222+ ArcaneFemFunctions::BoundaryConditions3D::applyNeumannToRhs (bs, node_dof, m_node_coord, rhs_values);
200223
201224 for (BC::IDirichletBoundaryCondition* bs : bc->dirichletBoundaryConditions ())
202225 BCFunctions.applyDirichletToLhsAndRhs (bs, node_dof, m_node_coord, m_linear_system, rhs_values);
@@ -318,13 +341,15 @@ _assembleBilinearOperator()
318341
319342 if (m_matrix_format == " DOK" ) {
320343 if (mesh ()->dimension () == 3 )
321- _assembleBilinear<4 >([this ](const Cell& cell) {
322- return _computeElementMatrixTetra4 (cell);
323- });
344+ if (m_hex_quad_mesh)
345+ _assembleBilinear<8 >([this ](const Cell& cell) { return _computeElementMatrixHexa8 (cell); });
346+ else
347+ _assembleBilinear<4 >([this ](const Cell& cell) { return _computeElementMatrixTetra4 (cell); });
324348 else
325- _assembleBilinear<3 >([this ](const Cell& cell) {
326- return _computeElementMatrixTria3 (cell);
327- });
349+ if (m_hex_quad_mesh)
350+ _assembleBilinear<4 >([this ](const Cell& cell) { return _computeElementMatrixQuad4 (cell); });
351+ else
352+ _assembleBilinear<3 >([this ](const Cell& cell) { return _computeElementMatrixTria3 (cell); });
328353 }
329354
330355 elapsedTime = platform::getRealTime () - elapsedTime;
@@ -422,15 +447,32 @@ _updateVariables()
422447 m_phi.synchronize ();
423448
424449 if (mesh ()->dimension () == 2 )
425- ENUMERATE_ (Cell, icell, allCells ()) {
426- Cell cell = *icell;
427- m_E[cell] = ArcaneFemFunctions::FeOperation2D::computeGradientTria3 (cell, m_node_coord, m_phi);
428- }
429- else
430- ENUMERATE_ (Cell, icell, allCells ()) {
431- Cell cell = *icell;
432- m_E[cell] = ArcaneFemFunctions::FeOperation3D::computeGradientTetra4 (cell, m_node_coord, m_phi);
433- }
450+ if (m_hex_quad_mesh)
451+ ENUMERATE_ (Cell, icell, allCells ()) {
452+ Cell cell = *icell;
453+ Real3 grad = ArcaneFemFunctions::FeOperation2D::computeGradientQuad4 (cell, m_node_coord, m_phi);
454+ m_E[cell] = -grad.x * grad.x - grad.y * grad.y ;
455+ }
456+ else
457+ ENUMERATE_ (Cell, icell, allCells ()) {
458+ Cell cell = *icell;
459+ Real3 grad = ArcaneFemFunctions::FeOperation2D::computeGradientTria3 (cell, m_node_coord, m_phi);
460+ m_E[cell] = -grad.x * grad.x - grad.y * grad.y ;
461+ }
462+
463+ if (mesh ()->dimension () == 3 )
464+ if (m_hex_quad_mesh)
465+ ENUMERATE_ (Cell, icell, allCells ()) {
466+ Cell cell = *icell;
467+ Real3 grad = ArcaneFemFunctions::FeOperation3D::computeGradientHexa8 (cell, m_node_coord, m_phi);
468+ m_E[cell] = -grad.x * grad.x - grad.y * grad.y - grad.z * grad.z ;
469+ }
470+ else
471+ ENUMERATE_ (Cell, icell, allCells ()) {
472+ Cell cell = *icell;
473+ Real3 grad = ArcaneFemFunctions::FeOperation3D::computeGradientTetra4 (cell, m_node_coord, m_phi);
474+ m_E[cell] = -grad.x * grad.x - grad.y * grad.y - grad.z * grad.z ;
475+ }
434476
435477 m_E.synchronize ();
436478
@@ -460,11 +502,10 @@ _validateResults()
460502 if (allNodes ().size () < 200 )
461503 ENUMERATE_ (Node, inode, allNodes ()) {
462504 Node node = *inode;
463- info () << " phi[" << node.localId () << " ][ " << node. uniqueId () << " ] = " << m_phi[node];
505+ info () << " phi[" << node.uniqueId () << " ] = " << m_phi[node];
464506 }
465507
466508 String filename = options ()->resultFile ();
467- info () << " ValidateResultFile filename=" << filename;
468509
469510 if (!filename.empty ())
470511 checkNodeResultFile (traceMng (), filename, m_phi, 1.0e-4 , 1.0e-16 );
0 commit comments