File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,10 +84,19 @@ int FESolidDomain::Elements() const { return (int)m_Elem.size(); }
8484
8585// -----------------------------------------------------------------------------
8686// ! loop over elements
87- void FESolidDomain::ForEachSolidElement (std::function<void (FESolidElement& el)> f)
87+ void FESolidDomain::ForEachSolidElement (std::function<void (FESolidElement& el)> f, bool runInParallel )
8888{
8989 int NE = Elements ();
90- for (int i = 0 ; i < NE; ++i) f (m_Elem[i]);
90+ if (runInParallel)
91+ {
92+ #pragma omp parallel for
93+ for (int i = 0 ; i < NE; ++i)
94+ f (m_Elem[i]);
95+ }
96+ else
97+ {
98+ for (int i = 0 ; i < NE; ++i) f (m_Elem[i]);
99+ }
91100}
92101
93102// -----------------------------------------------------------------------------
@@ -141,7 +150,7 @@ bool FESolidDomain::Init()
141150 // material point coordinates
142151 mp.m_r0 = el.Evaluate (r0, n);
143152 }
144- });
153+ }, false );
145154 }
146155 catch (NegativeJacobian e)
147156 {
Original file line number Diff line number Diff line change @@ -263,7 +263,7 @@ class FECORE_API FESolidDomain : public FEDomain
263263
264264public:
265265 // ! loop over elements
266- void ForEachSolidElement (std::function<void (FESolidElement& el)> f);
266+ void ForEachSolidElement (std::function<void (FESolidElement& el)> f, bool runInParallel = true );
267267
268268 // ! return the degrees of freedom of an element for this domain
269269 virtual int GetElementDofs (FESolidElement& el);
You can’t perform that action at this time.
0 commit comments