parallel.cpp serif/backend/mfem/shared/parallel.hpp mfem/fem/eltrans.hpp mfem/fem/gridfunc.hpp mfem/mesh/mesh.hpp serif serif::utils serif::utils::parallel #include"serif/backend/mfem/shared/parallel.hpp" #include"mfem/fem/eltrans.hpp" #include"mfem/fem/gridfunc.hpp" #include"mfem/mesh/mesh.hpp" #ifdef_OPENMP #include<omp.h> #endif namespaceserif::utils::parallel{ intworker_count()noexcept{ #ifdef_OPENMP returnomp_in_parallel()?1:omp_get_max_threads(); #else return1; #endif } voiddetail::run(constintcount,void*context,constBodybody){ #ifdef_OPENMP if(count>1&&worker_count()>1){ //Elementsdifferincost(vacuumpointscarrythecompactification),sohandthemoutoneatatime. #pragmaompparallelforschedule(dynamic,1) for(intindex=0;index<count;++index){ body(context,index,omp_get_thread_num()); } return; } #endif for(intindex=0;index<count;++index){ body(context,index,0); } } voidelement_transformation(const::mfem::Mesh&mesh,constintelement,::mfem::IsoparametricTransformation&transformation){ //MirrorsMesh::GetElementTransformation(int,IsoparametricTransformation*)inMFEM4.10. transformation.Attribute=mesh.GetAttribute(element); transformation.ElementNo=element; transformation.ElementType=::mfem::ElementTransformation::ELEMENT; transformation.mesh=&mesh; transformation.Reset(); const::mfem::GridFunction*nodes=mesh.GetNodes(); if(nodes==nullptr){ mesh.GetPointMatrix(element,transformation.GetPointMat()); transformation.SetFE(::mfem::Mesh::GetTransformationFEforElementType(mesh.GetElementType(element))); return; } ::mfem::DenseMatrix&point_matrix=transformation.GetPointMat(); ::mfem::Array<int>vdofs; ::mfem::DofTransformationdof_transformation; nodes->FESpace()->GetElementVDofs(element,vdofs,dof_transformation); nodes->HostRead(); constintspace_dimension=mesh.SpaceDimension(); constintcount=vdofs.Size()/space_dimension; point_matrix.SetSize(space_dimension,count); for(intk=0;k<space_dimension;++k){ for(intj=0;j<count;++j){ point_matrix(k,j)=(*nodes)(vdofs[count*k+j]); } } transformation.SetFE(nodes->FESpace()->GetFE(element)); } }