@@ -2119,6 +2119,7 @@ MORPHO_ENDCLASS
21192119 * ---------------------------------------------- */
21202120
21212121static value linearelasticity_referenceproperty ;
2122+ static value linearelasticity_weightbyreferenceproperty ;
21222123static value linearelasticity_poissonproperty ;
21232124
21242125typedef struct {
@@ -3890,6 +3891,7 @@ typedef struct {
38903891 value method ; // Method dictionary
38913892 objectmesh * mref ; // Reference mesh
38923893 vm * v ;
3894+ bool weightbyref ; // Use reference mesh for the element
38933895} integralref ;
38943896
38953897/* ----------------------------------------------
@@ -4206,12 +4208,14 @@ bool integral_prepareref(objectinstance *self, objectmesh *mesh, grade g, object
42064208 bool success = false;
42074209 value func = MORPHO_NIL ;
42084210 value mref = MORPHO_NIL ;
4211+ value wtbyref = MORPHO_NIL ;
42094212 value field = MORPHO_NIL ;
42104213 value method = MORPHO_NIL ;
42114214 ref -> v = NULL ;
42124215 ref -> nfields = 0 ;
42134216 ref -> method = MORPHO_NIL ;
42144217 ref -> mref = NULL ;
4218+ ref -> weightbyref = false;
42154219
42164220 if (objectinstance_getpropertyinterned (self , scalarpotential_functionproperty , & func ) &&
42174221 MORPHO_ISCALLABLE (func )) {
@@ -4222,6 +4226,9 @@ bool integral_prepareref(objectinstance *self, objectmesh *mesh, grade g, object
42224226 MORPHO_ISMESH (mref )) {
42234227 ref -> mref = MORPHO_GETMESH (mref );
42244228 }
4229+ if (objectinstance_getpropertyinterned (self , linearelasticity_weightbyreferenceproperty , & wtbyref )) {
4230+ ref -> weightbyref = !morpho_isfalse (wtbyref );
4231+ }
42254232 if (objectinstance_getpropertyinterned (self , functional_methodproperty , & method )) {
42264233 ref -> method = method ;
42274234 }
@@ -4352,12 +4359,15 @@ value LineIntegral_init(vm *v, int nargs, value *args) {
43524359 int nfixed ;
43534360 value method = MORPHO_NIL ;
43544361 value mref = MORPHO_NIL ;
4362+ value wtbyref = MORPHO_NIL ;
43554363
4356- if (builtin_options (v , nargs , args , & nfixed , 2 ,
4364+ if (builtin_options (v , nargs , args , & nfixed , 3 ,
43574365 functional_methodproperty , & method ,
4358- linearelasticity_referenceproperty , & mref )) {
4366+ linearelasticity_referenceproperty , & mref ,
4367+ linearelasticity_weightbyreferenceproperty , & wtbyref )) {
43594368 if (MORPHO_ISDICTIONARY (method )) objectinstance_setproperty (self , functional_methodproperty , method );
43604369 if (MORPHO_ISMESH (mref )) objectinstance_setproperty (self , linearelasticity_referenceproperty , mref );
4370+ if (MORPHO_ISBOOL (wtbyref )) objectinstance_setproperty (self , linearelasticity_weightbyreferenceproperty , wtbyref );
43614371 } else {
43624372 morpho_runtimeerror (v , LINEINTEGRAL_ARGS );
43634373 return MORPHO_NIL ;
@@ -4447,8 +4457,12 @@ bool areaintegral_integrand(vm *v, objectmesh *mesh, elementid id, int nv, int *
44474457 elref .iref = & iref ;
44484458 elref .vertexposn = x ;
44494459 elref .qgrad = qgrad ;
4450-
4451- if (!functional_elementsize (v , mesh , MESH_GRADE_AREA , id , nv , vid , & elref .elementsize )) return false;
4460+
4461+ if (iref .weightbyref ) {
4462+ if (!functional_elementsize (v , iref .mref , MESH_GRADE_AREA , id , nv , vid , & elref .elementsize )) return false;
4463+ } else {
4464+ if (!functional_elementsize (v , mesh , MESH_GRADE_AREA , id , nv , vid , & elref .elementsize )) return false;
4465+ }
44524466
44534467 iref .v = v ;
44544468 for (unsigned int i = 0 ; i < nv ; i ++ ) {
@@ -4621,7 +4635,7 @@ MORPHO_ENDCLASS
46214635 * Initialization
46224636 * ********************************************************************** */
46234637
4624- double ff (double x ) {
4638+ /* double ff(double x) {
46254639 return exp(x);
46264640}
46274641
@@ -4632,7 +4646,7 @@ double dff(double x) {
46324646void functional_fdtest(void) {
46334647 double h1 = 1e-8;
46344648
4635- //double xi[] = { -100, -10, -1.0, 0.0, 1e-7, 1e-5, 1e-2, 0.1, 1, 10, 100, 1e100 /* Terminator */ };
4649+ //double xi[] = { -100, -10, -1.0, 0.0, 1e-7, 1e-5, 1e-2, 0.1, 1, 10, 100, 1e100 };
46364650
46374651 for (int i=-6; i<3; i++) {
46384652 double x = pow(10.0, (double) i);
@@ -4646,7 +4660,7 @@ void functional_fdtest(void) {
46464660 printf("%g: %g %g %g\n", x, fex, fabs((f1-fex)/fex), fabs((f2-fex)/fex));
46474661 }
46484662
4649- }
4663+ }*/
46504664
46514665void functional_initialize (void ) {
46524666 fddelta1 = pow (MORPHO_EPS , 1.0 /3.0 );
@@ -4657,6 +4671,7 @@ void functional_initialize(void) {
46574671 scalarpotential_functionproperty = builtin_internsymbolascstring (SCALARPOTENTIAL_FUNCTION_PROPERTY );
46584672 scalarpotential_gradfunctionproperty = builtin_internsymbolascstring (SCALARPOTENTIAL_GRADFUNCTION_PROPERTY );
46594673 linearelasticity_referenceproperty = builtin_internsymbolascstring (LINEARELASTICITY_REFERENCE_PROPERTY );
4674+ linearelasticity_weightbyreferenceproperty = builtin_internsymbolascstring (LINEARELASTICITY_WTBYREF_PROPERTY );
46604675 linearelasticity_poissonproperty = builtin_internsymbolascstring (LINEARELASTICITY_POISSON_PROPERTY );
46614676 hydrogel_aproperty = builtin_internsymbolascstring (HYDROGEL_A_PROPERTY );
46624677 hydrogel_bproperty = builtin_internsymbolascstring (HYDROGEL_B_PROPERTY );
0 commit comments