Skip to content

Commit fd89fd0

Browse files
committed
fixup! Added: virtual method ASMbase::findPoints() searching for a list of spatial points. The default implementation invokes ASMbase::findPoint() in a loop over the specified points. It is overridden in ASMu2DLag to perform parametric inversion for bilinear quads and triangles.
1 parent da736dd commit fd89fd0

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/ASM/ASMu2DLag.C

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ extern "C" {
3939
//! \brief Evaluate the bilinear shape functions.
4040
void shape2_(const int& iop, const int& nenod, const double* xi,
4141
double* shp, const int& ipsw, const int& iwr, int& ierr);
42+
//! \brief Opens a temporary file for Fortran print.
43+
int openftnfile_(const char* fname, const ssize_t nchar);
44+
//! \brief Closes a Fortran file.
45+
void closeftnfile_(const int& iunit);
4246
}
4347

4448

@@ -769,19 +773,30 @@ bool ASMu2DLag::paramInvert (Vec3& X, PointParams& elm) const
769773
const double eps = 1.0e-15;
770774
const double tol = 1.0e-3;
771775
#if SP_DEBUG > 2
772-
const int ipsw = SP_DEBUG;
776+
int ipsw = SP_DEBUG;
773777
#else
774-
const int ipsw = 0;
778+
int ipsw = 0;
775779
#endif
776-
const int iwr = 6;
780+
// Open a temporary file for the Fortran output
781+
std::string tmpfile = "/tmp/" + std::string(getenv("USER")) + ".ftn";
782+
const int iwr = openftnfile_(tmpfile.c_str(),tmpfile.size());
783+
if (iwr <= 0) ipsw = -1; // suppress all output
777784
int ierr = 0;
778785
if (nelnod == 3)
779786
t3_inv_(nsd,tol,eps,X.ptr(),Xn.ptr(),elm.u,ipsw,iwr,ierr);
780787
else if (nelnod == 4)
781788
q4_inv_(nsd,tol,eps,X.ptr(),Xn.ptr(),elm.u,ipsw,iwr,ierr);
782789
else
783790
ierr = -99;
784-
791+
if (iwr > 0 && ipsw >= 0)
792+
{
793+
// Copy fortran output to IFEM::cout
794+
closeftnfile_(iwr);
795+
std::string cline;
796+
std::ifstream is(tmpfile);
797+
while (std::getline(is,cline))
798+
IFEM::cout << cline << std::endl;
799+
}
785800
if (ierr != 0 && ierr != 2)
786801
return false;
787802

0 commit comments

Comments
 (0)